#!/bin/bash # # mosquitto init script for Slackware. # # Copyright 2014 Michiel Broek, the Netherlands. case "$1" in start) echo -n "Starting Mosquitto: " if [ -f /etc/mosquitto/mosquitto.conf ]; then if [ -f /var/run/mosquitto.pid ]; then PID=$(cat /var/run/mosquitto.pid) if [ -d /proc/$PID -a -n "$(grep mosquitto /proc/$PID/cmdline)" ]; then echo "already running." else # Stale pidfile, remove it and start mosquitto rm /var/run/mosquitto.pid /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf -d echo "done." fi else /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf -d echo "done." fi else echo "not configured." fi ;; stop) echo -n "Stopping Mosquitto: " if [ -f /var/run/mosquitto.pid ]; then kill $(cat /var/run/mosquitto.pid) rm -f /var/run/mosquitto.pid echo "done." else echo "wasn't running." fi ;; reload) echo -n "Reloading Mosquitto: " if [ -f /var/run/mosquitto.pid ]; then kill -SIGHUP $(cat /var/run/mosquitto.pid) echo "done." else echo "wasn't running." fi ;; restart) $0 stop sleep 1 $0 start ;; *) echo "usage: $0 {start|stop|reload|restart}" esac