[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] /etc/rc.d/init.d/postgresql file missing



It's just a script (below) --not sure if it'll bring back your sites or
not, or if the sites got nuked then it will not.


- Mike

$ more /etc/rc.d/init.d/postgresql
#!/bin/bash

# postgresql    This is the init script for starting up the PostgreSQL
#               server
#
# chkconfig:   345 85 15
# description: Starts and stops the PostgreSQL backend daemon
# processname: postmaster
# pidfile:     /var/run/postmaster.pid
#

[ -x /usr/bin/postmaster        ] || exit 1
[ -s /etc/rc.d/init.d/functions ] || exit 1
[ -s /etc/sysconfig/network     ] || exit 1

. /etc/rc.d/init.d/functions
. /etc/sysconfig/network

[ $NETWORKING = "no"     ] && exit 0
[ -s /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n

VERBOSE=yes
[ "$2" = "quiet" ] && VERBOSE=

DOMAIN=initscripts
PIDFILE=/var/run/postmaster.pid
LOCKFILE=/var/lock/subsys/postgresql
PGDATA=/var/lib/pgsql/data
export PGDATA

case "$1" in
    start)
        if [ $VERBOSE ]; then
            LINE1=`getmsg postgresql_start_1`
            LINE2=`getmsg postgresql_start_2`
            $LCD_STOP
            $LCD_SWRITE "$LINE1" "$LINE2" &> /dev/null &
            echo -n "$LINE1 $LINE2: "
        fi

        if [ -s $PGDATA/PG_VERSION -a -d $PGDATA/base/template1 ]; then
            if [ `cat $PGDATA/PG_VERSION` != "7.0" ]; then
                [ $VERBOSE ] && echo "old version, upgrade to 7.0!"
                exit 1
            fi
        else
            [ $VERBOSE ] && echo "no database files found.  creating..."
            if [ ! -d $PGDATA ]; then
                mkdir -p $PGDATA
                chown postgres.postgres $PGDATA
            fi
            su postgres -c "/usr/bin/initdb --pglib=/usr/lib/pgsql --pgdata=$PGDATA"
        fi

        pid=`pidof postmaster`
        if [ $pid ]; then
            [ $VERBOSE ] && echo "postmaster already running!"
            exit 1
        fi

        rm -f /tmp/.s.PGSQL.*
        su postgres -c "nohup /usr/bin/postmaster >> /var/log/postgresql 2>&1 &"
        sleep 1

        pid=`pidof postmaster`
        if [ $pid ]; then
            [ $VERBOSE ] && echo "ok [$pid]"
            echo $pid > $PIDFILE
            touch $LOCKFILE
        else
            [ $VERBOSE     ] && echo "failed!"
            [ -f $PIDFILE  ] && rm -f $PIDFILE
            [ -f $LOCKFILE ] && rm -f $LOCKFILE
            exit 1
        fi

        if [ ! -d $PGDATA/base/cobalt ]; then
            /usr/local/sbin/setup-postgres
        fi
        ;;

    stop)
        if [ $VERBOSE ]; then
            LINE1=`getmsg postgresql_stop_1`
            LINE2=`getmsg postgresql_stop_2`
            $LCD_STOP
            $LCD_SWRITE "$LINE1" "$LINE2" &> /dev/null &
            echo -n "$LINE1 $LINE2: "
        fi

        pid=`pidof postmaster`
        if [ $pid ]; then
            if [ -s $PIDFILE ] && [ `cat $PIDFILE` != $pid ]; then
                [ $VERBOSE ] && echo -n "process ID mismatch! "
            fi
            kill $pid
            sleep 2
            [ $VERBOSE ] && echo "ok"
        else
            [ $VERBOSE ] && echo "not running!"
        fi

        [ -f $PIDFILE  ] && rm -f $PIDFILE
        [ -f $LOCKFILE ] && rm -f $LOCKFILE
        ;;

    status)
        status postmaster
        ;;

    restart)
        EXTRA=
        [ $VERBOSE ] || EXTRA=quiet
        $0 stop $EXTRA
        $0 start $EXTRA
        ;;

    hard-restart)
        $0 stop quiet
        $0 start quiet
        ;;

    *)
        echo "Usage: postgresql {start|stop|status|restart} [quiet]"
        exit 1

esac

exit 0


On Sat, 11 Jan 2003, Donald Harris wrote:

> While doing some cleaning, my programmer inadvertently shut down postgresql.
> It now won't restart, apparently because of a missing file. I've searched
> the archives and there are a couple of posts related to this, but nothing
> specific to how to replace the file.
> 
> Is there a way of replacing  /etc/rc.d/init.d/postgresql ?
> If we can replace it, will all the virtual site information be intact?
> 
> Any instructions, help, suggestions are appreciated.
> 
> We do not have a backup of the config files (stupid, I know).
> 
> Regards,
> 
> Donald Harris
> Mental Soup
> http://www.mentalsoup.com/
> 
> 
> _____________________________________
> cobalt-users mailing list
> cobalt-users@xxxxxxxxxxxxxxx
> To subscribe/unsubscribe, or to SEARCH THE ARCHIVES, go to:
> http://list.cobalt.com/mailman/listinfo/cobalt-users
>