-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpi_lan_access.sh
executable file
·47 lines (37 loc) · 1.04 KB
/
pi_lan_access.sh
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
if [ $1 == "--help" ]; then
echo "Usage: pi_lan_access.sh \"<boot volume>\" \"<wifi name>\" \"<wifi password>\""
exit 1
fi
boot_volume=$1
if [ $# -eq 0 ]; then
echo "No arguments provided"
echo "Please enter sd card boot mount point usually /Volumes/boot"
read boot_volume
exit 1
fi
#enabling ssh
echo "Enabling SSH, creating file ssh"
touch "$boot_volume/ssh"
wifi_ssid=$2
wifi_password=$3
if [ $# -eq 1 ]; then
echo ""
echo "Enabling wireless access"
echo "========================"
echo ""
echo "Please provide WiFi name:"
read wifi_ssid
echo "Please provide WiFi password"
read wifi_password
fi
wf="$boot_volume/wpa_supplicant.conf"
echo "Writing wpa_supplicant.info to $boot_volume with WiFi: $wifi_ssid and Passwird: $wifi_password "
echo "country=us" > $wf
echo "update_config=1" >> $wf
echo "ctrl_interface=/var/run/wpa_supplicant" >> $wf
echo "network={" >> $wf
echo " scan_ssid=1" >> $wf
echo " ssid=\"$wifi_ssid\"" >> $wf
echo " psk=\"$wifi_password\"" >> $wf
echo "}" >> $wf