configuration-templates – Blame information for rev 56
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
56 | office | 1 | #!/bin/sh |
2 | |||
3 | ### BEGIN INIT INFO |
||
4 | # Provides: private-bower |
||
5 | # Required-Start: $local_fs $syslog |
||
6 | # Required-Stop: $local_fs $syslog |
||
7 | # Default-Start: 2 3 4 5 |
||
8 | # Default-Stop: 0 1 6 |
||
9 | # Short-Description: Start and stop private-bower standalone server |
||
10 | # Description: Start and stop private-bower standalone server |
||
11 | ### END INIT INFO |
||
12 | |||
13 | # Author: Wizardry and Steamworks <office@grimore.org> |
||
14 | |||
15 | # Skip systemd redirect. |
||
16 | _SYSTEMCTL_SKIP_REDIRECT=OHYES |
||
17 | |||
18 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin |
||
19 | DESC="private-bower standalone server" |
||
20 | NAME=private-bower |
||
21 | DAEMON=$(which $NAME) |
||
22 | PIDFILE=/var/run/$NAME.pid |
||
23 | SCRIPTNAME=/etc/init.d/$NAME |
||
24 | |||
25 | # Exit if the package is not installed |
||
26 | [ -x "$DAEMON" ] || exit 0 |
||
27 | |||
28 | # Read configuration variable file if it is present |
||
29 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME |
||
30 | |||
31 | # Load the VERBOSE setting and other rcS variables |
||
32 | . /lib/init/vars.sh |
||
33 | |||
34 | # Define LSB log_* functions. |
||
35 | # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. |
||
36 | . /lib/lsb/init-functions |
||
37 | |||
38 | # Default configuration for daemon |
||
39 | DAEMON_ARGS="--config ${PRIVATE_BOWER_CONFIG_FILE}" |
||
40 | |||
41 | do_start() |
||
42 | { |
||
43 | # 0 if daemon has been started |
||
44 | # 1 if daemon was already running |
||
45 | # 2 if daemon could not be started |
||
46 | start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null || return 1 |
||
47 | start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --background --make-pidfile --chuid $DAEMON_USER --startas $DAEMON -- $DAEMON_ARGS || return 2 |
||
48 | } |
||
49 | |||
50 | do_stop() |
||
51 | { |
||
52 | # Return |
||
53 | # 0 if daemon has been stopped |
||
54 | # 1 if daemon was already stopped |
||
55 | # 2 if daemon could not be stopped |
||
56 | # other if a failure occurred |
||
57 | start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE > /dev/null # --name $DAEMON |
||
58 | RETVAL="$?" |
||
59 | [ "$RETVAL" = 2 ] && return 2 |
||
60 | # Wait for children to finish too if this is a daemon that forks |
||
61 | # and if the daemon is only ever run from this initscript. |
||
62 | # If the above conditions are not satisfied then add some other code |
||
63 | # that waits for the process to drop all resources that could be |
||
64 | # needed by services started subsequently. A last resort is to |
||
65 | # sleep for some time. |
||
66 | start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON |
||
67 | [ "$?" = 2 ] && return 2 |
||
68 | # Many daemons don't delete their pidfiles when they exit. |
||
69 | rm -f $PIDFILE |
||
70 | return "$RETVAL" |
||
71 | } |
||
72 | |||
73 | case "$1" in |
||
74 | start) |
||
75 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" |
||
76 | do_start |
||
77 | case "$?" in |
||
78 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; |
||
79 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; |
||
80 | esac |
||
81 | ;; |
||
82 | stop) |
||
83 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" |
||
84 | do_stop |
||
85 | case "$?" in |
||
86 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; |
||
87 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; |
||
88 | esac |
||
89 | ;; |
||
90 | restart|force-reload) |
||
91 | log_daemon_msg "Restarting $DESC" "$NAME" |
||
92 | do_stop |
||
93 | case "$?" in |
||
94 | 0|1) |
||
95 | do_start |
||
96 | case "$?" in |
||
97 | 0) log_end_msg 0 ;; |
||
98 | 1) log_end_msg 1 ;; # Old process is still running |
||
99 | *) log_end_msg 1 ;; # Failed to start |
||
100 | esac |
||
101 | ;; |
||
102 | *) |
||
103 | # Failed to stop |
||
104 | log_end_msg 1 |
||
105 | ;; |
||
106 | esac |
||
107 | ;; |
||
108 | *) |
||
109 | echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 |
||
110 | exit 3 |
||
111 | ;; |
||
112 | esac |