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