mirror of
https://github.com/tjboldt/Apple2-IO-RPi.git
synced 2025-08-15 09:27:25 +00:00
Add wifi setup support
This commit is contained in:
@@ -42,6 +42,30 @@ func ExecCommand() {
|
|||||||
"\r")
|
"\r")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if linuxCommand == "a2wifi" {
|
||||||
|
a2io.WriteString("\r" +
|
||||||
|
"Usage: a2wifi list\r" +
|
||||||
|
" a2wifi select SSID PASSWORD\r" +
|
||||||
|
"\r")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if linuxCommand == "a2wifi list" {
|
||||||
|
linuxCommand = "sudo iwlist wlan0 scanning | grep ESSID | sed s/.*ESSID://g | sed s/\\\"//g"
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(linuxCommand, "a2wifi select") {
|
||||||
|
params := strings.Fields(linuxCommand)
|
||||||
|
if (len(params) != 4) {
|
||||||
|
a2io.WriteString("\rIncorrect number of parameters. Usage: a2wifi select SSID PASSWORD\r\r")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ssid := params[2]
|
||||||
|
psk := params[3]
|
||||||
|
linuxCommand = "sudo printf \"country=ca\\nupdate_config=1\\nctrl_interface=/var/run/wpa_supplicant\\n\\nnetwork={\\n scan_ssid=1\\n ssid=\\\"%s\\\"\n psk=\\\"%s\\\"\\n}\\n\" " +
|
||||||
|
ssid + " " +
|
||||||
|
psk + " " +
|
||||||
|
" > /etc/wpa_supplicant/wpa_supplicant.conf; " +
|
||||||
|
"sudo wpa_cli -i wlan0 reconfigure"
|
||||||
|
}
|
||||||
cmd := exec.Command("bash", "-c", linuxCommand)
|
cmd := exec.Command("bash", "-c", linuxCommand)
|
||||||
cmd.Dir = workingDirectory
|
cmd.Dir = workingDirectory
|
||||||
cmdOut, err := cmd.Output()
|
cmdOut, err := cmd.Output()
|
||||||
|
Reference in New Issue
Block a user