Some SlackBuild scripts for Slackware.
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.
slackbuilds/ap/postgresql/rc.postgresql

54 lines
1.3 KiB

#!/bin/sh
PGDATA=/var/lib/pgsql
PGLOG=$PGDATA/serverlog
pgsql_init() {
if [ ! -d $PGDATA ]; then
echo "Initializing PostgreSQL cluster in $PGDATA..."
mkdir -p $PGDATA
chown postgres:postgres $PGDATA
su - postgres -c "/usr/bin/initdb -D $PGDATA"
elif [ ! -f $PGDATA/PG_VERSION ]; then
echo "$PGDATA is not a PostgreSQL cluster directory!"
exit 1
elif [ `cat $PGDATA/PG_VERSION` != '9.2' ]; then
echo "$PGDATA is the data directory of an old PostgreSQL server."
echo "PostgreSQL 9.2 can not directly use these data. If you are"
echo "migrating from a previous major version of PostgreSQL, please"
echo "read the file /usr/doc/postgresql-9.2.4/README_UPGRADE.txt."
exit 1
fi
}
case "$1" in
init)
pgsql_init
;;
start)
pgsql_init
su - postgres -c "/usr/bin/pg_ctl start -D $PGDATA -l $PGLOG"
;;
stop)
su - postgres -c "/usr/bin/pg_ctl stop -D $PGDATA -m smart"
;;
restart)
su - postgres -c "/usr/bin/pg_ctl restart -D $PGDATA -l $PGLOG -m smart"
;;
reload)
su - postgres -c "/usr/bin/pg_ctl reload -D $PGDATA"
;;
status)
su - postgres -c "/usr/bin/pg_ctl status -D $PGDATA"
;;
*)
echo "Usage: `basename $0` {init|start|stop|restart|reload|status}" 1>&2
exit 1
;;
esac