aboutsummaryrefslogtreecommitdiffstats
path: root/main/mqtt-exec/mqtt-exec.initd
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2014-05-21 08:33:04 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2014-05-21 08:42:11 +0000
commit725aa8296389545202816c164b5905a02f772c5a (patch)
treeb1290a72053a4372cc39b8fcb932b485a0ac8040 /main/mqtt-exec/mqtt-exec.initd
parentb8212dd81e9b69cc66811180a1da642eb260c268 (diff)
downloadaports-725aa8296389545202816c164b5905a02f772c5a.tar.bz2
aports-725aa8296389545202816c164b5905a02f772c5a.tar.xz
main/mqtt-exec: upgrade to 0.2 and add an init.d script
Diffstat (limited to 'main/mqtt-exec/mqtt-exec.initd')
-rw-r--r--main/mqtt-exec/mqtt-exec.initd40
1 files changed, 40 insertions, 0 deletions
diff --git a/main/mqtt-exec/mqtt-exec.initd b/main/mqtt-exec/mqtt-exec.initd
new file mode 100644
index 0000000000..727ee203af
--- /dev/null
+++ b/main/mqtt-exec/mqtt-exec.initd
@@ -0,0 +1,40 @@
+#!/sbin/runscript
+
+: ${mqtt_broker:="msg.alpinelinux.org"}
+: ${mqtt_topics:="git/aports/$git_branch"}
+: ${exec_user:=nobody}
+
+command=/usr/bin/mqtt-exec
+pidfile=/var/run/$SVCNAME/mqtt-exec.pid
+
+start() {
+ local topic
+ checkpath --directory --owner ${exec_user:-nobody} ${pidfile%/*}
+ set -- -h ${mqtt_broker} -v
+ for topic in $mqtt_topics; do
+ set -- "$@" -t "$topic"
+ done
+
+ if [ -n "$will_topic" ]; then
+ set -- "$@" --will-topic "$will_topic"
+ fi
+ if yesno "$will_retained"; then
+ set -- "$@" --will-retained
+ fi
+ if [ -n "$will_payload" ]; then
+ set -- "$@" --will-payload "$will_payload"
+ fi
+ if [ -n "$will_qos" ]; then
+ set -- "$@" --will-qos "$will_qos"
+ fi
+
+ ebegin "Starting $SVCNAME"
+ start-stop-daemon --start --stdout /dev/null --stderr /dev/null \
+ --background --make-pid --user ${exec_user} \
+ --pidfile ${pidfile} \
+ --exec $command \
+ -- "$@" \
+ -- ${exec_command}
+ eend
+}
+