From 1dffc1df50df4d9ef566123b74c9b65a4236fcaa Mon Sep 17 00:00:00 2001 From: j1nx Date: Tue, 21 Jul 2020 10:30:41 +0200 Subject: [PATCH] MycroftOS: Auto start wifi-connect at boot if no active wifi is present. --- .../package/wifi-connect/start-wifi-connect | 10 ++++++++++ .../package/wifi-connect/wifi-connect.mk | 6 ++++-- .../package/wifi-connect/wifi-connect.service | 11 +++++++++++ .../usr/lib/systemd/system-preset/10-mycroftos.preset | 1 + 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 buildroot-external/package/wifi-connect/start-wifi-connect create mode 100644 buildroot-external/package/wifi-connect/wifi-connect.service diff --git a/buildroot-external/package/wifi-connect/start-wifi-connect b/buildroot-external/package/wifi-connect/start-wifi-connect new file mode 100755 index 00000000..6bce25dc --- /dev/null +++ b/buildroot-external/package/wifi-connect/start-wifi-connect @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +iwgetid -r + +if [ $? -eq 0 ]; then + printf 'Skipping WiFi Connect\n' +else + printf 'Starting WiFi Connect\n' + /usr/local/sbin/wifi-connect +fi diff --git a/buildroot-external/package/wifi-connect/wifi-connect.mk b/buildroot-external/package/wifi-connect/wifi-connect.mk index a44a0071..c69ab635 100644 --- a/buildroot-external/package/wifi-connect/wifi-connect.mk +++ b/buildroot-external/package/wifi-connect/wifi-connect.mk @@ -33,8 +33,10 @@ define WIFI_CONNECT_INSTALL_TARGET_CMDS endef define WIFI_CONNECT_INSTALL_INIT_SYSTEMD -# $(INSTALL) -D -m 0644 $(BR2_EXTERNAL_MYCROFTOS_PATH)/package/wifi-connect/wifi-connect.service \ -# $(TARGET_DIR)/usr/lib/systemd/system/wifi-connect.service + $(INSTALL) -D -m 0644 $(BR2_EXTERNAL_MYCROFTOS_PATH)/package/wifi-connect/wifi-connect.service \ + $(TARGET_DIR)/usr/lib/systemd/system/wifi-connect.service + $(INSTALL) -D -m 0755 $(BR2_EXTERNAL_MYCROFTOS_PATH)/package/wifi-connect/start-wifi-connect \ + $(TARGET_DIR)/usr/local/sbin/start-wifi-connect endef $(eval $(generic-package)) diff --git a/buildroot-external/package/wifi-connect/wifi-connect.service b/buildroot-external/package/wifi-connect/wifi-connect.service new file mode 100644 index 00000000..4a662992 --- /dev/null +++ b/buildroot-external/package/wifi-connect/wifi-connect.service @@ -0,0 +1,11 @@ +[Unit] +Description=Mycroft wifi connect service +After=NetworkManager.service + +[Service] +Type=simple +ExecStart=/usr/local/sbin/start-wifi-connect +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system-preset/10-mycroftos.preset b/buildroot-external/rootfs-overlay/usr/lib/systemd/system-preset/10-mycroftos.preset index 706bf2d5..acb50d92 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system-preset/10-mycroftos.preset +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system-preset/10-mycroftos.preset @@ -8,6 +8,7 @@ enable pulseaudio.service enable avahi-daemon.service enable seeed-voicecard.service enable NetworkManager.service +enable wifi-connect.service enable mycroft-splash-start.service enable mycroft-splash-40.service