From a2ac75913b59362ab83d788050953c1c01830a8b Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Sat, 24 Aug 2024 13:42:47 +0900 Subject: [PATCH] support raspberry pi os bookworm --- WiFiPanel.html | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/WiFiPanel.html b/WiFiPanel.html index 531b892..6422536 100755 --- a/WiFiPanel.html +++ b/WiFiPanel.html @@ -167,18 +167,40 @@ var ret = await getOutputLines( await portWritelnWaitfor(" sudo touch /boot/ssh", cmdPrompt) ); - // set WiFi Info - var WiFiSet = - 'ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev\nupdate_config=1\ncountry=JP\nnetwork={\n ssid="{SSID}"\n psk="{PASS}"\n}'; + // WiFi Setup var ssid = ssidInput.value.trim(); var pass = passInput.value.trim(); - WiFiSet = WiFiSet.replace("{SSID}", ssid); - WiFiSet = WiFiSet.replace("{PASS}", pass); - console.log(WiFiSet); - infoPre.innerText = WiFiSet; - await saveFile(str2arrayBuffer(WiFiSet), "wpa_supplicant.conf"); - await cp("wpa_supplicant.conf", "/boot/wpa_supplicant.conf", true); + const WiFiSetup = `\ +#!/bin/sh +set -eu + +SSID=\$1 +PASSWORD=\$2 +DEBIAN_VERSION=$(cut -d . -f 1 /etc/debian_version) + +if [ "$DEBIAN_VERSION" -le 11 ]; then + WPA_CONF_PATH=/etc/wpa_supplicant/wpa_supplicant.conf + sudo sh -c "cat > $WPA_CONF_PATH" <