mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-05-03 00:48:25 +02:00
Cosmetic fix for not cluttering openrc output: * Restoring rfkill configuration ...cat: can't open '/var/lib/rfkill/*': No such file or directory Try 'rfkill --help' for more information. [ ok ]
52 lines
898 B
Bash
52 lines
898 B
Bash
#!/sbin/openrc-run
|
|
|
|
description="Save/Restore rfkill configuration"
|
|
|
|
rfkillstatedir=/var/lib/rfkill
|
|
|
|
extra_commands="save restore"
|
|
|
|
depend() {
|
|
need localmount
|
|
after bootmisc modules isapnp coldplug hotplug
|
|
}
|
|
|
|
restore() {
|
|
ebegin "Restoring rfkill configuration"
|
|
if [ -d "$rfkillstatedir" ]; then
|
|
for type in "$rfkillstatedir"/*; do
|
|
status=$(cat "$type")
|
|
type=$(basename "$type")
|
|
rfkill "$status" "$type"
|
|
done
|
|
fi
|
|
eend 0
|
|
}
|
|
|
|
save() {
|
|
ebegin "Storing rfkill configuration"
|
|
mkdir -p "$rfkillstatedir"
|
|
OLDIFS="$IFS"
|
|
IFS=$'\n'
|
|
for line in $(rfkill -r -n); do
|
|
type=$(echo "$line" | cut -d' ' -f2)
|
|
status=$(echo "$line" | cut -d' ' -f4 | tr -d 'ed')
|
|
echo "$status" > "$rfkillstatedir"/"$type"
|
|
done
|
|
IFS="$OLDIFS"
|
|
eend 0
|
|
}
|
|
|
|
start() {
|
|
if [ "${RESTORE_ON_START}" = "yes" ]; then
|
|
restore
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
stop() {
|
|
if [ "${SAVE_ON_STOP}" = "yes" ]; then
|
|
save
|
|
fi
|
|
return 0
|
|
}
|