Skip to content

Instantly share code, notes, and snippets.

@jbovet
Created May 11, 2017 03:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbovet/d5756a374d9e6da5ba9c9061ec174bff to your computer and use it in GitHub Desktop.
Save jbovet/d5756a374d9e6da5ba9c9061ec174bff to your computer and use it in GitHub Desktop.
slackware mosquitto script
#!/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