# 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"
# 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
}
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 $?
}