git: 2cf8ef5910fd - main - rc.suspend: execute rc-scripts with suspend keyword
Date: Tue, 23 May 2023 15:13:30 UTC
The branch main has been updated by christos:
URL: https://cgit.FreeBSD.org/src/commit/?id=2cf8ef5910fd3754f8021f9c67fde6b9d9030f33
commit 2cf8ef5910fd3754f8021f9c67fde6b9d9030f33
Author: Johannes Totz <jo@bruelltuete.com>
AuthorDate: 2023-05-23 15:11:31 +0000
Commit: Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2023-05-23 15:11:31 +0000
rc.suspend: execute rc-scripts with suspend keyword
For symmetry with rc.resume, give rc.suspend the ability to execute
rc-scripts. Use the suspend keyword for that.
Use-case is for setting a wake-up time, e.g. via efiwake.
Reviewed by: christos
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D39965
---
libexec/rc/rc.suspend | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/libexec/rc/rc.suspend b/libexec/rc/rc.suspend
index 5f22cd1a05b1..41b5bcbf897b 100755
--- a/libexec/rc/rc.suspend
+++ b/libexec/rc/rc.suspend
@@ -43,15 +43,28 @@ fi
echo $$ 2> /dev/null > /var/run/rc.suspend.pid
-# If you have troubles on suspending with PC-CARD modem, try this.
-# See also contrib/pccardq.c (Only for PAO users).
-# pccardq | awk -F '~' '$5 == "filled" && $4 ~ /uart/ \
-# { printf("pccardc power %d 0", $1); }' | sh
-
# If a device driver has problems suspending, try unloading it before
# suspend and reloading it on resume. Example:
# kldunload usb
+. /etc/rc.subr
+
+load_rc_config
+
+rcorder_opts="-k suspend"
+
+case ${local_startup} in
+[Nn][Oo] | '') ;;
+*) find_local_scripts_new ;;
+esac
+
+files=`rcorder ${rcorder_opts} /etc/rc.d/* ${local_rc} 2>/dev/null`
+
+for _rc_elem in $files; do
+ debug "run_rc_script $_rc_elem suspend"
+ run_rc_script $_rc_elem suspend
+done
+
/usr/bin/logger -t $subsystem suspend at `/bin/date +'%Y%m%d %H:%M:%S'`
/bin/sync && /bin/sync && /bin/sync
/bin/sleep 3