fix: hotspot save now restarts AP immediately (down + 1s wait + up)
This commit is contained in:
@@ -178,9 +178,18 @@ def hotspot_config_update():
|
||||
["sudo", "-n", "nmcli", "con", "mod", _HOTSPOT_PROFILE, "802-11-wireless-security.psk", password],
|
||||
capture_output=True, text=True, timeout=10, check=True,
|
||||
)
|
||||
return jsonify(message=f"Hotspot SSID updated to '{ssid}'."
|
||||
+ (" Password saved." if password else "")
|
||||
+ " Restart hotspot or device to apply.")
|
||||
# Restart the hotspot so changes take effect immediately.
|
||||
subprocess.run(
|
||||
["sudo", "-n", "nmcli", "con", "down", _HOTSPOT_PROFILE],
|
||||
capture_output=True, text=True, timeout=10,
|
||||
)
|
||||
time.sleep(1)
|
||||
subprocess.run(
|
||||
["sudo", "-n", "nmcli", "con", "up", _HOTSPOT_PROFILE],
|
||||
capture_output=True, text=True, timeout=15, check=True,
|
||||
)
|
||||
return jsonify(message=f"Hotspot updated to '{ssid}' and restarted."
|
||||
+ (" New password saved." if password else ""))
|
||||
except subprocess.CalledProcessError as e:
|
||||
return jsonify(error=f"Could not update hotspot: {e.stderr.strip() or 'nmcli failed'}"), 500
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
yaris ALL=(root) NOPASSWD: /usr/bin/nmcli -t -f 802-11-wireless.ssid con show Hotspot-local
|
||||
yaris ALL=(root) NOPASSWD: /usr/bin/nmcli con mod Hotspot-local 802-11-wireless.ssid *
|
||||
yaris ALL=(root) NOPASSWD: /usr/bin/nmcli con mod Hotspot-local 802-11-wireless-security.psk *
|
||||
yaris ALL=(root) NOPASSWD: /usr/bin/nmcli con down Hotspot-local
|
||||
yaris ALL=(root) NOPASSWD: /usr/bin/nmcli con up Hotspot-local
|
||||
|
||||
Reference in New Issue
Block a user