aboutsummaryrefslogtreecommitdiffstats
path: root/main/swatch/swatch.initd
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2010-11-26 11:59:54 +0100
committerMika Havela <mika.havela@gmail.com>2010-11-26 11:59:54 +0100
commit4a5c67baf55bbe6eea951668095e2a9e27bb2336 (patch)
treec6d37b667bdeaee2c3efdd4a17086f662e5bea12 /main/swatch/swatch.initd
parent75eefdb86db840f9e98e6d17c6dc4807f45a919b (diff)
downloadaports-4a5c67baf55bbe6eea951668095e2a9e27bb2336.tar.bz2
aports-4a5c67baf55bbe6eea951668095e2a9e27bb2336.tar.xz
testing/swatch: Moved to main
Confirmed that it works.
Diffstat (limited to 'main/swatch/swatch.initd')
-rwxr-xr-xmain/swatch/swatch.initd50
1 files changed, 50 insertions, 0 deletions
diff --git a/main/swatch/swatch.initd b/main/swatch/swatch.initd
new file mode 100755
index 0000000000..ec625e4026
--- /dev/null
+++ b/main/swatch/swatch.initd
@@ -0,0 +1,50 @@
+#!/sbin/runscript
+
+# 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 $?
+}
+