Skip to content

Instantly share code, notes, and snippets.

@rakslice
Last active August 28, 2024 09:20
Show Gist options
  • Save rakslice/3873b7e419c1d959cd51754acda752a1 to your computer and use it in GitHub Desktop.
Save rakslice/3873b7e419c1d959cd51754acda752a1 to your computer and use it in GitHub Desktop.
An ifupdown-ng executor fragment to check if the wlan is disabled by rfkill before trying to bring it up
#!/bin/sh
# /usr/libexec/ifupdown-ng/rfkillcheck
rfkill_iface=wlan0
rfkill_file=/sys/class/rfkill/rfkill1/soft
check() {
if [ "$IFACE" = "$rfkill_iface" ] && [ "$PHASE" = "pre-up" ]; then
if [ -e $rfkill_file ] && [ "`cat $rfkill_file`" != "0" ]
then
echo "$IFACE is disabled by rfkill" 1>&2
exit 1
fi
fi
}
@rakslice
Copy link
Author

Because the rfkill entry I was originally checking was a little race conditiony at boot, I reworked this to just hardcode the interface name and rfkill entry to check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment