-
-
Notifications
You must be signed in to change notification settings - Fork 492
/
patches
executable file
·1527 lines (1358 loc) · 85.2 KB
/
patches
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
{
# DietPi-Update incremental patches to apply system and software migrations and fixes
# Created by MichaIng / micha@dietpi.com / https://dietpi.com/
# License: GPLv2 / https://github.com/MichaIng/DietPi#license
# v7.1 + v7.8: Update changed hardware IDs before dietpi-obtain_hw_model would reset them to 22
if [[ -f '/etc/.dietpi_hw_model_identifier' ]]
then
G_HW_MODEL=$(</etc/.dietpi_hw_model_identifier)
# https://github.com/MichaIng/DietPi/pull/4193
if [[ $G_HW_MODEL == 14 || $G_HW_MODEL == 69 ]] # Odroid N1 (v7.8), Firefly RK3399
then
echo 24 > /etc/.dietpi_hw_model_identifier # Generic Rockchip RK3399
elif [[ $G_HW_MODEL == 50 || $G_HW_MODEL == 41 || $G_HW_MODEL == 3[54310] ]] # BananaPi M2+, OrangePi PC Plus, OPi Zero 2 Plus, OrangePi Plus, OrangePi Lite, OrangePi One, OrangePi PC
then
echo 25 > /etc/.dietpi_hw_model_identifier # Generic Allwinner H3
elif [[ $G_HW_MODEL == 3[87] ]] # OPi PC2, OPi Prime
then
echo 26 > /etc/.dietpi_hw_model_identifier # Generic Allwinner H5
fi
fi
# Load DietPi-Globals
/boot/dietpi/func/dietpi-obtain_hw_model # Always update
. /boot/dietpi/func/dietpi-globals
readonly G_PROGRAM_NAME='DietPi-Patch'
G_CHECK_ROOT_USER
G_CHECK_ROOTFS_RW
G_INIT
# Prevent backup prompts during patching e.g. from DietPi-Software reinstalls
export G_PROMPT_BACKUP_DISABLED=1
# Prevent initial and final service control during DietPi-Software reinstalls
export G_SERVICE_CONTROL=0
# Version-based incremental patches
Patch_7_0()
{
# Remove obsolete udev rule, as WiFi power saving is disabled via /etc/network/interfaces > "wireless-power off" > /etc/network/if-pre-up.d/wireless-tools (wireless-tools package) when the WiFi interface is configured.
[[ -f '/etc/udev/rules.d/10-wifi-disable-powermanagement.rules' ]] && G_EXEC rm /etc/udev/rules.d/10-wifi-disable-powermanagement.rules
}
Patch_7_1()
{
# Migrate from DietPi-NordVPN to DietPi-VPN
[[ -f '/boot/dietpi/misc/dietpi-nordvpn' ]] && G_EXEC rm /boot/dietpi/misc/dietpi-nordvpn
[[ -d '/var/lib/dietpi/dietpi-software/installed/dietpi-nordvpn' ]] && G_EXEC mv /var/lib/dietpi/dietpi-software/installed/dietpi-nordvpn /var/lib/dietpi/dietpi-vpn
if [[ -f '/var/lib/dietpi/dietpi-vpn/settings_dietpi.conf' ]]
then
G_EXEC sed -Ei 's/^NORDVPN_(SERVER|USERNAME|PASSWORD)=/VPN_\1=/' /var/lib/dietpi/dietpi-vpn/settings_dietpi.conf
local PROTOCOL VPN_SERVER
# shellcheck disable=SC1091
. /var/lib/dietpi/dietpi-vpn/settings_dietpi.conf
[[ -f '/etc/openvpn/client.ovpn' ]] || G_EXEC cp -a "/etc/openvpn/ovpn_$PROTOCOL/$VPN_SERVER" /etc/openvpn/client.ovpn
unset -v VPN_SERVER PROTOCOL VPN_USERNAME VPN_PASSWORD
G_EXEC sed -i 's|/var/lib/dietpi/dietpi-software/installed/dietpi-nordvpn/|/var/lib/dietpi/dietpi-vpn/|' /etc/openvpn/client.ovpn
fi
if [[ -f '/etc/systemd/system/dietpi-nordvpn.service' ]]
then
systemctl -q is-enabled dietpi-nordvpn && G_EXEC systemctl enable dietpi-vpn
G_EXEC systemctl disable dietpi-nordvpn
G_EXEC rm /etc/systemd/system/dietpi-nordvpn.service
fi
# MariaDB: Rename config file: https://github.com/MichaIng/DietPi/commit/c306d449a7c4ed86a1e9ff7c4914d9e1c2afd11a
[[ -f '/etc/mysql/mariadb.conf.d/99-dietpi-4byte.cnf' ]] && G_EXEC mv /etc/mysql/mariadb.conf.d/99-dietpi-4byte.cnf /etc/mysql/mariadb.conf.d/97-dietpi.cnf
# RPi: Additionally blacklist the bcm2835_isp kernel module when the RPi camera feature is disabled: https://github.com/MichaIng/DietPi/issues/4203
[[ -f '/etc/modprobe.d/dietpi-disable_rpi_camera.conf' ]] && ! grep -q 'bcm2835_isp' /etc/modprobe.d/dietpi-disable_rpi_camera.conf && echo 'blacklist bcm2835_isp' >> /etc/modprobe.d/dietpi-disable_rpi_camera.conf
# Mark now dedicated Go as installed if OpenBazaar is
[[ -d '/usr/local/go' ]] && ! grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[188\]=2' /boot/dietpi/.installed && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[58\]=2' /boot/dietpi/.installed && G_CONFIG_INJECT 'aSOFTWARE_INSTALL_STATE\[188\]=' 'aSOFTWARE_INSTALL_STATE[188]=2' /boot/dietpi/.installed
# Interactively inform user about possible No-IP => DietPi-DDNS migration
[[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[67\]=2' /boot/dietpi/.installed && G_WHIP_MSG '[ INFO ] No-IP client installation found
\nThe No-IP client install option has been replaced by our new DietPi-DDNS tool. The No-IP client remains functional on your system but we recommend a migration to our new tool.
\nSimply run "dietpi-ddns" from console, select "No-IP" as provider, enter domain and credentials, then select "Apply". The old No-IP client and service will be removed automatically as last step, once a final DDNS update test succeeded.'
# Remove obsolete DietPi-NordVPN and No-IP install states
[[ -f '/boot/dietpi/.installed' ]] && grep -qE '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[(67|171)\]=' /boot/dietpi/.installed && G_EXEC sed -Ei '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[(67|171)\]=/d' /boot/dietpi/.installed
# Inform user about possible Sonarr v2 => v3 upgrade
[[ -f '/mnt/dietpi_userdata/sonarr/nzbdrone.pid' ]] && G_WHIP_MSG '[ INFO ] Sonarr v3 has been released
\nYou seem to use Sonarr v2 while Sonarr v3 is now available. A migration is safe to do, but in some cases you might need to redo some configuration, so we do not force the upgrade now.
\nTo migrate to Sonarr v3, run the following command from console:
- dietpi-software reinstall 144
\nNB: If you use DietPi-Arr_to_RAM and update database backups via Sonarr "Custom Scripts" feature, the following change is required:
- Run "dietpi-arr_to_ram 2" once manually, which updates your database backup but also creates a new script.
- Use that script /mnt/dietpi_userdata/sonarr/dietpi-arr_to_ram.sh without arguments to update your database backup via "Custom Scripts". This is required as Sonarr v3 does not allow arguments for custom scripts and does not allow to call scripts from within the /boot directory.'
# Removing obsolete DietPi-Arr_to_RAM backup files
rm -f /mnt/dietpi_userdata/{{sonarr,radarr}/nzbdrone.db-{shm,wal},lidarr/lidarr.db-{shm,wal}}.bak
# On 64-bit RPi systems, remove the obsolete foreign architecture armhf
[[ $G_HW_MODEL -le 9 && $G_HW_ARCH == 3 && $(dpkg --print-architecture) == 'arm64' ]] && ! dpkg-query -l '*:armhf' &> /dev/null && G_EXEC dpkg --remove-architecture 'armhf'
# Plex Media Server: Fix secure remote access via app.plex.tv did not work if Unbound with DNS rebinding protection is installed: https://dietpi.com/phpbb/viewtopic.php?t=8896
[[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[42\]=2' /boot/dietpi/.installed && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[182\]=2' /boot/dietpi/.installed && echo -e 'server:\n\tprivate-domain: "plex.direct"' > /etc/unbound/unbound.conf.d/dietpi-plex.conf
}
Patch_7_2()
{
# Odroid XU4 does not support rng-tools: https://github.com/MichaIng/DietPi/issues/4318
[[ $G_HW_MODEL == 11 ]] && G_AGP rng-tools{,5,-debian}
# raspimjpeg: Move executable to a common system path
if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[59\]=2' /boot/dietpi/.installed
then
G_DIETPI-NOTIFY 2 'Moving raspimjpeg executable to a common system path'
[[ -f '/opt/vc/bin/raspimjpeg' ]] && G_EXEC mv /{opt/vc,usr/local}/bin/raspimjpeg
[[ -L '/usr/bin/raspimjpeg' ]] && G_EXEC rm /usr/bin/raspimjpeg
fi
# Bitwarden_RS: Rename into vaultwarden: https://github.com/MichaIng/DietPi/issues/4325
if [[ -d '/mnt/dietpi_userdata/bitwarden_rs' ]]
then
G_DIETPI-NOTIFY 2 'Migrating Bitwarden_RS which was renamed to "vaultwarden" ...'
# Remove Bitwarden_RS service
if [[ -f '/etc/systemd/system/bitwarden_rs.service' ]]
then
G_EXEC systemctl disable --now bitwarden_rs
G_EXEC rm /etc/systemd/system/bitwarden_rs.service
fi
[[ -d '/etc/systemd/system/bitwarden_rs.service.d' ]] && G_EXEC rm -R /etc/systemd/system/bitwarden_rs.service.d
# Remove Bitwarden_RS user and group
getent passwd bitwarden_rs > /dev/null && G_EXEC userdel bitwarden_rs
getent group bitwarden_rs > /dev/null && G_EXEC groupdel bitwarden_rs
# Remove Bitwarden_RS install directory
[[ -d '/opt/bitwarden_rs' ]] && G_EXEC rm -R /opt/bitwarden_rs
# Update and rename Bitwarden_RS config file
if [[ -f '/mnt/dietpi_userdata/bitwarden_rs/bitwarden_rs.env' ]]
then
G_CONFIG_INJECT 'DATA_FOLDER=' 'DATA_FOLDER=/mnt/dietpi_userdata/vaultwarden' /mnt/dietpi_userdata/bitwarden_rs/bitwarden_rs.env
G_EXEC mv /mnt/dietpi_userdata/bitwarden_rs/{bitwarden_rs,vaultwarden}.env
fi
G_EXEC mv /mnt/dietpi_userdata/{bitwarden_rs,vaultwarden}
fi
# Fix disabling dietpi-desktop_setup
[[ -f '/var/lib/dietpi/dietpi-software/installed/desktop/dietpi-desktop_setup.sh' ]] && grep -q 'echo -e' /var/lib/dietpi/dietpi-software/installed/desktop/dietpi-desktop_setup.sh && G_EXEC sed -i 's/echo -e/echo/' /var/lib/dietpi/dietpi-software/installed/desktop/dietpi-desktop_setup.sh
for i in /{root,home/*}/.config/autostart/dietpi-desktop_setup.desktop
do
[[ -f $i ]] && grep -q '^-e ' "$i" && G_EXEC sed -i 's/^-e //' "$i"
done
# LibSSL1.0.0: Remove obsolete install state
[[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[126\]=' /boot/dietpi/.installed && G_EXEC sed -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[126\]=/d' /boot/dietpi/.installed
# Roon Extension Manager: Inform users about available upgrade: https://github.com/MichaIng/DietPi/pull/4399
[[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[86\]=2' /boot/dietpi/.installed && G_WHIP_MSG '[ INFO ] Roon Extension Manager: Major upgrade available
\nThe Roon Extension Manager received a major upgrade to v1.0. It is now implemented as Docker container, rather than as Node.js module.
\nYou may upgrade via: dietpi-software reinstall 86
\nNB: Roon extensions which were installed via the legacy method must be reinstalled with the new Roon Extension Manager. Extensions which were installed as Docker images already, will continue to function.'
}
Patch_7_3()
{
# If the user did not remove the "dietpi" sudoers manually, update it to allow "sudo -u <user> -g <group>" with all target users and groups.
# This is required to call our software CLI wrapper scripts, which contain "sudo -u <service_user>" to assure correct config and data is loaded.
[[ -f '/etc/sudoers.d/dietpi' ]] && echo 'dietpi ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/dietpi
# Update DietPi-Backup filter file
if [[ -f '/boot/dietpi/.dietpi-backup_inc_exc' && $(head -1 /boot/dietpi/.dietpi-backup_inc_exc) != '# DietPi-Backup include/exclude filter' ]]
then
G_DIETPI-NOTIFY 2 'Updating DietPi-Backup filter file: /boot/dietpi/.dietpi-backup_inc_exc'
if grep -q '^[[:blank:]]*[^#]' /boot/dietpi/.dietpi-backup_inc_exc
then
cat << _EOF_ > .dietpi-backup_inc_exc
# DietPi-Backup include/exclude filter
# Prefix "-" exclude items, "+" include items which would match a wildcard exclude rule.
# Suffix "/" match directories only, no files or symlinks.
# Using wildcard "*" matches any item name or part of it.
# Since the list is processed from top to bottom and the first match defines the result,
# includes need to be defined before their wildcard exclude rule
# and in case excludes before their wildcard include rule.
# Symlinks are handled as such and never processed recursively.
# Excluded directories are not processed recursively, so contained items cannot be included.
# Hence, to include items within an excluded directory:
# - Do not exclude the directory itself, but contained items via wildcard.
# - Define includes first, to override the wildcard exclude rule.
# - See the below default rules, how we exclude all items below /mnt
# but include the dietpi_userdata directory, if it is no symlink.
# To prevent loops, the backup target dir, log and config are excluded internally.
+ /mnt/dietpi_userdata/
- /mnt/*
- /media/
$(grep '^[[:blank:]]*[^#]' /boot/dietpi/.dietpi-backup_inc_exc)
_EOF_
G_EXEC mv {,/boot/dietpi/}.dietpi-backup_inc_exc
else
G_EXEC rm /boot/dietpi/.dietpi-backup_inc_exc
fi
fi
# RPi: Remove deprecated I2C setting from config.txt
(( $G_HW_MODEL > 9 )) || G_EXEC sed -i '/dtparam=i2c1=/d' /boot/config.txt
# Tomcat 8: Remove obsolete install state
[[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[125\]=' /boot/dietpi/.installed && G_EXEC sed -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[125\]=/d' /boot/dietpi/.installed
# Remove license (flag) file if AUTO_SETUP_AUTOMATED=1 is set, which would otherwise never happen on pre-v7.2 images, and if AUTO_SETUP_ACCEPT_LICENSE=1 is set, to assure the prompt is skipped when for some reason the script is reloaded between update and first installs.
[[ -f '/var/lib/dietpi/license.txt' ]] && grep -Eq '^[[:blank:]]*AUTO_SETUP_A(UTOMATED|CCEPT_LICENSE)=1' /boot/dietpi.txt && G_EXEC rm /var/lib/dietpi/license.txt
}
Patch_7_4()
{
if [[ $G_HW_ARCH == [12] && ! -f '/etc/pip.conf' && -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[130\]=2' /boot/dietpi/.installed
then
G_WHIP_BUTTON_CANCEL_TEXT='No' G_WHIP_YESNO 'Adding piwheels.org to your pip sources
\nPython 3 pip is installed on your system, but piwheels.org is not used as source for pre-compiled Python 3 wheels. To speed up the installation and upgrade of modules via pip and reduce build dependencies, we highly recommend to make use of it.
\nRead more about the project at: https://piwheels.org/
\nDo you want pip to pull Python 3 wheels from piwheels.org automatically?' && G_EXEC eval "echo -e '[global]\nextra-index-url=https://www.piwheels.org/simple/' > /etc/pip.conf"
fi
}
Patch_7_5()
{
# Mark JRE as installed when JDK is installed
[[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[8\]=2' /boot/dietpi/.installed && G_CONFIG_INJECT 'aSOFTWARE_INSTALL_STATE\[196\]=' 'aSOFTWARE_INSTALL_STATE[196]=2' /boot/dietpi/.installed
if getent passwd blynk > /dev/null && ! getent group blynk > /dev/null
then
G_DIETPI-NOTIFY 2 'Creating the "blynk" group for the Blynk server, as replacement for the previously used "dietpi" group'
G_EXEC groupadd -r blynk
G_EXEC usermod -g blynk blynk
fi
# Amiberry on RPi: Revert cmdline.txt changes we do not apply anymore
if [[ $G_HW_MODEL -le 9 && -f '/boot/dietpi/.dietpi-autostart_index' && $(</boot/dietpi/.dietpi-autostart_index) == 6 ]]
then
G_DIETPI-NOTIFY 2 'Reverting some obsolete cmdline tweaks for Amiberry fast boot'
grep -q '[[:blank:]]loglevel=3' /boot/cmdline.txt && G_EXEC sed -i 's/[[:blank:]]*loglevel=3//' /boot/cmdline.txt
grep -q '[[:blank:]]console=tty3' /boot/cmdline.txt && G_EXEC sed -i 's/[[:blank:]]*console=tty3/ console=tty1/' /boot/cmdline.txt
fi
# RPi: Offer to prevent constant SD card polling
(( $G_HW_MODEL < 10 )) && ! grep -q '^dtparam=sd_poll_once' /boot/config.txt && G_WHIP_BUTTON_CANCEL_TEXT='Skip' G_WHIP_YESNO '[ INFO ] Disable SD card hot plug detection
\nAn issue was detected on RPi, where the default regular SD card polling leads to significant CPU load, when no SD card is actually attached:
- https://github.com/MichaIng/DietPi/issues/4602
\nThe regular polling is required to allow SD card hot plug detection, so that you can instantly mount them, when plugged to a running Pi.
\nAs long as an SD card is present or used as system drive, it does not imply notable CPU load, but also hot plug detection is not needed then. We hence recommend to have this feature disabled on all RPi systems.
\nDo you want to have SD card hot plug detection disabled now?' && G_CONFIG_INJECT 'dtparam=sd_poll_once' 'dtparam=sd_poll_once' /boot/config.txt
# Lidarr: Reinstall on non-ARMv6 platforms to migrate to .NET based build. Use old install directory (capital "L") as flag for this not been done already.
if [[ $G_HW_ARCH != 1 && -f '/boot/dietpi/.installed' && -d '/opt/Lidarr' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[106\]=2' /boot/dietpi/.installed
then
G_DIETPI-NOTIFY 2 'Reinstalling Lidarr to migrate to new .NET based builds. Your configs and data remain untouched!'
G_EXEC rm -R /opt/Lidarr
/boot/dietpi/dietpi-software reinstall 106
# Offer to uninstall Mono, if Sonarr is not installed
! grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[144\]=2' /boot/dietpi/.installed && G_WHIP_BUTTON_CANCEL_TEXT='Skip' G_WHIP_YESNO '[ INFO ] Lidarr has been migrated to the new .NET based builds.
\nThe dedicated Mono runtime install is hence not required anymore to run Lidarr and can be uninstalled, unless you require it for other purpose.
\nDo you want to uninstall Mono now?' && /boot/dietpi/dietpi-software uninstall 150
fi
}
Patch_7_6()
{
# RPi: Remove obsolete cmdline entry on v5.4+ kernel systems (not Stretch)
if (( $G_HW_MODEL < 10 && $G_DISTRO > 4 ))
then
G_DIETPI-NOTIFY 2 'Removing obsolete "elevator" entry from /boot/cmdline.txt'
G_EXEC sed -Ei 's/elevator=[^[:blank:]]*[[:blank:]]+//' /boot/cmdline.txt
G_EXEC sed -Ei 's/[[:blank:]]*elevator=[^[:blank:]]*//' /boot/cmdline.txt
fi
# https://github.com/jirka-h/haveged/pull/7 https://github.com/MichaIng/DietPi/issues/3689#issuecomment-678322767
if [[ $G_DISTRO == 5 && $G_HW_ARCH == [23] ]] && { [[ $G_HW_MODEL == 11 ]] || dpkg-query -s haveged &> /dev/null; }
then
G_DIETPI-NOTIFY 2 'Upgrading haveged entropy daemon to fix an issue on ARM:'
G_DIETPI-NOTIFY 2 ' - https://github.com/jirka-h/haveged/pull/7'
G_EXEC curl -sSfLO "https://dietpi.com/downloads/binaries/buster/libhavege2_$G_HW_ARCH_NAME.deb"
G_EXEC curl -sSfLO "https://dietpi.com/downloads/binaries/buster/haveged_$G_HW_ARCH_NAME.deb"
G_AGI "./libhavege2_$G_HW_ARCH_NAME.deb" "./haveged_$G_HW_ARCH_NAME.deb"
G_EXEC rm "./libhavege2_$G_HW_ARCH_NAME.deb" "./haveged_$G_HW_ARCH_NAME.deb"
# Mark the library as auto-installed so that it can be autoremoved when haveged itself is removed.
G_EXEC apt-mark auto libhavege2
fi
}
Patch_7_7()
{
G_DIETPI-NOTIFY 2 'Reverting Mosquitto and Webmin repositories back to HTTPS'
G_EXEC sed -Ei 's#http://(repo.mosquitto.org|download.webmin.com)#https://\1#' /etc/apt/sources.list
[[ $(find /etc/apt/sources.list/*.list 2> /dev/null) ]] && G_EXEC sed -Ei 's#http://(repo.mosquitto.org|download.webmin.com)#https://\1#' /etc/apt/sources.list.d/*.list
# Inform users about abandoned CouchPotato and in case add service to DietPi-Services includes, as it has been removed from the hardcoded list
if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[142\]=2' /boot/dietpi/.installed
then
G_WHIP_MSG '[ INFO ] CouchPotato has been abandoned
\nSadly, the CouchPotato project is not maintained anymore and has been abandoned. In turn we removed it from DietPi.
\nThe instance installed on your system will remain, but it cannot be installed, reinstalled or uninstalled anymore.
\nWe recommend to migrate to an alternative project, like Radarr, which can be found in DietPi-Software was well.
\nManual CouchPotato uninstall instructions: https://github.com/MichaIng/DietPi/issues/4323#issuecomment-927128724
'
if [[ -f '/etc/init.d/couchpotato' ]]
then
# shellcheck disable=SC2015
[[ -f '/boot/dietpi/.dietpi-services_include_exclude' ]] && grep -q 'couchpotato' /boot/dietpi/.dietpi-services_include_exclude || G_EXEC eval "echo '+ couchpotato' >> /boot/dietpi/.dietpi-services_include_exclude"
fi
fi
# Remove obsolete CouchPotato install state
[[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[142\]=' /boot/dietpi/.installed && G_EXEC sed -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[142\]=/d' /boot/dietpi/.installed
# Fix Deluge web interface service on Bullseye: https://github.com/MichaIng/DietPi/issues/4785
if [[ $G_DISTRO -ge 6 && -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[45\]=2' /boot/dietpi/.installed && ! grep -q 'ExecStart.* -d ' /etc/systemd/system/deluge-web.service
then
G_DIETPI-NOTIFY 2 'Patching Deluge web interface service to fix startup at Bullseye'
G_EXEC sed -i 's/deluge-web -l/deluge-web -d -l/' /etc/systemd/system/deluge-web.service
fi
# Mono: Migrate APT list and key to new location and naming
if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[150\]=2' /boot/dietpi/.installed
then
G_DIETPI-NOTIFY 2 'Migrating Mono APT list and key to new location and naming'
[[ -f '/etc/apt/sources.list.d/mono-xamarin.list' ]] && G_EXEC mv /etc/apt/sources.list.d/mono-xamarin.list /etc/apt/sources.list.d/dietpi-mono.list
[[ -f '/etc/apt/trusted.gpg.d/dietpi-mono.gpg' ]] || G_EXEC curl -sSfL 'https://download.mono-project.com/repo/xamarin_ring.gpg' -o /etc/apt/trusted.gpg.d/dietpi-mono.gpg
[[ -f '/etc/apt/trusted.gpg' ]] && G_EXEC apt-key --keyring /etc/apt/trusted.gpg del '3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF'
fi
# WireGuard: Patch config
if [[ -f '/etc/wireguard/wg0.conf' ]]
then
G_DIETPI-NOTIFY 2 'Updating WireGuard wg0 configuration'
G_EXEC sed -i '\|/boot/dietpi/func/obtain_network_details|d' /etc/wireguard/wg0.conf
G_EXEC sed -Ei "s#mawk .NR==3. /(run|boot|DietPi)/dietpi/.network#ip r l 0/0 | mawk '{print \$5;exit}'#g" /etc/wireguard/wg0.conf
fi
# GMediaRender: Patch service
if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[163\]=2' /boot/dietpi/.installed
then
G_DIETPI-NOTIFY 2 'Updating GMediaRender service'
cat << _EOF_ > /etc/systemd/system/gmrender.service
[Unit]
Description=GMediaRender (DietPi)
Documentation=https://github.com/hzeller/gmrender-resurrect/blob/master/INSTALL.md#commandline-options
Wants=network-online.target
After=network-online.target sound.target dietpi-boot.service
[Service]
User=gmrender
ExecStartPre=+/bin/bash -c '. /boot/dietpi/func/dietpi-globals; systemctl set-environment ACTIVE_IP=\$(G_GET_NET ip)'
ExecStart=/usr/local/bin/gmediarender -u '$G_HW_UUID' -f '$(</etc/hostname)' --gstout-audiosink=alsasink --gstout-audiodevice=default --logfile=stdout -I "\$ACTIVE_IP"
[Install]
WantedBy=multi-user.target
_EOF_
fi
# Disable obsolete DietPi-Boot service (do not stop it due to dependencies)
systemctl -q is-enabled dietpi-boot 2> /dev/null && G_EXEC systemctl disable dietpi-boot
# Remove obsolete files
[[ -f '/boot/dietpi-CHANGELOG.txt' ]] && G_EXEC rm /boot/dietpi-CHANGELOG.txt
[[ -f '/boot/dietpi/func/obtain_network_details' ]] && G_EXEC rm /boot/dietpi/func/obtain_network_details
[[ -f '/boot/dietpi/boot' ]] && G_EXEC rm /boot/dietpi/boot
[[ -f '/etc/systemd/system/dietpi-boot.service' ]] && G_EXEC rm /etc/systemd/system/dietpi-boot.service
[[ -f '/etc/systemd/system/wg-quick@wg0.service.d/dietpi.conf' ]] && G_EXEC rm /etc/systemd/system/wg-quick@wg0.service.d/dietpi.conf
[[ -d '/etc/systemd/system/wg-quick@wg0.service.d' ]] && G_EXEC rmdir --ignore-fail-on-non-empty /etc/systemd/system/wg-quick@wg0.service.d
[[ -d '/opt/FreshRSS/FreshRSS-master' ]] && G_EXEC rm -R /opt/FreshRSS/FreshRSS-master
[[ -L '/opt/FreshRSS/p/p' ]] && G_EXEC rm /opt/FreshRSS/p/p
# Translate and apply boot wait for network setting
local boot_wait_for_network=$(sed -n '/^[[:blank:]]*CONFIG_BOOT_WAIT_FOR_NETWORK=/{s/^[^=]*=//p;q}' /boot/dietpi.txt)
if [[ $boot_wait_for_network == 0 ]]
then
/boot/dietpi/func/dietpi-set_software boot_wait_for_network 0
elif grep -q '^[[:blank:]]*CONFIG_BOOT_WAIT_FOR_NETWORK=' /boot/dietpi.txt
then
/boot/dietpi/func/dietpi-set_software boot_wait_for_network 1
fi
G_EXEC sed -i '/^[[:blank:]]*CONFIG_BOOT_WAIT_FOR_NETWORK=/d' /boot/dietpi.txt
# Enable systemd-timesyncd on oneshot modes to start early at boot
local time_sync_mode=$(sed -n '/^[[:blank:]]*CONFIG_NTP_MODE=/{s/^[^=]*=//p;q}' /boot/dietpi.txt)
[[ $time_sync_mode == [123] ]] && G_EXEC systemctl enable systemd-timesyncd
# Inform and offer to re-apply the ssh.dietpi.com host key if missing: https://github.com/MichaIng/DietPi/issues/4844
if [[ ! -f '/root/.ssh/known_hosts' ]] || ! grep -Eq '^\[?ssh.dietpi.com(]:29248)?[[:blank:]]' /root/.ssh/known_hosts && G_WHIP_DEFAULT_ITEM='yes' G_WHIP_YESNO '[WARNING] ssh.dietpi.com SSH/SFTP host key missing
\nThe host key to connect to our SSH/SFTP server is missing on your system, which means that uploading bug reports and sending or purging survey data fails.
\nDo you want to re-add that host key now?'
then
[[ -d '/root/.ssh' ]] || G_EXEC mkdir -p /root/.ssh
[[ -f '/root/.ssh/known_hosts' ]] || > /root/.ssh/known_hosts
G_EXEC sed -i '/^dietpi.com/d' /root/.ssh/known_hosts
G_EXEC sed -i '/^185.101.93.93/d' /root/.ssh/known_hosts
G_CONFIG_INJECT '\[?ssh.dietpi.com(]:29248)?[[:blank:]]' '[ssh.dietpi.com]:29248 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDE6aw3r6aOEqendNu376iiCHr9tGBIWPgfrLkzjXjEsHGyVSUFNnZt6pftrDeK7UX+qX4FxOwQlugG4fymOHbimRCFiv6cf7VpYg1Ednquq9TLb7/cIIbX8a6AuRmX4fjdGuqwmBq3OG7ZksFcYEFKt5U4mAJIaL8hXiM2iXjgY02LqiQY/QWATsHI4ie9ZOnwrQE+Rr6mASN1BVFuIgyHIbwX54jsFSnZ/7CdBMkuAd9B8JkxppWVYpYIFHE9oWNfjh/epdK8yv9Oo6r0w5Rb+4qaAc5g+RAaknHeV6Gp75d2lxBdCm5XknKKbGma2+/DfoE8WZTSgzXrYcRlStYN' /root/.ssh/known_hosts
fi
if [[ -f '/etc/xdg/lxsession/LXDE/desktop.conf' ]]
then
G_DIETPI-NOTIFY 2 'Fixing the "No session for pid" error prompt on LXDE start'
G_CONFIG_INJECT 'polkit/command=' 'polkit/command=' /etc/xdg/lxsession/LXDE/desktop.conf '\[Session\]'
fi
}
Patch_7_8()
{
# Remove IPv4 preference
G_EXEC sed -i '/CONFIG_PREFER_IPV4/d' /boot/dietpi.txt
[[ -f '/etc/wgetrc' ]] && G_EXEC sed -i 's/^[[:blank:]]*prefer-family[[:blank:]]*=/#&/' /etc/wgetrc
[[ -f '/etc/apt/apt.conf.d/99-dietpi-force-ipv4' ]] && G_EXEC rm /etc/apt/apt.conf.d/99-dietpi-force-ipv4
# Inform users about removed Subsonic and in case add service to DietPi-Services includes, as it has been removed from the hardcoded list
if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[34\]=2' /boot/dietpi/.installed
then
G_WHIP_MSG '[ INFO ] Subsonic has been removed from DietPi-Software
\nSince it is not developed anymore and due to shared library dependencies only compatible with Debian Stretch, we removed Subsonic from DietPi-Software.
\nThe instance installed on your system will remain, but it cannot be installed, reinstalled or uninstalled anymore.
\nWe recommend to migrate to Airsonic-Advanced, which can be found in DietPi-Software was well.
\nManual Subsonic uninstall instructions: https://github.com/MichaIng/DietPi/pull/4895
'
if [[ -f '/etc/init.d/subsonic' ]]
then
# shellcheck disable=SC2015
[[ -f '/boot/dietpi/.dietpi-services_include_exclude' ]] && grep -q 'subsonic' /boot/dietpi/.dietpi-services_include_exclude || G_EXEC eval "echo '+ subsonic' >> /boot/dietpi/.dietpi-services_include_exclude"
fi
fi
# Remove obsolete Subsonic install state
[[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[34\]=' /boot/dietpi/.installed && G_EXEC sed -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[34\]=/d' /boot/dietpi/.installed
# Inform users about removed emonHub and in case add service to DietPi-Services includes, as it has been removed from the hardcoded list
if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[99\]=2' /boot/dietpi/.installed
then
G_WHIP_MSG '[ INFO ] emonHub has been removed from DietPi-Software
\nSince we do not have a single reported installation, we removed emonHub from DietPi-Software.
\nThe instance installed on your system will remain, but it cannot be installed, reinstalled or uninstalled anymore.
\nIf you want to keep using and updating it, have a look at the official repository: https://github.com/openenergymonitor/emonhub
\nManual emonHub uninstall instructions: https://github.com/MichaIng/DietPi/pull/4895
'
if [[ -f '/etc/systemd/system/emonhub.service' ]]
then
# shellcheck disable=SC2015
[[ -f '/boot/dietpi/.dietpi-services_include_exclude' ]] && grep -q 'emonhub' /boot/dietpi/.dietpi-services_include_exclude || G_EXEC eval "echo '+ emonhub' >> /boot/dietpi/.dietpi-services_include_exclude"
fi
fi
# Remove obsolete emonHub install state
[[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[99\]=' /boot/dietpi/.installed && G_EXEC sed -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[99\]=/d' /boot/dietpi/.installed
# Remove obsolete emonHub API key setting from dietpi.txt
grep -q 'SOFTWARE_EMONHUB_APIKEY' /boot/dietpi.txt && G_EXEC sed -Ei '/(SOFTWARE_EMONHUB_APIKEY|^#.*EmonCMS)/d' /boot/dietpi.txt
# Reinstall Roon Server
if [[ -f '/boot/dietpi/.installed' && ! -d '/opt/roonserver' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[154\]=2' /boot/dietpi/.installed
then
G_DIETPI-NOTIFY 2 'Reinstalling Roon Server to resolve an issue where the internal updater purges all Roon data and configs'
G_EXEC mkdir -p /opt/roonserver
for i in /mnt/dietpi_userdata/roonserver/{Appliance,RoonMono,RoonDotnet,Server,check.sh,start.sh,VERSION}
do
[[ -e $i ]] && G_EXEC mv "$i" "/opt${i#/mnt/dietpi_userdata}"
done
echo 154 >> /var/tmp/dietpi/dietpi-update_reinstalls
fi
# RPi 400: Inform user about fixed overclocking profiles
[[ $G_HW_MODEL == 4 && $G_HW_MODEL_NAME == *'400'* ]] && grep -qE '^[[:blank:]]*(arm|core)_freq=' /boot/config.txt && G_WHIP_MSG '[ INFO ] New overclocking profiles for Raspberry Pi 400
\ndietpi-config falsely offered Raspberry Pi 4 overclocking profiles on Raspberry Pi 400. This has now been fixed and a new set of profiles dedicated for the Raspberry Pi 400 has been added.
\nYou may try them out via: "dietpi-config" > "Performance Options" > "Overclocking"
\nFeel free to share your own testing results and suggest changes or additional profiles with us via forum or GitHub.'
# RPi: Remove ineffective rootdelay (wait for X seconds) from cmdline if rootwait (wait indefinitely) is present already
if (( $G_HW_MODEL < 10 )) && grep -Eq '(^|[[:blank:]])rootwait([[:blank:]]|$)' /boot/cmdline.txt && grep -Eq '(^|[[:blank:]])rootdelay=' /boot/cmdline.txt
then
G_DIETPI-NOTIFY 2 'Removing ineffective "rootdelay" argument from /boot/cmdline.txt'
G_EXEC sed -i -e 's/^rootdelay=[^[:blank:]]*[[:blank:]]*//g' -e 's/[[:blank:]]*[[:blank:]]rootdelay=[^[:blank:]]*//g' /boot/cmdline.txt
fi
# DietPi-Backup: Move logs to persistent backup location
if [[ -f '/var/log/dietpi-backup.log' ]]
then
G_WHIP_MSG '[WARNING] Moving dietpi-backup.log out of /var/log
\nNew DietPi-Backup log files are now created within the chosen backup directory. The existing old log is moved from /var/log/dietpi-backup.log to /tmp/dietpi-backup.log in case you need to review it.'
G_EXEC mv /{var/log,tmp}/dietpi-backup.log
fi
}
Patch_7_9()
{
# On Raspberry Pi, for backwards compatibility with software compiled against older libraspberrypi0, create symlinks from old to new filenames
if (( $G_HW_MODEL < 10 && $G_HW_ARCH < 3 )) && dpkg-query -s 'libraspberrypi0' &> /dev/null
then
G_DIETPI-NOTIFY 2 'Applying workaround for compiled against older libraspberrypi0'
G_EXEC cd /usr/lib/arm-linux-gnueabihf
while read -r line
do
[[ ! -f $line || -f ${line%.0} ]] && continue
line=${line#/usr/lib/arm-linux-gnueabihf/}
G_EXEC ln -sf "$line" "${line%.0}"
done < <(dpkg -L 'libraspberrypi0' | grep '^/usr/lib/arm-linux-gnueabihf/.*\.so.0$')
fi
# Update choice and preference index variables
[[ -f '/boot/dietpi/.installed' ]] && G_EXEC sed -Ei -e 's/INDEX_(LOGGING|WEBSERVER|DESKTOP|BROWSER)_CURRENT/INDEX_\1/g' -e '/INDEX_(LOGGING|WEBSERVER|DESKTOP|BROWSER|SSHSERVER|FILESERVER)_TARGET/d' -e '/INDEX_(SSHSERVER|FILESERVER)_CURRENT/d' /boot/dietpi/.installed
# Offer to update DietPi-Dashboard TCP port: https://github.com/MichaIng/DietPi/issues/4966
if [[ -f '/opt/dietpi-dashboard/config.toml' ]] && grep -Eq '^[[:blank:]]*port[[:blank:]]+=[[:blank:]]+8088$' /opt/dietpi-dashboard/config.toml
then
G_WHIP_BUTTON_CANCEL_TEXT='No' G_WHIP_YESNO '[ INFO ] Changed DietPi-Dashboard TCP port
\nThe default TCP network port for the DietPi-Dashboard has been changed from 8088 to 5252 to resolve a port conflict with InfluxDB. However, if you do not use or plan to use InfluxDB, port 8088 does not cause any issues.
\nDo you want to apply this change as well to your DietPi-Dashboard installation?
\nNB: You need to restart the service once for the port change to take effect:
- systemctl restart dietpi-dashboard' && G_CONFIG_INJECT 'port[[:blank:]]' 'port = 5252' /opt/dietpi-dashboard/config.toml && echo 200 >> /var/tmp/dietpi/dietpi-update_reinstalls
fi
# ownCloud/Nextcloud: Disable maintenance mode once manually, since DietPi-Services enabled of before this update but doesn't handle/disable it anymore afterwards.
[[ -f '/var/www/owncloud/config/config.php' ]] && grep -Eq "^[[:blank:]]*'maintenance'[[:blank:]]+=>[[:blank:]]+true,\$" /var/www/owncloud/config/config.php && G_EXEC sed -Ei "s/^[[:blank:]]*'maintenance'[[:blank:]]+=>[[:blank:]]+true,\$/ 'maintenance' => false,/" /var/www/owncloud/config/config.php
[[ -f '/var/www/nextcloud/config/config.php' ]] && grep -Eq "^[[:blank:]]*'maintenance'[[:blank:]]+=>[[:blank:]]+true,\$" /var/www/nextcloud/config/config.php && G_EXEC sed -Ei "s/^[[:blank:]]*'maintenance'[[:blank:]]+=>[[:blank:]]+true,\$/ 'maintenance' => false,/" /var/www/nextcloud/config/config.php
}
Patch_8_0()
{
# RPi: Fix possibly doubled CMA size in KMS overlay setting
if (( $G_HW_MODEL < 10 )) && grep -Eq 'dtoverlay=vc4-f?kms-v3d.*,cma-.*,cma-' /boot/config.txt
then
G_DIETPI-NOTIFY 2 'Fixing doubled CMA size in KMS overlay setting'
while grep -Eq 'dtoverlay=vc4-f?kms-v3d.*,cma-.*,cma-' /boot/config.txt
do
G_EXEC sed -Ei '/dtoverlay=vc4-f?kms-v3d.*,cma-.*,cma-/s/,cma-[^,]*//' /boot/config.txt
done
fi
# Reinstall Airsonic to migrate to Airsonic-Advanced and mitigate Log4Shell for it once and for all: https://github.com/MichaIng/DietPi/pull/4948
if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[33\]=2' /boot/dietpi/.installed && ! grep -q 'Airsonic-Advanced' /etc/systemd/system/airsonic.service
then
G_WHIP_MSG '[ INFO ] Reinstalling Airsonic to migrate to Airsonic-Advanced
\nThe classic Airsonic project has been archived by its maintainer and it suffers from the critical Log4Shell security vulnerability:
- https://dietpi.com/blog/?p=1172
\nAirsonic-Advanced is an actively developed successor which does not use the related Log4j library and can be used as a direct replacement for classic Airsonic, migrating all data and settings automatically.
\nAirsonic will be reinstalled as part of this update to migrate to Airsonic-Advanced. Afterwards, we recommend to check out the new "Credentials" settings, create a new safer encrypted password and remove the old one.'
# Migrate to "dietpi" as primary group and remove obsolete "airsonic" group
getent passwd airsonic > /dev/null && G_EXEC usermod -g dietpi airsonic
getent group airsonic > /dev/null && G_EXEC groupdel airsonic
echo 33 >> /var/tmp/dietpi/dietpi-update_reinstalls
fi
# RPi: Remove dummy files: https://github.com/RPi-Distro/raspberrypi-sys-mods/pull/60
if (( $G_HW_MODEL < 10 ))
then
[[ -f '/etc/apt/trusted.gpg.d/microsoft.gpg' && ! -s '/etc/apt/trusted.gpg.d/microsoft.gpg' ]] && G_EXEC rm /etc/apt/trusted.gpg.d/microsoft.gpg
[[ -f '/etc/apt/sources.list.d/vscode.list' && $(</etc/apt/sources.list.d/vscode.list) == '### Disabled by raspberrypi-sys-mods ###' ]] && G_EXEC rm /etc/apt/sources.list.d/vscode.list
fi
# RPi: Fix forced max frequencies: https://github.com/MichaIng/DietPi/issues/5088
(( $G_HW_MODEL < 10 )) && grep -Eq '(.){100}' /boot/config.txt && G_EXEC sed -Ei 's/^((.){99})..*$/\1/' /boot/config.txt
# Blynk Server: Apply Log4Shell mitigation
[[ -f '/etc/systemd/system/blynkserver.service' ]] && ! grep -q '\-Dlog4j2.formatMsgNoLookups=true' /etc/systemd/system/blynkserver.service && G_EXEC sed -i 's/java -jar/java -Dlog4j2.formatMsgNoLookups=true -jar/' /etc/systemd/system/blynkserver.service
}
Patch_8_1()
{
# DietPi-Services cleanup: https://dietpi.com/phpbb/viewtopic.php?p=42027#p42027
[[ -f '/dietpi-process_tool.conf' ]] && G_EXEC rm /dietpi-process_tool.conf
[[ -f '/dietpi-services_edit.conf' ]] && G_EXEC rm /dietpi-services_edit.conf
# RPi: Remove obsolete VCSM overlay since the device node has been removed
if (( $G_HW_MODEL < 10 ))
then
grep -q 'dtoverlay=dietpi-disable_vcsm' /boot/config.txt && G_EXEC sed -i '/dtoverlay=dietpi-disable_vcsm/d' /boot/config.txt
[[ -f '/boot/overlays/dietpi-disable_vcsm.dtbo' ]] && G_EXEC rm /boot/overlays/dietpi-disable_vcsm.dtbo
fi
# RPi: Fix MATE install: https://github.com/MichaIng/DietPi/issues/5214
[[ $G_HW_MODEL -le 9 && -f '/etc/apt/preferences.d/dietpi-lxde' ]] && cat << '_EOF_' > /etc/apt/preferences.d/dietpi-lxde
Package: openbox* obconf* libob* pcmanfm* libfm* gtk-* libgtk* libgail* gir1.2-gtk-3.0 lx*
Pin: origin archive.raspberrypi.org
Pin-Priority: -1
_EOF_
# Odroid C2 mainline image: Remove obsolete IRQ affinity: https://github.com/MichaIng/DietPi/issues/5235
[[ $G_HW_MODEL == 12 && -f '/var/lib/dietpi/postboot.d/c2_smp.sh' ]] && ! grep -q '^[[:blank:]]*63:.*dwc_otg' /proc/interrupts && G_EXEC rm /var/lib/dietpi/postboot.d/c2_smp.sh
# Fix Home Assistant restart: https://dietpi.com/phpbb/viewtopic.php?t=10025
[[ -f '/etc/systemd/system/home-assistant.service' ]] && G_CONFIG_INJECT 'RestartForceExitStatus=100' 'RestartForceExitStatus=100' /etc/systemd/system/home-assistant.service '\[Service\]'
}
Patch_8_2()
{
# Remove obsolete quotation from armbianEnv.txt
[[ -f '/boot/armbianEnv.txt' ]] && grep -q '^[[:blank:]]*extraargs="' /boot/armbianEnv.txt && G_EXEC sed -i -e 's/^[[:blank:]]*extraargs="[[:blank:]]*/extraargs=/' -e 's/[[:blank:]]*"[[:blank:]]*$//' /boot/armbianEnv.txt
# RPi: Remove multiple cgroup_enable=memory entries from cmdline.txt: https://github.com/MichaIng/DietPi/issues/5225#issuecomment-1033056312
[[ -f '/boot/cmdline.txt' ]] && while grep -q 'cgroup_enable=memory cgroup_enable=memory' /boot/cmdline.txt; do G_EXEC sed -i 's/cgroup_enable=memory cgroup_enable=memory/cgroup_enable=memory/g' /boot/cmdline.txt; done
# Apply cgroups-v2 workaround if the kernel does not support it: https://github.com/MichaIng/DietPi/issues/4705
# - This is required on Bullseye only, but we'll apply it on Buster as well to cover later distro upgrades, since the logic is too complicated for our upgrade blog article.
if dpkg --compare-versions "$(uname -r)" lt-nl 4.15
then
# Odroids
if [[ $G_HW_MODEL -gt 9 && $G_HW_MODEL -le 16 && -f '/boot/boot.ini' ]] && ! grep -q 'systemd.unified_cgroup_hierarchy=0' /boot/boot.ini
then
G_DIETPI-NOTIFY 2 'Forcing legacy cgroups v1 hierarchy on old kernel device'
G_EXEC sed -i '/^setenv bootargs "/s/"$/ systemd.unified_cgroup_hierarchy=0"/' /boot/boot.ini
# Sparky SBC
elif [[ $G_HW_MODEL == 70 && -f '/boot/uenv.txt' ]] && ! grep -q 'systemd.unified_cgroup_hierarchy=0' /boot/uenv.txt
then
G_DIETPI-NOTIFY 2 'Forcing legacy cgroups v1 hierarchy on old kernel device'
G_EXEC sed -i '/^bootargs=/s/$/ systemd.unified_cgroup_hierarchy=0/' /boot/uenv.txt
# ROCK Pi S
elif [[ $G_HW_MODEL == 73 && -f '/boot/boot.cmd' ]] && ! grep -q 'systemd.unified_cgroup_hierarchy=0' /boot/boot.cmd
then
G_DIETPI-NOTIFY 2 'Forcing legacy cgroups v1 hierarchy on old kernel device'
G_EXEC sed -i '/^setenv bootargs "/s/"$/ systemd.unified_cgroup_hierarchy=0"/' /boot/boot.cmd
G_AG_CHECK_INSTALL_PREREQ u-boot-tools
G_EXEC mkimage -C none -A arm64 -T script -d /boot/boot.cmd /boot/boot.scr
fi
fi
# Remove legacy PINE A64 patches from mainline kernel systems
if [[ $G_HW_MODEL == 40 && $(uname -r) == '5'* ]]
then
[[ -f '/etc/bashrc.d/dietpi-pine64-cursorfix.sh' ]] && G_EXEC rm /etc/bashrc.d/dietpi-pine64-cursorfix.sh
grep -q '^8723bs$' /etc/modules && G_EXEC sed -i '/^8723bs$/d' /etc/modules
fi
# Remove and migrate Chromium config files
[[ $G_HW_MODEL -gt 9 && -f '/root/.chromium-browser.init' ]] && G_EXEC rm /root/.chromium-browser.init
if [[ $G_DISTRO == 5 && $G_HW_MODEL -le 9 && -d '/etc/chromium.d' && -d '/etc/chromium-browser/customizations' ]]
then
[[ -f '/etc/chromium.d/custom_flags' ]] && G_EXEC mv /etc/{chromium.d/custom_flags,chromium-browser/customizations/dietpi}
G_EXEC rm -R /etc/chromium.d
fi
[[ -f '/etc/chromium.d/custom_flags' ]] && G_EXEC mv /etc/chromium.d/{custom_flags,dietpi}
# Remove obsolete Nvidia install state
[[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[151\]=' /boot/dietpi/.installed && G_EXEC sed -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[151\]=/d' /boot/dietpi/.installed
# Deluge: Apply autoconnect for web interface
if [[ -f '/mnt/dietpi_userdata/deluge/.config/deluge/hostlist.conf' && -f '/mnt/dietpi_userdata/deluge/.config/deluge/web.conf' ]] && grep -q '"default_daemon": "",' /mnt/dietpi_userdata/deluge/.config/deluge/web.conf
then
local id=$(mawk -F\" '/"[0-9a-f]+",/{print $2;exit}' /mnt/dietpi_userdata/deluge/.config/deluge/hostlist.conf)
G_CONFIG_INJECT '"default_daemon":' " \"default_daemon\": \"$id\"," /mnt/dietpi_userdata/deluge/.config/deluge/web.conf
fi
}
Patch_8_3(){ :; }
Patch_8_4()
{
# https://dietpi.com/phpbb/viewtopic.php?t=10229
if [[ -f '/boot/armbianEnv.txt' ]] && grep -q 'extraargs="net.ifnames=0"' /boot/armbianEnv.txt
then
G_DIETPI-NOTIFY 2 'Fixing syntax for legacy network interface nameing (eth0/wlan0). \e[33mNB: If you rely on "predictable" interface naming (enp0s0/wlp0s0), remove "net.ifnames=0" from /boot/armbianEnv.txt!'
G_EXEC sed -i 's/extraargs="net.ifnames=0"/extraargs=net.ifnames=0/' /boot/armbianEnv.txt
fi
# Update workaround for numpy on ARMv6/7 Buster
(( $G_HW_ARCH < 3 && $G_DISTRO == 5 )) && [[ -f '/etc/pip-constraints.txt' ]] && G_EXEC sed -i '/^numpy!=1.21.5; python_version=='\''3.7'\''$/c\numpy<1.21.5; python_version=='\''3.7'\' /etc/pip-constraints.txt
# https://github.com/MichaIng/DietPi/issues/5441
if [[ -f '/etc/sudoers.d/dietpi' ]]
then
G_DIETPI-NOTIFY 2 'Hardening /etc/sudoers.d/dietpi permissions'
G_EXEC chmod 0440 /etc/sudoers.d/dietpi
fi
# Remove obsolete software preference indices
[[ -f '/boot/dietpi/.installed' ]] && G_EXEC sed -Ei '/^[[:blank:]]*INDEX_(WEBSERVER|DESKTOP|BROWSER)=/d' /boot/dietpi/.installed
# Remove obsolete license file and setting
[[ -f '/var/lib/dietpi/license.txt' ]] && G_EXEC rm /var/lib/dietpi/license.txt
G_EXEC sed -i '/^[[:blank:]]*AUTO_SETUP_ACCEPT_LICENSE=/d' /boot/dietpi.txt
# Update DietPi initramfs cleanup script, following reasonable changes done by Armbian
if [[ -f '/etc/kernel/preinst.d/dietpi-initramfs_cleanup' ]]
then
G_EXEC mkdir -p /etc/kernel/post{inst,rm}.d
G_EXEC curl -sSfL "https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.build/images/U-Boot/dietpi-initramfs_cleanup" -o /etc/kernel/postinst.d/dietpi-initramfs_cleanup
G_EXEC chmod +x /etc/kernel/postinst.d/dietpi-initramfs_cleanup
G_EXEC ln -sf /etc/kernel/post{inst,rm}.d/dietpi-initramfs_cleanup
G_EXEC rm /etc/kernel/preinst.d/dietpi-initramfs_cleanup
G_EXEC rmdir --ignore-fail-on-non-empty /etc/kernel/preinst.d
fi
# https://github.com/MichaIng/DietPi/issues/4710
if (( $G_HW_ARCH == 2 )) && dpkg-query -s haveged &> /dev/null
then
G_DIETPI-NOTIFY 2 'Applying workaround for haveged entropy daemon bug: https://bugs.debian.org/985196'
[[ -d '/etc/systemd/system/haveged.service.d' ]] || G_EXEC mkdir /etc/systemd/system/haveged.service.d
G_EXEC eval 'echo -e '\''[Service]\nSystemCallFilter=uname'\'' > /etc/systemd/system/haveged.service.d/dietpi.conf'
G_EXEC systemctl daemon-reload
G_EXEC systemctl restart haveged
fi
# Remove obsolete OpenBazaar install state
[[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[58\]=' /boot/dietpi/.installed && G_EXEC sed -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[58\]=/d' /boot/dietpi/.installed
}
Patch_8_5(){ :; }
Patch_8_6(){ :; }
Patch_8_7()
{
# https://github.com/MichaIng/DietPi/issues/5594
if [[ -f '/boot/dietpi/.installed' && -f '/etc/systemd/system/webmin.service' && -f '/lib/systemd/system/webmin.service' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[115\]=2' /boot/dietpi/.installed
then
G_DIETPI-NOTIFY 2 'Removing conflicting Webmin systemd service...'
G_EXEC rm /etc/systemd/system/webmin.service
fi
# https://github.com/MichaIng/DietPi/issues/5602
if [[ $G_HW_ARCH == 1 && -f '/etc/apt/sources.list.d/raspotify.list' ]]
then
G_DIETPI-NOTIFY 2 'Downgrading Raspotify to the last version supported on your ARMv6 SBC...'
# Remove repo if present and remove package to avoid downgrade error
G_EXEC rm /etc/apt/sources.list.d/raspotify.list
[[ -f '/etc/apt/trusted.gpg.d/dietpi-raspotify.gpg' ]] && G_EXEC rm /etc/apt/trusted.gpg.d/dietpi-raspotify.gpg
G_AGUP
if dpkg-query -s raspotify &> /dev/null
then
G_EXEC dpkg -r raspotify
G_EXEC curl -fL 'https://github.com/dtcooper/raspotify/releases/download/0.31.8.1/raspotify_0.31.8.1.librespot.v0.3.1-54-gf4be9bb_armhf.deb' -o raspotify.deb
G_AGI ./raspotify.deb
G_EXEC rm raspotify.deb
fi
fi
# https://github.com/MichaIng/DietPi/pull/5600
(( $G_HW_MODEL > 9 )) || while grep -q 'cgroup_enable=memory.* cgroup_enable=memory' /boot/cmdline.txt
do
G_DIETPI-NOTIFY 2 'Removing duplicate "cgroup_enable=memory" kernel command-line argument...'
G_EXEC sed -i 's/ cgroup_enable=memory//' /boot/cmdline.txt
done
}
Patch_8_8(){ :; }
Patch_8_9()
{
# https://github.com/MichaIng/DietPi/issues/5734
if (( $G_HW_MODEL < 10 )) && dpkg-query -s raspberrypi-sys-mods &> /dev/null
then
G_EXEC curl -sSfO 'https://dietpi.com/downloads/binaries/raspberrypi-sys-mods.deb'
G_EXEC dpkg -i ./raspberrypi-sys-mods.deb
G_EXEC rm raspberrypi-sys-mods.deb
local i apackages
mapfile -t apackages < <(dpkg-query -Wf '${Conffiles}' raspberrypi-sys-mods | mawk '{print $1}')
for i in "${apackages[@]}"; do G_EXEC rm "$i"; done
fi
# Update ssh.dietpi.com known hosts entry: Allow port 29248 only and use Ed25519 host key from Bookworm on
if [[ -f '/root/.ssh/known_hosts' ]] && grep -Eq '^\[?ssh.dietpi.com(]:29248)?[[:blank:]]' /root/.ssh/known_hosts
then
if (( $G_DISTRO < 7 ))
then
G_CONFIG_INJECT '\[?ssh.dietpi.com(]:29248)?[[:blank:]]' '[ssh.dietpi.com]:29248 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDE6aw3r6aOEqendNu376iiCHr9tGBIWPgfrLkzjXjEsHGyVSUFNnZt6pftrDeK7UX+qX4FxOwQlugG4fymOHbimRCFiv6cf7VpYg1Ednquq9TLb7/cIIbX8a6AuRmX4fjdGuqwmBq3OG7ZksFcYEFKt5U4mAJIaL8hXiM2iXjgY02LqiQY/QWATsHI4ie9ZOnwrQE+Rr6mASN1BVFuIgyHIbwX54jsFSnZ/7CdBMkuAd9B8JkxppWVYpYIFHE9oWNfjh/epdK8yv9Oo6r0w5Rb+4qaAc5g+RAaknHeV6Gp75d2lxBdCm5XknKKbGma2+/DfoE8WZTSgzXrYcRlStYN' /root/.ssh/known_hosts
else
G_CONFIG_INJECT '\[?ssh.dietpi.com(]:29248)?[[:blank:]]' '[ssh.dietpi.com]:29248 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJdEPlagpQ+RVHNOX3jkG1Bya7Oza1dAke8h8NszVW84' /root/.ssh/known_hosts
fi
fi
# Remove obsolete Coturn settings, which were applied by dietpi-software from Buster-backports on
if [[ -f '/etc/turnserver.conf' && -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[168\]=2' /boot/dietpi/.installed
then
G_DIETPI-NOTIFY 2 'Removing obsolete Coturn settings...'
grep -q '^[[:blank:]]*use-auth-secret' /etc/turnserver.conf && grep -q '^[[:blank:]]*lt-cred-mech' /etc/turnserver.conf && G_EXEC sed -i 's/^[[:blank:]]*lt-cred-mech/#lt-cred-mech/' /etc/turnserver.conf
grep -q '^[[:blank:]]*no-loopback-peers' /etc/turnserver.conf && G_EXEC sed -i -e '/^[[:blank:]]*no-loopback-peers/d' -e 's/^[[:blank:]]*allow-loopback-peers/#allow-loopback-peers/' /etc/turnserver.conf
fi
}
Patch_8_10()
{
# Inform about available software updates and do needed migrations
if [[ -f '/boot/dietpi/.installed' ]]
then
# Home Assistant
grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[157\]=2' /boot/dietpi/.installed && G_WHIP_MSG '[ INFO ] HACS integration for Home Assistant available
\nThe Home Assistant Community Store (HACS) is now installed by default with Home Assistant. Add it via reinstall:
# dietpi-software reinstall 157
\nTo activate it, follow this guide: https://hacs.xyz/docs/configuration/basic/'
# GMediaRender
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[163\]=2' /boot/dietpi/.installed
then
if [[ -f '/etc/systemd/system/gmrender.service' ]]
then
G_EXEC systemctl unmask gmrender
G_EXEC systemctl disable --now gmrender
G_EXEC mv /etc/systemd/system/gm{,edia}render.service
fi
[[ -d '/etc/systemd/system/gmrender.service.d' ]] && G_EXEC mv /etc/systemd/system/gm{,edia}render.service.d
fi
fi
if [[ -f '/etc/kernel/postinst.d/dietpi-initramfs_cleanup' && ! -x '/etc/kernel/postinst.d/dietpi-initramfs_cleanup' ]]
then
G_DIETPI-NOTIFY 2 'Fixing and applying initramfs cleanup'
G_EXEC chmod +x /etc/kernel/postinst.d/dietpi-initramfs_cleanup
[[ -d '/etc/kernel/postrm.d' ]] || G_EXEC mkdir /etc/kernel/postrm.d
G_EXEC ln -sf /etc/kernel/post{inst,rm}.d/dietpi-initramfs_cleanup
/etc/kernel/postinst.d/dietpi-initramfs_cleanup
fi
}
Patch_8_11()
{
# Armbian mirror director now correctly handles HTTPS requests
if [[ -f '/etc/apt/sources.list.d/armbian.list' ]] && grep -q 'http://apt.armbian.com' /etc/apt/sources.list.d/armbian.list
then
G_DIETPI-NOTIFY 2 'Connecting to apt.armbian.com via secure HTTPS since their router now handles HTTPS redirects reliably'
G_EXEC sed -i 's|http://apt.armbian.com|https://apt.armbian.com|' /etc/apt/sources.list.d/armbian.list
fi
if [[ -f '/etc/apt/sources.list.d/dietpi-armbian.list' ]] && grep -q 'http://apt.armbian.com' /etc/apt/sources.list.d/dietpi-armbian.list
then
G_DIETPI-NOTIFY 2 'Connecting to apt.armbian.com via secure HTTPS since their router now handles HTTPS redirects reliably'
G_EXEC sed -i 's|http://apt.armbian.com|https://apt.armbian.com|' /etc/apt/sources.list.d/dietpi-armbian.list
fi
if (( $G_HW_MODEL == 56 ))
then
# Revert https://forum.armbian.com/topic/20133-nanopi-neo3-dtb-gone-since-linux-dtb-current-rockchip64-22021/ since dtb is available again
if [[ -f '/boot/dtb/rockchip/rk3328-nanopi-neo3-rev02.dtb' ]] && grep -q 'rk3328-nanopi-r2-rev00.dtb' /boot/armbianEnv.txt
then
G_DIETPI-NOTIFY 2 'Switching back to NEO3 device tree, which is available again'
G_EXEC sed -i 's/rk3328-nanopi-r2-rev00.dtb/rk3328-nanopi-neo3-rev02.dtb/' /boot/armbianEnv.txt
fi
fi
# https://gitlab.xfce.org/xfce/thunar/-/issues/50
if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[25\]=2' /boot/dietpi/.installed
then
G_DIETPI-NOTIFY 2 'Adding execute bit to our default desktop launchers/icons'
local adesktop_items=()
for i in 'opentyrian' 'kodi' 'steam' 'dxx-rebirth' 'chromium' 'chromium-browser' 'htop' 'codium' 'dietpi-launcher' 'dietpi-software' 'dietpi-config'
do
[[ -f /usr/share/applications/$i.desktop ]] && adesktop_items+=("/usr/share/applications/$i.desktop")
done
G_EXEC chmod +x "${adesktop_items[@]}"
fi
if (( $G_HW_MODEL == 76 ))
then
[[ -f '/etc/modules-load.d/dietpi-nanopi5.conf' ]] && G_EXEC mv /etc/modules-load.d/dietpi-{nanopi5,eth-leds}.conf
[[ -f '/etc/udev/rules.d/dietpi-nanopi5.rules' ]] && G_EXEC mv /etc/udev/rules.d/dietpi-{nanopi5,eth-leds}.rules
elif (( $G_HW_MODEL == 52 ))
then
# https://github.com/MichaIng/DietPi/issues/5554
grep -q 'systemd.unified_cgroup_hierarchy=0' /boot/armbianEnv.txt || G_EXEC sed -i '/^extraargs=/s/$/ systemd.unified_cgroup_hierarchy=0/' /boot/armbianEnv.txt
fi
# https://github.com/MichaIng/DietPi/issues/5830
[[ -f '/var/lib/dietpi/dietpi-ddns/update.sh' ]] && grep -q '^curl -6or4' /var/lib/dietpi/dietpi-ddns/update.sh && G_EXEC sed -i 's/^curl -6or4/curl/' /var/lib/dietpi/dietpi-ddns/update.sh
[[ -f '/etc/dpkg/dpkg.cfg.d/01-dietpi-exclude_doubled_devicetrees' ]] && G_EXEC_DESC='Removing obsolete DPKG exclude' G_EXEC rm /etc/dpkg/dpkg.cfg.d/01-dietpi-exclude_doubled_devicetrees
}
Patch_8_12()
{
# Remove obsolete Coturn logging change
[[ -f '/etc/systemd/system/coturn.service.d/dietpi-logging.conf' ]] && G_EXEC rm /etc/systemd/system/coturn.service.d/dietpi-logging.conf
[[ -d '/etc/systemd/system/coturn.service.d' ]] && G_EXEC rmdir --ignore-fail-on-non-empty /etc/systemd/system/coturn.service.d
# Radxa Zero: Enable USB OTG OOTB: https://github.com/MichaIng/DietPi/issues/5931
if [[ $G_HW_MODEL == 74 && -f '/boot/dietpiEnv.txt' ]]
then
G_DIETPI-NOTIFY 2 'Enabling USB OTG mode on USB2/PWR port'
local unmark=1
dpkg-query -s device-tree-compiler &> /dev/null && unmark=0
G_AGI device-tree-compiler
[[ -d '/boot/overlay-user' ]] || G_EXEC mkdir /boot/overlay-user
cat << '_EOF_' > /boot/overlay-user/dietpi-usb-otg.dts
/dts-v1/;
/plugin/;
/ {
compatible = "radxa,zero", "amlogic,g12a";
fragment@0 {
target = <&usb>;
__overlay__ {
dr_mode = "otg";
};
};
};
_EOF_
G_EXEC dtc -I dts -O dtb -o /boot/overlay-user/dietpi-usb-otg.{dtbo,dts}
local current=$(sed -En '/^[[:blank:]]*user_overlays=/{s/^[[:blank:]]*user_overlays=//;s/(^|[[:blank:]]*)dietpi-usb-otg([[:blank:]]*|$)/ /g;s/(^ | $)//g;p;q}' /boot/dietpiEnv.txt)
G_CONFIG_INJECT 'user_overlays=' "user_overlays=dietpi-usb-otg $current" /boot/dietpiEnv.txt
(( $unmark )) && G_EXEC apt-mark auto device-tree-compiler
fi
# Odroid C2: Fix USB device detection: https://github.com/MichaIng/DietPi/issues/5963
if [[ $G_HW_MODEL == 12 && -f '/boot/boot.cmd' ]] && ! grep -q 'usbcore.autosuspend=-1' /boot/boot.cmd
then
G_DIETPI-NOTIFY 2 'Fixing USB device detection on Odroid C2'
G_EXEC sed -i 's/coherent_pool=2M/coherent_pool=2M usbcore.autosuspend=-1/' /boot/boot.cmd
G_EXEC mkimage -C none -A arm64 -T script -d /boot/boot.cmd /boot/boot.scr
fi
# Inform about available software updates
if [[ -f '/boot/dietpi/.installed' ]]
then
# Shairport Sync
grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[37\]=2' /boot/dietpi/.installed && G_WHIP_MSG '[ INFO ] Shairport Sync update available
\nAn update to Shairport Sync v4.1.1 is available with support for "pipe" and "stdout" audio backends added. Apply it via reinstall:
# dietpi-software reinstall 37
\nRelease notes: https://github.com/mikebrady/shairport-sync/releases/tag/4.1.1'
fi
}
Patch_8_13(){ :; }
Patch_8_14()
{
if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[89\]=2' /boot/dietpi/.installed && [[ -f '/var/www/apc.php' || -f '/var/www/opcache.php' || -f '/var/www/phpinfo.php' ]]
then
G_WHIP_BUTTON_CANCEL_TEXT='Keep' G_WHIP_BUTTON_OK_TEXT='Remove' G_WHIP_DEFAULT_ITEM='yes' G_WHIP_YESNO 'Removing PHP info pages
\nWe used to install the PHP info pages apc.php, opcache.php and phpinfo.php into the webroot out-of-the-box with PHP. However, these pages provide too much information about your PHP environment and backend applications to be publicly accessible, especially without your explicit consent.
\nWe do hence recommend to remove these files if you do not actively use them to analyse your PHP setup and cache configuration, especiallly when your webserver is reachable from the Internet.
\nShall we remove these pages now?
\nYou can do this manually any time later:
# rm /var/www/apc.php /var/www/opcache.php /var/www/phpinfo.php' && G_EXEC rm -f /var/www/{apc,opcache,phpinfo}.php
fi
if dpkg-query -s wireless-regdb &> /dev/null
then
G_EXEC apt-mark manual wireless-regdb
if (( $G_DISTRO > 5 ))
then
G_EXEC update-alternatives --set regulatory.db /lib/firmware/regulatory.db-upstream
(( $G_DISTRO > 6 )) || { dpkg-query -s crda &> /dev/null && dpkg --compare-versions "$(uname -r)" ge 4.15 && G_WHIP_BUTTON_CANCEL_TEXT='Keep' G_WHIP_BUTTON_OK_TEXT='Remove' G_WHIP_DEFAULT_ITEM='yes' G_WHIP_YESNO 'Removing obsolete CRDA package
\nFrom Debian Bullseye on since Linux 4.15, the CRDA package to inform the kernel about WiFi country code changes is obsolete. The kernel is now able to load this data directly without the help of CRDA.
More info: https://bugs.debian.org/1003903
\nShall we remove this package now?
\nYou can do this manually any time later:
# apt autopurge crda'; } && G_AGP crda
fi
fi
# NanoPi R2S/NEO3
if [[ $G_HW_MODEL == 5[56] && ! -f '/etc/modprobe.d/dietpi-headless.conf' ]]
then
G_DIETPI-NOTIFY 2 'Blacklisting video related kernel modules'
cat << '_EOF_' > /etc/modprobe.d/dietpi-headless.conf
blacklist hantro_vpu
blacklist lima
blacklist rockchip_iep
blacklist rockchip_rga
blacklist rockchip_vdec
_EOF_
G_EXEC_OUTPUT=1 G_EXEC update-initramfs -u
fi
}
Patch_8_15()
{
if (( $G_HW_MODEL == 49 ))
then
if ! dpkg-query -s 'haveged' &> /dev/null
then
G_DIETPI-NOTIFY 2 'Installing correct entropy daemon on Quartz64'
G_AGI haveged
G_AGP rng-tools5
fi
# Revert with new kernel: https://github.com/MichaIng/DietPi/issues/5890
grep -q ' systemd.unified_cgroup_hierarchy=0' /boot/extlinux/extlinux.conf && G_EXEC sed -i '/^append /s/ systemd.unified_cgroup_hierarchy=0//' /boot/extlinux/extlinux.conf
fi
(( $G_DISTRO > 6 )) || for i in '/etc/systemd/system/serial-getty@'*'.service.d/dietpi-baudrate.conf'
do
[[ -f $i ]] || break
G_DIETPI-NOTIFY 2 "Fixing $i"
cat << _EOF_ > "$i"
[Service]
ExecStart=
$(sed -n '/^ExecStart=/s/ 115200/ 1500000,115200/p' '/lib/systemd/system/serial-getty@.service')
_EOF_
done
if [[ -f '/boot/dietpi/.installed' ]]
then
# WiFi Hotspot: https://github.com/MichaIng/DietPi/issues/6166
grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[60\]=2' /boot/dietpi/.installed && G_EXEC systemctl enable hostapd isc-dhcp-server
# Remove obsolete Build-Essential install state
grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[16\]=' /boot/dietpi/.installed && G_EXEC sed -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[16\]=/d' /boot/dietpi/.installed
# Remove obsolete CAVA console font
grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[119\]=' /boot/dietpi/.installed && G_EXEC rm -f /{root,home/*}/cava.psf
fi
}
Patch_8_16()
{
if [[ $G_HW_MODEL =~ ^78|80$ && -f '/boot/dietpiEnv.txt' ]]
then
if systemctl -q is-enabled 'serial-getty@ttyS2'
then
G_DIETPI-NOTIFY 2 'Fixing UART console on ttyFIQ0 instead of ttyS2'
G_EXEC sed -i '/^consoleargs=console=ttyS2,1500000 console=tty1$/c\consoleargs=console=ttyFIQ0,1500000 console=tty1' /boot/dietpiEnv.txt
/boot/dietpi/func/dietpi-set_hardware serialconsole disable ttyS2
/boot/dietpi/func/dietpi-set_hardware serialconsole enable ttyFIQ0