-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwpa-setup.sh
More file actions
46 lines (34 loc) · 746 Bytes
/
Copy pathwpa-setup.sh
File metadata and controls
46 lines (34 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
set -exo pipefail
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
mkdir root
mount "${DISK}2" root
cat << EOF >> root/etc/systemd/network/wlan0.network
[Match]
Name=wlan0
[Network]
DHCP=yes
EOF
wpa_passphrase "${SSID}" "${PASS}" > root/etc/wpa_supplicant/wpa_supplicant-wlan0.conf
ln -s \
/usr/lib/systemd/system/wpa_supplicant@.service \
root/etc/systemd/system/multi-user.target.wants/wpa_supplicant@wlan0.service
echo Unmounting
umount root
echo Cleaning up
rmdir root