summaryrefslogtreecommitdiff
path: root/package/kernel/om-watchdog/files/om-watchdog.init
blob: 79819ad96c0e8e818cfe996d7438fd6e0fabe708 (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
#!/bin/sh /etc/rc.common
#
# Copyright (C) 2011 OpenWrt.org
#

START=11
STOP=11

USE_PROCD=1
NAME=om-watchdog
PROG=/sbin/om-watchdog

get_gpio() {
	if [ -r /lib/ar71xx.sh ]; then
		. /lib/ar71xx.sh
		local board=$(ar71xx_board_name)

		case "$board" in
			"om2p" | \
			"om2p-hs" | \
			"om2p-hsv2" | \
			"om5p-acv2")
				return 12
				;;
			"om2pv2" | \
			"om2p-lc")
				return 26
				;;
			"om5p" | \
			"om5p-an")
				return 11
				;;
			"om5p-ac")
				return 17
				;;
			"mr600v2")
				return 15
				;;
			"mr900" | \
			"mr900v2" | \
			"mr1750")
				return 16
				;;
		esac
	else
		#we assume it is om1p in this case
		return 3
	fi

	return 255
}

start_service() {
	get_gpio
	gpio="$?"
	[ "$gpio" != "255" ] || return

	procd_open_instance
	procd_set_param command "${PROG}" "${gpio}"
	procd_set_param respawn
	procd_close_instance
}