wok-6.x view postgresql/stuff/etc/init.d/postgresql @ rev 4957
init script for mysql, openldap & postgresql always check /etc/<daemon>.d/*
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Feb 17 22:01:10 2010 +0100 (2010-02-17) |
parents | 8a251dbc2bed |
children | 7f188676b59c |
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 fi
25 echo -n "Starting $DESC: $NAME... "
26 su -c "pg_ctl start -w $OPTIONS -l /var/log/postgresql/postgresql.log" - postgres
27 status
28 sleep 2
29 for i in /etc/pgsql.d/* ; do
30 [ -x $i ] || continue
31 echo -n "Running $i..."
32 $i
33 status
34 done
35 # su -c "createdb test" - postgres
36 # su -c "psql test" - postgres
37 ;;
38 stop)
39 echo -n "Stopping $DESC: $NAME... "
40 su -c "pg_ctl stop $OPTIONS -m smart" - postgres
41 status
42 ;;
43 restart)
44 echo -n "Restarting $DESC: $NAME... "
45 su -c "pg_ctl restart $OPTIONS -m smart" - postgres
46 status
47 ;;
48 reload)
49 echo -n "Reloading $DESC: $NAME... "
50 su -c "pg_ctl reload $OPTIONS" - postgres
51 status
52 ;;
53 *)
54 echo ""
55 echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart|reload]"
56 echo ""
57 exit 1
58 ;;
59 esac
61 exit 0