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 | daemon -F /var/run/gutenbach/gutenbach-queue.pid --name gutenbach-queue --running |
---|
15 | if [ "$?" == 0 ]; then |
---|
16 | echo "The gutenbach queue daemon is already running." |
---|
17 | else |
---|
18 | if [ ! -e /var/run/gutenbach/current_queue ]; then |
---|
19 | touch /var/run/gutenbach/current_queue |
---|
20 | chmod ugoa+r /var/run/gutenbach/current_queue |
---|
21 | fi |
---|
22 | if [ ! -e /var/run/gutenbach/queue_times ]; then |
---|
23 | touch /var/run/gutenbach/queue_times |
---|
24 | fi |
---|
25 | if [ ! -e /var/run/gutenbach/exiftool_data ]; then |
---|
26 | touch /var/run/gutenbach/exiftool_data |
---|
27 | fi |
---|
28 | if [ ! -e /var/run/gutenbach/current_queue_temp ]; then |
---|
29 | touch /var/run/gutenbach/current_queue_temp |
---|
30 | fi |
---|
31 | |
---|
32 | echo "Starting gutenbach daemon..." |
---|
33 | daemon -F /var/run/gutenbach/gutenbach-queue.pid --name gutenbach-queue -u daemon /usr/lib/gutenbach/queue/build-gutenbach-queue |
---|
34 | echo "Done." |
---|
35 | fi |
---|
36 | ;; |
---|
37 | |
---|
38 | stop) |
---|
39 | daemon -F /var/run/gutenbach/gutenbach-queue.pid --stop --name gutenbach-queue |
---|
40 | /usr/lib/gutenbach/queue/kill-gutenbach-queue |
---|
41 | |
---|
42 | if [ -e /var/run/gutenbach/current_queue ]; then |
---|
43 | rm /var/run/gutenbach/current_queue |
---|
44 | fi |
---|
45 | if [ -e /var/run/gutenbach/queue_times ]; then |
---|
46 | rm /var/run/gutenbach/queue_times |
---|
47 | fi |
---|
48 | if [ -e /var/run/gutenbach/exiftool_data ]; then |
---|
49 | rm /var/run/gutenbach/exiftool_data |
---|
50 | fi |
---|
51 | if [ -e /var/run/gutenbach/current_queue_temp ]; then |
---|
52 | rm /var/run/gutenbach/current_queue_temp |
---|
53 | fi |
---|
54 | ;; |
---|
55 | |
---|
56 | restart) |
---|
57 | daemon -F /var/run/gutenbach/gutenbach-queue.pid --stop --name gutenbach-queue |
---|
58 | /usr/lib/gutenbach/queue/kill-gutenbach-queue |
---|
59 | |
---|
60 | if [ -e /var/run/gutenbach/current_queue ]; then |
---|
61 | rm /var/run/gutenbach/current_queue |
---|
62 | fi |
---|
63 | if [ -e /var/run/gutenbach/queue_times ]; then |
---|
64 | rm /var/run/gutenbach/queue_times |
---|
65 | fi |
---|
66 | if [ -e /var/run/gutenbach/exiftool_data ]; then |
---|
67 | rm /var/run/gutenbach/exiftool_data |
---|
68 | fi |
---|
69 | if [ -e /var/run/gutenbach/current_queue_temp ]; then |
---|
70 | rm /var/run/gutenbach/current_queue_temp |
---|
71 | fi |
---|
72 | |
---|
73 | touch /var/run/gutenbach/current_queue |
---|
74 | chmod ugoa+r /var/run/gutenbach/current_queue |
---|
75 | touch /var/run/gutenbach/queue_times |
---|
76 | touch /var/run/gutenbach/exiftool_data |
---|
77 | touch /var/run/gutenbach/current_queue_temp |
---|
78 | |
---|
79 | echo "Starting gutenbach daemon..." |
---|
80 | daemon -F /var/run/gutenbach/gutenbach-queue.pid --name gutenbach-queue -u daemon /usr/lib/gutenbach/queue/build-gutenbach-queue |
---|
81 | echo "Done." |
---|
82 | ;; |
---|
83 | |
---|
84 | force-reload) |
---|
85 | ;; |
---|
86 | |
---|
87 | *) |
---|
88 | echo "Usage: $0 {start|stop|restart}" |
---|
89 | exit 1 |
---|
90 | ;; |
---|
91 | esac |
---|