Home | History | Annotate | Line # | Download | only in rc.d
      1 #!/bin/sh
      2 #
      3 # $NetBSD: gpio,v 1.2 2022/04/30 13:48:09 brad Exp $
      4 #
      5 
      6 # PROVIDE: gpio
      7 # BEFORE:  securelevel
      8 
      9 $_rc_subr_loaded . /etc/rc.subr
     10 
     11 name="gpio"
     12 rcvar=$name
     13 start_cmd="gpio_start"
     14 stop_cmd=":"
     15 
     16 gpio_start()
     17 {
     18 	if [ -f /etc/gpio.conf ]; then
     19 		echo "Configuring GPIO."
     20 		cat /etc/gpio.conf |
     21 		collapse_backslash_newline |
     22 		while read -r args; do
     23 			case "$args" in
     24 			"!"*)
     25 				# Run arbitrary command in a subshell.
     26 				( eval "${args#*!}" )
     27 				;;
     28 			*)
     29 			        (
     30 				    args=${args%%#*}		# strip comments
     31 				    test -z "$args" && continue
     32 				    /usr/sbin/gpioctl -q $args
     33 				)
     34 				;;
     35 			esac
     36 		done
     37 	fi
     38 }
     39 
     40 load_rc_config $name
     41 run_rc_command "$1"
     42