Created
March 5, 2018 16:57
-
-
Save telenieko/d17544fc7e4b347beffa87252393384c to your computer and use it in GitHub Desktop.
Sample files to enable wireless on Debian initramfs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # this goes into /etc/initramfs-tools/scripts/init-premount/a_enable_wireless | |
| PREREQ="" | |
| prereqs() | |
| { | |
| echo "$PREREQ" | |
| } | |
| case $1 in | |
| prereqs) | |
| prereqs | |
| exit 0 | |
| ;; | |
| esac | |
| . /scripts/functions | |
| AUTH_LIMIT=30 | |
| INTERFACE="wlp5s0" | |
| alias WPACLI="/sbin/wpa_cli -p/tmp/wpa_supplicant -i$INTERFACE " | |
| log_begin_msg "Starting WLAN connection" | |
| /sbin/wpa_supplicant -i$INTERFACE -c/etc/wpa_supplicant.conf -P/run/initram-wpa_supplicant.pid -B -f /tmp/wpa_supplicant.log | |
| # Wait for AUTH_LIMIT seconds, then check the status | |
| limit=${AUTH_LIMIT} | |
| echo -n "Waiting for connection (max ${AUTH_LIMIT} seconds)" | |
| while [ $limit -ge 0 -a `WPACLI status | grep wpa_state` != "wpa_state=COMPLETED" ] | |
| do | |
| sleep 1 | |
| echo -n "." | |
| limit=`expr $limit - 1` | |
| done | |
| echo "" | |
| if [ `WPACLI status | grep wpa_state` != "wpa_state=COMPLETED" ]; then | |
| ONLINE=0 | |
| log_failure_msg "WLAN offline after timeout" | |
| panic | |
| else | |
| ONLINE=1 | |
| log_success_msg "WLAN online" | |
| fi | |
| configure_networking |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # !/bin/sh | |
| # This goes into /etc/initramfs-tools/hooks/enable-wireless | |
| set -e | |
| PREREQ="" | |
| prereqs() | |
| { | |
| echo "${PREREQ}" | |
| } | |
| case "${1}" in | |
| prereqs) | |
| prereqs | |
| exit 0 | |
| ;; | |
| esac | |
| . /usr/share/initramfs-tools/hook-functions | |
| # CHANGE HERE for your correct modules. | |
| manual_add_modules iwlwifi iwlmvm | |
| copy_exec /sbin/wpa_supplicant | |
| copy_exec /sbin/wpa_cli | |
| copy_file config /etc/initramfs-tools/wpa_supplicant.conf /etc/wpa_supplicant.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is run on the shell | |
| chmod +x /etc/initramfs-tools/scripts/local-bottom/kill_wireless | |
| chmod +x /etc/initramfs-tools/scripts/init-premount/a_enable_wireless | |
| chmod +x /etc/initramfs-tools/hooks/enable-wireless | |
| update-initramfs -k all -u | |
| update-grub |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # this goes into /etc/initramfs-tools/scripts/local-bottom/kill_wireless | |
| PREREQ="" | |
| prereqs() | |
| { | |
| echo "$PREREQ" | |
| } | |
| case $1 in | |
| prereqs) | |
| prereqs | |
| exit 0 | |
| ;; | |
| esac | |
| echo "Killing wpa_supplicant so the system takes over later." | |
| kill `cat /run/initram-wpa_supplicant.pid` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # sample /etc/initramfs-tools/wpa_supplicant.conf | |
| # note that this is independent of the system /etc/wpa_supplicant.conf (if any) | |
| # only add the network you need at boot time. **And keep the ctrl_interface** !! | |
| ctrl_interface=/tmp/wpa_supplicant | |
| network={ | |
| ssid="MyNetwork" | |
| scan_ssid=1 | |
| psk="network passphrase" | |
| key_mgmt=WPA-PSK | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks all for the scripts and improvements thereupon. To make this work on my Raspberry Pi 4 running Debian 13, I additionally needed to
add the following lines to
hooks/enable-wireless:before calling
/sbin/iwininit-premount/a_enable_wireless, unblock the wireless device:This is on top of @morfikov's comments.