diff options
Diffstat (limited to 'user/mosquitto/mosquitto.initd')
-rw-r--r-- | user/mosquitto/mosquitto.initd | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/user/mosquitto/mosquitto.initd b/user/mosquitto/mosquitto.initd new file mode 100644 index 000000000..818931213 --- /dev/null +++ b/user/mosquitto/mosquitto.initd @@ -0,0 +1,36 @@ +#!/sbin/openrc-run +MOSQUITTO_CFG="${MOSQUITTO_CFG:-/etc/mosquitto/${RC_SVCNAME}.conf}" + +command="/usr/bin/mosquitto" +command_args="-c '${MOSQUITTO_CFG}' $command_args" +command_args_background="--daemon" +pidfile="$(awk '$1 == "pid_file" {print $2}' "${MOSQUITTO_CFG}" || true)" + +extra_started_commands="reload" +description_reload="Reload configuration" + +start_pre() { + if ! [ -e "$MOSQUITTO_CFG" ]; then + eerror "$MOSQUITTO_CFG does not exist" + return 1 + fi + + if [ -z "$pidfile" ]; then + eerror "${MOSQUITTO_CFG} is missing the pid_file option" + return 1 + fi + + MOSQUITTO_LOG="$(awk '$1 " " $2 == "log_dest file" {print $3}' "${MOSQUITTO_CFG}")" + if [ -n "$MOSQUITTO_LOG" ]; then + MOSQUITTO_USER="$(awk '$1 == "user" {print $2}' "${MOSQUITTO_CFG}")" + MOSQUITTO_USER="${MOSQUITTO_USER:-mosquitto}" + checkpath -fm 660 -o "${MOSQUITTO_USER}" \ + "${MOSQUITTO_LOG}" || return 1 + fi +} + +reload() { + ebegin "Reloading ${RC_SVCNAME}" + start-stop-daemon --signal HUP --pidfile "${pidfile}" + eend $? +} |