diff options
author | YAEGASHI Takeshi <yaegashi@debian.org> | 2014-02-15 19:14:40 (JST) |
---|---|---|
committer | YAEGASHI Takeshi <yaegashi@debian.org> | 2014-02-17 05:37:22 (JST) |
commit | 7489123c46a67ef328aead1b1eca0239b3d98eae (patch) | |
tree | 0ed837227f4d808bdc946cd6c917fdf86ee7aa28 /debian/init.d.ex | |
parent | 6952f164c10689e3c112dbef85e461a6246654be (diff) | |
download | cgit-7489123c46a67ef328aead1b1eca0239b3d98eae.zip cgit-7489123c46a67ef328aead1b1eca0239b3d98eae.tar.gz |
Debianized by dh_make -s -p cgit_0.10
Diffstat (limited to 'debian/init.d.ex')
-rw-r--r-- | debian/init.d.ex | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/debian/init.d.ex b/debian/init.d.ex new file mode 100644 index 0000000..5bf16a6 --- /dev/null +++ b/debian/init.d.ex | |||
@@ -0,0 +1,166 @@ | |||
1 | #!/bin/sh | ||
2 | ### BEGIN INIT INFO | ||
3 | # Provides: cgit | ||
4 | # Required-Start: $local_fs $network $remote_fs $syslog | ||
5 | # Required-Stop: $local_fs $network $remote_fs $syslog | ||
6 | # Default-Start: 2 3 4 5 | ||
7 | # Default-Stop: 0 1 6 | ||
8 | # Short-Description: <Enter a short description of the software> | ||
9 | # Description: <Enter a long description of the software> | ||
10 | # <...> | ||
11 | # <...> | ||
12 | ### END INIT INFO | ||
13 | |||
14 | # Author: YAEGASHI Takeshi <yaegashi@debian.org> | ||
15 | |||
16 | # Do NOT "set -e" | ||
17 | |||
18 | # PATH should only include /usr/* if it runs after the mountnfs.sh script | ||
19 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | ||
20 | DESC="cgit" | ||
21 | NAME=cgit | ||
22 | DAEMON=/usr/sbin/cgit | ||
23 | DAEMON_ARGS="" | ||
24 | PIDFILE=/var/run/$NAME.pid | ||
25 | SCRIPTNAME=/etc/init.d/$NAME | ||
26 | |||
27 | # Exit if the package is not installed | ||
28 | [ -x "$DAEMON" ] || exit 0 | ||
29 | |||
30 | # Read configuration variable file if it is present | ||
31 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME | ||
32 | |||
33 | # Load the VERBOSE setting and other rcS variables | ||
34 | . /lib/init/vars.sh | ||
35 | |||
36 | # Define LSB log_* functions. | ||
37 | # Depend on lsb-base (>= 3.2-14) to ensure that this file is present | ||
38 | # and status_of_proc is working. | ||
39 | . /lib/lsb/init-functions | ||
40 | |||
41 | # | ||
42 | # Function that starts the daemon/service | ||
43 | # | ||
44 | do_start() | ||
45 | { | ||
46 | # Return | ||
47 | # 0 if daemon has been started | ||
48 | # 1 if daemon was already running | ||
49 | # 2 if daemon could not be started | ||
50 | start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ | ||
51 | || return 1 | ||
52 | start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ | ||
53 | $DAEMON_ARGS \ | ||
54 | || return 2 | ||
55 | # The above code will not work for interpreted scripts, use the next | ||
56 | # six lines below instead (Ref: #643337, start-stop-daemon(8) ) | ||
57 | #start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON \ | ||
58 | # --name $NAME --test > /dev/null \ | ||
59 | # || return 1 | ||
60 | #start-stop-daemon --start --quiet --pidfile $PIDFILE --startas $DAEMON \ | ||
61 | # --name $NAME -- $DAEMON_ARGS \ | ||
62 | # || return 2 | ||
63 | |||
64 | # Add code here, if necessary, that waits for the process to be ready | ||
65 | # to handle requests from services started subsequently which depend | ||
66 | # on this one. As a last resort, sleep for some time. | ||
67 | } | ||
68 | |||
69 | # | ||
70 | # Function that stops the daemon/service | ||
71 | # | ||
72 | do_stop() | ||
73 | { | ||
74 | # Return | ||
75 | # 0 if daemon has been stopped | ||
76 | # 1 if daemon was already stopped | ||
77 | # 2 if daemon could not be stopped | ||
78 | # other if a failure occurred | ||
79 | start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME | ||
80 | RETVAL="$?" | ||
81 | [ "$RETVAL" = 2 ] && return 2 | ||
82 | # Wait for children to finish too if this is a daemon that forks | ||
83 | # and if the daemon is only ever run from this initscript. | ||
84 | # If the above conditions are not satisfied then add some other code | ||
85 | # that waits for the process to drop all resources that could be | ||
86 | # needed by services started subsequently. A last resort is to | ||
87 | # sleep for some time. | ||
88 | start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON | ||
89 | [ "$?" = 2 ] && return 2 | ||
90 | # Many daemons don't delete their pidfiles when they exit. | ||
91 | rm -f $PIDFILE | ||
92 | return "$RETVAL" | ||
93 | } | ||
94 | |||
95 | # | ||
96 | # Function that sends a SIGHUP to the daemon/service | ||
97 | # | ||
98 | do_reload() { | ||
99 | # | ||
100 | # If the daemon can reload its configuration without | ||
101 | # restarting (for example, when it is sent a SIGHUP), | ||
102 | # then implement that here. | ||
103 | # | ||
104 | start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME | ||
105 | return 0 | ||
106 | } | ||
107 | |||
108 | case "$1" in | ||
109 | start) | ||
110 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" | ||
111 | do_start | ||
112 | case "$?" in | ||
113 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; | ||
114 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; | ||
115 | esac | ||
116 | ;; | ||
117 | stop) | ||
118 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" | ||
119 | do_stop | ||
120 | case "$?" in | ||
121 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; | ||
122 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; | ||
123 | esac | ||
124 | ;; | ||
125 | status) | ||
126 | status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? | ||
127 | ;; | ||
128 | #reload|force-reload) | ||
129 | # | ||
130 | # If do_reload() is not implemented then leave this commented out | ||
131 | # and leave 'force-reload' as an alias for 'restart'. | ||
132 | # | ||
133 | #log_daemon_msg "Reloading $DESC" "$NAME" | ||
134 | #do_reload | ||
135 | #log_end_msg $? | ||
136 | #;; | ||
137 | restart|force-reload) | ||
138 | # | ||
139 | # If the "reload" option is implemented then remove the | ||
140 | # 'force-reload' alias | ||
141 | # | ||
142 | log_daemon_msg "Restarting $DESC" "$NAME" | ||
143 | do_stop | ||
144 | case "$?" in | ||
145 | 0|1) | ||
146 | do_start | ||
147 | case "$?" in | ||
148 | 0) log_end_msg 0 ;; | ||
149 | 1) log_end_msg 1 ;; # Old process is still running | ||
150 | *) log_end_msg 1 ;; # Failed to start | ||
151 | esac | ||
152 | ;; | ||
153 | *) | ||
154 | # Failed to stop | ||
155 | log_end_msg 1 | ||
156 | ;; | ||
157 | esac | ||
158 | ;; | ||
159 | *) | ||
160 | #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 | ||
161 | echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 | ||
162 | exit 3 | ||
163 | ;; | ||
164 | esac | ||
165 | |||
166 | : | ||