Ticket #961: debian-init-script-patch-final

File debian-init-script-patch-final, 9.5 KB (added by ioerror, at 2010-03-04T09:42:30Z)

the lenny files required to install, remove, and purge a .deb

Line 
1Thu Mar  4 01:02:34 PST 2010  jacob@appelbaum.net
2  * debian init and default scripts
3
4Thu Mar  4 01:05:16 PST 2010  jacob@appelbaum.net
5  * defaults for init.d script
6
7Thu Mar  4 01:10:27 PST 2010  jacob@appelbaum.net
8  * postinst fix
9
10Thu Mar  4 01:15:00 PST 2010  jacob@appelbaum.net
11  * getent fixup
12
13Thu Mar  4 01:17:05 PST 2010  jacob@appelbaum.net
14  * daemon fixups
15
16Thu Mar  4 01:24:00 PST 2010  jacob@appelbaum.net
17  * remove user at dpkg --remove
18
19Thu Mar  4 01:25:46 PST 2010  jacob@appelbaum.net
20  * disable the daemon by default
21
22Thu Mar  4 01:26:43 PST 2010  jacob@appelbaum.net
23  * only remove user, not group
24
25Thu Mar  4 01:31:37 PST 2010  jacob@appelbaum.net
26  * purging user at purge time only
27
28New patches:
29
30[debian init and default scripts
31jacob@appelbaum.net**20100304090234] {
32addfile ./misc/lenny/debian/allmydata-tahoe.init
33hunk ./misc/lenny/debian/allmydata-tahoe.init 1
34+#! /bin/sh
35+### BEGIN INIT INFO
36+# Provides:          allmydata-tahoe
37+# Required-Start:    $remote_fs
38+# Required-Stop:     $remote_fs
39+# Default-Start:     2 3 4 5
40+# Default-Stop:      0 1 6
41+# Short-Description: Tahoe-LAFS initscript
42+# Description:       This starts Tahoe and runs it as a daemon
43+### END INIT INFO
44+
45+# Author: Jacob Appelbaum <jacob@appelbaum.net>
46+
47+# Do NOT "set -e"
48+
49+# PATH should only include /usr/* if it runs after the mountnfs.sh script
50+PATH=/sbin:/usr/sbin:/bin:/usr/bin
51+DESC="Tahoe-LAFS is a secure, decentralized, data store."
52+NAME=tahoe
53+DEFAULTS=allmydata-tahoe
54+DAEMONHOME="/var/lib/tahoelafsd/"
55+DAEMON=/usr/bin/$NAME
56+DAEMON_ARGS=" start $DAEMONHOME"
57+PIDFILE=/var/lib/tahoelafsd/twisted.pid
58+USERNAME=tahoelafsd
59+SCRIPTNAME=/etc/init.d/$NAME
60+
61+# Exit if the package is not installed
62+[ -x "$DAEMON" ] || exit 0
63+
64+# Read configuration variable file if it is present
65+[ -r /etc/default/$DEFAULTS ] && . /etc/default/$DEFAULTS
66+
67+# Exit if we're unconfigured
68+if [ "$ENABLED" = "FALSE" ]; then
69+    echo "Tahoe is disabled; please edit /etc/defaults/$DEFAULTS";
70+    exit 0;
71+fi
72+
73+# Load the VERBOSE setting and other rcS variables
74+. /lib/init/vars.sh
75+
76+# Define LSB log_* functions.
77+# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
78+. /lib/lsb/init-functions
79+
80+#
81+# Function that starts the daemon/service
82+#
83+do_start()
84+{
85+       # Return
86+       #   2 if daemon could not be started
87+       su -c "$DAEMON $DAEMON_ARGS" $USERNAME \
88+               || return 2
89+}
90+
91+#
92+# Function that stops the daemon/service
93+#
94+do_stop()
95+{
96+       # Return
97+       #   0 if daemon has been stopped
98+       #   1 if daemon was already stopped
99+       #   2 if daemon could not be stopped
100+        su -c "$DAEMON stop $DAEMONHOME" $USERNAME \
101+                || return 2
102+       RETVAL="$?"
103+       [ "$RETVAL" = 2 ] && return 2
104+       return "$RETVAL"
105+}
106+
107+#
108+# Function that sends a SIGHUP to the daemon/service
109+#
110+do_reload() {
111+       #
112+       # If the daemon can reload its configuration without
113+       # restarting (for example, when it is sent a SIGHUP),
114+       # then implement that here.
115+       #
116+       echo "Tahoe does not currently support HUP by reloading its config file."
117+       return 0
118+}
119+
120+case "$1" in
121+  start)
122+       [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
123+       do_start
124+       case "$?" in
125+               0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
126+               2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
127+       esac
128+       ;;
129+  stop)
130+       [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
131+       do_stop
132+       case "$?" in
133+               0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
134+               2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
135+       esac
136+       ;;
137+  #reload|force-reload)
138+       #
139+       # If do_reload() is not implemented then leave this commented out
140+       # and leave 'force-reload' as an alias for 'restart'.
141+       #
142+       #log_daemon_msg "Reloading $DESC" "$NAME"
143+       #do_reload
144+       #log_end_msg $?
145+       #;;
146+  restart|force-reload)
147+       #
148+       # If the "reload" option is implemented then remove the
149+       # 'force-reload' alias
150+       #
151+       log_daemon_msg "Restarting $DESC" "$NAME"
152+       do_stop
153+       case "$?" in
154+         0|1)
155+               do_start
156+               case "$?" in
157+                       0) log_end_msg 0 ;;
158+                       1) log_end_msg 1 ;; # Old process is still running
159+                       *) log_end_msg 1 ;; # Failed to start
160+               esac
161+               ;;
162+         *)
163+               # Failed to stop
164+               log_end_msg 1
165+               ;;
166+       esac
167+       ;;
168+  *)
169+       #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
170+       echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
171+       exit 3
172+       ;;
173+esac
174+
175+:
176addfile ./misc/lenny/debian/allmydata-tahoe.postinst
177hunk ./misc/lenny/debian/allmydata-tahoe.postinst 1
178+# Automatically added by dh_pycentral
179+if which pycentral >/dev/null 2>&1; then
180+       pycentral pkginstall allmydata-tahoe
181+       if grep -qs '^allmydata-tahoe$' /var/lib/pycentral/delayed-pkgs; then
182+               sed -i '/^allmydata-tahoe$/d' /var/lib/pycentral/delayed-pkgs
183+       fi
184+fi
185+# End automatically added section
186+# Automatically added by dh_pycentral
187+if which pycentral >/dev/null 2>&1; then
188+       pycentral pkginstall allmydata-tahoe
189+       if grep -qs '^allmydata-tahoe$' /var/lib/pycentral/delayed-pkgs; then
190+               sed -i '/^allmydata-tahoe$/d' /var/lib/pycentral/delayed-pkgs
191+       fi
192+fi
193+# End automatically added section
194+
195+# This checks for a tahoelafsd user
196+uid=`getend passwd tahoelafsd | cut -d ":" -f 3`
197+home=`getent passwd tahoelafsd |cut -d ":" -f 6`
198+
199+if [ "$uid" ]; then
200+    if [ "$home" = "/var/lib/tahoelafsd" ]; then
201+        chmod 750 /var/lib/tahoelafs/
202+    else
203+        echo "tahoelafsd has an incorrect home directory!"
204+    fi
205+else
206+    echo "Adding tahoelafsd group..."
207+    addgroup --system tahoelafsd
208+    echo "Adding tahoelafsd user..."
209+    adduser --disabled-login --system --home /var/lib/tahoelafs \
210+            --shell /bin/bash --ingroup tahoelafsd tahoelafsd
211+    echo "Protecting tahoelafsd home directory from snooping eyes"
212+    chmod 750 /var/lib/tahoelafs/
213+fi
214addfile ./misc/lenny/debian/allmydata-tahoe.postrm
215hunk ./misc/lenny/debian/allmydata-tahoe.postrm 1
216+#!/bin/sh -e
217+
218+if [ "$1" = "purge" ]; then
219+    rm -rf /var/lib/tahoelafsd/
220+fi
221+
222+exit 0
223}
224
225[defaults for init.d script
226jacob@appelbaum.net**20100304090516] {
227addfile ./misc/lenny/debian/allmydata-tahoe.default
228hunk ./misc/lenny/debian/allmydata-tahoe.default 1
229+# Defaults for tahoelafsd initscript
230+# sourced by /etc/init.d/allmydata-tahoe
231+# installed at /etc/default/allmydata-tahoe by the maintainer scripts
232+
233+# Uncomment these to change the default settings in the init.d script
234+# USERNAME="tahoelafsd"
235+# DAEMONHOME="/var/lib/tahoelafsd/"
236+# DAEMON_ARGS=" start $DAEMONHOME"
237+
238+# By default, Tahoe is unconfigured
239+# (this is very unfriendly to non-power users)
240+# To configure Tahoe, consider running:
241+# tahoe create-client $DAEMONHOME
242+
243+# Once you've run the above command, set the following line to "TRUE"
244+# to have the init.d script start Tahoe
245+ENABLED="TRUE"
246+
247}
248
249[postinst fix
250jacob@appelbaum.net**20100304091027] hunk ./misc/lenny/debian/allmydata-tahoe.postinst 1
251+#!/bin/sh -e
252
253[getent fixup
254jacob@appelbaum.net**20100304091500] {
255hunk ./misc/lenny/debian/allmydata-tahoe.postinst 2
256-# Automatically added by dh_pycentral
257-if which pycentral >/dev/null 2>&1; then
258-       pycentral pkginstall allmydata-tahoe
259-       if grep -qs '^allmydata-tahoe$' /var/lib/pycentral/delayed-pkgs; then
260-               sed -i '/^allmydata-tahoe$/d' /var/lib/pycentral/delayed-pkgs
261-       fi
262-fi
263-# End automatically added section
264-# Automatically added by dh_pycentral
265-if which pycentral >/dev/null 2>&1; then
266-       pycentral pkginstall allmydata-tahoe
267-       if grep -qs '^allmydata-tahoe$' /var/lib/pycentral/delayed-pkgs; then
268-               sed -i '/^allmydata-tahoe$/d' /var/lib/pycentral/delayed-pkgs
269-       fi
270-fi
271-# End automatically added section
272hunk ./misc/lenny/debian/allmydata-tahoe.postinst 4
273-uid=`getend passwd tahoelafsd | cut -d ":" -f 3`
274+uid=`getent passwd tahoelafsd | cut -d ":" -f 3`
275}
276
277[daemon fixups
278jacob@appelbaum.net**20100304091705] {
279hunk ./misc/lenny/debian/allmydata-tahoe.postinst 9
280-        chmod 750 /var/lib/tahoelafs/
281+        chmod 750 /var/lib/tahoelafsd/
282hunk ./misc/lenny/debian/allmydata-tahoe.postinst 17
283-    adduser --disabled-login --system --home /var/lib/tahoelafs \
284+    adduser --disabled-login --system --home /var/lib/tahoelafsd \
285hunk ./misc/lenny/debian/allmydata-tahoe.postinst 20
286-    chmod 750 /var/lib/tahoelafs/
287+    chmod 750 /var/lib/tahoelafsd/
288}
289
290[remove user at dpkg --remove
291jacob@appelbaum.net**20100304092400] hunk ./misc/lenny/debian/allmydata-tahoe.postrm 3
292+delgroup tahoelafsd
293+deluser tahoelafsd
294+
295
296[disable the daemon by default
297jacob@appelbaum.net**20100304092546] hunk ./misc/lenny/debian/allmydata-tahoe.default 17
298-ENABLED="TRUE"
299+ENABLED="FALSE"
300
301[only remove user, not group
302jacob@appelbaum.net**20100304092643] hunk ./misc/lenny/debian/allmydata-tahoe.postrm 3
303-delgroup tahoelafsd
304
305[purging user at purge time only
306jacob@appelbaum.net**20100304093137] {
307hunk ./misc/lenny/debian/allmydata-tahoe.postrm 3
308-deluser tahoelafsd
309-
310hunk ./misc/lenny/debian/allmydata-tahoe.postrm 5
311+    deluser tahoelafsd
312}
313
314Context:
315
316[CREDITS to Jacob Appelbaum
317zooko@zooko.com**20100304015616
318 Ignore-this: 70db493abbc23968fcc8db93f386ea54
319]
320[desert-island-build-with-proper-versions
321jacob@appelbaum.net**20100304013858]
322[docs: a few small edits to try to guide newcomers through the docs
323zooko@zooko.com**20100303231902
324 Ignore-this: a6aab44f5bf5ad97ea73e6976bc4042d
325 These edits were suggested by my watching over Jake Appelbaum's shoulder as he completely ignored/skipped/missed install.html and also as he decided that debian.txt wouldn't help him with basic installation. Then I threw in a few docs edits that have been sitting around in my sandbox asking to be committed for months.
326]
327[TAG allmydata-tahoe-1.6.1
328david-sarah@jacaranda.org**20100228062314
329 Ignore-this: eb5f03ada8ea953ee7780e7fe068539
330]
331Patch bundle hash:
33248eb3a8ddd4c04f5494873d8c823fbad3e5b3512