wok-6.x view postgresql/stuff/etc/init.d/postgresql @ rev 1967
pgsql: external init script support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Jan 01 13:44:39 2009 +0000 (2009-01-01) |
parents | df0ba7a1b7e1 |
children | 8a251dbc2bed |
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 "Running $i..."
31 $i
32 done
33 else
34 echo -n "Starting $DESC: $NAME... "
35 su -c "pg_ctl start -w $OPTIONS -l /var/log/postgresql/postgresql.log" - postgres
36 status
37 sleep 2
38 fi
39 # su -c "createdb test" - postgres
40 # su -c "psql test" - postgres
41 ;;
42 stop)
43 echo -n "Stopping $DESC: $NAME... "
44 su -c "pg_ctl stop $OPTIONS -m smart" - postgres
45 status
46 ;;
47 restart)
48 echo -n "Restarting $DESC: $NAME... "
49 su -c "pg_ctl restart $OPTIONS -m smart" - postgres
50 status
51 ;;
52 reload)
53 echo -n "Reloading $DESC: $NAME... "
54 su -c "pg_ctl reload $OPTIONS" - postgres
55 status
56 ;;
57 *)
58 echo ""
59 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart|reload]"
60 echo ""
61 exit 1
62 ;;
63 esac
65 exit 0