-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathpistar-upgrade
executable file
·1628 lines (1477 loc) · 69.8 KB
/
pistar-upgrade
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#
##############################################################################
# #
# Pi-Star Auto Upgrade Tool #
# #
# Version 1.1, Code, Design and Development by Andy Taylor (MW0MWZ). #
# #
# Make it simple to upgrade to the current version of Pi-Star. #
# #
##############################################################################
#
if [ "$(id -u)" != "0" ]; then
echo -e "You need to be root to run this command...\n"
exit 1
fi
exec 200>/var/lock/pistar-upgrade.lock || exit 1
if ! flock -n 200 ; then
echo -e "Another instance is already running...\n"
exit 1
fi
main_function() {
# Get the current Modem
if [ -f /etc/dstar-radio.mmdvmhost ]; then
pistarModem=$(awk -F "=" '/Hardware/ {print $2}' /etc/dstar-radio.mmdvmhost)
elif [ -f /etc/dstar-radio.dstarrepeater ]; then
pistarModem=$(awk -F "=" '/Hardware/ {print $2}' /etc/dstar-radio.dstarrepeater)
else
pistarModem=Unknown
fi
# Get the Pi-Star Version Info
pistarCurVersion=$(awk -F "= " '/Version/ {print $2}' /etc/pistar-release)
# Get the hardware type, this may be important later (RPi | NanoPi | OdroidXU4)
pistarHardware=$(awk -F "= " '/Hardware/ {print $2}' /etc/pistar-release)
# Make the disk writable
if [ -d /boot/firmware ]; then
(sudo mount -o remount,rw / 2>/dev/null ; sudo mount -o remount,rw /boot/firmware 2>/dev/null)
else
mount -o remount,rw /boot
mount -o remount,rw /
fi
echo "Detected Pi-Star ${pistarCurVersion} running on ${pistarHardware} hardware, attached to ${pistarModem} modem..."
case ${pistarCurVersion} in
3.4.1)
if [ ! -z "${pistarHardware}" ]; then
Message="Upgraded from ${pistarCurVersion} to 3.4.2..."
echo "Installing extra software..."
apt-get update
apt-get install -y stm32flash
echo "Cleaning up unused files..."
rm -f /usr/local/etc/config_clean.zip
echo "Bumping the version information..."
sed -i 's/3.4.1/3.4.2/g' /etc/pistar-release
sed -i 's/3.4.1/3.4.2/g' /etc/motd
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.1 are not supported..."
fi
;;
3.4.2)
if [ ! -z "${pistarHardware}" ]; then
Message="Upgraded from ${pistarCurVersion} to 3.4.3..."
sed -i 's/3.4.2/3.4.3/g' /etc/pistar-release
sed -i 's/3.4.2/3.4.3/g' /etc/motd
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.2 are not supported..."
fi
;;
3.4.3)
# Check to see if the USB Max Current setting is in place or not...
if grep -Fxq "max_usb_current=1" /boot/config.txt
then
# It's already there, just version bump
if [ ! -z "${pistarHardware}" ]; then
Message="Upgraded from ${pistarCurVersion} to 3.4.4..."
sed -i 's/3.4.3/3.4.4/g' /etc/pistar-release
sed -i 's/3.4.3/3.4.4/g' /etc/motd
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.3 are not supported..."
fi
else
# Add the config lines and then version bump
echo "Updating boot config to add high current USB support"
echo -e "\n# Increase USB Current\nmax_usb_current=1" >> /boot/config.txt
if [ ! -z "${pistarHardware}" ]; then
Message="Upgraded from ${pistarCurVersion} to 3.4.4..."
sed -i 's/3.4.3/3.4.4/g' /etc/pistar-release
sed -i 's/3.4.3/3.4.4/g' /etc/motd
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.3 are not supported..."
fi
fi
;;
3.4.4)
if [ ! -z "${pistarHardware}" ]; then
Message="Upgraded from ${pistarCurVersion} to 3.4.5..."
sed -i 's/3.4.4/3.4.5/g' /etc/pistar-release
sed -i 's/3.4.4/3.4.5/g' /etc/motd
echo "Installing Shell in a Box..."
apt-get update
apt-get install -y shellinabox
echo "Configuring Shell in a Box..."
sed -i '/SHELLINABOX_PORT=/c SHELLINABOX_PORT=2222' /etc/default/shellinabox
sed -i '/SHELLINABOX_ARGS=/c SHELLINABOX_ARGS="--no-beep --disable-ssl-menu --disable-ssl --css=/etc/shellinabox/options-enabled/00_White\\ On\\ Black.css"' /etc/default/shellinabox
rm -rf /etc/shellinabox/options-enabled/00+Black\ on\ White.css
rm -rf /etc/shellinabox/options-enabled/01_Monochrome.css
systemctl enable shellinabox
systemctl start shellinabox
systemctl restart shellinabox
echo "Updating firewall..."
/usr/local/sbin/pistar-firewall > /dev/null 2>&1
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.4 are not supported..."
fi
;;
3.4.5)
if [ ! -z "${pistarHardware}" ]; then
sed -i 's/3.4.5/3.4.6/g' /etc/pistar-release
sed -i 's/3.4.5/3.4.6/g' /etc/motd
sed -i '13d;17d' /etc/motd
sed -i '2,9d' /etc/motd
sed -i '2i║ ║' /etc/motd
sed -i '3i║ ██████╗ ██╗ ███████╗████████╗ █████╗ ██████╗ ║' /etc/motd
sed -i '4i║ ██╔══██╗██║ ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗ ║' /etc/motd
sed -i '5i║ ██████╔╝██║█████╗███████╗ ██║ ███████║██████╔╝ ║' /etc/motd
sed -i '6i║ ██╔═══╝ ██║╚════╝╚════██║ ██║ ██╔══██║██╔══██╗ ║' /etc/motd
sed -i '7i║ ██║ ██║ ███████║ ██║ ██║ ██║██║ ██║ ║' /etc/motd
sed -i '8i║ ╚═╝ ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ║' /etc/motd
sed -i '9i║ ║' /etc/motd
Message="Upgraded from ${pistarCurVersion} to 3.4.6..."
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.4 are not supported..."
fi
;;
3.4.6)
if [ ! -z "${pistarHardware}" ]; then
sed -i 's/3.4.6/3.4.7/g' /etc/pistar-release
sed -i 's/3.4.6/3.4.7/g' /etc/motd
apt-get update
apt-get install -y libimobiledevice-utils usb-modeswitch usb-modeswitch-data
Message="Upgraded from ${pistarCurVersion} to 3.4.7..."
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.4 are not supported..."
fi
;;
3.4.7)
if [ ! -z "${pistarHardware}" ]; then
sed -i 's/3.4.7/3.4.8/g' /etc/pistar-release
sed -i 's/3.4.7/3.4.8/g' /etc/motd
cd /tmp
curl --fail -O -s http://archive.raspbian.org/raspbian/pool/main/o/openssl1.0/libssl1.0.2_1.0.2l-2+deb9u3_armhf.deb
curl --fail -O -s http://archive.raspbian.org/raspbian/pool/main/s/shellinabox/shellinabox_2.20_armhf.deb
dpkg -i /tmp/libssl1.0.2_1.0.2l-2+deb9u3_armhf.deb
rm /tmp/libssl1.0.2_1.0.2l-2+deb9u3_armhf.deb
if [ -z "$STY" ]; then exec screen -dm -S update dpkg -i /tmp/shellinabox_2.20_armhf.deb "$0"; fi
Message="Upgraded from ${pistarCurVersion} to 3.4.8..."
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.4 are not supported..."
fi
;;
3.4.8)
if [ ! -z "${pistarHardware}" ]; then
sed -i 's/3.4.8/3.4.9/g' /etc/pistar-release
sed -i 's/3.4.8/3.4.9/g' /etc/motd
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 7638D0442B90D010
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8B48AD6246925553
echo 'deb http://httpredir.debian.org/debian jessie-backports main contrib non-free' > /etc/apt/sources.list.d/jessie-backports.list
apt-get update
apt-get -t jessie-backports install usb-modeswitch usb-modeswitch-data
Message="Upgraded from ${pistarCurVersion} to 3.4.9..."
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.4 are not supported..."
fi
;;
3.4.9)
if [ ! -z "${pistarHardware}" ]; then
sed -i 's/3.4.9/3.4.10/g' /etc/pistar-release
sed -i '10,1d' /etc/motd
sed -i '10i╚═══════════════════════════════════════════════════════════════v3.4.10═╝' /etc/motd
# Add the Colby Ross Random Seed fix
rm -rf /var/lib/systemd/random-seed
ln -s /tmp/random-seed /var/lib/systemd/random-seed
# Add the Unit file(s)
echo '[Unit]' > /lib/systemd/system/ysf2dmr.service
echo 'Description=Pi-Star YSF2DMR Service' >> /lib/systemd/system/ysf2dmr.service
echo 'After=syslog.target network.target mmdvmhost.timer' >> /lib/systemd/system/ysf2dmr.service
echo '' >> /lib/systemd/system/ysf2dmr.service
echo '[Service]' >> /lib/systemd/system/ysf2dmr.service
echo 'Type=forking' >> /lib/systemd/system/ysf2dmr.service
echo 'ExecStart=/usr/local/sbin/ysf2dmr.service start' >> /lib/systemd/system/ysf2dmr.service
echo 'ExecStop=/usr/local/sbin/ysf2dmr.service stop' >> /lib/systemd/system/ysf2dmr.service
echo 'ExecReload=/usr/local/sbin/ysf2dmr.service restart' >> /lib/systemd/system/ysf2dmr.service
echo '' >> /lib/systemd/system/ysf2dmr.service
echo '[Install]' >> /lib/systemd/system/ysf2dmr.service
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/ysf2dmr.service
echo '[Timer]' > /lib/systemd/system/ysf2dmr.timer
echo 'OnStartupSec=20' >> /lib/systemd/system/ysf2dmr.timer
echo '' >> /lib/systemd/system/ysf2dmr.timer
echo '[Install]' >> /lib/systemd/system/ysf2dmr.timer
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/ysf2dmr.timer
# Restart SystemD and add the service
systemctl daemon-reload
systemctl enable ysf2dmr.timer
Message="Upgraded from ${pistarCurVersion} to 3.4.10..."
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.4 are not supported..."
fi
;;
3.4.10)
if [ ! -z "${pistarHardware}" ]; then
sed -i 's/3.4.10/3.4.11/g' /etc/pistar-release
sed -i 's/3.4.10/3.4.11/g' /etc/motd
# Install the tools
apt-get update
apt-get install -y hostapd dnsmasq
systemctl daemon-reload
systemctl disable hostapd
systemctl disable dnsmasq
# Setup the config(s)
echo 'DAEMON_CONF="/etc/hostapd/hostapd.conf"' >> /etc/default/hostapd
echo 'interface=wlan0_ap' > /etc/hostapd/hostapd.conf
echo 'ssid=Pi-Star' >> /etc/hostapd/hostapd.conf
echo 'hw_mode=g' >> /etc/hostapd/hostapd.conf
echo 'macaddr_acl=0' >> /etc/hostapd/hostapd.conf
echo 'auth_algs=1' >> /etc/hostapd/hostapd.conf
echo 'ignore_broadcast_ssid=0' >> /etc/hostapd/hostapd.conf
echo 'channel=6' >> /etc/hostapd/hostapd.conf
echo 'wpa=2' >> /etc/hostapd/hostapd.conf
echo 'wpa_passphrase=raspberry' >> /etc/hostapd/hostapd.conf
echo 'wpa_key_mgmt=WPA-PSK' >> /etc/hostapd/hostapd.conf
echo 'wpa_pairwise=TKIP' >> /etc/hostapd/hostapd.conf
echo 'rsn_pairwise=CCMP' >> /etc/hostapd/hostapd.conf
echo '' >> /etc/network/interfaces
echo 'iface wlan0_ap inet static' >> /etc/network/interfaces
echo ' hwaddress ether b8:27:eb:00:00:01' >> /etc/network/interfaces
echo ' address 192.168.50.1' >> /etc/network/interfaces
echo ' netmask 255.255.255.0' >> /etc/network/interfaces
echo ' network 192.168.50.0' >> /etc/network/interfaces
echo ' broadcast 192.168.50.255' >> /etc/network/interfaces
echo 'interface=lo,wlan0_ap' > /etc/dnsmasq.conf
echo 'server=208.67.222.123' >> /etc/dnsmasq.conf
echo 'server=208.67.220.123' >> /etc/dnsmasq.conf
echo 'domain-needed' >> /etc/dnsmasq.conf
echo 'bogus-priv' >> /etc/dnsmasq.conf
echo 'dhcp-authoritative' >> /etc/dnsmasq.conf
echo 'dhcp-range=192.168.50.50,192.168.50.99,4h' >> /etc/dnsmasq.conf
echo 'dhcp-option=1,255.255.255.0' >> /etc/dnsmasq.conf
echo 'dhcp-option=3,192.168.50.1' >> /etc/dnsmasq.conf
echo 'dhcp-option=6,192.168.50.1' >> /etc/dnsmasq.conf
# Add the Unit file(s)
echo '[Unit]' > /lib/systemd/system/pistar-ap.service
echo 'Description=Pi-Star HostAPD Service' >> /lib/systemd/system/pistar-ap.service
echo 'After=syslog.target network.target' >> /lib/systemd/system/pistar-ap.service
echo '' >> /lib/systemd/system/pistar-ap.service
echo '[Service]' >> /lib/systemd/system/pistar-ap.service
echo 'Type=notify' >> /lib/systemd/system/pistar-ap.service
echo 'RemainAfterExit=yes' >> /lib/systemd/system/pistar-ap.service
echo 'ExecStart=/usr/local/sbin/pistar-ap.service start' >> /lib/systemd/system/pistar-ap.service
echo 'ExecStop=/usr/local/sbin/pistar-ap.service stop' >> /lib/systemd/system/pistar-ap.service
echo 'ExecReload=/usr/local/sbin/pistar-ap.service restart' >> /lib/systemd/system/pistar-ap.service
echo '' >> /lib/systemd/system/pistar-ap.service
echo '[Install]' >> /lib/systemd/system/pistar-ap.service
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/pistar-ap.service
echo '[Timer]' > /lib/systemd/system/pistar-ap.timer
echo 'OnStartupSec=120' >> /lib/systemd/system/pistar-ap.timer
echo '' >> /lib/systemd/system/pistar-ap.timer
echo '[Install]' >> /lib/systemd/system/pistar-ap.timer
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/pistar-ap.timer
# Restart SystemD and add the service
systemctl daemon-reload
systemctl enable pistar-ap.timer
# Report the update status
Message="Upgraded from ${pistarCurVersion} to 3.4.11..."
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.4 are not supported..."
fi
;;
3.4.11)
if [ ! -z "${pistarHardware}" ]; then
sed -i 's/3.4.11/3.4.12/g' /etc/pistar-release
sed -i 's/3.4.11/3.4.12/g' /etc/motd
# NXDN Gateway Service
echo '[Unit]' > /lib/systemd/system/nxdngateway.service
echo 'Description=NXDN Servce' >> /lib/systemd/system/nxdngateway.service
echo 'After=syslog.target network.target mmdvmhost.timer' >> /lib/systemd/system/nxdngateway.service
echo '' >> /lib/systemd/system/nxdngateway.service
echo '[Service]' >> /lib/systemd/system/nxdngateway.service
echo 'Type=forking' >> /lib/systemd/system/nxdngateway.service
echo 'ExecStart=/usr/local/sbin/nxdngateway.service start' >> /lib/systemd/system/nxdngateway.service
echo 'ExecStop=/usr/local/sbin/nxdngateway.service stop' >> /lib/systemd/system/nxdngateway.service
echo 'ExecReload=/usr/local/sbin/nxdngateway.service restart' >> /lib/systemd/system/nxdngateway.service
echo '' >> /lib/systemd/system/nxdngateway.service
echo '[Install]' >> /lib/systemd/system/nxdngateway.service
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/nxdngateway.service
# NXDN Gateway Timer
echo '[Timer]' > /lib/systemd/system/nxdngateway.timer
echo 'OnStartupSec=20' >> /lib/systemd/system/nxdngateway.timer
echo '' >> /lib/systemd/system/nxdngateway.timer
echo '[Install]' >> /lib/systemd/system/nxdngateway.timer
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/nxdngateway.timer
# NXDN Parrot Service
echo '[Unit]' > /lib/systemd/system/nxdnparrot.service
echo 'Description=NXDN Parrot' >> /lib/systemd/system/nxdnparrot.service
echo 'After=syslog.target network.target nxdngateway.timer' >> /lib/systemd/system/nxdnparrot.service
echo '' >> /lib/systemd/system/nxdnparrot.service
echo '[Service]' >> /lib/systemd/system/nxdnparrot.service
echo 'Type=forking' >> /lib/systemd/system/nxdnparrot.service
echo 'ExecStart=/usr/local/sbin/nxdnparrot.service start' >> /lib/systemd/system/nxdnparrot.service
echo 'ExecStop=/usr/local/sbin/nxdnparrot.service stop' >> /lib/systemd/system/nxdnparrot.service
echo 'ExecReload=/usr/local/sbin/nxdnparrot.service restart' >> /lib/systemd/system/nxdnparrot.service
echo '' >> /lib/systemd/system/nxdnparrot.service
echo '[Install]' >> /lib/systemd/system/nxdnparrot.service
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/nxdnparrot.service
# NXDN Parrot Timer
echo '[Timer]' > /lib/systemd/system/nxdnparrot.timer
echo 'OnStartupSec=25' >> /lib/systemd/system/nxdnparrot.timer
echo '' >> /lib/systemd/system/nxdnparrot.timer
echo '[Install]' >> /lib/systemd/system/nxdnparrot.timer
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/nxdnparrot.timer
# NXDN Gateway Config
echo '[General]' > /etc/nxdngateway
echo 'Callsign=M1ABC' >> /etc/nxdngateway
echo 'RptAddress=127.0.0.1' >> /etc/nxdngateway
echo 'RptPort=14021' >> /etc/nxdngateway
echo 'LocalPort=14020' >> /etc/nxdngateway
echo 'Debug=0' >> /etc/nxdngateway
echo 'Daemon=1' >> /etc/nxdngateway
echo '' >> /etc/nxdngateway
echo '[Voice]' >> /etc/nxdngateway
echo 'Enabled=1' >> /etc/nxdngateway
echo 'Language=en_GB' >> /etc/nxdngateway
echo 'Directory=/usr/local/etc/NXDN_Audio' >> /etc/nxdngateway
echo '' >> /etc/nxdngateway
echo '[Id Lookup]' >> /etc/nxdngateway
echo 'Name=/usr/local/etc/NXDN.csv' >> /etc/nxdngateway
echo 'Time=24' >> /etc/nxdngateway
echo '' >> /etc/nxdngateway
echo '[Log]' >> /etc/nxdngateway
echo 'FilePath=/var/log/pi-star' >> /etc/nxdngateway
echo 'FileRoot=NXDNGateway' >> /etc/nxdngateway
echo '' >> /etc/nxdngateway
echo '[Network]' >> /etc/nxdngateway
echo 'Port=14050' >> /etc/nxdngateway
echo 'HostsFile=/usr/local/etc/NXDNHosts.txt' >> /etc/nxdngateway
echo 'ReloadTime=60' >> /etc/nxdngateway
echo 'ParrotAddress=127.0.0.1' >> /etc/nxdngateway
echo 'ParrotPort=42021' >> /etc/nxdngateway
echo 'NXDN2DMRAddress=127.0.0.1' >> /etc/nxdngateway
echo 'NXDN2DMRPort=42022' >> /etc/nxdngateway
echo 'Startup=65000' >> /etc/nxdngateway
echo 'Debug=0' >> /etc/nxdngateway
# Download the voice files
mkdir -p /usr/local/etc/NXDN_Audio
curl --fail -o /usr/local/etc/NXDN_Audio/de_DE.indx -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/de_DE.indx
curl --fail -o /usr/local/etc/NXDN_Audio/de_DE.nxdn -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/de_DE.nxdn
curl --fail -o /usr/local/etc/NXDN_Audio/dk_DK.indx -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/dk_DK.indx
curl --fail -o /usr/local/etc/NXDN_Audio/dk_DK.nxdn -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/dk_DK.nxdn
curl --fail -o /usr/local/etc/NXDN_Audio/en_GB.indx -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/en_GB.indx
curl --fail -o /usr/local/etc/NXDN_Audio/en_GB.nxdn -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/en_GB.nxdn
curl --fail -o /usr/local/etc/NXDN_Audio/en_US.indx -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/en_US.indx
curl --fail -o /usr/local/etc/NXDN_Audio/en_US.nxdn -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/en_US.nxdn
curl --fail -o /usr/local/etc/NXDN_Audio/es_ES.indx -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/es_ES.indx
curl --fail -o /usr/local/etc/NXDN_Audio/es_ES.nxdn -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/es_ES.nxdn
curl --fail -o /usr/local/etc/NXDN_Audio/fr_FR.indx -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/fr_FR.indx
curl --fail -o /usr/local/etc/NXDN_Audio/fr_FR.nxdn -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/fr_FR.nxdn
curl --fail -o /usr/local/etc/NXDN_Audio/it_IT.indx -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/it_IT.indx
curl --fail -o /usr/local/etc/NXDN_Audio/it_IT.nxdn -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/it_IT.nxdn
curl --fail -o /usr/local/etc/NXDN_Audio/no_NO.indx -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/no_NO.indx
curl --fail -o /usr/local/etc/NXDN_Audio/no_NO.nxdn -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/no_NO.nxdn
curl --fail -o /usr/local/etc/NXDN_Audio/pl_PL.indx -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/pl_PL.indx
curl --fail -o /usr/local/etc/NXDN_Audio/pl_PL.nxdn -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/pl_PL.nxdn
curl --fail -o /usr/local/etc/NXDN_Audio/se_SE.indx -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/se_SE.indx
curl --fail -o /usr/local/etc/NXDN_Audio/se_SE.nxdn -s https://raw.githubusercontent.com/g4klx/NXDNClients/master/NXDNGateway/Audio/se_SE.nxdn
# Update systemd and enable new services
systemctl daemon-reload
systemctl enable nxdngateway.timer
systemctl enable nxdnparrot.timer
Message="Upgraded from ${pistarCurVersion} to 3.4.12..."
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.4 are not supported..."
fi
;;
3.4.12)
if [ ! -z "${pistarHardware}" ]; then
sed -i 's/3.4.12/3.4.13/g' /etc/pistar-release
sed -i 's/3.4.12/3.4.13/g' /etc/motd
# YSF2NXDN Gateway Service
echo '[Unit]' > /lib/systemd/system/ysf2nxdn.service
echo 'Description=Pi-Star YSF2NXDN Service' >> /lib/systemd/system/ysf2nxdn.service
echo 'After=syslog.target network.target mmdvmhost.timer' >> /lib/systemd/system/ysf2nxdn.service
echo '' >> /lib/systemd/system/ysf2nxdn.service
echo '[Service]' >> /lib/systemd/system/ysf2nxdn.service
echo 'Type=forking' >> /lib/systemd/system/ysf2nxdn.service
echo 'ExecStart=/usr/local/sbin/ysf2nxdn.service start' >> /lib/systemd/system/ysf2nxdn.service
echo 'ExecStop=/usr/local/sbin/ysf2nxdn.service stop' >> /lib/systemd/system/ysf2nxdn.service
echo 'ExecReload=/usr/local/sbin/ysf2nxdn.service restart' >> /lib/systemd/system/ysf2nxdn.service
echo '' >> /lib/systemd/system/ysf2nxdn.service
echo '[Install]' >> /lib/systemd/system/ysf2nxdn.service
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/ysf2nxdn.service
# YSF2NXDN Gateway Timer
echo '[Timer]' > /lib/systemd/system/ysf2nxdn.timer
echo 'OnStartupSec=20' >> /lib/systemd/system/ysf2nxdn.timer
echo '' >> /lib/systemd/system/ysf2nxdn.timer
echo '[Install]' >> /lib/systemd/system/ysf2nxdn.timer
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/ysf2nxdn.timer
# YSF2P25 Gateway Service
echo '[Unit]' > /lib/systemd/system/ysf2p25.service
echo 'Description=Pi-Star YSF2P25 Service' >> /lib/systemd/system/ysf2p25.service
echo 'After=syslog.target network.target mmdvmhost.timer' >> /lib/systemd/system/ysf2p25.service
echo '' >> /lib/systemd/system/ysf2p25.service
echo '[Service]' >> /lib/systemd/system/ysf2p25.service
echo 'Type=forking' >> /lib/systemd/system/ysf2p25.service
echo 'ExecStart=/usr/local/sbin/ysf2p25.service start' >> /lib/systemd/system/ysf2p25.service
echo 'ExecStop=/usr/local/sbin/ysf2p25.service stop' >> /lib/systemd/system/ysf2p25.service
echo 'ExecReload=/usr/local/sbin/ysf2p25.service restart' >> /lib/systemd/system/ysf2p25.service
echo '' >> /lib/systemd/system/ysf2p25.service
echo '[Install]' >> /lib/systemd/system/ysf2p25.service
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/ysf2p25.service
# YSF2P25 Gateway Timer
echo '[Timer]' > /lib/systemd/system/ysf2p25.timer
echo 'OnStartupSec=20' >> /lib/systemd/system/ysf2p25.timer
echo '' >> /lib/systemd/system/ysf2p25.timer
echo '[Install]' >> /lib/systemd/system/ysf2p25.timer
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/ysf2p25.timer
# NXDN Parrot Service
echo '[Unit]' > /lib/systemd/system/nxdnparrot.service
echo 'Description=NXDN Parrot' >> /lib/systemd/system/nxdnparrot.service
echo 'After=syslog.target network.target nxdngateway.timer' >> /lib/systemd/system/nxdnparrot.service
echo '' >> /lib/systemd/system/nxdnparrot.service
echo '[Service]' >> /lib/systemd/system/nxdnparrot.service
echo 'Type=forking' >> /lib/systemd/system/nxdnparrot.service
echo 'ExecStart=/usr/local/sbin/nxdnparrot.service start' >> /lib/systemd/system/nxdnparrot.service
echo 'ExecStop=/usr/local/sbin/nxdnparrot.service stop' >> /lib/systemd/system/nxdnparrot.service
echo 'ExecReload=/usr/local/sbin/nxdnparrot.service restart' >> /lib/systemd/system/nxdnparrot.service
echo '' >> /lib/systemd/system/nxdnparrot.service
echo '[Install]' >> /lib/systemd/system/nxdnparrot.service
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/nxdnparrot.service
# NXDN Parrot Timer
echo '[Timer]' > /lib/systemd/system/nxdnparrot.timer
echo 'OnStartupSec=25' >> /lib/systemd/system/nxdnparrot.timer
echo '' >> /lib/systemd/system/nxdnparrot.timer
echo '[Install]' >> /lib/systemd/system/nxdnparrot.timer
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/nxdnparrot.timer
# Download configs
curl --fail -o /etc/ysf2nxdn -s https://raw.githubusercontent.com/juribeparada/YSF2NXDN/master/YSF2NXDN.ini
curl --fail -o /etc/ysf2p25 -s https://raw.githubusercontent.com/juribeparada/YSF2P25/master/YSF2P25.ini
# Update systemd and enable new services
systemctl daemon-reload
systemctl enable ysf2nxdn.timer
systemctl enable ysf2p25.timer
Message="Upgraded from ${pistarCurVersion} to 3.4.13..."
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.4 are not supported..."
fi
;;
3.4.13)
if [ ! -z "${pistarHardware}" ]; then
sed -i 's/3.4.13/3.4.14/g' /etc/pistar-release
sed -i 's/3.4.13/3.4.14/g' /etc/motd
# DMR2YSF Gateway Config
echo '[YSF Network]' > /etc/dmr2ysf
echo 'Callsign=M1ABC' >> /etc/dmr2ysf
echo 'Suffix=ND' >> /etc/dmr2ysf
echo 'GatewayAddress=127.0.0.1' >> /etc/dmr2ysf
echo 'GatewayPort=4200' >> /etc/dmr2ysf
echo 'LocalAddress=127.0.0.1' >> /etc/dmr2ysf
echo 'LocalPort=3200' >> /etc/dmr2ysf
echo 'Daemon=1' >> /etc/dmr2ysf
echo '' >> /etc/dmr2ysf
echo '[DMR Network]' >> /etc/dmr2ysf
echo 'Id=1234567' >> /etc/dmr2ysf
echo 'RptAddress=127.0.0.1' >> /etc/dmr2ysf
echo 'RptPort=62034' >> /etc/dmr2ysf
echo 'LocalAddress=127.0.0.1' >> /etc/dmr2ysf
echo 'LocalPort=62033' >> /etc/dmr2ysf
echo 'Debug=0' >> /etc/dmr2ysf
echo '' >> /etc/dmr2ysf
echo '[DMR Id Lookup]' >> /etc/dmr2ysf
echo 'File=/usr/local/etc/DMRIds.dat' >> /etc/dmr2ysf
echo 'Time=24' >> /etc/dmr2ysf
echo '' >> /etc/dmr2ysf
echo '[Log]' >> /etc/dmr2ysf
echo 'DisplayLevel=0' >> /etc/dmr2ysf
echo 'FileLevel=2' >> /etc/dmr2ysf
echo 'FilePath=/var/log/pi-star' >> /etc/dmr2ysf
echo 'FileRoot=DMR2YSF' >> /etc/dmr2ysf
echo '' >> /etc/dmr2ysf
echo '[Enabled]' >> /etc/dmr2ysf
echo 'Enabled=0' >> /etc/dmr2ysf
# DMR2YSF Gateway Service
echo '[Unit]' > /lib/systemd/system/dmr2ysf.service
echo 'Description=Pi-Star DMR2YSF Service' >> /lib/systemd/system/dmr2ysf.service
echo 'After=syslog.target network.target mmdvmhost.timer' >> /lib/systemd/system/dmr2ysf.service
echo '' >> /lib/systemd/system/dmr2ysf.service
echo '[Service]' >> /lib/systemd/system/dmr2ysf.service
echo 'Type=forking' >> /lib/systemd/system/dmr2ysf.service
echo 'ExecStart=/usr/local/sbin/dmr2ysf.service start' >> /lib/systemd/system/dmr2ysf.service
echo 'ExecStop=/usr/local/sbin/dmr2ysf.service stop' >> /lib/systemd/system/dmr2ysf.service
echo 'ExecReload=/usr/local/sbin/dmr2ysf.service restart' >> /lib/systemd/system/dmr2ysf.service
echo '' >> /lib/systemd/system/dmr2ysf.service
echo '[Install]' >> /lib/systemd/system/dmr2ysf.service
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/dmr2ysf.service
# DMR2YSF Gateway Timer
echo '[Timer]' > /lib/systemd/system/dmr2ysf.timer
echo 'OnStartupSec=20' >> /lib/systemd/system/dmr2ysf.timer
echo '' >> /lib/systemd/system/dmr2ysf.timer
echo '[Install]' >> /lib/systemd/system/dmr2ysf.timer
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/dmr2ysf.timer
# Update systemd and enable new services
systemctl daemon-reload
systemctl enable dmr2ysf.timer
Message="Upgraded from ${pistarCurVersion} to 3.4.14..."
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.4 are not supported..."
fi
;;
3.4.14)
if [ ! -z "${pistarHardware}" ]; then
sed -i 's/3.4.14/3.4.15/g' /etc/pistar-release
sed -i 's/3.4.14/3.4.15/g' /etc/motd
# DMR2NXDN Gateway Config
echo '[NXDN Network]' > /etc/dmr2nxdn
echo 'GatewayAddress=127.0.0.1' >> /etc/dmr2nxdn
echo 'GatewayPort=14020' >> /etc/dmr2nxdn
echo 'LocalAddress=127.0.0.1' >> /etc/dmr2nxdn
echo 'LocalPort=14021' >> /etc/dmr2nxdn
echo 'Daemon=1' >> /etc/dmr2nxdn
echo '' >> /etc/dmr2nxdn
echo '[DMR Network]' >> /etc/dmr2nxdn
echo 'Id=1234567' >> /etc/dmr2nxdn
echo 'RptAddress=127.0.0.1' >> /etc/dmr2nxdn
echo 'RptPort=62036' >> /etc/dmr2nxdn
echo 'LocalAddress=127.0.0.1' >> /etc/dmr2nxdn
echo 'LocalPort=62035' >> /etc/dmr2nxdn
echo 'Debug=0' >> /etc/dmr2nxdn
echo '' >> /etc/dmr2nxdn
echo '[DMR Id Lookup]' >> /etc/dmr2nxdn
echo 'File=/usr/local/etc/DMRIds.dat' >> /etc/dmr2nxdn
echo 'Time=24' >> /etc/dmr2nxdn
echo '' >> /etc/dmr2nxdn
echo '[NXDN Id Lookup]' >> /etc/dmr2nxdn
echo 'File=/usr/local/etc/NXDN.csv' >> /etc/dmr2nxdn
echo 'Time=24' >> /etc/dmr2nxdn
echo '' >> /etc/dmr2nxdn
echo '[Log]' >> /etc/dmr2nxdn
echo 'DisplayLevel=0' >> /etc/dmr2nxdn
echo 'FileLevel=2' >> /etc/dmr2nxdn
echo 'FilePath=/var/log/pi-star' >> /etc/dmr2nxdn
echo 'FileRoot=DMR2NXDN' >> /etc/dmr2nxdn
echo '' >> /etc/dmr2nxdn
echo '[Enabled]' >> /etc/dmr2nxdn
echo 'Enabled=0' >> /etc/dmr2nxdn
# DMR2NXDN Gateway Service
echo '[Unit]' > /lib/systemd/system/dmr2nxdn.service
echo 'Description=Pi-Star DMR2NXDN Service' >> /lib/systemd/system/dmr2nxdn.service
echo 'After=syslog.target network.target mmdvmhost.timer' >> /lib/systemd/system/dmr2nxdn.service
echo '' >> /lib/systemd/system/dmr2nxdn.service
echo '[Service]' >> /lib/systemd/system/dmr2nxdn.service
echo 'Type=forking' >> /lib/systemd/system/dmr2nxdn.service
echo 'ExecStart=/usr/local/sbin/dmr2nxdn.service start' >> /lib/systemd/system/dmr2nxdn.service
echo 'ExecStop=/usr/local/sbin/dmr2nxdn.service stop' >> /lib/systemd/system/dmr2nxdn.service
echo 'ExecReload=/usr/local/sbin/dmr2nxdn.service restart' >> /lib/systemd/system/dmr2nxdn.service
echo '' >> /lib/systemd/system/dmr2nxdn.service
echo '[Install]' >> /lib/systemd/system/dmr2nxdn.service
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/dmr2nxdn.service
# DMR2NXDN Gateway Timer
echo '[Timer]' > /lib/systemd/system/dmr2nxdn.timer
echo 'OnStartupSec=20' >> /lib/systemd/system/dmr2nxdn.timer
echo '' >> /lib/systemd/system/dmr2nxdn.timer
echo '[Install]' >> /lib/systemd/system/dmr2nxdn.timer
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/dmr2nxdn.timer
# Update systemd and enable new services
systemctl daemon-reload
systemctl enable dmr2nxdn.timer
Message="Upgraded from ${pistarCurVersion} to 3.4.15..."
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.4 are not supported..."
fi
;;
3.4.15)
if [ ! -z "${pistarHardware}" ]; then
sed -i 's/3.4.15/3.4.16/g' /etc/pistar-release
sed -i 's/3.4.15/3.4.16/g' /etc/motd
# DAPNet Gateway Service
echo '[Unit]' > /lib/systemd/system/dapnetgateway.service
echo 'Description=Pi-Star DAPNet Gateway Service' >> /lib/systemd/system/dapnetgateway.service
echo 'After=syslog.target network.target mmdvmhost.timer' >> /lib/systemd/system/dapnetgateway.service
echo '' >> /lib/systemd/system/dapnetgateway.service
echo '[Service]' >> /lib/systemd/system/dapnetgateway.service
echo 'Type=forking' >> /lib/systemd/system/dapnetgateway.service
echo 'ExecStart=/usr/local/sbin/dapnetgateway.service start' >> /lib/systemd/system/dapnetgateway.service
echo 'ExecStop=/usr/local/sbin/dapnetgateway.service stop' >> /lib/systemd/system/dapnetgateway.service
echo 'ExecReload=/usr/local/sbin/dapnetgateway.service restart' >> /lib/systemd/system/dapnetgateway.service
echo '' >> /lib/systemd/system/dapnetgateway.service
echo '[Install]' >> /lib/systemd/system/dapnetgateway.service
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/dapnetgateway.service
# DAPNet Gateway Timer
echo '[Timer]' > /lib/systemd/system/dapnetgateway.timer
echo 'OnStartupSec=20' >> /lib/systemd/system/dapnetgateway.timer
echo '' >> /lib/systemd/system/dapnetgateway.timer
echo '[Install]' >> /lib/systemd/system/dapnetgateway.timer
echo 'WantedBy=multi-user.target' >> /lib/systemd/system/dapnetgateway.timer
# Update systemd and enable new services
systemctl daemon-reload
systemctl enable dapnetgateway.timer
Message="Upgraded from ${pistarCurVersion} to 3.4.16..."
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.4 are not supported..."
fi
;;
3.4.16)
if [ ! -z "${pistarHardware}" ]; then
sed -i 's/3.4.16/3.4.17/g' /etc/pistar-release
sed -i 's/3.4.16/3.4.17/g' /etc/motd
# Update all the startup timers
sed -i "/OnStartupSec=/c\\OnStartupSec=20" /lib/systemd/system/pistar-upnp.timer
sed -i "/OnStartupSec=/c\\OnStartupSec=20" /lib/systemd/system/dmrgateway.timer
sed -i "/OnStartupSec=/c\\OnStartupSec=20" /lib/systemd/system/ircddbgateway.timer
sed -i "/OnStartupSec=/c\\OnStartupSec=20" /lib/systemd/system/nxdnparrot.timer
sed -i "/OnStartupSec=/c\\OnStartupSec=20" /lib/systemd/system/p25parrot.timer
sed -i "/OnStartupSec=/c\\OnStartupSec=20" /lib/systemd/system/ysfparrot.timer
# Update systemd and enable new services
systemctl daemon-reload
Message="Upgraded from ${pistarCurVersion} to 3.4.17..."
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.4 are not supported..."
fi
;;
3.4.17)
if [ ! -z "${pistarHardware}" ]; then
sed -i 's/3.4.17/3.4.18/g' /etc/pistar-release
sed -i 's/3.4.17/3.4.18/g' /etc/motd
# Fix up the sources to stop some of the update nags
sed -i 's/mirrordirector/legacy/g' /etc/apt/sources.list
sed -i 's/httpredir/archive/g' /etc/apt/sources.list.d/jessie-backports.list
echo 'Acquire::Check-Valid-Until "0";' > /etc/apt/apt.conf.d/10no-check-valid-until
Message="Upgraded from ${pistarCurVersion} to 3.4.18..."
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.4 are not supported..."
fi
;;
3.4.18)
if [ ! -z "${pistarHardware}" ]; then
sed -i 's/3.4.18/3.4.19/g' /etc/pistar-release
sed -i 's/3.4.18/3.4.19/g' /etc/motd
# Fix up the issues with Lets Encrypt certificate
sed -i '/^mozilla\/DST_Root_CA_X3.crt$/ s/^/!/' /etc/ca-certificates.conf
update-ca-certificates
Message="Upgraded from ${pistarCurVersion} to 3.4.19..."
echo $Message
exec "$0" "$@"
exit 1
else
Message="In-place upgrades from 3.4.4 are not supported..."
fi
;;
3.4.19)
Message="You are already running the latest version..."
;;
4.0.0-Beta)
Message="Please re-image this system with the release version Pi-Star v4.1.x as soon as possible."
;;
4.0.0-RC1)
sed -i 's/4.0.0-RC1/4.0.0-RC2/g' /etc/pistar-release
# Update all the startup timers
sed -i "/OnStartupSec=/c\\OnStartupSec=20" /lib/systemd/system/pistar-upnp.timer
sed -i "/OnStartupSec=/c\\OnStartupSec=20" /lib/systemd/system/dmrgateway.timer
sed -i "/OnStartupSec=/c\\OnStartupSec=20" /lib/systemd/system/ircddbgateway.timer
sed -i "/OnStartupSec=/c\\OnStartupSec=20" /lib/systemd/system/nxdnparrot.timer
sed -i "/OnStartupSec=/c\\OnStartupSec=20" /lib/systemd/system/p25parrot.timer
sed -i "/OnStartupSec=/c\\OnStartupSec=20" /lib/systemd/system/ysfparrot.timer
# Update systemd and enable new services
systemctl daemon-reload
# Fix some broken libs
apt-get update && apt-get install --reinstall libraspberrypi0 libraspberrypi-dev libraspberrypi-bin
# Re-create the MOTD
/usr/local/sbin/pistar-motdgen
Message="Upgraded from ${pistarCurVersion} to 4.0.0-RC2..."
echo $Message
exec "$0" "$@"
exit 1
;;
4.0.0-RC2)
sed -i 's/4.0.0-RC2/4.0.0-RC3/g' /etc/pistar-release
# apt-daily.service
echo '[Unit]' > /etc/systemd/system/apt-daily.service
echo 'Description=Daily apt download activities' >> /etc/systemd/system/apt-daily.service
echo 'Documentation=man:apt(8)' >> /etc/systemd/system/apt-daily.service
echo 'ConditionACPower=true' >> /etc/systemd/system/apt-daily.service
echo 'After=network-online.target' >> /etc/systemd/system/apt-daily.service
echo 'Wants=network-online.target' >> /etc/systemd/system/apt-daily.service
echo '' >> /etc/systemd/system/apt-daily.service
echo '[Service]' >> /etc/systemd/system/apt-daily.service
echo 'Type=oneshot' >> /etc/systemd/system/apt-daily.service
echo 'ExecStartPre=/bin/mount -o remount,rw /' >> /etc/systemd/system/apt-daily.service
echo 'ExecStartPre=/bin/mount -o remount,rw /boot' >> /etc/systemd/system/apt-daily.service
echo 'ExecStart=/usr/lib/apt/apt.systemd.daily update' >> /etc/systemd/system/apt-daily.service
#apt-daily-upgrade.service
echo '[Unit]' > /etc/systemd/system/apt-daily-upgrade.service
echo 'Description=Daily apt upgrade and clean activities' >> /etc/systemd/system/apt-daily-upgrade.service
echo 'Documentation=man:apt(8)' >> /etc/systemd/system/apt-daily-upgrade.service
echo 'ConditionACPower=true' >> /etc/systemd/system/apt-daily-upgrade.service
echo 'After=apt-daily.service' >> /etc/systemd/system/apt-daily-upgrade.service
echo '' >> /etc/systemd/system/apt-daily-upgrade.service
echo '[Service]' >> /etc/systemd/system/apt-daily-upgrade.service
echo 'Type=oneshot' >> /etc/systemd/system/apt-daily-upgrade.service
echo 'ExecStartPre=/bin/mount -o remount,rw /' >> /etc/systemd/system/apt-daily-upgrade.service
echo 'ExecStartPre=/bin/mount -o remount,rw /boot' >> /etc/systemd/system/apt-daily-upgrade.service
echo 'ExecStart=/usr/lib/apt/apt.systemd.daily install' >> /etc/systemd/system/apt-daily-upgrade.service
echo 'KillMode=process' >> /etc/systemd/system/apt-daily-upgrade.service
echo 'TimeoutStopSec=900' >> /etc/systemd/system/apt-daily-upgrade.service
# Update systemd and enable new services
systemctl daemon-reload
# Re-create the MOTD
/usr/local/sbin/pistar-motdgen
# OK we are done
Message="Upgraded from ${pistarCurVersion} to 4.0.0-RC3..."
echo $Message
exec "$0" "$@"
exit 1
;;
4.0.0-RC3)
sed -i 's/4.0.0-RC3/4.0.0-RC4/g' /etc/pistar-release
echo '#!/bin/sh' > /usr/local/avrdude
echo '' >> /usr/local/avrdude
echo 'sudo strace -o "|autoreset" -eioctl /usr/bin/avrdude-original $@' >> /usr/local/avrdude
# apt-daily.service
echo 'ExecStartPost=/bin/mount -o remount,ro /' >> /etc/systemd/system/apt-daily.service
echo 'ExecStartPost=/bin/mount -o remount,ro /boot' >> /etc/systemd/system/apt-daily.service
#apt-daily-upgrade.service
echo 'ExecStartPost=/bin/mount -o remount,ro /' >> /etc/systemd/system/apt-daily-upgrade.service
echo 'ExecStartPost=/bin/mount -o remount,ro /boot' >> /etc/systemd/system/apt-daily-upgrade.service
# Re-create the MOTD
/usr/local/sbin/pistar-motdgen
# OK we are done
Message="Upgraded from ${pistarCurVersion} to 4.0.0-RC4..."
echo $Message
exec "$0" "$@"
exit 1
;;
4.0.0-RC4)
Message="Please re-image this system with Pi-Star v4.1.x as soon as possible."
;;
4.0.0)
Message="Please re-image this system with Pi-Star v4.1.x as soon as possible."
;;
4.1.0-Beta)
Message="Please re-image this system with the release version Pi-Star v4.1.x as soon as possible."
;;
4.1.0-RC1)
sed -i 's/4.1.0-RC1/4.1.0-RC2/g' /etc/pistar-release
# Clean up for the new version of Buster going to release
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 04EE7237B7D453EC
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 648ACFD622F3D138
apt-get update --allow-releaseinfo-change
# Re-create the MOTD
/usr/local/sbin/pistar-motdgen
# OK we are done
Message="Upgraded from ${pistarCurVersion} to 4.1.0-RC2..."
echo $Message
exec "$0" "$@"
exit 1
;;
4.1.0-RC2)
sed -i 's/4.1.0-RC2/4.1.0-RC3/g' /etc/pistar-release
# logrotate issues;
if [[ -f /etc/logrotate.d/alternatives ]]; then
rm -rf /etc/logrotate.d/alternatives
fi
if [[ -f /etc/logrotate.d/btmp ]]; then
rm -rf /etc/logrotate.d/btmp
fi
if [[ -f /etc/logrotate.d/wtmp ]]; then
rm -rf /etc/logrotate.d/wtmp
fi
if [[ -f /etc/logrotate.d/rsyslog.dpkg-dist ]]; then
rm -rf /etc/logrotate.d/rsyslog.dpkg-dist
fi
if [[ $(grep "copytruncate" /etc/logrotate.d/rsyslog | wc -l) -eq 0 ]]; then
sed -i "s/sharedscripts/sharedscripts\n\tcopytruncate/g" /etc/logrotate.d/rsyslog
fi
if [[ $(grep "pgrep" /etc/logrotate.d/rsyslog | wc -l) -eq 0 ]]; then
sed -i "/invoke-rc.d/c\\\t\t# invoke-rc.d rsyslog rotate > /dev/null\n\t\tkill -s 1 \$(pgrep rsyslog) > /dev/null" /etc/logrotate.d/rsyslog
fi
systemctl restart logrotate
# Add some missing firemwares
apt-get update && apt-get install -y firmware-misc-nonfree
# Re-create the MOTD
/usr/local/sbin/pistar-motdgen
# OK we are done
Message="Upgraded from ${pistarCurVersion} to 4.1.0-RC3..."
echo $Message
exec "$0" "$@"
exit 1
;;
4.1.0-RC3)
sed -i 's/4.1.0-RC3/4.1.0-RC4/g' /etc/pistar-release
# Check / Reset the GPIO pins on boot (specifically on the Pi 4 hardware)
sed -i '/^\/usr\/local\/sbin\/pistar-motdgen/{N;N;s/$/\n# Reset the GPIO Pins on Pi4 Only\n\/usr\/local\/sbin\/pistar-mmdvmhshatreset boot\n/}' /etc/rc.local
# Re-create the MOTD
/usr/local/sbin/pistar-motdgen
# OK we are done
Message="Upgraded from ${pistarCurVersion} to 4.1.0-RC4..."
echo $Message
exec "$0" "$@"
exit 1
;;
4.1.0-RC4)
sed -i 's/4.1.0-RC4/4.1.0-RC5/g' /etc/pistar-release
# Fix up some minor issues with resolvconf's config
sed -i '2ifi' /etc/dhcp/dhclient-enter-hooks.d/resolvconf
sed -i '2i\\ttouch /var/lib/dhcpcd5/resolv.conf' /etc/dhcp/dhclient-enter-hooks.d/resolvconf
sed -i '2iif [ ! -f "/var/lib/dhcpcd5/resolv.conf" ]; then' /etc/dhcp/dhclient-enter-hooks.d/resolvconf
sed -i '2i\\n' /etc/dhcp/dhclient-enter-hooks.d/resolvconf
# Fix fstab to accunt for the change
sed -i "/\/var\/lib\/dhcpcd5/c\\tmpfs\t\t\t\/var\/lib\/dhcpcd5\ttmpfs\tnodev,noatime,nosuid,mode=1777,size=32k\t\t0\t0" /etc/fstab
# Change the filesystem to match
cp /etc/resolv.conf /var/lib/dhcpcd5/resolv.conf
rm -rf /etc/resolv.conf
rm -rf /etc/resolv.conf.bak
ln -s /var/lib/dhcpcd5/resolv.conf /etc/resolv.conf
# Re-create the MOTD
/usr/local/sbin/pistar-motdgen
# OK we are done
Message="Upgraded from ${pistarCurVersion} to 4.1.0-RC5..."
echo $Message
exec "$0" "$@"
exit 1
;;
4.1.0-RC5)
sed -i 's/4.1.0-RC5/4.1.0-RC6/g' /etc/pistar-release
# Fix issue with sysctl.conf not being applied in Raspbian Buster
sed -i '3i/etc/init.d/procps restart' /etc/network/if-up.d/pistar-motdgen
# Re-create the MOTD
/usr/local/sbin/pistar-motdgen
# OK we are done
Message="Upgraded from ${pistarCurVersion} to 4.1.0-RC6..."
echo $Message
exec "$0" "$@"
exit 1
;;
4.1.0-RC6)
sed -i 's/4.1.0-RC6/4.1.0-RC7/g' /etc/pistar-release
# Fix up random seed
cp /lib/systemd/system/systemd-random-seed.service /etc/systemd/system/systemd-random-seed.service
sed -i '/ExecStart=\/lib\/systemd\/systemd-random-seed load/a ExecStop=\/bin\/mount -o remount,rw \/' /etc/systemd/system/systemd-random-seed.service
rm -rf /var/lib/systemd/random-seed
# Update systemd and enable new services
systemctl daemon-reload
systemctl stop systemd-random-seed.service
systemctl start systemd-random-seed.service
# Re-create the MOTD
/usr/local/sbin/pistar-motdgen
# OK we are done
Message="Upgraded from ${pistarCurVersion} to 4.1.0-RC7..."
echo $Message
exec "$0" "$@"
exit 1
;;
4.1.0-RC7)