]> gitweb.michael.orlitzky.com - mjo-overlay.git/blob - app-laptop/hdapsd/files/hdapsd.init.3
a1fab31a6e3589b494453ab4ce190bff40ad71db
[mjo-overlay.git] / app-laptop / hdapsd / files / hdapsd.init.3
1 #!/sbin/runscript
2 # Copyright 1999-2014 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License, v2
4
5 depend() {
6 need localmount
7 }
8
9 checkconfig() {
10 # An empty DISKLIST is allowed because the disk will be
11 # auto-detected.
12 for DISK in ${DISKLIST}; do
13 if [ ! -b /dev/${DISK} ]; then
14 eerror "Could not find disk /dev/${DISK}!"
15 eerror "Adjust the DISK setting in /etc/conf.d/hdapsd"
16 return 1
17 fi
18
19 if [ ! -e /sys/block/${DISK}/queue/protect ] && \
20 [ ! -e /sys/block/${DISK}/device/unload_heads ] ; then
21 eerror "No protect entry for ${DISK}!"
22 eerror "Make sure your kernel is patched with the blk_freeze patch"
23 return 1
24 fi
25 done
26
27 # Load the tp_smapi module first. This is not a requirement, but
28 # it helps hdapsd's adaptive mode.
29 if [ ! -e /sys/devices/platform/smapi ] ; then
30 modprobe tp_smapi 2>/dev/null
31 fi
32
33 if [ ! -d /sys/devices/platform/hdaps ] ; then
34 ebegin "Loading hdaps module"
35 modprobe hdaps
36 eend $? || return 1
37 fi
38 }
39
40 start() {
41 checkconfig || return 1
42
43 local DISKOPTS DISK
44 for DISK in ${DISKLIST}; do
45 DISKOPTS="${DISKOPTS} -d ${DISK}"
46 done
47
48 # Since we're allowed to have an empty $THRESHOLD, we append
49 # "--sensitivity $THRESHOLD" to $OPTIONS here only when it exists.
50 if [ ! -z "${THRESHOLD}" ] ; then
51 OPTIONS="${OPTIONS} --sensitivity ${THRESHOLD}"
52 fi
53
54 ebegin "Starting Hard Drive Active Protection System daemon"
55 start-stop-daemon --start --exec /usr/sbin/hdapsd \
56 --pidfile /var/run/hdapsd.pid \
57 -- --syslog --background --pidfile \
58 ${DISKOPTS} ${OPTIONS}
59 eend $?
60 }
61
62 stop() {
63 ebegin "Stopping Hard Drive Active Protection System daemon"
64 start-stop-daemon --stop --exec /usr/sbin/hdapsd \
65 --pidfile /var/run/hdapsd.pid
66 eend $?
67 }