summaryrefslogtreecommitdiff
blob: 8b4930612c4de0a8cbc5a3c60bea0853cfb2ed93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/sbin/openrc-run
# Copyright 2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

checkconfig() {
    if [ -z "$DISK" ] ; then
	eerror "You need to setup DISK in /etc/conf.d/hpfall first"
	return 1
    fi

    if [ ! -b /dev/${DISK} ]; then
        eerror "Could not find disk /dev/${DISK}!"
        eerror "Adjust the DISK setting in /etc/conf.d/hpfall"
        return 1
    fi

    if [ ! -e /sys/block/${DISK}/device/unload_heads ] ; then
        eerror "No protect entry for ${DISK}!"
        eerror "Kernel 2.6.28 and above is required"
        return 1
    fi

    if [ ! -c /dev/freefall ]; then
        ebegin "Loading hp_accel module"
        modprobe hp_accel
        eend $? || return 1
    fi
}

start () {
    checkconfig || return 1

    ebegin "Starting active hard-drive protection daemon"
    start-stop-daemon --start --quiet \
        --exec /usr/sbin/hpfall /dev/${DISK}
    eend $?
}

stop() {
    ebegin "Stopping active hard-drive protection daemon"
    start-stop-daemon --stop --quiet \
        --exec /usr/sbin/hpfall
    eend $?
}