X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mjo-overlay.git;a=blobdiff_plain;f=app-laptop%2Fhdapsd%2Ffiles%2Fhdapsd.init.3;h=b4d0eab26b5c6a359ffd3ab97ebf5ee660a31bf0;hp=a1fab31a6e3589b494453ab4ce190bff40ad71db;hb=40dd1e0874f00f397dce6c757ceb0e99381f1550;hpb=355435cef33f61445cddf225a80e6aff7c3d4610 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 $? }