[53936a5] | 1 | #!/bin/bash |
---|
| 2 | ### BEGIN INIT INFO |
---|
| 3 | # Provides: gutenbach-remctl |
---|
| 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 remctld. |
---|
| 9 | # Description: Starts remctld. |
---|
| 10 | ### END INIT INFO |
---|
| 11 | |
---|
| 12 | case "$1" in |
---|
| 13 | start) |
---|
| 14 | if [ -e /var/run/gutenbach/remctld.pid ]; then |
---|
| 15 | pid=$(cat /var/run/gutenbach/remctld.pid) |
---|
| 16 | if [ -n "$pid" ]; then |
---|
| 17 | kill -0 "$pid" |
---|
| 18 | if [ "$?" == 0 ]; then |
---|
| 19 | echo "Ending remctld..." >&2 |
---|
| 20 | kill "$pid" || true |
---|
| 21 | fi |
---|
| 22 | fi |
---|
| 23 | fi |
---|
| 24 | |
---|
| 25 | pid=$(sudo lsof -i :4373 | grep remctld | sed s/remctld\ // | sed s/\ .*//) |
---|
| 26 | if [ -n "$pid" ]; then |
---|
| 27 | kill -0 "$pid" |
---|
| 28 | if [ "$?" == 0 ]; then |
---|
| 29 | echo "Ending remctld socket binding..." >&2 |
---|
| 30 | kill "$pid" || true |
---|
| 31 | fi |
---|
| 32 | fi |
---|
| 33 | |
---|
| 34 | echo "Starting remctld..." >&2 |
---|
| 35 | remctld -m -P /var/run/gutenbach/remctld.pid & |
---|
| 36 | ;; |
---|
| 37 | |
---|
| 38 | stop) |
---|
| 39 | if [ -e /var/run/gutenbach/remctld.pid ]; then |
---|
| 40 | pid=$(cat /var/run/gutenbach/remctld.pid) |
---|
| 41 | if [ -n "$pid" ]; then |
---|
| 42 | kill -0 "$pid" |
---|
| 43 | if [ "$?" == 0 ]; then |
---|
| 44 | echo "Ending remctld..." >&2 |
---|
| 45 | kill "$pid" || true |
---|
| 46 | fi |
---|
| 47 | fi |
---|
| 48 | fi |
---|
| 49 | |
---|
| 50 | pid=$(sudo lsof -i :4373 | grep remctld | sed s/remctld\ // | sed s/\ .*//) |
---|
| 51 | if [ -n "$pid" ]; then |
---|
| 52 | kill -0 "$pid" |
---|
| 53 | if [ "$?" == 0 ]; then |
---|
| 54 | echo "Ending remctld socket binding..." >&2 |
---|
| 55 | kill "$pid" || true |
---|
| 56 | fi |
---|
| 57 | fi |
---|
| 58 | ;; |
---|
| 59 | |
---|
| 60 | restart) |
---|
| 61 | if [ -e /var/run/gutenbach/remctld.pid ]; then |
---|
| 62 | pid=$(cat /var/run/gutenbach/remctld.pid) |
---|
| 63 | if [ -n "$pid" ]; then |
---|
| 64 | kill -0 "$pid" |
---|
| 65 | if [ "$?" == 0 ]; then |
---|
| 66 | echo "Ending remctld..." >&2 |
---|
| 67 | kill "$pid" || true |
---|
| 68 | fi |
---|
| 69 | fi |
---|
| 70 | fi |
---|
| 71 | |
---|
| 72 | pid=$(sudo lsof -i :4373 | grep remctld | sed s/remctld\ // | sed s/\ .*//) |
---|
| 73 | if [ -n "$pid" ]; then |
---|
| 74 | kill -0 "$pid" |
---|
| 75 | if [ "$?" == 0 ]; then |
---|
| 76 | echo "Ending remctld socket binding..." >&2 |
---|
| 77 | kill "$pid" || true |
---|
| 78 | fi |
---|
| 79 | fi |
---|
| 80 | |
---|
| 81 | echo "Starting remctld..." >&2 |
---|
| 82 | remctld -m -P /var/run/gutenbach/remctld.pid & |
---|
| 83 | ;; |
---|
| 84 | |
---|
| 85 | force-reload) |
---|
| 86 | if [ -e /var/run/gutenbach/remctld.pid ]; then |
---|
| 87 | pid=$(cat /var/run/gutenbach/remctld.pid) |
---|
| 88 | if [ -n "$pid" ]; then |
---|
| 89 | kill -0 "$pid" |
---|
| 90 | if [ "$?" == 0 ]; then |
---|
| 91 | echo "Ending remctld..." >&2 |
---|
| 92 | kill "$pid" || true |
---|
| 93 | fi |
---|
| 94 | fi |
---|
| 95 | fi |
---|
| 96 | |
---|
| 97 | pid=$(sudo lsof -i :4373 | grep remctld | sed s/remctld\ // | sed s/\ .*//) |
---|
| 98 | if [ -n "$pid" ]; then |
---|
| 99 | kill -0 "$pid" |
---|
| 100 | if [ "$?" == 0 ]; then |
---|
| 101 | echo "Ending remctld socket binding..." >&2 |
---|
| 102 | kill "$pid" || true |
---|
| 103 | fi |
---|
| 104 | fi |
---|
| 105 | |
---|
| 106 | echo "Starting remctld..." >&2 |
---|
| 107 | remctld -m -P /var/run/gutenbach/remctld.pid & |
---|
| 108 | ;; |
---|
| 109 | |
---|
| 110 | *) |
---|
| 111 | echo "Usage: $0 {start|stop|restart}" |
---|
| 112 | exit 1 |
---|
| 113 | ;; |
---|
| 114 | esac |
---|