2 # Copyright 1999-2014 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License, v2
5 description="Hard Drive Active Protection System daemon"
6 command="/usr/sbin/hdapsd"
7 pidfile="/run/hdapsd.pid"
9 # Always daemonize when started by OpenRC, and don't make the pidfile
10 # configurable. Even if the user sets something dumb for the pidfile
11 # in /etc/hdapsd.conf, we want it to work! Fortunately the settings
12 # passed on the command-line override the config file.
13 command_args="--background --pidfile=${pidfile}"
21 # An empty DISKLIST is allowed because the disk will be
23 for DISK in ${DISKLIST}; do
24 if [ ! -b /dev/${DISK} ]; then
25 eerror "Could not find disk /dev/${DISK}!"
26 eerror "Adjust the DISK setting in /etc/conf.d/hdapsd"
30 if [ ! -e /sys/block/${DISK}/queue/protect ] && \
31 [ ! -e /sys/block/${DISK}/device/unload_heads ] ; then
32 eerror "No protect entry for ${DISK}!"
33 eerror "Make sure your kernel is patched with the blk_freeze patch"
38 # Load the tp_smapi module first. This is not a requirement, but
39 # it helps hdapsd's adaptive mode.
40 if [ ! -e /sys/devices/platform/smapi ] ; then
41 modprobe tp_smapi 2>/dev/null
44 if [ ! -d /sys/devices/platform/hdaps ] ; then
45 ebegin "Loading hdaps module"
52 checkconfig || return 1
54 for DISK in ${DISKLIST}; do
55 command_args="${command_args} -d ${DISK}"
58 # Since all of these settings are now optional, we append them
60 if [ ! -z "${THRESHOLD}" ] ; then
61 command_args="${command_args} --sensitivity ${THRESHOLD}"
64 if [ ! -z "${SYSLOG}" ] ; then
65 command_args="${command_args} --syslog"
68 if [ ! -z "${OPTIONS}" ] ; then
69 command_args="${command_args} ${OPTIONS}"
72 ebegin "Starting the ${description}"
73 start-stop-daemon --start --exec "${command}" --pidfile "${pidfile}" \