diff options
author | Cedric Schieli <cschieli@gmail.com> | 2010-06-01 12:37:47 +0000 |
---|---|---|
committer | Cedric Schieli <cschieli@gmail.com> | 2010-06-01 12:37:47 +0000 |
commit | 10b8b99e48384b4470cac1330080c12d2ade01de (patch) | |
tree | 7bb4ad6cd94a2c9a960fd9a4532d123eee5151d5 /testing/swatch/swatch.initd | |
parent | 9252f1cfd78299b137400ed8169a79f7f833daac (diff) | |
parent | c6c0b6f9dbde1244e7b31f74c703178a867e873f (diff) | |
download | aports-to-upstream.tar.bz2 aports-to-upstream.tar.xz |
Merge remote branch 'upstream/master' into to-upstreamto-upstream
Diffstat (limited to 'testing/swatch/swatch.initd')
-rwxr-xr-x | testing/swatch/swatch.initd | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/testing/swatch/swatch.initd b/testing/swatch/swatch.initd new file mode 100755 index 00000000..ec625e40 --- /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 $? +} + |