diff options
Diffstat (limited to 'meta-openstack/recipes-support/salt/files/salt-api')
| -rwxr-xr-x | meta-openstack/recipes-support/salt/files/salt-api | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/meta-openstack/recipes-support/salt/files/salt-api b/meta-openstack/recipes-support/salt/files/salt-api new file mode 100755 index 0000000..4b45bd2 --- /dev/null +++ b/meta-openstack/recipes-support/salt/files/salt-api | |||
| @@ -0,0 +1,110 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | ### BEGIN INIT INFO | ||
| 3 | # Provides: salt-api | ||
| 4 | # Required-Start: $remote_fs $network | ||
| 5 | # Required-Stop: $remote_fs $network | ||
| 6 | # Default-Start: 2 3 4 5 | ||
| 7 | # Default-Stop: 0 1 6 | ||
| 8 | # Short-Description: salt api control daemon | ||
| 9 | # Description: This is a daemon that exposes an external API | ||
| 10 | ### END INIT INFO | ||
| 11 | |||
| 12 | # Author: Michael Prokop <mika@debian.org> | ||
| 13 | |||
| 14 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | ||
| 15 | DESC="salt api control daemon" | ||
| 16 | NAME=salt-api | ||
| 17 | DAEMON=/usr/bin/salt-api | ||
| 18 | DAEMON_ARGS="-d" | ||
| 19 | PIDFILE=/var/run/$NAME.pid | ||
| 20 | SCRIPTNAME=/etc/init.d/$NAME | ||
| 21 | |||
| 22 | # Exit if the package is not installed | ||
| 23 | [ -x "$DAEMON" ] || exit 0 | ||
| 24 | |||
| 25 | # Read configuration variable file if it is present | ||
| 26 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME | ||
| 27 | |||
| 28 | # Source function library. | ||
| 29 | . /etc/init.d/functions | ||
| 30 | |||
| 31 | do_start() { | ||
| 32 | # Return | ||
| 33 | # 0 if daemon has been started | ||
| 34 | # 1 if daemon was already running | ||
| 35 | # 2 if daemon could not be started | ||
| 36 | pid=$(pidof -x $DAEMON) | ||
| 37 | if [ -n "$pid" ] ; then | ||
| 38 | return 1 | ||
| 39 | fi | ||
| 40 | |||
| 41 | start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS \ | ||
| 42 | || return 2 | ||
| 43 | } | ||
| 44 | |||
| 45 | do_stop() { | ||
| 46 | # Return | ||
| 47 | # 0 if daemon has been stopped | ||
| 48 | # 1 if daemon was already stopped | ||
| 49 | # 2 if daemon could not be stopped | ||
| 50 | # other if a failure occ | ||
| 51 | start-stop-daemon --stop --retry=TERM/30/KILL/5 --quiet --pidfile $PIDFILE --name $NAME | ||
| 52 | RETVAL=$? | ||
| 53 | [ "$RETVAL" = 2 ] && return 2 | ||
| 54 | rm -f $PIDFILE | ||
| 55 | return "$RETVAL" | ||
| 56 | } | ||
| 57 | |||
| 58 | case "$1" in | ||
| 59 | start) | ||
| 60 | [ "$VERBOSE" != no ] && echo "Starting $DESC" "$NAME" | ||
| 61 | do_start | ||
| 62 | case "$?" in | ||
| 63 | 0|1) [ "$VERBOSE" != no ] && echo OK ;; | ||
| 64 | 2) [ "$VERBOSE" != no ] && echo FAILED ;; | ||
| 65 | esac | ||
| 66 | ;; | ||
| 67 | stop) | ||
| 68 | [ "$VERBOSE" != no ] && echo "Stopping $DESC" "$NAME" | ||
| 69 | do_stop | ||
| 70 | case "$?" in | ||
| 71 | 0|1) [ "$VERBOSE" != no ] && echo OK ;; | ||
| 72 | 2) [ "$VERBOSE" != no ] && echo FAILED ;; | ||
| 73 | esac | ||
| 74 | ;; | ||
| 75 | status) | ||
| 76 | pid=`pidof -x $DAEMON` | ||
| 77 | if [ -n "$pid" ]; then | ||
| 78 | echo "$NAME (pid $pid) is running ..." | ||
| 79 | else | ||
| 80 | echo "$NAME is stopped" | ||
| 81 | fi | ||
| 82 | ;; | ||
| 83 | #reload) | ||
| 84 | # not implemented | ||
| 85 | #;; | ||
| 86 | restart|force-reload) | ||
| 87 | echo "Restarting $DESC" "$NAME" | ||
| 88 | do_stop | ||
| 89 | case "$?" in | ||
| 90 | 0|1) | ||
| 91 | do_start | ||
| 92 | case "$?" in | ||
| 93 | 0) echo OK ;; | ||
| 94 | 1) echo FAILED ;; # Old process is still running | ||
| 95 | *) echo FAILED ;; # Failed to start | ||
| 96 | esac | ||
| 97 | ;; | ||
| 98 | *) | ||
| 99 | # Failed to stop | ||
| 100 | echo FAILED | ||
| 101 | ;; | ||
| 102 | esac | ||
| 103 | ;; | ||
| 104 | *) | ||
| 105 | echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 | ||
| 106 | exit 3 | ||
| 107 | ;; | ||
| 108 | esac | ||
| 109 | |||
| 110 | exit 0 | ||
