Simple Linux Panel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mdserver-web/plugins/postgresql/init.d/postgresql.tpl

68 lines
1.4 KiB

3 years ago
#!/bin/bash
# chkconfig: 2345 55 25
# description: PostgreSQL Service
### BEGIN INIT INFO
# Provides: Midoks
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts PostgreSQL
# Description: starts the PostgreSQL
### END INIT INFO
PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export LC_ALL="en_US.UTF-8"
MW_PATH={$SERVER_PATH}
PATH=$PATH:$MW_PATH/bin
if [ -f $MW_PATH/bin/activate ];then
source $MW_PATH/bin/activate
fi
pg_start()
{
touch {$APP_PATH}/logs/server.log
{$APP_PATH}/bin/pg_ctl -D {$APP_PATH}/data -l {$APP_PATH}/logs/server.log start
}
pg_stop()
{
{$APP_PATH}/bin/pg_ctl -D {$APP_PATH}/data -l {$APP_PATH}/logs/server.log stop
}
pg_status()
{
3 years ago
isStart=$(ps aux | grep 'postgres'| grep -v grep | grep -v 'postgresql status' | awk '{print $2}')
3 years ago
if [ "$isStart" != '' ];then
echo -e "\033[32mPostgreSQL (pid $isStart) already running\033[0m"
else
echo -e "\033[31mPostgreSQL not running\033[0m"
fi
3 years ago
}
pg_reload()
{
3 years ago
echo '' > {$APP_PATH}/logs/server.log
{$APP_PATH}/bin/pg_ctl -D {$APP_PATH}/data -l {$APP_PATH}/logs/server.log reload
3 years ago
}
case "$1" in
'start') pg_start;;
'stop') pg_stop;;
'reload') pg_reload;;
'restart')
pg_stop
pg_start;;
3 years ago
'status')
pg_status;;
3 years ago
esac