From: Bruce S. <bl...@us...> - 2004-04-14 20:50:38
|
Update of /cvsroot/devil-linux/build/scripts/scripts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32520/scripts/scripts Added Files: postgresql Log Message: Added PostgreSQL server --- NEW FILE: postgresql --- #!/bin/bash # # $Source: /cvsroot/devil-linux/build/scripts/scripts/postgresql,v $ # $Revision: 1.1 $ # $Date: 2004/04/14 20:50:30 $ # # http://www.devil-linux.org # ### BEGIN INIT INFO # Provides: postgresql # Required-Start: $network $syslog # Required-Stop: $network $syslog # Default-Start: 3 5 # Default-Stop: 0 6 # Description: starts the postgresql server ### END INIT INFO # settings source /etc/sysconfig/config # parameters NAME="POSTGRESQL Server" CONFIGNAME=POSTGRESQL export PGDATA=/var/pgsql/data DAEMON=/usr/bin/postmaster PIDFILE=$PGDATA/postmaster.pid # source function library source /etc/init.d/functions eval START=\$START_$CONFIGNAME # Determine the base and follow a runlevel link name. base=${0##*/} link=${base#*[SK][0-9][0-9]} # Force execution if not called by a runlevel directory. test $link = $base && START=yes test "$START" = "yes" || exit 0 if [ ! -e $DAEMON ]; then echo echo "$DAEMON not found. Did you install the package?" exit 1 fi case "$1" in start) getpids $DAEMON if [ -n "$pidlist" ]; then echo -n "$NAME already running" print_status failure exit 1 fi if [ ! -d $PGDATA ]; then echo -n "Initializing Database: " mkdir -p $PGDATA chown -R postgres:postgres /var/pgsql su - postgres /usr/bin/initdb -D $PGDATA > /dev/null 2>&1 if [ -f $PGDATA/PG_VERSION ]; then print_status success else print_status failure exit 1 fi fi echo -n "Starting $NAME: " su - postgres /usr/bin/pg_ctl -D $PGDATA -p $DAEMON start > /dev/null 2>&1 sleep 1 getpids $DAEMON if [ -n "$pidlist" ]; then print_status success else print_status failure fi ;; stop) echo -n "Shutting down $NAME: " if [ -f $PIDFILE ]; then su - postgres /usr/bin/pg_ctl stop -D $PGDATA -s -m fast sleep 1 getpids $DAEMON if [ -n "$pidlist" ]; then echo echo -n "Waiting for $NAME to shutdown" fi i=60 while [ -n "$pidlist" ] && [ $i -gt 0 ] ; do echo -n "." sleep 5 i=$[$i-5] getpids $DAEMON done if [ -n "$pidlist" ]; then print_status failure else print_status success fi else echo -n " doesn't seem to be running" print_status warning fi ;; restart) $0 stop sleep 1 $0 start ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 ;; esac |