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
This commit is contained in:
Johannes Totz 2023-05-23 18:11:31 +03:00 committed by Christos Margiolis
parent 98ab9802af
commit 2cf8ef5910

View file

@ -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