Browse Source

wifi utils static analysis

Bob Mottram 7 years ago
parent
commit
c44d07bd2f
2 changed files with 128 additions and 132 deletions
  1. 0
    1
      src/freedombone-app-syncthing
  2. 128
    131
      src/freedombone-utils-wifi

+ 0
- 1
src/freedombone-app-syncthing View File

@@ -112,7 +112,6 @@ function syncthing_add_id {
112 112
     syncthing_create_ids_file
113 113
 
114 114
     data=$(mktemp 2>/dev/null)
115
-    trap "rm -f $data" 0 1 2 5 15
116 115
     dialog --backtitle $"Freedombone User Control Panel" \
117 116
            --title $"Add a Syncthing device ID" \
118 117
            --form $"Paste the device ID for your laptop/desktop/netbook/phone/tablet below" 9 80 2 \

+ 128
- 131
src/freedombone-utils-wifi View File

@@ -74,10 +74,10 @@ function wifi_static_network_interface {
74 74
     else
75 75
         read_config_param "LOCAL_NETWORK_STATIC_IP_ADDRESS"
76 76
         read_config_param "ROUTER_IP_ADDRESS"
77
-        echo 'iface default inet static' > /etc/network/interfaces.d/static
78
-        echo "    address ${LOCAL_NETWORK_STATIC_IP_ADDRESS}" >> /etc/network/interfaces.d/static
79
-        echo '    netmask 255.255.255.0' >> /etc/network/interfaces.d/static
80
-        echo "    gateway ${ROUTER_IP_ADDRESS}" >> /etc/network/interfaces.d/static
77
+        { echo 'iface default inet static';
78
+          echo "    address ${LOCAL_NETWORK_STATIC_IP_ADDRESS}";
79
+          echo '    netmask 255.255.255.0';
80
+          echo "    gateway ${ROUTER_IP_ADDRESS}"; } > /etc/network/interfaces.d/static
81 81
     fi
82 82
 }
83 83
 
@@ -98,14 +98,14 @@ function setup_wifi_atheros {
98 98
     else
99 99
         atheros_drivers_file=$(pwd)/$atheros_drivers_file
100 100
     fi
101
-    dpkg -i $atheros_drivers_file
101
+    dpkg -i "$atheros_drivers_file"
102 102
     reset_usb_devices
103 103
     update_wifi_adaptors
104
-    if [ $IFACE ]; then
105
-        wpa_action ${IFACE} stop
106
-        wpa_cli -i ${IFACE} terminate
104
+    if [ "$IFACE" ]; then
105
+        wpa_action "${IFACE}" stop
106
+        wpa_cli -i "${IFACE}" terminate
107 107
         #ifconfig $IFACE up
108
-        ifup $IFACE
108
+        ifup "$IFACE"
109 109
     fi
110 110
 }
111 111
 
@@ -129,8 +129,8 @@ function setup_wifi {
129 129
         HOTSPOT='yes'
130 130
     fi
131 131
 
132
-    if [ -f $WIFI_NETWORKS_FILE ]; then
133
-        ${PROJECT_NAME}-wifi --networks $WIFI_NETWORKS_FILE
132
+    if [ -f "$WIFI_NETWORKS_FILE" ]; then
133
+        "${PROJECT_NAME}-wifi" --networks "$WIFI_NETWORKS_FILE"
134 134
         mark_complete "${FUNCNAME[0]}"
135 135
         return
136 136
     fi
@@ -144,9 +144,9 @@ function setup_wifi {
144 144
             echo $'Wifi passphrase was too short'
145 145
             return
146 146
         fi
147
-        ${PROJECT_NAME}-wifi -s $WIFI_SSID -t $WIFI_TYPE -p $WIFI_PASSPHRASE --hotspot $HOTSPOT --networks $WIFI_NETWORKS_FILE
147
+        "${PROJECT_NAME}-wifi" -s "$WIFI_SSID" -t "$WIFI_TYPE" -p "$WIFI_PASSPHRASE" --hotspot "$HOTSPOT" --networks "$WIFI_NETWORKS_FILE"
148 148
     else
149
-        ${PROJECT_NAME}-wifi -s $WIFI_SSID -t $WIFI_TYPE --hotspot $HOTSPOT --networks $WIFI_NETWORKS_FILE
149
+        "${PROJECT_NAME}-wifi" -s "$WIFI_SSID" -t "$WIFI_TYPE" --hotspot "$HOTSPOT" --networks "$WIFI_NETWORKS_FILE"
150 150
     fi
151 151
     mark_completed "${FUNCNAME[0]}"
152 152
 }
@@ -156,13 +156,13 @@ function install_atheros_wifi {
156 156
     if [[ $(is_completed "${FUNCNAME[0]}") == "1" ]]; then
157 157
         return
158 158
     fi
159
-    if [ $INSTALLING_ON_BBB != "yes" ]; then
159
+    if [ "$INSTALLING_ON_BBB" != "yes" ]; then
160 160
         return
161 161
     fi
162 162
     if [[ $ENABLE_BATMAN != "yes" ]]; then
163 163
         return
164 164
     fi
165
-    if [ -d $INSTALL_DIR/open-ath9k-htc-firmware ]; then
165
+    if [ -d "$INSTALL_DIR/open-ath9k-htc-firmware" ]; then
166 166
         return
167 167
     fi
168 168
     # have drivers already been installed ?
@@ -170,32 +170,28 @@ function install_atheros_wifi {
170 170
         return
171 171
     fi
172 172
     apt-get -yq install build-essential cmake git m4 texinfo
173
-    if [ ! -d $INSTALL_DIR ]; then
174
-        mkdir -p $INSTALL_DIR
173
+    if [ ! -d "$INSTALL_DIR" ]; then
174
+        mkdir -p "$INSTALL_DIR"
175 175
     fi
176
-    cd $INSTALL_DIR
177
-    if [ ! -d $INSTALL_DIR/open-ath9k-htc-firmware ]; then
176
+    cd "$INSTALL_DIR" || exit 24678246
177
+    if [ ! -d "$INSTALL_DIR/open-ath9k-htc-firmware" ]; then
178 178
         function_check git_clone
179
-        git_clone $ATHEROS_WIFI_REPO $INSTALL_DIR/open-ath9k-htc-firmware
180
-        if [ ! "$?" = "0" ]; then
181
-            rm -rf $INSTALL_DIR/open-ath9k-htc-firmware
179
+        if ! git_clone "$ATHEROS_WIFI_REPO" "$INSTALL_DIR/open-ath9k-htc-firmware"; then
180
+            rm -rf "$INSTALL_DIR/open-ath9k-htc-firmware"
182 181
             exit 74283
183 182
         fi
184 183
     fi
185
-    cd $INSTALL_DIR/open-ath9k-htc-firmware
184
+    cd "$INSTALL_DIR/open-ath9k-htc-firmware" || exit 24682468
186 185
     git checkout 1.4.0
187
-    make toolchain
188
-    if [ ! "$?" = "0" ]; then
189
-        rm -rf $INSTALL_DIR/open-ath9k-htc-firmware
186
+    if ! make toolchain; then
187
+        rm -rf "$INSTALL_DIR/open-ath9k-htc-firmware"
190 188
         exit 24820
191 189
     fi
192
-    make firmware
193
-    if [ ! "$?" = "0" ]; then
194
-        rm -rf $INSTALL_DIR/open-ath9k-htc-firmware
190
+    if ! make firmware; then
191
+        rm -rf "$INSTALL_DIR/open-ath9k-htc-firmware"
195 192
         exit 63412
196 193
     fi
197
-    cp target_firmware/*.fw /lib/firmware/
198
-    if [ ! "$?" = "0" ]; then
194
+    if ! cp target_firmware/*.fw /lib/firmware/; then
199 195
         exit 74681
200 196
     fi
201 197
     mark_completed "${FUNCNAME[0]}"
@@ -206,7 +202,7 @@ function update_wifi_adaptors {
206 202
     IFACE_SECONDARY=
207 203
 
208 204
     for i in $(seq 10 -1 0); do
209
-        ifdown --force wlan${i} 2> /dev/null
205
+        ifdown --force "wlan${i}" 2> /dev/null
210 206
     done
211 207
 
212 208
     for i in $(seq 10 -1 0); do
@@ -226,7 +222,7 @@ function wifi_get_psk {
226 222
     passphrase=$2
227 223
 
228 224
     psk=$(wpa_passphrase "$ssid" "$passphrase" | grep 'psk=' | sed -n 2p | awk -F '=' '{print $2}')
229
-    echo $psk
225
+    echo "$psk"
230 226
 }
231 227
 
232 228
 function hotspot_off {
@@ -274,34 +270,34 @@ function hotspot_on {
274 270
 
275 271
     sed -i 's|#DAEMON_CONF=.*|DAEMON_CONF="/etc/hostapd/hostapd.conf"|g' /etc/default/hostapd
276 272
 
277
-    echo '### Wireless network name ###' > /etc/hostapd/hostapd.conf
278
-    echo "interface=$WIFI_INTERFACE" >> /etc/hostapd/hostapd.conf
279
-    echo '' >> /etc/hostapd/hostapd.conf
280
-    echo '### Set your bridge name ###' >> /etc/hostapd/hostapd.conf
281
-    echo 'bridge=br0' >> /etc/hostapd/hostapd.conf
282
-    echo '' >> /etc/hostapd/hostapd.conf
283
-    echo 'driver=nl80211' >> /etc/hostapd/hostapd.conf
284
-    echo "country_code=UK" >> /etc/hostapd/hostapd.conf
285
-    echo "ssid=$WIFI_SSID" >> /etc/hostapd/hostapd.conf
286
-    echo 'hw_mode=g' >> /etc/hostapd/hostapd.conf
287
-    echo 'channel=6' >> /etc/hostapd/hostapd.conf
288
-    echo 'wpa=2' >> /etc/hostapd/hostapd.conf
289
-    echo "wpa_passphrase=$WIFI_PASSPHRASE" >> /etc/hostapd/hostapd.conf
290
-    echo '' >> /etc/hostapd/hostapd.conf
291
-    echo '## Key management algorithms ##' >> /etc/hostapd/hostapd.conf
292
-    echo 'wpa_key_mgmt=WPA-PSK' >> /etc/hostapd/hostapd.conf
293
-    echo '' >> /etc/hostapd/hostapd.conf
294
-    echo '## Set cipher suites (encryption algorithms) ##' >> /etc/hostapd/hostapd.conf
295
-    echo '## TKIP = Temporal Key Integrity Protocol' >> /etc/hostapd/hostapd.conf
296
-    echo '## CCMP = AES in Counter mode with CBC-MAC' >> /etc/hostapd/hostapd.conf
297
-    echo 'wpa_pairwise=TKIP' >> /etc/hostapd/hostapd.conf
298
-    echo 'rsn_pairwise=CCMP' >> /etc/hostapd/hostapd.conf
299
-    echo '' >> /etc/hostapd/hostapd.conf
300
-    echo '## Shared Key Authentication ##'
301
-    echo 'auth_algs=1' >> /etc/hostapd/hostapd.conf
302
-    echo '' >> /etc/hostapd/hostapd.conf
303
-    echo '## Accept all MAC address ###' >> /etc/hostapd/hostapd.conf
304
-    echo 'macaddr_acl=0' >> /etc/hostapd/hostapd.conf
273
+    { echo '### Wireless network name ###';
274
+      echo "interface=$WIFI_INTERFACE";
275
+      echo '';
276
+      echo '### Set your bridge name ###';
277
+      echo 'bridge=br0';
278
+      echo '';
279
+      echo 'driver=nl80211';
280
+      echo "country_code=UK";
281
+      echo "ssid=$WIFI_SSID";
282
+      echo 'hw_mode=g';
283
+      echo 'channel=6';
284
+      echo 'wpa=2';
285
+      echo "wpa_passphrase=$WIFI_PASSPHRASE";
286
+      echo '';
287
+      echo '## Key management algorithms ##';
288
+      echo 'wpa_key_mgmt=WPA-PSK';
289
+      echo '';
290
+      echo '## Set cipher suites (encryption algorithms) ##';
291
+      echo '## TKIP = Temporal Key Integrity Protocol';
292
+      echo '## CCMP = AES in Counter mode with CBC-MAC';
293
+      echo 'wpa_pairwise=TKIP';
294
+      echo 'rsn_pairwise=CCMP';
295
+      echo '';
296
+      echo '## Shared Key Authentication ##'
297
+      echo 'auth_algs=1';
298
+      echo '';
299
+      echo '## Accept all MAC address ###';
300
+      echo 'macaddr_acl=0'; } > /etc/hostapd/hostapd.conf
305 301
 
306 302
     if [ ! -f /etc/network/interfaces_original_static ]; then
307 303
         if [ -f /etc/network/interfaces.d/static ]; then
@@ -365,7 +361,7 @@ function wifi_wpa2_psk {
365 361
     echo "  wpa-roam $WIFI_CONFIG" >> /etc/network/interfaces.d/wifi
366 362
     wifi_static_network_interface
367 363
 
368
-    wpa_passphrase "$ssid" "$passphrase" > $WIFI_CONFIG
364
+    wpa_passphrase "$ssid" "$passphrase" > "$WIFI_CONFIG"
369 365
 
370 366
     systemctl restart network-manager
371 367
     ifup $WIFI_INTERFACE
@@ -385,24 +381,23 @@ function wifi_none {
385 381
 
386 382
     wifi_static_network_interface
387 383
 
388
-    echo 'ctrl_interface=/run/wpa_supplicant' > $WIFI_CONFIG
389
-    echo 'update_config=1' >> $WIFI_CONFIG
390
-    echo 'eapol_version=1' >> $WIFI_CONFIG
391
-    echo '' >> $WIFI_CONFIG
392
-
393
-    echo 'network={' >> $WIFI_CONFIG
384
+    { echo 'ctrl_interface=/run/wpa_supplicant';
385
+      echo 'update_config=1';
386
+      echo 'eapol_version=1';
387
+      echo '';
388
+      echo 'network={'; } > "$WIFI_CONFIG"
394 389
     if [[ "${ssid}" != $'any' && "${ssid}" != $'all' && "${ssid}" != $'open' ]]; then
395
-        echo "  ssid=\"${ssid}\"" >> $WIFI_CONFIG
390
+        echo "  ssid=\"${ssid}\"" >> "$WIFI_CONFIG"
396 391
     fi
397
-    echo '  key_mgmt=NONE' >> $WIFI_CONFIG
398
-    echo '}' >> $WIFI_CONFIG
392
+    echo '  key_mgmt=NONE' >> "$WIFI_CONFIG"
393
+    echo '}' >> "$WIFI_CONFIG"
399 394
 
400 395
     systemctl restart network-manager
401 396
     ifup $WIFI_INTERFACE
402 397
 }
403 398
 
404 399
 function networks_from_file {
405
-    if [ ! -f $WIFI_NETWORKS_FILE ]; then
400
+    if [ ! -f "$WIFI_NETWORKS_FILE" ]; then
406 401
         exit 4
407 402
     fi
408 403
 
@@ -416,21 +411,21 @@ function networks_from_file {
416 411
     echo 'allow-hotplug eth0' > /etc/network/interfaces.d/static
417 412
     echo 'iface eth0 inet dhcp' >> /etc/network/interfaces.d/static
418 413
 
419
-    echo "allow-hotplug ${WIFI_INTERFACE}" >> /etc/network/interfaces.d/wifi
420
-    echo "iface ${WIFI_INTERFACE} inet manual" >> /etc/network/interfaces.d/wifi
421
-    echo "  wpa-roam $WIFI_CONFIG" >> /etc/network/interfaces.d/wifi
414
+    { echo "allow-hotplug ${WIFI_INTERFACE}";
415
+      echo "iface ${WIFI_INTERFACE} inet manual";
416
+      echo "  wpa-roam $WIFI_CONFIG"; } > /etc/network/interfaces.d/wifi
422 417
 
423 418
     wifi_static_network_interface
424 419
 
425 420
     # remove wpa_supplicant.conf if it exists
426
-    if [ -f $WIFI_CONFIG ]; then
427
-        rm -f $WIFI_CONFIG
421
+    if [ -f "$WIFI_CONFIG" ]; then
422
+        rm -f "$WIFI_CONFIG"
428 423
     fi
429 424
 
430
-    echo 'ctrl_interface=/run/wpa_supplicant' > $WIFI_CONFIG
431
-    echo 'update_config=1' >> $WIFI_CONFIG
432
-    echo 'eapol_version=1' >> $WIFI_CONFIG
433
-    echo '' >> $WIFI_CONFIG
425
+    { echo 'ctrl_interface=/run/wpa_supplicant';
426
+      echo 'update_config=1';
427
+      echo 'eapol_version=1';
428
+      echo ''; } > "$WIFI_CONFIG"
434 429
 
435 430
     ctr=0
436 431
     while read -r line
@@ -443,19 +438,19 @@ function networks_from_file {
443 438
                 if [ $ctr -eq 1 ]; then
444 439
                     WIFI_TYPE="$line"
445 440
                     if [[ $WIFI_TYPE == $'none' || $WIFI_TYPE == $'open' ]]; then
446
-                        echo 'network={' >> $WIFI_CONFIG
441
+                        echo 'network={' >> "$WIFI_CONFIG"
447 442
                         if [[ "${WIFI_SSID}" != $'any' && "${WIFI_SSID}" != $'all' && "${WIFI_SSID}" != $'open' ]]; then
448
-                            echo "  ssid=\"${WIFI_SSID}\"" >> $WIFI_CONFIG
443
+                            echo "  ssid=\"${WIFI_SSID}\"" >> "$WIFI_CONFIG"
449 444
                         fi
450
-                        echo '  key_mgmt=NONE' >> $WIFI_CONFIG
451
-                        echo '}' >> $WIFI_CONFIG
445
+                        echo '  key_mgmt=NONE' >> "$WIFI_CONFIG"
446
+                        echo '}' >> "$WIFI_CONFIG"
452 447
                         ctr=0
453 448
                         continue
454 449
                     fi
455 450
                 fi
456 451
                 if [ $ctr -eq 2 ]; then
457 452
                     WIFI_PASSPHRASE="$line"
458
-                    wpa_passphrase "$WIFI_SSID" "$WIFI_PASSPHRASE" >> $WIFI_CONFIG
453
+                    wpa_passphrase "$WIFI_SSID" "$WIFI_PASSPHRASE" >> "$WIFI_CONFIG"
459 454
                     ctr=0
460 455
                     continue
461 456
                 fi
@@ -463,7 +458,7 @@ function networks_from_file {
463 458
                 ctr=$((ctr + 1))
464 459
             fi
465 460
         fi
466
-    done < $WIFI_NETWORKS_FILE
461
+    done < "$WIFI_NETWORKS_FILE"
467 462
 
468 463
     systemctl restart network-manager
469 464
     #ifconfig ${WIFI_INTERFACE} up
@@ -471,27 +466,27 @@ function networks_from_file {
471 466
 }
472 467
 
473 468
 function wifi_networks_file_header {
474
-    echo $'# Add wifi networks as follows:' > $WIFI_NETWORKS_FILE
475
-    echo '#' >> $WIFI_NETWORKS_FILE
476
-    echo $'# MySSID' >> $WIFI_NETWORKS_FILE
477
-    echo $'# wpa2-psk' >> $WIFI_NETWORKS_FILE
478
-    echo $'# myWifiPassphrase' >> $WIFI_NETWORKS_FILE
479
-    echo '#' >> $WIFI_NETWORKS_FILE
480
-    echo $'# AnotherSSID' >> $WIFI_NETWORKS_FILE
481
-    echo $'# none' >> $WIFI_NETWORKS_FILE
482
-    echo '#' >> $WIFI_NETWORKS_FILE
469
+    { echo $'# Add wifi networks as follows:';
470
+      echo '#';
471
+      echo $'# MySSID';
472
+      echo $'# wpa2-psk';
473
+      echo $'# myWifiPassphrase';
474
+      echo '#';
475
+      echo $'# AnotherSSID';
476
+      echo $'# none';
477
+      echo '#'; } > "$WIFI_NETWORKS_FILE"
483 478
 }
484 479
 
485 480
 function create_networks_interactive {
486 481
     remove_config_param "WIFI_INTERFACE"
487 482
     update_wifi_adaptors
488
-    if [ ! $IFACE ]; then
483
+    if [ ! "$IFACE" ]; then
489 484
         # Don't try to configure wifi if there are no adaptors
490 485
         return
491 486
     fi
492 487
 
493
-    if [ -f $WIFI_NETWORKS_FILE ]; then
494
-        rm $WIFI_NETWORKS_FILE
488
+    if [ -f "$WIFI_NETWORKS_FILE" ]; then
489
+        rm "$WIFI_NETWORKS_FILE"
495 490
     fi
496 491
 
497 492
     # By default connect to any open wifi
@@ -503,11 +498,10 @@ function create_networks_interactive {
503 498
     wifi_settings_defined=
504 499
     while [ ! $wifi_networks_done ]
505 500
     do
506
-        data=$(tempfile 2>/dev/null)
507
-        trap "rm -f $data" 0 1 2 5 15
508
-        wifistr=$"\nTo use this system via wifi (eg. USB dongle) enter the details below, otherwise just select Ok:"
501
+        data=$(mktemp 2>/dev/null)
502
+        wifistr=$"\\nTo use this system via wifi (eg. USB dongle) enter the details below, otherwise just select Ok:"
509 503
         if [ -f /root/.wifi-only ]; then
510
-            wifistr=$"\nEnter your wifi login details below."
504
+            wifistr=$"\\nEnter your wifi login details below."
511 505
         fi
512 506
         dialog --backtitle $"Freedombone Configuration" \
513 507
                --title $"Wifi Settings ${wifi_ctr}" \
@@ -515,15 +509,18 @@ function create_networks_interactive {
515 509
                $"SSID (can be 'any'):" 1 1 "$WIFI_SSID" 1 24 30 30 \
516 510
                $"Type (open/wpa2-psk):" 2 1 "$WIFI_TYPE" 2 24 10 10 \
517 511
                $"Passphrase:" 3 1 "$WIFI_PASSPHRASE" 3 24 50 50 \
518
-               2> $data
512
+               2> "$data"
519 513
         sel=$?
520 514
         case $sel in
521
-            1) return;;
522
-            255) return;;
515
+            1) rm -f "$data"
516
+               return;;
517
+            255) rm -f "$data"
518
+                 return;;
523 519
         esac
524
-        WIFI_SSID=$(cat $data | sed -n 1p)
525
-        WIFI_TYPE=$(cat $data | sed -n 2p)
526
-        WIFI_PASSPHRASE=$(cat $data | sed -n 3p)
520
+        WIFI_SSID=$(sed -n 1p < "$data")
521
+        WIFI_TYPE=$(sed -n 2p < "$data")
522
+        WIFI_PASSPHRASE=$(sed -n 3p < "$data")
523
+        rm -f "$data"
527 524
 
528 525
         # If the wifi-only indicator is present then wifi details must
529 526
         # be specified, otherwise they're optional
@@ -539,16 +536,16 @@ function create_networks_interactive {
539 536
             fi
540 537
         fi
541 538
 
542
-        if [ ! -f $WIFI_NETWORKS_FILE ]; then
539
+        if [ ! -f "$WIFI_NETWORKS_FILE" ]; then
543 540
             wifi_networks_file_header
544 541
         fi
545 542
 
546 543
         # update the wifi networks file
547
-        echo '' >> $WIFI_NETWORKS_FILE
548
-        echo "$WIFI_SSID" >> $WIFI_NETWORKS_FILE
549
-        echo "$WIFI_TYPE" >> $WIFI_NETWORKS_FILE
544
+        { echo '';
545
+          echo "$WIFI_SSID";
546
+          echo "$WIFI_TYPE"; } >> "$WIFI_NETWORKS_FILE"
550 547
         if [ ${#WIFI_PASSPHRASE} -gt 1 ]; then
551
-            echo "$WIFI_PASSPHRASE" >> $WIFI_NETWORKS_FILE
548
+            echo "$WIFI_PASSPHRASE" >> "$WIFI_NETWORKS_FILE"
552 549
         fi
553 550
 
554 551
         if [ ${#WIFI_SSID} -gt 1 ]; then
@@ -626,28 +623,28 @@ function remove_wifi_startup_script {
626 623
         systemctl disable wifistart
627 624
         rm $systemd_file
628 625
     fi
629
-    if [ -f $HOME/${PROJECT_NAME}-wifi.cfg ]; then
630
-        rm $HOME/${PROJECT_NAME}-wifi.cfg
626
+    if [ -f "$HOME/${PROJECT_NAME}-wifi.cfg" ]; then
627
+        rm "$HOME/${PROJECT_NAME}-wifi.cfg"
631 628
     fi
632 629
 }
633 630
 
634 631
 function create_wifi_startup_script {
635 632
     systemd_file=/etc/systemd/system/wifistart.service
636
-    echo '[Unit]' > $systemd_file
637
-    echo 'Description=WifiStartup (Start wifi networking)' >> $systemd_file
638
-    echo 'After=syslog.target' >> $systemd_file
639
-    echo 'After=network.target' >> $systemd_file
640
-    echo 'After=remote-fs.target' >> $systemd_file
641
-    echo '' >> $systemd_file
642
-    echo '[Service]' >> $systemd_file
643
-    echo 'Type=simple' >> $systemd_file
644
-    echo 'User=root' >> $systemd_file
645
-    echo 'Group=root' >> $systemd_file
646
-    echo 'WorkingDirectory=/root' >> $systemd_file
647
-    echo "ExecStart=/usr/local/bin/${PROJECT_NAME}-wifi --wait 5 2> /dev/null" >> $systemd_file
648
-    echo '' >> $systemd_file
649
-    echo '[Install]' >> $systemd_file
650
-    echo 'WantedBy=multi-user.target' >> $systemd_file
633
+    { echo '[Unit]';
634
+      echo 'Description=WifiStartup (Start wifi networking)';
635
+      echo 'After=syslog.target';
636
+      echo 'After=network.target';
637
+      echo 'After=remote-fs.target';
638
+      echo '';
639
+      echo '[Service]';
640
+      echo 'Type=simple';
641
+      echo 'User=root';
642
+      echo 'Group=root';
643
+      echo 'WorkingDirectory=/root';
644
+      echo "ExecStart=/usr/local/bin/${PROJECT_NAME}-wifi --wait 5 2> /dev/null";
645
+      echo '';
646
+      echo '[Install]';
647
+      echo 'WantedBy=multi-user.target'; } > $systemd_file
651 648
 
652 649
     systemctl enable wifistart
653 650
     systemctl daemon-reload