wok-next view postgresql/stuff/etc/init.d/postgresql @ rev 2302

mysql,openldap,postgresql: display init scripts status
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Feb 24 11:01:55 2009 +0000 (2009-02-24)
parents 69efa92df38e
children a44a640b886e
line source
1 #!/bin/sh
2 # /etc/init.d/postgresql : Start, stop and restart PostgreSQL server on SliTaz,
3 # at boot time or with the command line.
4 #
5 # To start postgresql server at boot time, just put postgresql in the $RUN_DAEMONS
6 # variable of /etc/rcS.conf and configure options with /etc/daemons.conf
7 #
8 . /etc/init.d/rc.functions
9 . /etc/daemons.conf
11 NAME=Postgresql
12 DESC="PostgreSQL server"
13 OPTIONS=$PGSQL_OPTIONS
14 INIT_OPTIONS=$PGSQLINIT_OPTIONS
15 [ -n "$OPTIONS" ] || OPTIONS="-D /var/lib/pgsql -s"
16 [ -n "$INIT_OPTIONS" ] || INIT_OPTIONS="--no-locale --encoding=SQL_ASCII -D /var/lib/pgsql"
18 case "$1" in
19 start)
20 if [ ! -f /var/lib/pgsql/PG_VERSION ]; then
21 echo "Initializing $DESC database"
22 rm -rf /var/lib/pgsql/* 2> /dev/null
23 su -c "initdb $INIT_OPTIONS" - postgres
24 echo -n "Starting $DESC: $NAME... "
25 su -c "pg_ctl start -w $OPTIONS -l /var/log/postgresql/postgresql.log" - postgres
26 status
27 sleep 2
28 for i in /etc/pgsql.d/* ; do
29 [ -x $i ] || continue
30 echo -n "Running $i..."
31 $i
32 status
33 done
34 else
35 echo -n "Starting $DESC: $NAME... "
36 su -c "pg_ctl start -w $OPTIONS -l /var/log/postgresql/postgresql.log" - postgres
37 status
38 sleep 2
39 fi
40 # su -c "createdb test" - postgres
41 # su -c "psql test" - postgres
42 ;;
43 stop)
44 echo -n "Stopping $DESC: $NAME... "
45 su -c "pg_ctl stop $OPTIONS -m smart" - postgres
46 status
47 ;;
48 restart)
49 echo -n "Restarting $DESC: $NAME... "
50 su -c "pg_ctl restart $OPTIONS -m smart" - postgres
51 status
52 ;;
53 reload)
54 echo -n "Reloading $DESC: $NAME... "
55 su -c "pg_ctl reload $OPTIONS" - postgres
56 status
57 ;;
58 *)
59 echo ""
60 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart|reload]"
61 echo ""
62 exit 1
63 ;;
64 esac
66 exit 0