#!/usr/bin/env	bash
export dbpath=/home/local
export path=/home/local
sed_mongodbpath() {
	sed -i 's#/usr/local#'$path'#' $dbpath/ehr/mongodb6/startmongodb.sh

	sed -i 's#/usr/local#'$path'#' $dbpath/ehr/mongodb6/startmongodb2.sh

	sed -i 's#/usr/local#'$path'#' $dbpath/ehr/mongodb6/stopmongodb.sh

	sed -i 's#/usr/local#'$path'#' $dbpath/ehr/mongodb6/mongodb_data_bak.sh

	sed -i 's#/usr/local#'$path'#' $dbpath/ehr/mongodb6/bin/mongod.cfg

	sed -i 's#/usr/local#'$path'#' $dbpath/ehr/mongodb6/bin/mongod2.cfg
}

sed_pgdbpath() {

	sed -i 's#/usr/local#'$path'#' $dbpath/ehr/postgresql15/startpostgresql.sh

	sed -i 's#/usr/local#'$path'#' $dbpath/ehr/postgresql15/stoppostgresql.sh

	sed -i 's#/usr/local#'$path'#' $dbpath/ehr/postgresql15/postgresql_data_bak.sh
}
sed_mongodbpath
sed_pgdbpath

detect_os() {
	if [ -f /etc/os-release ]; then
		. /etc/os-release
		OS=$NAME
	else
		OS=$(uname -s)
	fi

	if [ "$OS" = "Ubuntu" ]; then
		echo "This is Ubuntu"
		ln -s $dbpath/ehr/postgresql15/lib/libpq.so.5 /usr/lib/libpq.so.5
	elif [ "$OS" = "CentOS Linux" ]; then
		echo "This is CentOS"
		ln -s $dbpath/ehr/postgresql15/lib/libpq.so.5 /usr/lib64/libpq.so.5
	else
		echo "This is not Ubuntu or CentOS"
	fi
}
detect_os

