1 | #! /bin/sh -e |
---|
2 | ### BEGIN INIT INFO |
---|
3 | # Provides: debathena-pyhesiodfs |
---|
4 | # Required-Start: openafs-client |
---|
5 | # Required-Stop: openafs-client |
---|
6 | # Should-Start: $local_fs $network |
---|
7 | # Default-Start: 2 3 4 5 |
---|
8 | # Default-Stop: 0 1 6 |
---|
9 | # Short-Description: Debathena automounter using pyFUSE |
---|
10 | # Description: Auto-creates symlinks from /mit/LOCKER to AFS using Hesiod lookups. |
---|
11 | ### END INIT INFO |
---|
12 | |
---|
13 | PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin/:/usr/sbin:/usr/bin |
---|
14 | DAEMON="/usr/bin/pyhesiodfs" |
---|
15 | NAME=debathena-pyhesiodfs |
---|
16 | pyhesiodfs_dir="/mit" |
---|
17 | |
---|
18 | if [ -f /etc/default/pyhesiodfs ]; then |
---|
19 | . /etc/default/pyhesiodfs |
---|
20 | fi |
---|
21 | |
---|
22 | # If the hesiod module hasn't been installed yet, this will fail and cause the |
---|
23 | # installation to fail, too. So fail silently instead |
---|
24 | if ! python -m hesiod >/dev/null 2>/dev/null |
---|
25 | then |
---|
26 | exit 0 |
---|
27 | fi |
---|
28 | |
---|
29 | case "$1" in |
---|
30 | start) |
---|
31 | if start-stop-daemon --test --start --quiet \ |
---|
32 | --pidfile "/var/run/$NAME.pid" \ |
---|
33 | --startas "$DAEMON" -- -f "$pyhesiodfs_dir" |
---|
34 | then |
---|
35 | modprobe fuse |
---|
36 | mkdir -p "$pyhesiodfs_dir" |
---|
37 | chgrp pyhesiodfs "$pyhesiodfs_dir" |
---|
38 | chmod g+w "$pyhesiodfs_dir" |
---|
39 | echo -n "Starting $DESC: " |
---|
40 | start-stop-daemon --oknodo --start --quiet \ |
---|
41 | --pidfile "/var/run/$NAME.pid" \ |
---|
42 | --chuid pyhesiodfs:pyhesiodfs --background \ |
---|
43 | --make-pidfile --startas "$DAEMON" -- -f "$pyhesiodfs_dir" |
---|
44 | echo "$NAME." |
---|
45 | fi |
---|
46 | ;; |
---|
47 | stop) |
---|
48 | echo -n "Stopping $DESC: " |
---|
49 | if start-stop-daemon --test --stop --quiet --pidfile "/var/run/$NAME.pid" |
---|
50 | then |
---|
51 | fusermount -u "$pyhesiodfs_dir" |
---|
52 | echo "$NAME" |
---|
53 | else |
---|
54 | echo "automounter for $pyhesiodfs_dir not running." >&2 |
---|
55 | fi |
---|
56 | rm -f "/var/run/$NAME.pid" |
---|
57 | ;; |
---|
58 | force-reload|restart) |
---|
59 | "$0" stop |
---|
60 | "$0" start |
---|
61 | ;; |
---|
62 | *) |
---|
63 | N=/"etc/init.d/$NAME" |
---|
64 | # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 |
---|
65 | echo "Usage: $N {start|stop|restart|force-reload}" >&2 |
---|
66 | exit 1 |
---|
67 | ;; |
---|
68 | esac |
---|
69 | |
---|
70 | exit 0 |
---|