wok view postgresql/stuff/etc/init.d/postgresql @ rev 19159

/etc/init.d/*: use 'action' in pair with 'status'.
'action' returns translated message, so why not to add full translatable /etc/init.d/* content
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu May 26 20:16:45 2016 +0300 (2016-05-26)
parents a44a640b886e
children
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="$(_ '%s server' PostgreSQL)"
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 _ 'Initializing PostgreSQL server database'
22 rm -rf /var/lib/pgsql/* 2>/dev/null
23 su -c "initdb $INIT_OPTIONS" - postgres
24 fi
25 action 'Starting %s: %s...' "$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 action 'Running %s...' $i
32 $i
33 status
34 done
35 # su -c "createdb test" - postgres
36 # su -c "psql test" - postgres
37 ;;
38 stop)
39 action 'Stopping %s: %s...' "$DESC" $NAME
40 su -c "pg_ctl stop $OPTIONS -m smart" - postgres
41 status
42 ;;
43 restart)
44 action 'Restarting %s: %s...' "$DESC" $NAME
45 su -c "pg_ctl restart $OPTIONS -m smart" - postgres
46 status
47 ;;
48 reload)
49 action 'Reloading %s: %s...' "$DESC" $NAME
50 su -c "pg_ctl reload $OPTIONS" - postgres
51 status
52 ;;
53 *)
54 emsg "<n><b>$(_ 'Usage:')</b> $0 [start|stop|restart|reload]"
55 newline
56 exit 1
57 ;;
58 esac
60 exit 0