aboutsummaryrefslogtreecommitdiffstats
path: root/testing/swatch/swatch.initd
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2010-05-13 06:50:59 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2010-05-13 07:34:17 +0000
commit7f6fabd695a88e5704e680f91caae0369b5a487e (patch)
tree273e1ef901213a78d3a5ef90265d4528f08fe70c /testing/swatch/swatch.initd
parent27bfa3b740264709e5a6429eec1f68346b64b33b (diff)
testing/swatch: new aport
Diffstat (limited to 'testing/swatch/swatch.initd')
-rwxr-xr-xtesting/swatch/swatch.initd50
1 files changed, 50 insertions, 0 deletions
diff --git a/testing/swatch/swatch.initd b/testing/swatch/swatch.initd
new file mode 100755
index 00000000000..ec625e40268
--- /dev/null
+++ b/testing/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 $?
+}
+