Browse Source

Daemon to start wifi

Bob Mottram 8 years ago
parent
commit
6dea0a87ff

+ 4
- 1
src/freedombone-controlpanel View File

@@ -1384,13 +1384,16 @@ function wifi_settings {
1384 1384
         cp $TEMP_WIFI_NETWORKS_FILE $WIFI_NETWORKS_FILE
1385 1385
         rm $TEMP_WIFI_NETWORKS_FILE
1386 1386
         ${PROJECT_NAME}-wifi --networks $WIFI_NETWORKS_FILE
1387
+        create_wifi_startup_script
1387 1388
         if [[ $(wifi_is_running) == "1" ]]; then
1388 1389
             dialog --title $"Wifi Settings" \
1389 1390
                    --msgbox $"Wifi settings were changed." 6 60
1390 1391
         else
1391 1392
             dialog --title $"Wifi Settings" \
1392
-                   --msgbox $"Wifi settings were changed. You will need to restart the system for the changes to take effect." 6 60
1393
+                   --msgbox $"Wifi settings were changed. You will need to restart the system with ethernet cable removed for the changes to take effect." 7 60
1393 1394
         fi
1395
+    else
1396
+        remove_wifi_startup_script
1394 1397
     fi
1395 1398
 }
1396 1399
 

+ 16
- 1
src/freedombone-image-customise View File

@@ -409,7 +409,22 @@ EOF
409 409
         END_MESSAGE_HEIGHT=12
410 410
     fi
411 411
     echo "            if [ -f /root/${PROJECT_NAME}-wifi.cfg ]; then" >> $rootdir/root/.bashrc
412
-    echo "                ${PROJECT_NAME}-wifi" >> $rootdir/root/.bashrc
412
+    echo "                echo '[Unit]' > /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
413
+    echo "                echo 'Description=WifiStartup (Start wifi networking)' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
414
+    echo "                echo 'After=syslog.target' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
415
+    echo "                echo 'After=network.target' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
416
+    echo "                echo '' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
417
+    echo "                echo '[Service]' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
418
+    echo "                echo 'Type=simple' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
419
+    echo "                echo 'User=root' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
420
+    echo "                echo 'Group=root' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
421
+    echo "                echo 'WorkingDirectory=/root' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
422
+    echo "                echo 'ExecStart=/usr/local/bin/freedombone-wifi' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
423
+    echo "                echo '' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
424
+    echo "                echo '[Install]' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
425
+    echo "                echo 'WantedBy=multi-user.target' >> /etc/systemd/system/wifistart.service" >> $rootdir/root/.bashrc
426
+    echo "                systemctl enable wifistart" >> $rootdir/root/.bashrc
427
+    echo "                systemctl daemon-reload" >> $rootdir/root/.bashrc
413 428
     echo '            fi' >> $rootdir/root/.bashrc
414 429
     echo "            dialog --title '$END_MESSAGE1' --msgbox \"$END_MESSAGE2\" ${END_MESSAGE_HEIGHT} 60" >> $rootdir/root/.bashrc
415 430
     echo '            reboot' >> $rootdir/root/.bashrc

+ 6
- 5
src/freedombone-utils-final View File

@@ -44,9 +44,9 @@ function install_final {
44 44
     echo ''
45 45
 
46 46
     echo $"
47
-    *** ${PROJECT_NAME} installation is complete. Rebooting... ***
47
+    *** ${PROJECT_NAME} installation is complete ***
48 48
 
49
-    Ensure that these ports are forwarded from your internet router
49
+    Ensure that ports are forwarded from your internet router
50 50
 "
51 51
     echo ''
52 52
 
@@ -60,9 +60,10 @@ function install_final {
60 60
     fi
61 61
     if [ ! -f $IMAGE_PASSWORD_FILE ]; then
62 62
         if [ -f /root/${PROJECT_NAME}-wifi.cfg ]; then
63
-            if [[ $(wifi_is_running) == "0" ]]; then
64
-                ${PROJECT_NAME}-wifi
65
-            fi
63
+            create_wifi_startup_script
64
+            echo $'Shutting down the system. Detatch the ethernet cable, then power on again.'
65
+            shutdown now
66
+            return
66 67
         fi
67 68
         reboot
68 69
     fi

+ 30
- 0
src/freedombone-utils-wifi View File

@@ -549,4 +549,34 @@ function count_wlan {
549 549
     echo $ctr
550 550
 }
551 551
 
552
+function create_wifi_startup_script {
553
+    systemd_file=/etc/systemd/system/wifistart.service
554
+    echo '[Unit]' > $systemd_file
555
+    echo 'Description=WifiStartup (Start wifi networking)' >> $systemd_file
556
+    echo 'After=syslog.target' >> $systemd_file
557
+    echo 'After=network.target' >> $systemd_file
558
+    echo '' >> $systemd_file
559
+    echo '[Service]' >> $systemd_file
560
+    echo 'Type=simple' >> $systemd_file
561
+    echo 'User=root' >> $systemd_file
562
+    echo 'Group=root' >> $systemd_file
563
+    echo 'WorkingDirectory=/root' >> $systemd_file
564
+    echo "ExecStart=/usr/local/bin/${PROJECT_NAME}-wifi" >> $systemd_file
565
+    echo '' >> $systemd_file
566
+    echo '[Install]' >> $systemd_file
567
+    echo 'WantedBy=multi-user.target' >> $systemd_file
568
+
569
+    systemctl enable wifistart
570
+    systemctl daemon-reload
571
+}
572
+
573
+function remove_wifi_startup_script {
574
+    systemd_file=/etc/systemd/system/wifistart.service
575
+    if [ -f $systemd_file ]; then
576
+        systemctl disable wifistart
577
+        systemctl daemon-reload
578
+        rm $systemd_file
579
+    fi
580
+}
581
+
552 582
 # NOTE: deliberately no exit 0