Last active
February 22, 2019 19:51
-
-
Save basuke/7777918 to your computer and use it in GitHub Desktop.
Amazon Linux Init script for mosquitto MQTT 3.1 broker.
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/bash | |
# | |
# mosquitto This shell script takes care of starting and stopping | |
# mosquitto (MQTT 3.1 broker) on Amazon Linux. | |
# | |
# chkconfig: - 58 74 | |
# description: mosquitto is a MQTT 3.1 broker. \ | |
# http://mosquitto.org/ | |
### 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.1 broker. | |
### END INIT INFO | |
# Source function library. | |
. /etc/init.d/functions | |
# Source networking configuration. | |
. /etc/sysconfig/network | |
prog=mosquitto | |
bin=/usr/local/sbin/$prog | |
config=/etc/mosquitto/mosquitto.conf | |
options="-d -c $config" | |
lockfile=/var/lock/subsys/$prog | |
pidfile=/var/run/$prog.pid | |
start() { | |
[ "$EUID" != "0" ] && exit 4 | |
[ "$NETWORKING" = "no" ] && exit 1 | |
[ -x $bin ] || exit 5 | |
# Start daemon. | |
echo -n $"Starting $prog: " | |
daemon --pidfile $pidfile $bin $options | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && touch $lockfile | |
return $RETVAL | |
} | |
stop() { | |
[ "$EUID" != "0" ] && exit 4 | |
echo -n $"Shutting down $prog: " | |
killproc $prog | |
RETVAL=$? | |
echo | |
[ $RETVAL -eq 0 ] && rm -f $lockfile | |
return $RETVAL | |
} | |
# See how we were called. | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status $prog | |
;; | |
restart) | |
stop | |
start | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|status|restart}" | |
exit 2 | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment