summaryrefslogtreecommitdiff
path: root/recipes-connectivity/mosquitto/mosquitto/mosquitto.init
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-connectivity/mosquitto/mosquitto/mosquitto.init')
-rwxr-xr-xrecipes-connectivity/mosquitto/mosquitto/mosquitto.init115
1 files changed, 79 insertions, 36 deletions
diff --git a/recipes-connectivity/mosquitto/mosquitto/mosquitto.init b/recipes-connectivity/mosquitto/mosquitto/mosquitto.init
index 7b3e634..21bffe6 100755
--- a/recipes-connectivity/mosquitto/mosquitto/mosquitto.init
+++ b/recipes-connectivity/mosquitto/mosquitto/mosquitto.init
@@ -1,53 +1,96 @@
-#!/bin/sh
-#
-# mosquitto Starts and stops Mosquitto
-# mosquitto (MQTT 3.5 broker)
-#
-# chkconfig: - 58 74
-# description: mosquitto is a MQTT 3.5 broker. \
-# http://mosquitto.org/
+#! /bin/sh
+
+# Based on the Debian initscript for mosquitto
### BEGIN INIT INFO
-# Provides: mosquitto
-# Required-Start: $network $local_fs
-# Required-Stop: $network $local_fs
-# Should-Start: $syslog $named
-# Should-Stop: $syslog $named
-# Short-Description: start and stop mosquitto
-# Description: mosquitto is a MQTT 3.5 broker.
+# Provides: mosquitto
+# Required-Start: $remote_fs $syslog
+# Required-Stop: $remote_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: mosquitto MQTT message broker
+# Description:
+# This is a message broker that supports version 3.1/3.1.1 of the MQ Telemetry
+# Transport (MQTT) protocol.
+#
+# MQTT provides a method of carrying out messaging using a publish/subscribe
+# model. It is lightweight, both in terms of bandwidth usage and ease of
+# implementation. This makes it particularly useful at the edge of the network
+# where a sensor or other simple device may be implemented using an arduino for
+# example.
### END INIT INFO
-PIDFILE=/var/run/mosquitto.pid
-DAEMON=/usr/sbin/mosquitto
+## mlinux
ENABLED="yes"
[ -f /etc/default/mosquitto ] && . /etc/default/mosquitto
+[ "$ENABLED" = "yes" ] || exit
+## mlinux
-start() {
- echo "Starting Mosquitto..."
- start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON -- -d -c /etc/mosquitto/mosquitto.conf
-}
+set -e
-stop() {
- echo "Stopping Mosquitto..."
- start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
-}
+PIDFILE=@LOCALSTATEDIR@/run/mosquitto.pid
+DAEMON=@SBINDIR@/mosquitto
-[ "$ENABLED" = "yes" ] || exit
+# start and stop the mosquitto MQTT message broker
+
+test -x ${DAEMON} || exit 0
+
+umask 022
+
+. @SYSCONFDIR@/init.d/functions
+
+export PATH="${PATH:+$PATH:}@SBINDIR@:@BASE_SBINDIR@"
case "$1" in
- start)
- start
+ start)
+ echo "Starting Mosquitto message broker" "mosquitto"
+ if start-stop-daemon --start --quiet --oknodo --background --make-pidfile --pidfile ${PIDFILE} --exec ${DAEMON} -- -c @SYSCONFDIR@/mosquitto/mosquitto.conf ; then
+ exit 0
+ else
+ exit 1
+ fi
;;
- stop)
- stop
+ stop)
+ echo "Stopping Mosquitto message broker" "mosquitto"
+ if start-stop-daemon --stop --quiet --oknodo --pidfile ${PIDFILE}; then
+ rm -f ${PIDFILE}
+ exit 0
+ else
+ exit 1
+ fi
;;
- restart)
- stop
- start
+
+
+ reload|force-reload)
+ if [ -f ${PIDFILE} ] ; then
+ echo "Reloading configuration for mosquitto"
+ pid=`cat ${PIDFILE}`
+ kill -HUP $pid
+ else
+ echo "mosquitto does not seem to be running"
+ fi
+ ;;
+
+ restart)
+ echo "Restarting Mosquitto message broker" "mosquitto"
+ if start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile ${PIDFILE}; then
+ rm -f ${PIDFILE}
+ fi
+ if start-stop-daemon --start --quiet --oknodo --background --make-pidfile --pidfile ${PIDFILE} --exec ${DAEMON} -- -c @SYSCONFDIR@/mosquitto/mosquitto.conf ; then
+ exit 0
+ else
+ exit 1
+ fi
;;
- *)
- echo $"Usage: $0 {start|stop|restart}"
- exit 2
+
+ status)
+ status ${DAEMON} && exit 0 || exit $?
+ ;;
+
+ *)
+ echo "Usage: $0 {start|stop|reload|force-reload|restart|status}"
+ exit 1
esac
+exit 0