-
-
Notifications
You must be signed in to change notification settings - Fork 553
Expand file tree
/
Copy pathpatches
More file actions
executable file
·2497 lines (2270 loc) · 131 KB
/
patches
File metadata and controls
executable file
·2497 lines (2270 loc) · 131 KB
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
# shellcheck disable=SC2329
{
# 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
# 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
# ToDo: On RPi 4, the 64-bit kernel is now used by default, without "arm_64bit=1" set: https://forums.raspberrypi.com/viewtopic.php?p=2088935#p2088935
# - We could set "arm_64bit=0", but for now lets assure that 32-bit software is installed and see how it goes. This enables general support for RPi with 64-bit kernel running 32-bit userland.
# shellcheck disable=SC2034
[[ $G_HW_MODEL == [2-9] && $G_HW_ARCH == 3 && $(dpkg --print-architecture) == 'armhf' ]] && G_HW_ARCH=2 G_HW_ARCH_NAME='armv7l'
# Version-based incremental patches
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 --follow-symlinks -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 --follow-symlinks -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 --follow-symlinks -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 --follow-symlinks -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
# 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 --follow-symlinks -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 --follow-symlinks -i 's/cgroup_enable=memory cgroup_enable=memory/cgroup_enable=memory/g' /boot/cmdline.txt; done
# Remove legacy PINE A64 patches from mainline kernel systems
if (( $G_HW_MODEL == 40 ))
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 --follow-symlinks -i '/^8723bs$/d' /etc/modules
fi
# Migrate Chromium config file
[[ -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 --follow-symlinks -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 --follow-symlinks -i 's/extraargs="net.ifnames=0"/extraargs=net.ifnames=0/' /boot/armbianEnv.txt
fi
# 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 --follow-symlinks -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 --follow-symlinks -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'
G_EXEC mkdir -p /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 --follow-symlinks -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
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 --follow-symlinks -i 's/ cgroup_enable=memory//' /boot/cmdline.txt
done
# vaultwarden
if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[183\]=2' /boot/dietpi/.installed && dpkg --compare-versions "$(dpkg-query -Wf '${Version}' vaultwarden 2> /dev/null)" lt 1.30.5-dietpi1
then
# Pre-v8.7 cleanup
[[ -f '/opt/vaultwarden/target/release/vaultwarden' ]] && G_EXEC rm -R /opt/vaultwarden
[[ -f '/etc/systemd/system/vaultwarden.service' ]] && G_EXEC rm /etc/systemd/system/vaultwarden.service
G_DIETPI-NOTIFY 2 'Updating vaultwarden package ...'
G_EXEC_OUTPUT=1 G_EXEC curl -fo package.deb "https://dietpi.com/downloads/binaries/$G_DISTRO_NAME/vaultwarden_$G_HW_ARCH_NAME.deb"
G_AGI ./package.deb
G_EXEC rm package.deb
fi
}
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
G_CONFIG_INJECT '\[?ssh.dietpi.com(]:29248)?[[:blank:]]' '[ssh.dietpi.com]:29248 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJdEPlagpQ+RVHNOX3jkG1Bya7Oza1dAke8h8NszVW84' /root/.ssh/known_hosts
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 --follow-symlinks -i 's/^[[:blank:]]*lt-cred-mech/#lt-cred-mech/' /etc/turnserver.conf
grep -q '^[[:blank:]]*no-loopback-peers' /etc/turnserver.conf && G_EXEC sed --follow-symlinks -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/use/configuration/basic/#to-set-up-the-hacs-integration'
# 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()
{
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 --follow-symlinks -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 --follow-symlinks -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 --follow-symlinks -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 --follow-symlinks -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
}
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_DIETPI-NOTIFY 2 'Configuring regulatory database and purging CRDA if installed'
G_EXEC apt-mark manual wireless-regdb
G_EXEC update-alternatives --set regulatory.db /lib/firmware/regulatory.db-upstream
G_AGP crda
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
G_DIETPI-NOTIFY 2 'Removing obsolete entropy daemon'
G_AGP haveged rng-tools5
[[ -d '/etc/systemd/system/haveged.service.d' ]] || G_EXEC rm -R /etc/systemd/system/haveged.service.d
# 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 --follow-symlinks -i '/^append /s/ systemd.unified_cgroup_hierarchy=0//' /boot/extlinux/extlinux.conf
fi
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 --follow-symlinks -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 --follow-symlinks -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
fi
if dpkg-query -s 'haveged' &> /dev/null
then
G_DIETPI-NOTIFY 2 'Removing obsolete entropy daemon'
G_AGP haveged
[[ -d '/etc/systemd/system/haveged.service.d' ]] || G_EXEC rm -R /etc/systemd/system/haveged.service.d
fi
elif (( $G_HW_MODEL == 81 )) && dpkg --compare-versions "$(dpkg-query -Wf '${Version}' linux-image-visionfive2 2> /dev/null)" lt-nl 5.15.105-dietpi1
then
G_EXEC systemctl unmask serial-getty@hvc0
fi
# Migrate DietPi controlled services to be started by systemd
if [[ -f '/boot/dietpi/.installed' ]]
then
G_WHIP_MSG '[ INFO ] DietPi-Services rework
\nWe reworked the way how services installed via dietpi-software are started at boot. This is now done by systemd itself instead of dietpi-services to enable parallelism and address some longstanding issues and confusion caused by this DietPi-specific behaviour. The previous "dietpi_controlled" vs "systemd_controlled" differenciation is hence history.
\nTo stop services from being autostarted at boot, you can now run "systemctl disable servicename", to enable its autostart: "systemctl enable servicename".
\nTo preserve some of the service ordering benefits from the previous behaviour, some systemd units will now be configured to make use of native systemd unit ordering.'
# PHP version
case $G_DISTRO in
7) local PHP_VERSION='8.2';;
*) local PHP_VERSION='8.4';;
esac
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[83\]=2' /boot/dietpi/.installed
then
G_EXEC mkdir -p /etc/systemd/system/apache2.service.d
G_EXEC eval "echo -e '[Unit]\nAfter=php$PHP_VERSION-fpm.service' > /etc/systemd/system/apache2.service.d/dietpi.conf"
fi
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[85\]=2' /boot/dietpi/.installed
then
G_EXEC mkdir -p /etc/systemd/system/nginx.service.d
G_EXEC eval "echo -e '[Unit]\nAfter=php$PHP_VERSION-fpm.service' > /etc/systemd/system/nginx.service.d/dietpi.conf"
fi
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[84\]=2' /boot/dietpi/.installed
then
G_EXEC mkdir -p /etc/systemd/system/lighttpd.service.d
G_EXEC eval "echo -e '[Unit]\nAfter=php$PHP_VERSION-fpm.service' > /etc/systemd/system/lighttpd.service.d/dietpi.conf"
fi
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[88\]=2' /boot/dietpi/.installed
then
G_EXEC mkdir -p /etc/systemd/system/mariadb.service.d
G_EXEC eval 'echo -e '\''[Unit]\nBefore=cron.service'\'' > /etc/systemd/system/mariadb.service.d/dietpi.conf'
fi
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[91\]=2' /boot/dietpi/.installed
then
G_EXEC mkdir -p /etc/systemd/system/redis-server.service.d
G_EXEC eval 'echo -e '\''[Unit]\nBefore=cron.service'\'' > /etc/systemd/system/redis-server.service.d/dietpi.conf'
fi
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[89\]=2' /boot/dietpi/.installed
then
G_EXEC mkdir -p "/etc/systemd/system/php$PHP_VERSION-fpm.service.d"
G_EXEC eval "echo -e '[Unit]\nAfter=redis-server.service mariadb.service postgresql.service' > '/etc/systemd/system/php$PHP_VERSION-fpm.service.d/dietpi.conf'"
fi
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[45\]=2' /boot/dietpi/.installed
then
G_CONFIG_INJECT 'Wants=' 'Wants=network-online.target' /etc/systemd/system/deluged.service '\[Unit\]'
G_CONFIG_INJECT 'After=' 'After=network-online.target remote-fs.target' /etc/systemd/system/deluged.service 'Wants='
G_CONFIG_INJECT 'After=' 'After=deluged.service' /etc/systemd/system/deluge-web.service '\[Unit\]'
fi
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[122\]=2' /boot/dietpi/.installed
then
G_CONFIG_INJECT 'Wants=' 'Wants=network-online.target' /etc/systemd/system/node-red.service '\[Unit\]'
G_CONFIG_INJECT 'After=' 'After=network-online.target' /etc/systemd/system/node-red.service 'Wants='
fi
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[52\]=2' /boot/dietpi/.installed
then
G_CONFIG_INJECT 'Wants=' 'Wants=network-online.target' /etc/systemd/system/cuberite.service '\[Unit\]'
G_CONFIG_INJECT 'After=' 'After=network-online.target' /etc/systemd/system/cuberite.service 'Wants='
fi
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[164\]=2' /boot/dietpi/.installed
then
G_CONFIG_INJECT 'Wants=' 'Wants=network-online.target' /etc/systemd/system/nukkit.service '\[Unit\]'
G_CONFIG_INJECT 'After=' 'After=network-online.target' /etc/systemd/system/nukkit.service 'Wants='
fi
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[181\]=2' /boot/dietpi/.installed
then
G_CONFIG_INJECT 'Wants=' 'Wants=network-online.target' /etc/systemd/system/papermc.service '\[Unit\]'
G_CONFIG_INJECT 'After=' 'After=network-online.target' /etc/systemd/system/papermc.service 'Wants='
fi
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[132\]=2' /boot/dietpi/.installed
then
G_CONFIG_INJECT 'Wants=' 'Wants=network-online.target' /etc/systemd/system/aria2.service '\[Unit\]'
G_CONFIG_INJECT 'After=' 'After=network-online.target remote-fs.target' /etc/systemd/system/aria2.service 'Wants='
fi
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[149\]=2' /boot/dietpi/.installed
then
G_CONFIG_INJECT 'Wants=' 'Wants=network-online.target' /etc/systemd/system/nzbget.service '\[Unit\]'
G_CONFIG_INJECT 'After=' 'After=network-online.target remote-fs.target' /etc/systemd/system/nzbget.service 'Wants='
fi
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[143\]=2' /boot/dietpi/.installed
then
G_CONFIG_INJECT 'After=' 'After=network-online.target mariadb.service' /etc/systemd/system/koel.service '\[Unit\]'
fi
# v8.16.-1 dev cleanup
[[ -f '/etc/systemd/system/cron.service.d/dietpi.conf' ]] && G_EXEC rm /etc/systemd/system/cron.service.d/dietpi.conf
[[ -d '/etc/systemd/system/cron.service.d' ]] && G_EXEC rmdir --ignore-fail-on-non-empty /etc/systemd/system/cron.service.d
/boot/dietpi/dietpi-services enable
fi
# Remove custom mode from /var/log tmpfs mount. It has common 0755 by default, not sure why we change that.
grep -q '^tmpfs /var/log tmpfs .*,mode=1777$' /etc/fstab && G_EXEC sed --follow-symlinks -i '\|^tmpfs /var/log tmpfs |s|,mode=1777$||' /etc/fstab
# CONFIG_GPU_DRIVER Change: https://github.com/MichaIng/DietPi/issues/6262
if (( $G_HW_MODEL == 21 && $G_DIETPI_INSTALL_STAGE == 2 ))
then
if dpkg-query -s 'steam' &> /dev/null ||
dpkg-query -s 'i965-va-driver' &> /dev/null ||
dpkg-query -s 'nvidia-driver' &> /dev/null ||
dpkg-query -s 'xserver-xorg-video-amdgpu' &> /dev/null
then
G_WHIP_MSG '[ INFO ] DietPi GPU driver installations have been reworked for x86 platforms.\n\nThis resolves issues with Vulkan, Steam and improves overall driver package installations.\n\nOn the next page you will be asked to select a GPU driver stack for this device. Once completed, select "Back" to resume the DietPi update.\n\nNB: If you have a custom GPU driver you have manually installed on this system, please select "Custom" from the next page. DietPi will then ignore changing GPU drivers on this system.'
/boot/dietpi/dietpi-config 2
fi
fi
# Remove image info if it is an official image from us
[[ -f '/boot/dietpi/.prep_info' && $(</boot/dietpi/.prep_info) == '0'$'\n''from scratch' ]] && G_EXEC rm /boot/dietpi/.prep_info
}
Patch_8_17()
{
# https://dietpi.com/forum/t/cron-service-is-masked/16544
[[ $(systemctl is-enabled cron) == 'masked' ]] && G_EXEC systemctl unmask cron
# RPi
if (( $G_HW_MODEL < 10 ))
then
# Patch onboard audio
[[ -f '/etc/modprobe.d/dietpi-disable_rpi_sound.conf' ]] && G_EXEC mv /etc/modprobe.d/dietpi-disable_rpi_{sound,audio}.conf
if grep -q '^[[:blank:]]*dtoverlay=dietpi-disable_hdmi_audio' /boot/config.txt
then
G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*dtoverlay=dietpi-disable_hdmi_audio/d' /boot/config.txt
G_EXEC sed --follow-symlinks -i '/root=/s/$/ snd_bcm2835.enable_hdmi=0/' /boot/cmdline.txt
fi
if grep -q '^[[:blank:]]*dtoverlay=dietpi-disable_headphones' /boot/config.txt
then
G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*dtoverlay=dietpi-disable_headphones/d' /boot/config.txt
G_EXEC sed --follow-symlinks -i '/root=/s/$/ snd_bcm2835.enable_headphones=0/' /boot/cmdline.txt
fi
[[ -f '/boot/overlays/dietpi-disable_hdmi_audio.dtbo' ]] && G_EXEC rm /boot/overlays/dietpi-disable_hdmi_audio.dtbo
[[ -f '/boot/overlays/dietpi-disable_headphones.dtbo' ]] && G_EXEC rm /boot/overlays/dietpi-disable_headphones.dtbo
# Remove deprecated rpivid-v4l2 overlay
if grep -q '^[[:blank:]]*dtoverlay=rpivid-v4l2$' /boot/config.txt
then
G_DIETPI-NOTIFY 2 'Removing deprecated device tree overlay: rpivid-v4l2'
G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*dtoverlay=rpivid-v4l2$/d' /boot/config.txt
fi
# NanoPi R2S
elif (( $G_HW_MODEL == 55 ))
then
G_DIETPI-NOTIFY 2 'Updating udev rule for NanoPi R2S Ethernet LEDs'
G_EXEC eval 'echo '\''ledtrig-netdev'\'' > /etc/modules-load.d/dietpi-eth-leds.conf'
cat << '_EOF_' > /etc/udev/rules.d/dietpi-eth-leds.rules
SUBSYSTEM=="leds", KERNEL=="wan_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth0", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s eth0 up", RUN+="/bin/ip l s eth0 down"
SUBSYSTEM=="leds", KERNEL=="lan_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth1", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s eth1 up", RUN+="/bin/ip l s eth1 down"
_EOF_
# NanoPi R5S/R5C
elif (( $G_HW_MODEL == 76 ))
then
local model='R5S'
[[ $(</proc/device-tree/model) == *'R5C'* ]] 2> /dev/null && model='R5C'
G_DIETPI-NOTIFY 2 "Updating udev rule for NanoPi $model Ethernet LEDs"
G_EXEC eval 'echo '\''ledtrig-netdev'\'' > /etc/modules-load.d/dietpi-eth-leds.conf'
if [[ $model == 'R5S' ]]
then
cat << '_EOF_' > /etc/udev/rules.d/dietpi-eth-leds.rules
SUBSYSTEM=="leds", KERNEL=="wan_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth0", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s eth0 up", RUN+="/bin/ip l s eth0 down"
SUBSYSTEM=="leds", KERNEL=="lan1_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth1", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s eth1 up", RUN+="/bin/ip l s eth1 down"
SUBSYSTEM=="leds", KERNEL=="lan2_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth2", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s eth2 up", RUN+="/bin/ip l s eth2 down"
_EOF_
else
cat << '_EOF_' > /etc/udev/rules.d/dietpi-eth-leds.rules
SUBSYSTEM=="leds", KERNEL=="wan_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth0", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s eth0 up", RUN+="/bin/ip l s eth0 down"
SUBSYSTEM=="leds", KERNEL=="lan1_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth1", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s eth1 up", RUN+="/bin/ip l s eth1 down"
_EOF_
fi
# NanoPi R6S/R6C
elif (( $G_HW_MODEL == 79 ))
then
local model='R6S'
[[ $(</proc/device-tree/model) == *'R6C'* ]] 2> /dev/null && model='R6C'
G_DIETPI-NOTIFY 2 "Updating udev rule for NanoPi $model Ethernet LEDs"
G_EXEC eval 'echo '\''ledtrig-netdev'\'' > /etc/modules-load.d/dietpi-eth-leds.conf'
if [[ $model == 'R6S' ]]
then
cat << '_EOF_' > /etc/udev/rules.d/dietpi-eth-leds.rules
SUBSYSTEM=="leds", KERNEL=="lan2_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth0", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s eth0 up", RUN+="/bin/ip l s eth0 down"
SUBSYSTEM=="leds", KERNEL=="lan1_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth1", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s eth1 up", RUN+="/bin/ip l s eth1 down"
SUBSYSTEM=="leds", KERNEL=="wan_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth2", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s eth2 up", RUN+="/bin/ip l s eth2 down"
_EOF_
else
cat << '_EOF_' > /etc/udev/rules.d/dietpi-eth-leds.rules
SUBSYSTEM=="leds", KERNEL=="wan_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth0", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s eth0 up", RUN+="/bin/ip l s eth0 down"
SUBSYSTEM=="leds", KERNEL=="lan1_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth1", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s eth1 up", RUN+="/bin/ip l s eth1 down"
_EOF_
fi
fi
}
Patch_8_18()
{
# Update Allo GUI
if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[160\]=2' /boot/dietpi/.installed
then
G_DIETPI-NOTIFY 2 'Preparing Allo GUI update to latest version'
getent passwd allo > /dev/null && G_EXEC userdel allo
# Pre-v14.0 database migration
if [[ -d '/mnt/dietpi_userdata/mysql/allo_db' ]] && G_EXEC_NOHALT=1 G_EXEC systemctl start mariadb
then
G_EXEC mysqladmin -f drop allo_db
[[ $(mysql -e 'select user from mysql.user where user="allo_db";') ]] && G_EXEC mysql -e 'drop user allo_db@localhost'
fi
# Beta v8.2.1
[[ -d '/mnt/dietpi_userdata/allo' ]] && G_EXEC rm -R /mnt/dietpi_userdata/allo
# Pre-v8.10
if [[ -f '/etc/systemd/system/gmrender.service.disable' ]]
then
# shellcheck disable=SC2015
[[ -f '/etc/systemd/system/gmediarender.service' || -f '/lib/systemd/system/gmediarender.service' ]] && G_EXEC rm /etc/systemd/system/gmrender.service.disable || G_EXEC mv /etc/systemd/system/gm{,edia}render.service.disable
fi
# Pre-v14.3/DietPi v8.16 service handling
local i
for i in roonbridge gmediarender netdata squeezelite
do
[[ -f /etc/systemd/system/$i.service.disable ]] && G_EXEC mv "/etc/systemd/system/$i.service"{.disable,} && G_EXEC systemctl disable "$i"
[[ -f /lib/systemd/system/$i.service.disable ]] && G_EXEC mv "/lib/systemd/system/$i.service"{.disable,} && G_EXEC systemctl disable "$i"
done
fi
}
Patch_8_19()
{
# Software updates and migrations
if [[ -f '/boot/dietpi/.installed' ]]
then
# Remove obsolete Spotify Connect Web and Firefox Sync Server install states
grep -Eq '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[(141|177)\]=' /boot/dietpi/.installed && G_EXEC sed --follow-symlinks -Ei '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[(141|177)\]=/d' /boot/dietpi/.installed
# Mopidy: Bullseye suite now available in official APT repo
[[ -f '/etc/apt/sources.list.d/mopidy.list' ]] && grep -q buster /etc/apt/sources.list.d/mopidy.list && G_EXEC sed --follow-symlinks -i 's/buster/bullseye/' /etc/apt/sources.list.d/mopidy.list
# ympd
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[32\]=2' /boot/dietpi/.installed
then
G_DIETPI-NOTIFY 2 'Preparing ympd update ...'
echo 32 >> /var/tmp/dietpi/dietpi-update_reinstalls
[[ -f '/etc/systemd/system/ympd.service' ]] && G_EXEC rm /etc/systemd/system/ympd.service
fi
fi
}
Patch_8_20()
{
# Software updates and migrations
if [[ -f '/boot/dietpi/.installed' ]]
then
# Set deprecated X-XSS-Protection header to 0
# - Apache
[[ -f '/etc/apache2/conf-available/dietpi.conf' ]] && G_EXEC sed --follow-symlinks -i '/^Header set X-XSS-Protection "/c\Header set X-XSS-Protection "0"' /etc/apache2/conf-available/dietpi.conf
# - ownCloud
[[ -f '/etc/nginx/sites-dietpi/dietpi-owncloud.conf' ]] && G_EXEC sed --follow-symlinks -i 's/add_header X-XSS-Protection "1; mode=block" always;/add_header X-XSS-Protection "0" always;/' /etc/nginx/sites-dietpi/dietpi-owncloud.conf
[[ -f '/etc/lighttpd/conf-available/99-dietpi-owncloud.conf' ]] && G_EXEC sed --follow-symlinks -i 's/"X-XSS-Protection" => "1; mode=block"/"X-XSS-Protection" => "0"/' /etc/lighttpd/conf-available/99-dietpi-owncloud.conf
# - Pi-hole
[[ -f '/etc/nginx/sites-dietpi/dietpi-pihole.conf' ]] && G_EXEC sed --follow-symlinks -i 's/add_header X-XSS-Protection "1; mode=block";/add_header X-XSS-Protection "0";/' /etc/nginx/sites-dietpi/dietpi-pihole.conf
[[ -f '/etc/lighttpd/conf-available/99-dietpi-pihole.conf' ]] && G_EXEC sed --follow-symlinks -i 's/"X-XSS-Protection" => "1; mode=block"/"X-XSS-Protection" => "0"/' /etc/lighttpd/conf-available/99-dietpi-pihole.conf
# DietPi-Dashboard: https://github.com/nonnorm/DietPi-Dashboard/releases/tag/v0.6.2
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[200\]=2' /boot/dietpi/.installed
then
G_DIETPI-NOTIFY 2 'Preparing DietPi-Dashboard update to fix CVE-2023-38505 DoS vulnerability ...'
G_EXEC eval 'echo 200 >> /var/tmp/dietpi/dietpi-update_reinstalls'
fi
fi
# Odroid N2: Assure that hardware random generator driver is loaded as early as possible to prevent rngd failures: https://github.com/MichaIng/DietPi/issues/6483
(( $G_HW_MODEL == 15 )) && G_EXEC eval 'echo '\''meson_rng'\'' > /etc/modules-load.d/dietpi-hwrng.conf'
}
Patch_8_21()
{
# Remove obsolete sysctl config
[[ -f '/etc/sysctl.d/dietpi.conf' ]] && G_EXEC rm /etc/sysctl.d/dietpi.conf
# Orange Pi 5/ROCK 5B: The "legacy-rockchip-rk3588" and "legacy-rk35xx" kernel families have been merged below the second name, hence migrate in case: https://github.com/armbian/build/pull/5362
if [[ $G_HW_MODEL =~ ^(78|80)$ ]] && dpkg-query -s 'linux-image-legacy-rockchip-rk3588' &> /dev/null
then
G_DIETPI-NOTIFY 2 'Updating RK3588 kernel package ...'
local apackages=('linux-image-legacy-rk35xx' 'linux-dtb-legacy-rk35xx')
dpkg-query -s 'linux-headers-legacy-rockchip-rk3588' &> /dev/null && apackages+=('linux-headers-legacy-rk35xx')
G_AGI "${apackages[@]}"
(( $G_HW_MODEL == 80 )) && G_CONFIG_INJECT 'overlay_prefix=' 'overlay_prefix=rk3588' /boot/dietpiEnv.txt && G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*fdtfile=/d' /boot/dietpiEnv.txt
G_EXEC apt-mark auto "${apackages[@]/rk35xx/rockchip-rk3588}"
fi
}
Patch_8_22()
{
# NanoPi R4S: Fix Ethernet LEDs: https://github.com/MichaIng/DietPi/issues/6342#issuecomment-1697669420
if (( $G_HW_MODEL == 47 ))
then
G_DIETPI-NOTIFY 2 'Updating udev rule for NanoPi R4S Ethernet LEDs'
G_EXEC eval 'echo '\''ledtrig-netdev'\'' > /etc/modules-load.d/dietpi-eth-leds.conf'
cat << '_EOF_' > /etc/udev/rules.d/dietpi-eth-leds.rules
SUBSYSTEM=="leds", KERNEL=="green:lan", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth0", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s eth0 up", RUN+="/bin/ip l s eth0 down"
SUBSYSTEM=="leds", KERNEL=="green:wan", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth1", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s eth1 up", RUN+="/bin/ip l s eth1 down"
_EOF_
# Orange Pi 5: Fix fdtfile entry
elif (( $G_HW_MODEL == 80 )) && grep -q '^fdtfile=$' /boot/dietpiEnv.txt
then
G_DIETPI-NOTIFY 2 'Fixing fdtfile entry in dietpiEnv.txt ...'
G_EXEC sed --follow-symlinks -i '/^fdtfile=$/d' /boot/dietpiEnv.txt
fi
}
Patch_8_23()
{
# VisionFive 2
if (( $G_HW_MODEL == 81 )) && dpkg --compare-versions "$(dpkg-query -Wf '${Version}' linux-image-visionfive2 2> /dev/null)" lt-nl 6.1.59-dietpi1
then
G_DIETPI-NOTIFY 2 'Updating RISC-V StarFive VisionFive 2 kernel ...'
G_EXEC_OUTPUT=1 G_EXEC curl -fo package.deb 'https://dietpi.com/downloads/binaries/linux-image-visionfive2.deb'
G_EXEC_OUTPUT=1 G_EXEC dpkg -i --force-confdef,confold package.deb
G_EXEC rm package.deb
local serial overlays=()
read -r serial < /proc/device-tree/serial-number
if [[ $serial == 'VF7110A1-'* ]]
then
G_DIETPI-NOTIFY 2 'A revision detected, applying device tree overlay to fix Ethernet ...'
read -ra overlays < <(mawk '$1=="fdtoverlays"{$1="";print}' /boot/extlinux/extlinux.conf)
local i=
for i in "${overlays[@]}"; do [[ $i == *'/ethernet-A12.dtbo' ]] && break; done
if [[ $i == *'/ethernet-A12.dtbo' ]]
then
G_DIETPI-NOTIFY 2 'A revision Ethernet overlay was applied already ...'
else
overlays+=('/usr/lib/linux-image-visionfive2/starfive/vf2-overlay/ethernet-A12.dtbo')
G_CONFIG_INJECT 'fdtoverlays[[:blank:]]' "fdtoverlays ${overlays[*]}" /boot/extlinux/extlinux.conf
fi
fi
if [[ $serial == *'-D008E000-'* ]]
then
G_DIETPI-NOTIFY 2 '8 GB RAM model detected, applying device tree overlay to make all 8 GB available to the system ...'
read -ra overlays < <(mawk '$1=="fdtoverlays"{$1="";print}' /boot/extlinux/extlinux.conf)
local i=
for i in "${overlays[@]}"; do [[ $i == *'/8GB.dtbo' ]] && break; done
if [[ $i == *'/8GB.dtbo' ]]
then
G_DIETPI-NOTIFY 2 '8 GB RAM overlay was applied already ...'
else
overlays+=('/usr/lib/linux-image-visionfive2/starfive/vf2-overlay/8GB.dtbo')
G_CONFIG_INJECT 'fdtoverlays[[:blank:]]' "fdtoverlays ${overlays[*]}" /boot/extlinux/extlinux.conf
fi
fi
G_AGI libubootenv-tool
G_WHIP_MSG '[ INFO ] VisionFive 2 U-Boot environment and boot priorities
\nThe latest StarFive U-Boot release does not support our image anymore without adjusting the U-Boot environment.
\nThe kernel package we just installed comes with the needed config files to change the U-Boot environment. We took the chance to ship a generic default which allows to boot from all filesystems on all partitions from all boot media, including NVMe, USB, eMMC, SD cards and DHCP/TFTP.
\nEspecially before updating to latest SPI bootloader, we recommend to flash this environment, right after you rebooted the system, with the following command:
# fw_setenv
\nAfterwards, you can print the U-Boot environment via "fw_printenv" and set individual variables via
# fw_setenv name value
\nThe "boot_targets" variabe takes a list of targets, which U-Boot tries to boot from left to right. The default is
# fw_setenv boot_targets "mmc1 usb0 nvme0 mmc0 dhcp"
\n"mnc1" is the SD card, "mmc0" the eMMC module.
\nPlease report back if you face any issues with this U-Boot environment, e.g. also with other distributions.'
fi
# ADS-B Feeder used to install two service files that aren't needed: https://github.com/MichaIng/DietPi/pull/6661
if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[141\]=2' /boot/dietpi/.installed
then
systemctl -q is-enabled adsb-update.timer && G_EXEC systemctl --no-reload disable --now adsb-update.timer
[[ -f '/etc/systemd/system/adsb-update.timer' ]] && G_EXEC rm /etc/systemd/system/adsb-update.timer
systemctl -q is-enabled adsb-update && G_EXEC systemctl --no-reload disable --now adsb-update
[[ -f '/etc/systemd/system/adsb-update.service' ]] && G_EXEC rm /etc/systemd/system/adsb-update.service
fi
}
Patch_8_24()
{
# ROCK 3A: The "rk35xx" kernel packages have been merged into "rockchip64", and "edge-rk35xx" is Linux 6.1.11, older than "current-rockchip64", which is 6.1.50
if (( $G_HW_MODEL == 77 )) && dpkg-query -s 'linux-image-edge-rk35xx' &> /dev/null
then
G_DIETPI-NOTIFY 2 'Updating ROCK 3A kernel package ...'
local apackages=('linux-image-current-rockchip64' 'linux-dtb-current-rockchip64')
dpkg-query -s 'linux-headers-edge-rk35xx' &> /dev/null && apackages+=('linux-headers-current-rockchip64')
G_AGI "${apackages[@]}"
G_EXEC apt-mark auto "${apackages[@]/current-rockchip64/edge-rk35xx}"
# Orange Pi Zero 3: Pre-v8.24 WiFi config migration
elif [[ $G_HW_MODEL == 83 && -f '/etc/modules-load.d/dietpi-enable_wifi.conf' ]]
then
if [[ -f '/etc/modprobe.d/dietpi-disable_wifi.conf' ]]
then
G_EXEC rm /etc/modules-load.d/dietpi-enable_wifi.conf
else
G_EXEC eval 'echo -e '\''cpufreq_dt\nsprdwl_ng'\'' > /etc/modules-load.d/dietpi-enable_wifi.conf'
fi
[[ -f '/etc/modprobe.d/dietpi-disable_bluetooth.conf' ]] || G_EXEC eval 'echo '\''sprdbt_tty'\'' > /etc/modules-load.d/dietpi-enable_bluetooth.conf'
fi
# Shairport Sync
if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[37\]=2' /boot/dietpi/.installed && dpkg --compare-versions "$(dpkg-query -Wf '${Version}' shairport-sync 2> /dev/null)" lt 4.3.2-dietpi2
then
G_DIETPI-NOTIFY 2 'Updating Shairport Sync package ...'
G_EXEC_OUTPUT=1 G_EXEC curl -fo package.deb "https://dietpi.com/downloads/binaries/$G_DISTRO_NAME/shairport-sync_$G_HW_ARCH_NAME.deb"
G_AGI ./package.deb
G_EXEC rm package.deb
fi
}
Patch_8_25()
{
# Software updates and migrations
if [[ -f '/boot/dietpi/.installed' ]]
then
# NZBGet: Disable file logging
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[149\]=2' /boot/dietpi/.installed && [[ -f '/mnt/dietpi_userdata/nzbget/nzbget.conf' ]]
then
G_CONFIG_INJECT 'WriteLog=' 'WriteLog=none' /mnt/dietpi_userdata/nzbget/nzbget.conf
[[ -f '/etc/systemd/system/nzbget.service' ]] && G_EXEC sed --follow-symlinks -i -e '/^Type=/d' -e '/^ExecStart=/c\ExecStart=/mnt/dietpi_userdata/nzbget/nzbget -so OutputMode=log' /etc/systemd/system/nzbget.service
[[ -f '/var/log/nzbget.log' ]] && G_EXEC rm /var/log/nzbget.log
fi
# TasmoAdmin with Lighttpd: https://github.com/MichaIng/DietPi/issues/6805
[[ -f '/etc/lighttpd/conf-available/99-dietpi-tasmoadmin.conf' ]] && G_EXEC curl -sSfo /etc/lighttpd/conf-available/99-dietpi-tasmoadmin.conf "https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.conf/dps_27/lighttpd.tasmoadmin.3.conf"
fi
}
Patch_9_0()
{
# Software updates and migrations
if [[ -f '/boot/dietpi/.installed' ]]
then
# Nextcloud
# - Apache
if [[ -f '/etc/apache2/sites-available/dietpi-nextcloud.conf' ]]
then
G_EXEC mv /etc/apache2/sites-available/dietpi-nextcloud.conf /etc/apache2/sites-available/dietpi-nextcloud.conf.dietpi-old
G_EXEC curl -sSfo /etc/apache2/sites-available/dietpi-nextcloud.conf "https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.conf/dps_114/apache.nextcloud.conf"
[[ -f '/etc/apache2/sites-available/dietpi-nextcloud.conf.dietpi-new' ]] && G_EXEC rm /etc/apache2/sites-available/dietpi-nextcloud.conf.dietpi-new
fi
# - Lighttpd
if [[ -f '/etc/lighttpd/conf-available/99-dietpi-nextcloud.conf' ]]
then
G_EXEC mv /etc/lighttpd/conf-available/99-dietpi-nextcloud.conf /etc/lighttpd/conf-available/99-dietpi-nextcloud.conf.dietpi-old
G_EXEC curl -sSfo /etc/lighttpd/conf-available/99-dietpi-nextcloud.conf "https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.conf/dps_114/lighttpd.nextcloud.conf"
[[ -f '/etc/lighttpd/conf-available/99-dietpi-nextcloud.conf.dietpi-new' ]] && G_EXEC rm /etc/lighttpd/conf-available/99-dietpi-nextcloud.conf.dietpi-new
fi
# Kodi
[[ -f '/usr/share/applications/kodi.desktop' ]] && G_CONFIG_INJECT 'Exec=' 'Exec=kodi --standalone' /usr/share/applications/kodi.desktop
fi
}
Patch_9_1()
{
# Raspberry Pi
if [[ -f '/etc/kernel/postinst.d/dietpi-USBridgeSig' ]]
then
G_DIETPI-NOTIFY 2 'Removing obsolete USBridge Sig driver update script, since Allo does not provides those for recent kernel versions anymore'
G_EXEC rm /etc/kernel/postinst.d/dietpi-USBridgeSig
fi
# Software updates and migrations
if [[ -f '/boot/dietpi/.installed' ]]
then
# Nextcloud
# - Nginx
if [[ -f '/etc/nginx/sites-dietpi/dietpi-nextcloud.conf' ]]
then
# shellcheck disable=SC2016
echo '# Set the "immutable" cache control option for assets with a cache busting "v=" argument
map $arg_v $asset_immutable {
"" "";
default ", immutable";
}' > /etc/nginx/conf.d/dietpi-nextcloud.conf
G_EXEC mv /etc/nginx/sites-dietpi/dietpi-nextcloud.conf /etc/nginx/sites-dietpi/dietpi-nextcloud.conf.dietpi-old
G_EXEC curl -sSfo /etc/nginx/sites-dietpi/dietpi-nextcloud.conf "https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.conf/dps_114/nginx.nextcloud.conf"
[[ -f '/etc/nginx/sites-dietpi/dietpi-nextcloud.conf.dietpi-new' ]] && G_EXEC rm /etc/nginx/sites-dietpi/dietpi-nextcloud.conf.dietpi-new
fi
# GMediaRender: https://dietpi.com/forum/t/gmediarender-default-args-on-allo-image-for-raspberry-pi/19205
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[163\]=2' /boot/dietpi/.installed && grep -q ' -f -I ' /etc/default/gmediarender
then
G_DIETPI-NOTIFY 2 'Fixing default GMediaRender command arguments'
G_EXEC sed --follow-symlinks -i "s/ -f -I / -f $HOSTNAME -I /" /etc/default/gmediarender
fi
# OctoPrint: https://github.com/MichaIng/DietPi/issues/6915
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[153\]=2' /boot/dietpi/.installed && grep -q ', reboot, poweroff' /etc/sudoers.d/octoprint
then
G_DIETPI-NOTIFY 2 'Fixing OctoPrint sudoers rule'
# shellcheck disable=SC2230
G_EXEC sed --follow-symlinks -i "s|, reboot, poweroff|, $(which reboot), $(which poweroff)|" /etc/sudoers.d/octoprint
fi
fi
}
Patch_9_2()
{
# Software updates and migrations
if [[ -f '/boot/dietpi/.installed' ]]
then
# Nextcloud
# - Nginx
if [[ -f '/etc/nginx/sites-dietpi/dietpi-nextcloud.conf' ]] && ! grep -q 'include mime.types;' /etc/nginx/sites-dietpi/dietpi-nextcloud.conf
then
G_DIETPI-NOTIFY 2 'Fixing Nextclound Nginx config ...'
G_EXEC sed --follow-symlinks -i '/types {/i\\tinclude mime.types;' /etc/nginx/sites-dietpi/dietpi-nextcloud.conf
fi
# PaperMC
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[36\]=2' /boot/dietpi/.installed
then
if [[ -f '/mnt/dietpi_userdata/papermc/plugins/floodgate-bukkit.jar' ]]
then
G_DIETPI-NOTIFY 2 'Renaming Floodgate plugin file to correct Spigot edition name ...'
G_EXEC mv /mnt/dietpi_userdata/papermc/plugins/floodgate-{bukkit,spigot}.jar
fi
if [[ -f '/mnt/dietpi_userdata/papermc/plugins/Geyser-Spigot/config.yml' ]] && grep -q '^auth-type: floodgate' /mnt/dietpi_userdata/papermc/plugins/Geyser-Spigot/config.yml
then
G_DIETPI-NOTIFY 2 'Fixing Geyser plugin config ...'
G_EXEC sed --follow-symlinks -i 's/^auth-type: floodgate/ auth-type: floodgate/' /mnt/dietpi_userdata/papermc/plugins/Geyser-Spigot/config.yml
fi
fi
# Squeezelite
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[36\]=2' /boot/dietpi/.installed && dpkg --compare-versions "$(dpkg-query -Wf '${Version}' squeezelite 2> /dev/null)" lt 2.0.0-1468-dietpi1
then
G_DIETPI-NOTIFY 2 'Updating Squeezelite package ...'
G_EXEC_OUTPUT=1 G_EXEC curl -fo package.deb "https://dietpi.com/downloads/binaries/$G_DISTRO_NAME/squeezelite_$G_HW_ARCH_NAME.deb"
G_AGI ./package.deb
G_EXEC rm package.deb
fi
# Amiberry
if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[108\]=2' /boot/dietpi/.installed && dpkg --compare-versions "$(dpkg-query -Wf '${Version}' amiberry 2> /dev/null)" lt 5.6.8-dietpi1
then
G_DIETPI-NOTIFY 2 'Preparing Amiberry upgrade to v5.6.8'
G_EXEC eval 'echo 108 >> /var/tmp/dietpi/dietpi-update_reinstalls'
fi
fi
}
PATCH_9_3_RAN=0
Patch_9_3()
{
# Purge ancient vmtouch which prevents /boot from being unmounted e.g. for RPi firmware migration: https://github.com/MichaIng/DietPi/issues/6819, https://github.com/MichaIng/DietPi/issues/6976
[[ -f '/etc/default/vmtouch' ]] && grep -q '/boot/dietpi' /etc/default/vmtouch && G_AGP vmtouch
# Add DietPi APT repo
/boot/dietpi/func/dietpi-set_software apt-mirror dietpi
G_AGUP
G_AGUG
PATCH_9_3_RAN=1
}
Patch_9_4()
{
# Update DietPi APT list for several SBCs we added components to our repo for
if [[ $PATCH_9_3_RAN == 0 && $G_HW_MODEL =~ ^(11|40|44|45|48|56|57|59|60|64|65|67|76|78|79|80|82|83|85|88|89|90)$ ]]
then
/boot/dietpi/func/dietpi-set_software apt-mirror dietpi
G_AGUP