File venv-salt-minion.initd of Package venv-salt-minion
#!/bin/sh
#
# Salt Bundle minion
###################################
# LSB header
### BEGIN INIT INFO
# Provides: venv-salt-minion
# Required-Start: $local_fs $remote_fs $network $named $time
# Should-Start: $time ypbind smtp
# Required-Stop: $local_fs $remote_fs $network $named $time
# Should-Stop: ypbind smtp
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Salt minion daemon
# Description: This is the Salt Bundle minion daemon that
# can be controlled by the Salt master.
### END INIT INFO
# chkconfig header
# chkconfig: 345 97 04
# description: This is the Salt Bundle minion daemon \
# that can be controlled by the Salt master.
#
# processname: /usr/bin/venv-salt-minion
# Source function library.
. /etc/rc.status
# Default values (can be overridden below)
VENV_SALT_MINION=/usr/lib/venv-salt-minion/bin/salt-minion
CHECK_PID_SUBSTR=usr/lib/venv-salt-minion
PIDFILE=/var/run/venv-salt-minion.pid
RETVAL=0
status() {
if test -f $PIDFILE; then
PID=$(cat $PIDFILE)
if test -n "$PID"; then
PRESENT_PID=$(ps ax | grep $CHECK_PID_SUBSTR | grep -v grep | awk '{print $1}' | grep "^$PID\$")
if test -n "$PRESENT_PID"; then
return 0
fi
fi
fi
return 1
}
start() {
echo -n $"Starting venv-salt-minion daemon: "
$VENV_SALT_MINION -d
test -f $PIDFILE
rc_status -v
RETVAL=$?
echo
return $RETVAL
}
stop_minion_pid() {
PID=$1
TRIES=10
while test $TRIES -gt 0; do
if test -n "$PID"; then
PRESENT_PID=$(ps ax | grep $CHECK_PID_SUBSTR | grep -v grep | awk '{print $1}' | grep "^$PID\$")
else
PRESENT_PID=$(ps ax | grep $CHECK_PID_SUBSTR | grep -v grep | awk '{print $1}' | sort -n | head -n 1)
fi
if test -n "$PRESENT_PID"; then
kill $PRESENT_PID
sleep 1
else
return 0
fi
TRIES=$(($TRIES-1))
done
return 1
}
stop() {
IS_RESTARTING=$1
echo -n $"Stopping venv-salt-minion daemon: "
if test -f $PIDFILE; then
PID=$(cat $PIDFILE)
fi
stop_minion_pid "$PID"
rc_status -v
RETVAL=$?
echo
}
restart() {
stop 1;
start;
}
# See how we were called.
case "$1" in
start|stop)
$1
;;
status)
echo -n "Checking for service venv-salt-minion "
status
rc_status -v
RETVAL=$?
;;
condrestart|restart|try-restart)
restart || :
;;
reload)
echo "can't reload configuration, you have to restart it"
RETVAL=1
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload}"
exit 1
;;
esac
exit $RETVAL