Module Name: src
Committed By: brad
Date: Sat Apr 30 13:48:09 UTC 2022
Modified Files:
src/etc/rc.d: gpio
src/share/man/man5: gpio.conf.5
Log Message:
Like /etc/rc.d/network, add the ability to put a '!' character as the
first character in /etc/gpio.conf and have the rest evaluated in a
shell. It is useful to be able to do actions after setting up gpio
pins or attaching gpioiic(4).
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/etc/rc.d/gpio
cvs rdiff -u -r1.2 -r1.3 src/share/man/man5/gpio.conf.5
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/etc/rc.d/gpio
diff -u src/etc/rc.d/gpio:1.1 src/etc/rc.d/gpio:1.2
--- src/etc/rc.d/gpio:1.1 Sat Jul 25 16:20:10 2009
+++ src/etc/rc.d/gpio Sat Apr 30 13:48:09 2022
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: gpio,v 1.1 2009/07/25 16:20:10 mbalmer Exp $
+# $NetBSD: gpio,v 1.2 2022/04/30 13:48:09 brad Exp $
#
# PROVIDE: gpio
@@ -18,10 +18,21 @@ gpio_start()
if [ -f /etc/gpio.conf ]; then
echo "Configuring GPIO."
cat /etc/gpio.conf |
+ collapse_backslash_newline |
while read -r args; do
- args=${args%%#*} # strip comments
- test -z "$args" && continue
- /usr/sbin/gpioctl -q $args
+ 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
}
Index: src/share/man/man5/gpio.conf.5
diff -u src/share/man/man5/gpio.conf.5:1.2 src/share/man/man5/gpio.conf.5:1.3
--- src/share/man/man5/gpio.conf.5:1.2 Sat Aug 1 13:14:40 2009
+++ src/share/man/man5/gpio.conf.5 Sat Apr 30 13:48:09 2022
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpio.conf.5,v 1.2 2009/08/01 13:14:40 mbalmer Exp $
+.\" $NetBSD: gpio.conf.5,v 1.3 2022/04/30 13:48:09 brad Exp $
.\"
.\" Copyright (c) 2009 Marc Balmer <[email protected]>
.\" All rights reserved.
@@ -40,6 +40,9 @@ and is intended for configuring GPIO pin
Lines starting with a hash
.Pq Sq #
and empty lines are ignored.
+If a line starts with
+.Sq \&! ,
+the rest of line will get evaluated as shell script fragment.
All other lines are passed to
.Xr gpioctl 8 .
.Sh FILES