diff options
author | A. Wilcox <awilcox@wilcox-tech.com> | 2019-09-28 15:04:14 +0000 |
---|---|---|
committer | A. Wilcox <awilcox@wilcox-tech.com> | 2019-09-28 15:04:14 +0000 |
commit | 5cd64ffbbf9c1744efcb0319d30735ce2cf5b471 (patch) | |
tree | 8150bc345cbcb976330aaa52882412e957aa4a62 /user/mosquitto/mosquitto.initd | |
parent | f9ba226858a27bb322bad90ad988971f9afa8314 (diff) | |
parent | dee3259450baedd016093d7ec23f1664a942822a (diff) | |
download | packages-5cd64ffbbf9c1744efcb0319d30735ce2cf5b471.tar.gz packages-5cd64ffbbf9c1744efcb0319d30735ce2cf5b471.tar.bz2 packages-5cd64ffbbf9c1744efcb0319d30735ce2cf5b471.tar.xz packages-5cd64ffbbf9c1744efcb0319d30735ce2cf5b471.zip |
Merge branch 'mqtt' into 'master'
Add mosquitto and py3-paho-mqtt
See merge request adelie/packages!328
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 $? +} |