summaryrefslogtreecommitdiff
path: root/sys-apps/qcontrol/files/init.d
blob: 1a2ea38eb4d4e533637b477dcbbe74519763ef8d (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/sbin/openrc-run
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Header: $

# Init script from Debian

depend() {
        after local
}

start() {
	einfo "System boot completed"
	if [ ! -c /dev/input/by-path/platform-gpio-keys-event- ]; then
		eerror "qcontrol error: gpio_keys device not available"
		return 1
	fi
	start-stop-daemon --start --quiet --background --pidfile /var/run/qcontrol.pid --make-pidfile --exec /usr/sbin/qcontrol -- -d
	# Change status led to show green
	device=$(grep "Hardware[[:space:]]*:" /proc/cpuinfo 2>/dev/null | \
		 head -n1 | sed "s/^[^:]*: //")
	case $device in
	    "QNAP TS-109/TS-209" | "QNAP TS-119/TS-219")
			qcontrol statusled greenon || true
			qcontrol powerled on || true
			if [ "$SOUND_BUZZER" != no ]; then
				qcontrol buzzer short || true
			fi
		;;
	    "QNAP TS-409" | "QNAP TS-41x")
			qcontrol statusled greenon || true
			if [ "$SOUND_BUZZER" != no ]; then
				qcontrol buzzer short || true
			fi
		;;
	    *)
		eerror "qcontrol error: device is not supported"
		;;
	esac
        start-stop-daemon --stop --quiet --pidfile /var/run/qcontrol.pid --name qcontrol
	rm /var/run/qcontrol.sock
}

stop() {
	einfo "Shutting down system"
	if [ ! -c /dev/input/by-path/platform-gpio-keys-event- ]; then
		eerror "qcontrol error: gpio_keys device not available"
		return 1
	fi
	start-stop-daemon --start --quiet --background --pidfile /var/run/qcontrol.pid --make-pidfile --exec /usr/sbin/qcontrol -- -d
	# Change status led to show red
	device=$(grep "Hardware[[:space:]]*:" /proc/cpuinfo 2>/dev/null | \
		 head -n1 | sed "s/^[^:]*: //")
	case $device in
	    "QNAP TS-109/TS-209" | "QNAP TS-119/TS-219")
			qcontrol statusled rednon || true
			qcontrol powerled 1hz || true
			if [ "$SOUND_BUZZER" != no ]; then
				qcontrol buzzer short || true
			fi
		;;
	    "QNAP TS-409" | "QNAP TS-41x")
			qcontrol statusled redon || true
			if [ "$SOUND_BUZZER" != no ]; then
				qcontrol buzzer short || true
			fi
		;;
	    *)
		eerror "qcontrol error: device is not supported"
		;;
	esac
        start-stop-daemon --stop --quiet --pidfile /var/run/qcontrol.pid --name qcontrol
	rm /var/run/qcontrol.sock
}