Postgres-applicatif
Ce script permet de démarrer/arrêter une instance PostgreSQL
#! /bin/bash
# Auteur : DiouxX
# Postgresql Sogo start script
#
# Decembre 2012
#
#GLOBAL VARIABLES
DIRECTORY=/opt/postgres-redmine
LOG_FILE=/opt/postgres-redmine/postgres.log
APPLICATION="Postgres Redmine"
DIRECTORY_BIN=/opt/postgresql-9.2.2/bin
start ()
{
#Commande pour demmarer l'instance Redmine
cd $DIRECTORY_BIN
su postgres -c "./pg_ctl -D $DIRECTORY -l $LOG_FILE start"
if [ $? -eq 0 ]
then
echo "Start $APPLICATION Instance [OK]"
else
echo "Start $APPLICATION Instance [KO]"
fi
}
stop ()
{
#Commande pour arreter l'instance Redmine
cd $DIRECTORY_BIN
su postgres -c "./pg_ctl -D $DIRECTORY -m fast stop"
if [ $? -eq 0 ]
then
echo "Stop $APPLICATION Instance [OK]"
else
echo "Stop $APPLICATION Instance [KO]"
fi
}
restart ()
{
stop
sleep 2
start
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'status')
cat $DIRECTORY/postmaster.pid > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "$APPLICATION Instance Running"
else
echo "$APPLICATION Instance Stop"
fi
;;
'restart')
restart
;;
*)
echo "Usage: $0 { start | stop | restart | status }"
exit 1
;;
esac
exit 0