1 | #!/bin/bash |
---|
2 | ### BEGIN INIT INFO |
---|
3 | # Provides: gutenbach-queue |
---|
4 | # Required-Start: $remote_fs $syslog |
---|
5 | # Required-Stop: $remote_fs $syslog |
---|
6 | # Default-Start: 2 3 4 5 |
---|
7 | # Default-Stop: 0 1 6 |
---|
8 | # Short-Description: Starts the queue daemon for gutenbach. |
---|
9 | # Description: Starts the queue daemon for gutenbach. |
---|
10 | ### END INIT INFO |
---|
11 | |
---|
12 | case "$1" in |
---|
13 | start) |
---|
14 | if [ ! -e /tmp/gutenbach ]; then |
---|
15 | mkdir /tmp/gutenbach |
---|
16 | fi |
---|
17 | chmod ugoa+rw /tmp/gutenbach |
---|
18 | |
---|
19 | daemon -F /tmp/gutenbach/gutenbach-queue.pid --name gutenbach-queue --running |
---|
20 | if [ "$?" == 0 ]; then |
---|
21 | echo "The gutenbach queue daemon is already running." |
---|
22 | else |
---|
23 | if [ ! -e /tmp/gutenbach/current_queue ]; then |
---|
24 | touch /tmp/gutenbach/current_queue |
---|
25 | chmod ugoa+r /tmp/gutenbach/current_queue |
---|
26 | fi |
---|
27 | if [ ! -e /tmp/gutenbach/current_queue_temp ]; then |
---|
28 | touch /tmp/gutenbach/current_queue_temp |
---|
29 | fi |
---|
30 | |
---|
31 | echo "Starting gutenbach daemon..." |
---|
32 | daemon -F /tmp/gutenbach/gutenbach-queue.pid --name gutenbach-queue -u daemon /usr/lib/gutenbach/queue/build-gutenbach-queue |
---|
33 | echo "Done." |
---|
34 | fi |
---|
35 | ;; |
---|
36 | |
---|
37 | stop) |
---|
38 | daemon -F /tmp/gutenbach/gutenbach-queue.pid --stop --name gutenbach-queue |
---|
39 | /usr/lib/gutenbach/queue/kill-gutenbach-queue |
---|
40 | |
---|
41 | if [ -e /tmp/gutenbach/current_queue ]; then |
---|
42 | rm /tmp/gutenbach/current_queue |
---|
43 | fi |
---|
44 | if [ -e /tmp/gutenbach/current_queue_temp ]; then |
---|
45 | rm /tmp/gutenbach/current_queue_temp |
---|
46 | fi |
---|
47 | ;; |
---|
48 | |
---|
49 | restart) |
---|
50 | daemon -F /tmp/gutenbach/gutenbach-queue.pid --stop --name gutenbach-queue |
---|
51 | /usr/lib/gutenbach/queue/kill-gutenbach-queue |
---|
52 | |
---|
53 | if [ -e /tmp/gutenbach/current_queue ]; then |
---|
54 | rm /tmp/gutenbach/current_queue |
---|
55 | fi |
---|
56 | if [ -e /tmp/gutenbach/current_queue_temp ]; then |
---|
57 | rm /tmp/gutenbach/current_queue_temp |
---|
58 | fi |
---|
59 | |
---|
60 | if [ ! -e /tmp/gutenbach ]; then |
---|
61 | mkdir /tmp/gutenbach |
---|
62 | fi |
---|
63 | |
---|
64 | chmod ugoa+rw /tmp/gutenbach |
---|
65 | touch /tmp/gutenbach/current_queue |
---|
66 | chmod ugoa+r /tmp/gutenbach/current_queue |
---|
67 | touch /tmp/gutenbach/current_queue_temp |
---|
68 | |
---|
69 | echo "Starting gutenbach daemon..." |
---|
70 | daemon -F /tmp/gutenbach/gutenbach-queue.pid --name gutenbach-queue -u daemon /usr/lib/gutenbach/queue/build-gutenbach-queue |
---|
71 | echo "Done." |
---|
72 | ;; |
---|
73 | |
---|
74 | force-reload) |
---|
75 | ;; |
---|
76 | |
---|
77 | *) |
---|
78 | echo "Usage: $0 {start|stop|restart}" |
---|
79 | exit 1 |
---|
80 | ;; |
---|
81 | esac |
---|