From 40dd1e0874f00f397dce6c757ceb0e99381f1550 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 25 Oct 2014 21:48:36 -0400 Subject: [PATCH] Rewrite the conf and init.d files a million times. --- app-laptop/hdapsd/files/hdapsd.conf.3 | 12 ++++++-- app-laptop/hdapsd/files/hdapsd.init.3 | 41 ++++++++++++++++----------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/app-laptop/hdapsd/files/hdapsd.conf.3 b/app-laptop/hdapsd/files/hdapsd.conf.3 index f30f6ae..a83d8bb 100644 --- a/app-laptop/hdapsd/files/hdapsd.conf.3 +++ b/app-laptop/hdapsd/files/hdapsd.conf.3 @@ -4,15 +4,21 @@ # The list of the disk devices that hdapsd should monitor. Usually # this is "hda", "sda", or "hda sda". The hdaps daemon will attempt to -# auto-detect your drive if this is left empty. +# auto-detect your drive if this is left empty. Empty by default. # #DISKLIST="sda" # Hdapsd sensitivity. The lower the threshold, the earlier the heads -# are parked when movement is detected. +# are parked when movement is detected. The default is determined by +# hdapsd, and is currently 15. # #THRESHOLD="10" -# Set any extra options here, like -a for "adaptive mode". +# Log to syslog? Disabled by default. +# +#SYSLOG="true" + +# Set any extra options here, like -a for "adaptive mode". Empty by +# default. # #OPTIONS="-a" diff --git a/app-laptop/hdapsd/files/hdapsd.init.3 b/app-laptop/hdapsd/files/hdapsd.init.3 index a1fab31..b4d0eab 100644 --- a/app-laptop/hdapsd/files/hdapsd.init.3 +++ b/app-laptop/hdapsd/files/hdapsd.init.3 @@ -2,6 +2,17 @@ # Copyright 1999-2014 Gentoo Foundation # Distributed under the terms of the GNU General Public License, v2 +description="Hard Drive Active Protection System daemon" +command="/usr/sbin/hdapsd" +pidfile="/run/hdapsd.pid" + +# Always daemonize when started by OpenRC, and don't make the pidfile +# configurable. Even if the user sets something dumb for the pidfile +# in /etc/hdapsd.conf, we want it to work! Fortunately the settings +# passed on the command-line override the config file. +command_args="--background --pidfile=${pidfile}" + + depend() { need localmount } @@ -40,28 +51,26 @@ checkconfig() { start() { checkconfig || return 1 - local DISKOPTS DISK for DISK in ${DISKLIST}; do - DISKOPTS="${DISKOPTS} -d ${DISK}" + command_args="${command_args} -d ${DISK}" done - # Since we're allowed to have an empty $THRESHOLD, we append - # "--sensitivity $THRESHOLD" to $OPTIONS here only when it exists. + # Since all of these settings are now optional, we append them + # only if we need to. if [ ! -z "${THRESHOLD}" ] ; then - OPTIONS="${OPTIONS} --sensitivity ${THRESHOLD}" + command_args="${command_args} --sensitivity ${THRESHOLD}" fi - ebegin "Starting Hard Drive Active Protection System daemon" - start-stop-daemon --start --exec /usr/sbin/hdapsd \ - --pidfile /var/run/hdapsd.pid \ - -- --syslog --background --pidfile \ - ${DISKOPTS} ${OPTIONS} - eend $? -} + if [ ! -z "${SYSLOG}" ] ; then + command_args="${command_args} --syslog" + fi + + if [ ! -z "${OPTIONS}" ] ; then + command_args="${command_args} ${OPTIONS}" + fi -stop() { - ebegin "Stopping Hard Drive Active Protection System daemon" - start-stop-daemon --stop --exec /usr/sbin/hdapsd \ - --pidfile /var/run/hdapsd.pid + ebegin "Starting the ${description}" + start-stop-daemon --start --exec "${command}" --pidfile "${pidfile}" \ + -- ${command_args} eend $? } -- 2.44.2