Debian Codegraph @

debian/init

raw
1 #! /bin/sh
2
3 ### BEGIN INIT INFO
4 # Provides: pgqd
5 # Required-Start: $local_fs $remote_fs $network $named $syslog
6 # Required-Stop: $local_fs $remote_fs $network $named $syslog
7 # Default-Start: 2 3 4 5
8 # Default-Stop: 0 1 6
9 # Short-Description: PgQ maintenance daemon
10 # Description: PgQ maintenance daemon
11 ### END INIT INFO
12
13 PATH=/sbin:/usr/sbin:/bin:/usr/bin
14 DESC="PgQ daemon"
15 NAME=pgqd
16 USER=postgres
17 DAEMON=/usr/bin/$NAME
18 DAEMON_ARGS="-d -q /etc/pgqd.ini"
19 PIDFILE=/var/run/postgresql/$NAME.pid
20 SCRIPTNAME=/etc/init.d/$NAME
21
22 # Exit if the package is not installed
23 [ -x "$DAEMON" ] || exit 0
24
25 # Read configuration variable file if it is present
26 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
27
28 # Load the VERBOSE setting and other rcS variables
29 #. /lib/init/vars.sh
30
31 # Define LSB log_* functions.
32 # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
33 # and status_of_proc is working.
34 . /lib/lsb/init-functions
35
36 SSD="start-stop-daemon --quiet --pidfile $PIDFILE --user $USER --name $NAME --exec $DAEMON"
37
38 #
39 # Function that starts the daemon/service
40 #
41 do_start()
42 {
43 $SSD --start --chuid $USER -- $DAEMON_ARGS
44 }
45
46 #
47 # Function that stops the daemon/service
48 #
49 do_stop()
50 {
51 $SSD --stop --retry=TERM/30/KILL/5
52 rm -f $PIDFILE
53 }
54
55 #
56 # Function that sends a SIGHUP to the daemon/service
57 #
58 do_reload() {
59 $SSD --stop --signal 1
60 }
61
62 case "$1" in
63 start)
64 [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
65 do_start
66 case "$?" in
67 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
68 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
69 esac
70 ;;
71 stop)
72 [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
73 do_stop
74 case "$?" in
75 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
76 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
77 esac
78 ;;
79 status)
80 status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
81 ;;
82 reload|force-reload)
83 log_daemon_msg "Reloading $DESC" "$NAME"
84 do_reload
85 log_end_msg $?
86 ;;
87 restart)
88 log_daemon_msg "Restarting $DESC" "$NAME"
89 do_stop
90 case "$?" in
91 0|1)
92 do_start
93 case "$?" in
94 0) log_end_msg 0 ;;
95 1) log_end_msg 1 ;; # Old process is still running
96 *) log_end_msg 1 ;; # Failed to start
97 esac
98 ;;
99 *)
100 # Failed to stop
101 log_end_msg 1
102 ;;
103 esac
104 ;;
105 *)
106 echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload}" >&2
107 exit 3
108 ;;
109 esac
110
111 :