slackware mosquitto script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Mosquitto daemon control script. | |
# Written for Slackware Linux by Jose Bovet Derpich <jose.bovet@gmail.com>. | |
BIN=/usr/sbin/mosquitto | |
CONF=/etc/mosquitto/mosquitto.conf | |
# enable pid_file in /etc/mosquitto/mosquitto.conf | |
PID=/var/run/mosquitto.pid | |
mosquitto_start() { | |
if [ ! -r $CONF ]; then # no config file, exit: | |
echo "$CONF does not appear to exist. Abort." | |
exit 1 | |
fi | |
if [ -s $PID ]; then | |
echo "Mosquitto appears to already be running?" | |
exit 1 | |
fi | |
echo "Starting Mosquitto server daemon..." | |
if [ -x $BIN ]; then | |
$BIN -c $CONF -d | |
fi | |
} | |
mosquitto_stop() { | |
echo "Shutdown Mosquitto..." | |
if [ -r $PID ]; then | |
kill -TERM $(cat $PID) | |
rm $PID | |
fi | |
} | |
mosquitto_restart() { | |
mosquitto_stop | |
sleep 3 | |
mosquitto_start | |
} | |
case "$1" in | |
start) | |
mosquitto_start | |
;; | |
stop) | |
mosquitto_stop | |
;; | |
restart) | |
mosquitto_restart | |
;; | |
*) | |
echo "usage: `basename $0` {start|stop|restart}" | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment