Bladeren bron

Daemon to start wifi

Bob Mottram 9 jaren geleden
bovenliggende
commit
6dea0a87ff
4 gewijzigde bestanden met toevoegingen van 56 en 7 verwijderingen
  1. 4
    1
      src/freedombone-controlpanel
  2. 16
    1
      src/freedombone-image-customise
  3. 6
    5
      src/freedombone-utils-final
  4. 30
    0
      src/freedombone-utils-wifi

+ 4
- 1
src/freedombone-controlpanel Bestand weergeven

1384
         cp $TEMP_WIFI_NETWORKS_FILE $WIFI_NETWORKS_FILE
1384
         cp $TEMP_WIFI_NETWORKS_FILE $WIFI_NETWORKS_FILE
1385
         rm $TEMP_WIFI_NETWORKS_FILE
1385
         rm $TEMP_WIFI_NETWORKS_FILE
1386
         ${PROJECT_NAME}-wifi --networks $WIFI_NETWORKS_FILE
1386
         ${PROJECT_NAME}-wifi --networks $WIFI_NETWORKS_FILE
1387
+        create_wifi_startup_script
1387
         if [[ $(wifi_is_running) == "1" ]]; then
1388
         if [[ $(wifi_is_running) == "1" ]]; then
1388
             dialog --title $"Wifi Settings" \
1389
             dialog --title $"Wifi Settings" \
1389
                    --msgbox $"Wifi settings were changed." 6 60
1390
                    --msgbox $"Wifi settings were changed." 6 60
1390
         else
1391
         else
1391
             dialog --title $"Wifi Settings" \
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
         fi
1394
         fi
1395
+    else
1396
+        remove_wifi_startup_script
1394
     fi
1397
     fi
1395
 }
1398
 }
1396
 
1399
 

+ 16
- 1
src/freedombone-image-customise Bestand weergeven

409
         END_MESSAGE_HEIGHT=12
409
         END_MESSAGE_HEIGHT=12
410
     fi
410
     fi
411
     echo "            if [ -f /root/${PROJECT_NAME}-wifi.cfg ]; then" >> $rootdir/root/.bashrc
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
     echo '            fi' >> $rootdir/root/.bashrc
428
     echo '            fi' >> $rootdir/root/.bashrc
414
     echo "            dialog --title '$END_MESSAGE1' --msgbox \"$END_MESSAGE2\" ${END_MESSAGE_HEIGHT} 60" >> $rootdir/root/.bashrc
429
     echo "            dialog --title '$END_MESSAGE1' --msgbox \"$END_MESSAGE2\" ${END_MESSAGE_HEIGHT} 60" >> $rootdir/root/.bashrc
415
     echo '            reboot' >> $rootdir/root/.bashrc
430
     echo '            reboot' >> $rootdir/root/.bashrc

+ 6
- 5
src/freedombone-utils-final Bestand weergeven

44
     echo ''
44
     echo ''
45
 
45
 
46
     echo $"
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
     echo ''
51
     echo ''
52
 
52
 
60
     fi
60
     fi
61
     if [ ! -f $IMAGE_PASSWORD_FILE ]; then
61
     if [ ! -f $IMAGE_PASSWORD_FILE ]; then
62
         if [ -f /root/${PROJECT_NAME}-wifi.cfg ]; then
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
         fi
67
         fi
67
         reboot
68
         reboot
68
     fi
69
     fi

+ 30
- 0
src/freedombone-utils-wifi Bestand weergeven

549
     echo $ctr
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
 # NOTE: deliberately no exit 0
582
 # NOTE: deliberately no exit 0