summaryrefslogtreecommitdiff
path: root/etc/rc.d/gpio
blob: 43e63b0cefe2face7ad796d1dbb41194a03cff4f (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
#!/bin/sh
#
# $NetBSD: gpio,v 1.2 2022/04/30 13:48:09 brad Exp $
#

# PROVIDE: gpio
# BEFORE:  securelevel

$_rc_subr_loaded . /etc/rc.subr

name="gpio"
rcvar=$name
start_cmd="gpio_start"
stop_cmd=":"

gpio_start()
{
	if [ -f /etc/gpio.conf ]; then
		echo "Configuring GPIO."
		cat /etc/gpio.conf |
		collapse_backslash_newline |
		while read -r args; do
			case "$args" in
			"!"*)
				# Run arbitrary command in a subshell.
				( eval "${args#*!}" )
				;;
			*)
			        (
				    args=${args%%#*}		# strip comments
				    test -z "$args" && continue
				    /usr/sbin/gpioctl -q $args
				)
				;;
			esac
		done
	fi
}

load_rc_config $name
run_rc_command "$1"