aboutsummaryrefslogtreecommitdiffstats
path: root/community/swatch/swatch.initd
diff options
context:
space:
mode:
authorLeo <thinkabit.ukim@gmail.com>2019-06-03 02:07:44 -0300
committerNatanael Copa <ncopa@alpinelinux.org>2019-06-05 08:22:26 +0000
commit1b22d5065a94e42cfc4ac0b3bb99d08f9f2f7e7f (patch)
treed2433f838770014e002cfb14b1431346d065c6c7 /community/swatch/swatch.initd
parentf8f0722a166047d0dba2dd7e3624d4fca56c3e8a (diff)
downloadaports-1b22d5065a94e42cfc4ac0b3bb99d08f9f2f7e7f.tar.bz2
aports-1b22d5065a94e42cfc4ac0b3bb99d08f9f2f7e7f.tar.xz
community/swatch: move from main
Diffstat (limited to 'community/swatch/swatch.initd')
-rwxr-xr-xcommunity/swatch/swatch.initd50
1 files changed, 50 insertions, 0 deletions
diff --git a/community/swatch/swatch.initd b/community/swatch/swatch.initd
new file mode 100755
index 0000000000..1ca390f2b3
--- /dev/null
+++ b/community/swatch/swatch.initd
@@ -0,0 +1,50 @@
+#!/sbin/openrc-run
+
+# swatch init.d file for alpine linux.
+
+name=swatch
+daemon=/usr/bin/$name
+configfile=/etc/${name}/swatchrc
+tailfile=/var/log/messages
+
+SVC="${SVCNAME#*.}"
+if [ -n "${SVC}" ] && [ "${SVCNAME}" != "${name}" ]; then
+ SVCPID="${name}.${SVC}.pid"
+ configfile="${configfile}.${SVC}"
+ tailfile=$(find /var/log -name "${SVC}" | head -1)
+ [ ! "${tailfile}" ] && tailfile="/var/log/${SVC}"
+else
+ SVCPID="${name}.pid"
+fi
+
+depend() {
+# need net
+ after syslog
+}
+
+start() {
+ ebegin "Starting ${name}"
+ einfo "Preparing to monitor ${tailfile}"
+ if [ ! -e "${tailfile}" ]; then
+ eerror "${tailfile} does not exist"
+ return 1
+ fi
+ if [ ! -e "${configfile}" ]; then
+ eerror "Configfile ${configfile} is missing"
+ return 1
+ fi
+ mkdir -p "${scriptdir}"
+ start-stop-daemon --start --quiet --background \
+ --make-pidfile --pidfile /var/run/${SVCPID} \
+ --exec ${daemon} -- \
+ --config-file="${configfile}" --script-dir="${scriptdir}" \
+ --tail-file="${tailfile}" --tail-args="${tailargs}"
+ eend $?
+}
+
+stop() {
+ ebegin "Stopping ${name}"
+ kill $(ps | grep .swatch_script.$(cat /var/run/${SVCPID}) | grep -v 'grep' | awk '{ print $1}')
+ eend $?
+}
+