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.

62 lines
1.6 KiB

#!/bin/sh
PGCONF=/etc/pgsql
PGDATA=/var/lib/pgsql
PGLOG="-l /var/log/pgsql/server.log"
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"
if [ ! -f $PGCONF/postgresql.conf ]; then
sed "s,ConfigDir,$PGDATA,
s,^#data_directory,data_directory,
s,^#hba_file,hba_file,
s,^#ident_file,ident_file," \
$PGDATA/postgresql.conf > $PGCONF/postgresql.conf
fi
elif [ ! -f $PGDATA/PG_VERSION ]; then
echo "$PGDATA is not a PostgreSQL cluster directory!"
exit 1
elif [ `cat $PGDATA/PG_VERSION` != '11' ]; then
echo "$PGDATA is the data directory of an old PostgreSQL server."
echo "PostgreSQL 10.8 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-11.6/README_UPGRADE.txt."
exit 1
fi
}
case "$1" in
init)
pgsql_init
;;
start)
pgsql_init
su - postgres -c "/usr/bin/pg_ctl start -D $PGCONF $PGLOG"
;;
stop)
su - postgres -c "/usr/bin/pg_ctl stop -D $PGCONF -m smart"
;;
restart)
su - postgres -c "/usr/bin/pg_ctl restart -D $PGCONF $PGLOG -m smart"
;;
reload)
su - postgres -c "/usr/bin/pg_ctl reload -D $PGCONF"
;;
status)
su - postgres -c "/usr/bin/pg_ctl status -D $PGCONF"
;;
*)
echo "Usage: `basename $0` {init|start|stop|restart|reload|status}" 1>&2
exit 1
;;
esac