Skip to content

Instantly share code, notes, and snippets.

@jbovet jbovet/rc.mosquitto
Created May 11, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.