]> git.mar77i.info Git - superuser/commitdiff
ensure wpa_supplicant is started master
authormar77i <mar77i@protonmail.ch>
Fri, 17 Jul 2026 08:51:15 +0000 (10:51 +0200)
committermar77i <mar77i@protonmail.ch>
Fri, 17 Jul 2026 08:51:15 +0000 (10:51 +0200)
select_wifi.py

index 28c51ec91522fd2baeae67a1d338902ea9be6255..c50aebb4418f9e4d9117db27823e88306ea27061 100755 (executable)
@@ -2,7 +2,7 @@
 
 import os
 import sys
-from subprocess import check_call
+from subprocess import check_call, run
 
 WPA_CONFIG = "/etc/wpa_supplicant/wpa_supplicant.conf"
 
@@ -116,11 +116,12 @@ def main():
     with open(WPA_CONFIG) as fh:
         for line in fh:
             wpa_config.lines.append(line.rstrip())
-    if not wpa_config.choose():
-        return
-    with open(WPA_CONFIG, "wt") as fh:
-        wpa_config.print(fh)
-    check_call(["rc-service", "wpa_supplicant", "restart"])
+    if wpa_config.choose():
+        with open(WPA_CONFIG, "wt") as fh:
+            wpa_config.print(fh)
+        check_call(["rc-service", "wpa_supplicant", "restart"])
+    elif run(["rc-service", "wpa_supplicant", "status", "-q"]).returncode != 0:
+        check_call(["rc-service", "wpa_supplicant", "start"])
 
 
 if __name__ == "__main__":