Last active
July 5, 2022 05:37
-
-
Save tatumroaquin/2fb35f23690c41b3e41cc450ff5ada17 to your computer and use it in GitHub Desktop.
connects RPI4 to an access point so that SSH can be accessed directly without cables.
This file contains 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 | |
#https://archlinuxarm.org/forum/viewtopic.php?f=31&t=11529 | |
#dependency: pacman -S wpa_supplicant | |
set -e | |
if [ $# -ne 3 ]; then | |
echo "Usage: $0 </dev/disk> <ssid> <passphase>" | |
exit 1 | |
fi | |
DISK="$1" | |
SSID="$2" | |
PASS="$3" | |
if [ ! -b "${DISK}" ]; then | |
echo "Not a block device: ${DISK}" | |
exit 1 | |
fi | |
if [ "${USER}" != "root" ]; then | |
echo "Must run as root." | |
exit 1 | |
fi | |
echo Mounting | |
if [ ! -d "root" ]; then | |
mkdir root | |
mount "${DISK}2" root | |
else | |
mount "${DISK}2" root | |
fi | |
cat << EOF >> root/etc/systemd/network/wlan0.network | |
[Match] | |
Name=wlan0 | |
[Network] | |
DHCP=yes | |
MulticastDNS=yes | |
LLMNR=yes | |
EOF | |
wpa_passphrase "${SSID}" "${PASS}" > root/etc/wpa_supplicant/wpa_supplicant-wlan0.conf | |
ln -s \ | |
/usr/lib/systemd/system/[email protected] \ | |
root/etc/systemd/system/multi-user.target.wants/[email protected] | |
echo Unmounting | |
umount root | |
echo Cleaning up | |
rmdir root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment