diff options
author | Max Rees <maxcrees@me.com> | 2019-08-27 19:05:42 -0500 |
---|---|---|
committer | Max Rees <maxcrees@me.com> | 2019-08-27 19:14:37 -0500 |
commit | a1ee5f0e6ac73ea9cc57706114ed0b43d6c691fe (patch) | |
tree | a3758e4fc94124eef2119ace9c4ac80881ac52a3 /user/mosquitto/mosquitto.initd | |
parent | 4a3fb555bd3f8141225a2b5e40f2a5fd7d9484ec (diff) | |
download | packages-a1ee5f0e6ac73ea9cc57706114ed0b43d6c691fe.tar.gz packages-a1ee5f0e6ac73ea9cc57706114ed0b43d6c691fe.tar.bz2 packages-a1ee5f0e6ac73ea9cc57706114ed0b43d6c691fe.tar.xz packages-a1ee5f0e6ac73ea9cc57706114ed0b43d6c691fe.zip |
user/mosquitto: new package
In the future:
* cunit may be added to run unit tests.
* libwebsockets may be added for websocket support.
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 $? +} |