X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=app-laptop%2Fhdapsd%2Ffiles%2Fhdapsd.init.3;fp=app-laptop%2Fhdapsd%2Ffiles%2Fhdapsd.init.3;h=a1fab31a6e3589b494453ab4ce190bff40ad71db;hb=355435cef33f61445cddf225a80e6aff7c3d4610;hp=0000000000000000000000000000000000000000;hpb=dc2bba3b259f780f6c7be9252e4e57c3afa2d419;p=mjo-overlay.git diff --git a/app-laptop/hdapsd/files/hdapsd.init.3 b/app-laptop/hdapsd/files/hdapsd.init.3 new file mode 100644 index 0000000..a1fab31 --- /dev/null +++ b/app-laptop/hdapsd/files/hdapsd.init.3 @@ -0,0 +1,67 @@ +#!/sbin/runscript +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License, v2 + +depend() { + need localmount +} + +checkconfig() { + # An empty DISKLIST is allowed because the disk will be + # auto-detected. + for DISK in ${DISKLIST}; do + if [ ! -b /dev/${DISK} ]; then + eerror "Could not find disk /dev/${DISK}!" + eerror "Adjust the DISK setting in /etc/conf.d/hdapsd" + return 1 + fi + + if [ ! -e /sys/block/${DISK}/queue/protect ] && \ + [ ! -e /sys/block/${DISK}/device/unload_heads ] ; then + eerror "No protect entry for ${DISK}!" + eerror "Make sure your kernel is patched with the blk_freeze patch" + return 1 + fi + done + + # Load the tp_smapi module first. This is not a requirement, but + # it helps hdapsd's adaptive mode. + if [ ! -e /sys/devices/platform/smapi ] ; then + modprobe tp_smapi 2>/dev/null + fi + + if [ ! -d /sys/devices/platform/hdaps ] ; then + ebegin "Loading hdaps module" + modprobe hdaps + eend $? || return 1 + fi +} + +start() { + checkconfig || return 1 + + local DISKOPTS DISK + for DISK in ${DISKLIST}; do + DISKOPTS="${DISKOPTS} -d ${DISK}" + done + + # Since we're allowed to have an empty $THRESHOLD, we append + # "--sensitivity $THRESHOLD" to $OPTIONS here only when it exists. + if [ ! -z "${THRESHOLD}" ] ; then + OPTIONS="${OPTIONS} --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 $? +} + +stop() { + ebegin "Stopping Hard Drive Active Protection System daemon" + start-stop-daemon --stop --exec /usr/sbin/hdapsd \ + --pidfile /var/run/hdapsd.pid + eend $? +}