#!/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' && $( /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/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() { 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' && $( /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' [[ $( /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' [[ $( /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 G_AGUG fi # Odroid XU4 if (( $G_HW_MODEL == 11 )) then G_DIETPI-NOTIFY 2 'Migrating boot.ini to support new Linux 6.6 device tree overlay locations' /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc # shellcheck disable=SC2016 G_EXEC sed --follow-symlinks -i '\|/boot/dtb/overlays/${overlay}.dtbo|c\ load mmc 0:1 0x60000000 /boot/dtb/${overlay}.dtbo || load mmc 0:1 0x60000000 /boot/dtb/overlays/${overlay}.dtbo || load mmc 0:1 0x60000000 dtb/${overlay}.dtbo || load mmc 0:1 0x60000000 dtb/overlays/${overlay}.dtbo' /boot/boot.ini G_DIETPI-NOTIFY 2 'Fixing CEC toggle in boot.ini' G_EXEC sed --follow-symlinks -i 's|rm /cec@101B0000;|rm /soc/cec@101b0000;|' /boot/boot.ini G_DIETPI-NOTIFY 2 'Cleaning up obsolete configs' [[ -f '/etc/modprobe.d/odroid-cloudshell.conf' ]] && G_EXEC rm /etc/modprobe.d/odroid-cloudshell.conf G_EXEC sed --follow-symlinks -Ei '/^[[:blank:]]*(gpioplug-ir-recv|fbtft_device)[[:blank:]]*$/d' /etc/modules # Orange Pi 5 Plus elif (( $G_HW_MODEL == 82 )) then G_DIETPI-NOTIFY 2 'Assuring persistent classic Ethernet interface names: /etc/udev/rules.d/99-dietpi-orangepi5plus.rules' G_WHIP_MSG '[ WARN ] Persistent eth0/eth1 interface names will be applied \nSince classic interface names are randomly applied among the two onboard Ethernet adapters, we install a udev rule, which assures they remain the same on each (re)boot: - /etc/udev/rules.d/99-dietpi-orangepi5plus.rules \nIf you applied an own workaround via /etc/network/interfaces or similar, this will not be affected. But if you created own udev rules to mitigate the issue, please check whether those conflict with ours. Of course you can remove or rename above file to maintain status quo.' cat << '_EOF_' > /etc/udev/rules.d/99-dietpi-orangepi5plus.rules SUBSYSTEM=="net", KERNEL=="eth0", KERNELS=="0004:41:00.0", RUN:="/bin/true" SUBSYSTEM=="net", KERNEL=="eth1", KERNELS=="0003:31:00.0", NAME="to_eth0", RUN:="/bin/true" SUBSYSTEM=="net", KERNEL=="to_eth0", RUN="/bin/ip l s dev eth0 name eth1", RUN+="/bin/ip l s dev to_eth0 name eth0", RUN+="/bin/udevadm trigger -c add /sys/class/net/eth0 /sys/class/net/eth1" _EOF_ # Orange Pi Zero 3 1.5 GiB RAM: Fix lost Ethernet adapter on reboot: https://github.com/MichaIng/DietPi/issues/6938 elif (( $G_HW_MODEL == 83 )) && dpkg-query -s 'linux-u-boot-orangepizero3-next' &> /dev/null then G_DIETPI-NOTIFY 2 'Switching to new U-Boot build which fixes lost Ethernet adapter on reboot ...' G_AGP linux-u-boot-orangepizero3-next G_AGI linux-u-boot-orangepizero3-current /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc fi if [[ -f '/boot/dietpi/.installed' ]] then # GMediaRender if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[163\]=2' /boot/dietpi/.installed && ! dpkg-query -s 'gmediarender' &> /dev/null then # Pre-v8.10 G_DIETPI-NOTIFY 2 'Updateing GMediaRender ...' [[ -f '/etc/systemd/system/gmediarender.service' ]] && G_EXEC rm /etc/systemd/system/gmediarender.service [[ -d '/etc/systemd/system/gmediarender.service.d' ]] && grep -Rq '/usr/local/bin/gmediarender' /etc/systemd/system/gmediarender.service.d && G_EXEC rm -R /etc/systemd/system/gmediarender.service.d getent passwd gmrender > /dev/null && G_EXEC userdel gmrender getent group gmrender > /dev/null && G_EXEC groupdel gmrender [[ -f '/usr/local/bin/gmediarender' ]] && G_EXEC rm /usr/local/bin/gmediarender [[ -d '/usr/local/share/gmediarender' ]] && G_EXEC rm -R /usr/local/share/gmediarender G_AGI gmediarender fi # Shairport Sync if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[37\]=2' /boot/dietpi/.installed then [[ -f '/usr/local/share/man/man7/shairport-sync.7.gz' ]] && G_EXEC rm /usr/local/share/man/man7/shairport-sync.7.gz [[ -d '/usr/local/share/man/man7' ]] && G_EXEC rmdir -p --ignore-fail-on-non-empty /usr/local/share/man/man7 fi fi } Patch_9_5() { # Update DietPi APT list for several SBCs we added components to our repo for if [[ $PATCH_9_3_RAN == 0 && $G_HW_MODEL =~ ^(12|15|16|54|74)$ ]] then /boot/dietpi/func/dietpi-set_software apt-mirror dietpi G_AGUP G_AGUG fi # Flash new U-Boot on Odroid C1 and Radxa ZERO 3 (( $G_HW_MODEL == 10 || $G_HW_MODEL == 90 )) && /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc # Do not hardcode device tree on Radxa ZERO 3, after flashing our new U-Boot, since it does now select the correct device tree with onboard WiFi support, based on hardware details. (( $G_HW_MODEL == 90 )) && sed --follow-symlinks -i '/^fdtfile=rockchip/rk3566-radxa-zero3.dtb$/d' /boot/dietpiEnv.txt # Update MPD flag: https://github.com/MusicPlayerDaemon/MPD/commit/ce77b14 [[ -f '/etc/systemd/system/mpd.service.d/dietpi.conf' ]] && G_EXEC sed --follow-symlinks -i 's/no-daemon/systemd/' /etc/systemd/system/mpd.service.d/dietpi.conf # Migrate jellyfin-ffmpeg5 => jellyfin-ffmpeg6 if dpkg-query -s jellyfin &> /dev/null && dpkg-query -s jellyfin-ffmpeg5 &> /dev/null then G_DIETPI-NOTIFY 2 'Migrating to Jellyfin FFmpeg 6' G_AGI jellyfin G_AGP jellyfin-ffmpeg5 # conffiles fi } Patch_9_6() { # Update DietPi APT list for several SBCs we added components to our repo for if [[ $PATCH_9_3_RAN == 0 && $G_HW_MODEL =~ ^(42|43|46|47|52|55|58|68|72|73|76|77|86|87)$ ]] then /boot/dietpi/func/dietpi-set_software apt-mirror dietpi G_AGUP G_AGUG # Orange Pi 5: Offer to flash new U-Boot image to solve random Ethernet MAC address: https://github.com/MichaIng/DietPi/issues/6663 elif (( $G_HW_MODEL == 80 )) then if G_WHIP_YESNO '[ INFO ] U-Boot update available to solve random Ethernet MAC address \nIn case you are affected by a random Ethernet MAC address, which changes every boot, flashing the latest U-Boot image has shown to solve it: https://github.com/MichaIng/DietPi/issues/6663 \nDo you want to flash the latest U-Boot image now? \nNB: This can be done any time later via dietpi-config > Advanced Options.' then if [[ $G_ROOTFS_DEV == '/dev/mmcblk'* || $G_ROOTFS_DEV == '/dev/loop'* ]] then /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc elif [[ -b '/dev/mtdblock0' ]] then # shellcheck disable=SC1091 . /usr/lib/u-boot/platform_install.sh # shellcheck disable=SC2154 G_EXEC_OUTPUT=1 G_EXEC dd if="$DIR/rkspi_loader.img" of=/dev/mtdblock0 oflag=direct conv=notrunc status=progress else G_WHIP_MSG '[FAILED] SPI block device /dev/mtdblock0 not found \nWe expect the SPI block device /dev/mtdblock0 to be the target for the U-Boot image. It however does not exist. \nPlease report this to our forum or GitHub site, so we can check back: - https://dietpi.com/forum/c/troubleshooting/10 - https://github.com/MichaIng/DietPi/issues' fi fi # NanoPi R6C: Migrate to dedicated APT component and U-Boot package: https://github.com/MichaIng/DietPi/issues/7109 elif (( $G_HW_MODEL == 79 )) && grep -q '^[[:blank:]]*fdtfile=rockchip/rk3588s-nanopi-r6c.dtb$' /boot/dietpiEnv.txt then HW_VARIANT=2 /boot/dietpi/func/dietpi-set_software apt-mirror dietpi G_AGUP G_AGI linux-u-boot-nanopi-r6c-vendor # Odroid XU4/Meson: Install zstd for better compressed initramfs images elif dpkg-query -s 'linux-image-current-odroidxu4' &> /dev/null || dpkg-query -s 'linux-image-edge-odroidxu4' &> /dev/null || dpkg-query -s 'linux-image-current-meson' &> /dev/null || dpkg-query -s 'linux-image-edge-meson' &> /dev/null then G_AGI zstd fi # Remove obsolete drop-in config: https://github.com/MichaIng/DietPi/issues/7104 [[ -f '/etc/systemd/system/ifup@.service.d/dietpi.conf' ]] && G_EXEC rm -R /etc/systemd/system/ifup@.service.d/dietpi.conf [[ -d '/etc/systemd/system/ifup@.service.d' ]] && G_EXEC rmdir --ignore-fail-on-non-empty /etc/systemd/system/ifup@.service.d # Fix filter for STDOUT logging since Bookworm: https://github.com/fail2ban/fail2ban/pull/3597 if [[ -f '/etc/fail2ban/filter.d/dropbear.conf' && ! -f '/etc/fail2ban/filter.d/dropbear.local' ]] then G_DIETPI-NOTIFY 2 'Fixing Dropbear Fail2Ban filter for STDOUT logging since Bookworm: https://github.com/fail2ban/fail2ban/pull/3597' cat << '_EOF_' > /etc/fail2ban/filter.d/dropbear.local [INCLUDES] before = common.conf [Definition] _daemon = dropbear # Fix filter for STDOUT logging since Bookworm: https://github.com/fail2ban/fail2ban/pull/3597 prefregex = ^%(__prefix_line)s(\[\d+\] [A-Z][a-z]+ \d\d \d\d:\d\d:\d\d )?(?:[Ll]ogin|[Bb]ad|[Ee]xit).+$ failregex = ^[Ll]ogin attempt for nonexistent user ('.*' )?from :\d+$ ^[Bb]ad (PAM )?password attempt for .+ from (:\d+)?$ ^[Ee]xit before auth \(user '.+', \d+ fails\): Max auth tries reached - user '.+' from :\d+\s*$ ignoreregex = # Add journalmatch to enhance performance since Bookworm journalmatch = _SYSTEMD_UNIT=dropbear.service + _COMM=dropbear _EOF_ G_EXEC systemctl restart fail2ban fi } Patch_9_7() { # Software updates, migrations and patches if [[ -f '/boot/dietpi/.installed' ]] then # Bazarr if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[180\]=2' /boot/dietpi/.installed && [[ -f '/etc/systemd/system/bazarr.service' ]] then G_CONFIG_INJECT 'KillSignal=' 'KillSignal=SIGINT' /etc/systemd/system/bazarr.service '\[Service\]' fi fi } Patch_9_8() { # NanoPi R5S/R5C if (( $G_HW_MODEL == 76 )) && ! dpkg-query -s 'firmware-nanopi5' &> /dev/null then local model='R5S' [[ $( /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=="green:lan-1", 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:lan-2", 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=="green:wan", 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=="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" SUBSYSTEM=="leds", KERNEL=="green:wlan", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="wlan0", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s wlan0 up", RUN+="/bin/ip l s wlan0 down" _EOF_ fi # NanoPi R6S/R6C elif (( $G_HW_MODEL == 79 )) && ! dpkg-query -s 'firmware-nanopi6' &> /dev/null then read -r model < /proc/device-tree/model if [[ $model == *'R6C'* ]] then G_DIETPI-NOTIFY 2 'Updating udev rule for NanoPi R6C 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=="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=="user_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="wlan0", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s wlan0 up", RUN+="/bin/ip l s wlan0 down" _EOF_ fi # Orange Pi 3B: Migrate to mainline kernel device tree names elif (( $G_HW_MODEL == 87 )) then G_DIETPI-NOTIFY 2 'Flashing new Orange Pi 3B bootloader to support v2.1 board revision and automatic device tree selection' /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc if [[ $G_ROOTFS_DEV != '/dev/mmcblk'* ]] then # shellcheck disable=SC1091 . /usr/lib/u-boot/platform_install.sh if declare -f write_uboot_platform_mtd | grep -q 'flashcp' then G_AG_CHECK_INSTALL_PREREQ mtd-utils write_uboot_platform_mtd "$DIR" /dev/mtd0 else write_uboot_platform_mtd "$DIR" /dev/mtdblock0 fi fi G_EXEC sed --follow-symlinks -i '/^fdtfile=/d' /boot/dietpiEnv.txt fi } Patch_9_9() { # Software updates, migrations and patches if [[ -f '/boot/dietpi/.installed' ]] then # InfluxDB if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[74\]=2' /boot/dietpi/.installed then # Recreate symlink deleted with package update: https://dietpi.com/forum/t/influxdb-not-working-after-update/21868 [[ -e '/var/lib/influxdb' ]] || G_EXEC ln -sf /mnt/dietpi_userdata/influxdb /var/lib/influxdb # Migrate to now existing Bookworm suite if [[ -f '/etc/apt/sources.list.d/influxdb.list' ]] then G_EXEC sed --follow-symlinks -i 's/bullseye/bookworm/g' /etc/apt/sources.list.d/influxdb.list G_EXEC mv /etc/apt/sources.list.d/{,dietpi-}influxdb.list fi fi # Mopidy: Migrate to now existing Bookworm suite if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[118\]=2' /boot/dietpi/.installed && [[ -f '/etc/apt/sources.list.d/mopidy.list' ]] then G_EXEC sed --follow-symlinks -i 's/bullseye/bookworm/g' /etc/apt/sources.list.d/mopidy.list G_EXEC mv /etc/apt/sources.list.d/{,dietpi-}mopidy.list fi # Logitech Media Server => Lyrion Music Server: https://github.com/MichaIng/DietPi/issues/7306 if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[35\]=2' /boot/dietpi/.installed && [[ -f '/lib/systemd/system/logitechmediaserver.service' ]] then G_DIETPI-NOTIFY 2 'Preparing Logitech Media Server reinstall to migrate to Lyrion Music Server ...' G_EXEC systemctl --no-reload unmask logitechmediaserver G_EXEC systemctl --no-reload disable --now logitechmediaserver # Avoid that purging the old package removes user, log and data dir which are still in use by the new package # shellcheck disable=SC2016 G_EXEC sed --follow-symlinks -i '/^if \[ "$1" = purge \]; then/,/^fi/d' /var/lib/dpkg/info/logitechmediaserver.postrm G_EXEC eval 'echo 35 >> /var/tmp/dietpi/dietpi-update_reinstalls' fi fi } Patch_9_10() { # RISC-V if (( $G_HW_ARCH == 11 )) then G_DIETPI-NOTIFY 2 'Migrating RISC-V systems from Debian Sid/unstable to Trixie/testing ...' local apt_mirror=$(mawk '$1=="deb"{print $2;exit}' /etc/apt/sources.list) /boot/dietpi/func/dietpi-set_software apt-mirror "${apt_mirror:-default}" fi # Software updates, migrations and patches if [[ -f '/boot/dietpi/.installed' ]] then # Raspotify if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[167\]=2' /boot/dietpi/.installed then G_DIETPI-NOTIFY 2 'Migrating to new Raspotify APT list name and key format ...' [[ -f '/etc/apt/sources.list.d/raspotify.list' ]] && G_EXEC mv /etc/apt/sources.list.d/{,dietpi-}raspotify.list if [[ -f '/etc/apt/trusted.gpg.d/dietpi-raspotify.gpg' ]] then G_EXEC curl -sSfo /etc/apt/trusted.gpg.d/dietpi-raspotify.asc 'https://dtcooper.github.io/raspotify/key.asc' G_EXEC rm /etc/apt/trusted.gpg.d/dietpi-raspotify.gpg fi fi # Remove obsolete install states: https://github.com/MichaIng/DietPi/pull/7351 for i in 4 {10..15} {18..21} 127 do grep -q "^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[$i\]=" /boot/dietpi/.installed && G_EXEC sed --follow-symlinks -i "/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[$i\]=/d" /boot/dietpi/.installed done fi } Patch_9_11(){ :; } Patch_9_12() { # Software updates, migrations and patches if [[ -f '/boot/dietpi/.installed' ]] then # RPi.GPIO => rpi-lgpio migration if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[69\]=2' /boot/dietpi/.installed then G_DIETPI-NOTIFY 2 'Migrating from legacy RPi.GPIO to modern compatible rpi-lgpio Python 3 library ...' G_AGI python3-rpi-lgpio G_AGP python3-rpi.gpio fi # Amiberry v7 info if [[ -d '/mnt/dietpi_userdata/amiberry_v5_bak' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[108\]=2' /boot/dietpi/.installed then G_WHIP_MSG '[ INFO ] Amiberry v7 upgrade detected \nAPT has upgraded you Amiberry v5 instance to Amiberry v7. It is based on latest WinUAE, which includes some enhancements and JIT for x86_64, but looses JIT for ARM, and is overall more CPU-intense than v5. Recommended for ARM and RISC-V SBCs slower than Raspberry Pi 4, the developer has hence released Amiberry-Lite, which is based on the less CPU-intense older WinUAE, and supports JIT for ARM. \nIf you experience bad performance of the new Amiberry v7 on your ARM or RISC-V system, please check out the new Amiberry-Lite dietpi-software option. Both can be installed concurrently, and Amiberry-Lite will pick up an automatically generated backup of your previous Amiberry v5 config/data dir.' fi fi } Patch_9_13() { # Remove obsolete lines in old dietpi-benchmark results [[ -f '/var/lib/dietpi/dietpi-benchmark/results' ]] && G_EXEC sed -i '/^# /d' /var/lib/dietpi/dietpi-benchmark/results # Move dietpi-set_userdata log to permanent location [[ -f '/var/log/dietpi-move_userdata.log' ]] && G_EXEC mv /var/log/dietpi-move_userdata.log /var/tmp/dietpi/logs/dietpi-set_userdata.log # Software updates, migrations and patches if [[ -f '/boot/dietpi/.installed' ]] then # Update motionEye: https://github.com/motioneye-project/motioneye/security/advisories/GHSA-g5mq-prx7-c588 command -v pip3 > /dev/null && pip3 freeze | grep -iq '^motioneye==0\.43\..*' && G_EXEC pip3 install --upgrade --pre motioneye # Remove Google AIY and Mycroft AI grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[169\]=' /boot/dietpi/.installed && G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[169\]=/d' /boot/dietpi/.installed grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[176\]=' /boot/dietpi/.installed && G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[176\]=/d' /boot/dietpi/.installed # Redis if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[91\]=2' /boot/dietpi/.installed then # Enable memory overcomit: https://github.com/jemalloc/jemalloc/issues/1328 if (( $G_HW_MODEL == 75 )) then [[ $(sysctl -n vm.overcommit_memory) == 1 ]] || G_WHIP_MSG '[WARNING] Memory overcomit is disabled \nFor Redis to run reliably, memory overcomit should be enabled. This can only be done on the host system of this container. E.g. run the following two commands on the host: echo vm.overcommit_memory=1 | sudo tee /etc/sysctl.d/98-dietpi-redis.conf sudo sysctl -p /etc/sysctl.d/98-dietpi-redis.conf' else G_DIETPI-NOTIFY 2 'Enabling memory overcomit for Redis server' G_EXEC eval 'echo '\''vm.overcommit_memory=1'\'' > /etc/sysctl.d/98-dietpi-redis.conf' local dryrun=() [[ ! -w '/proc/sys/vm/overcommit_memory' ]] && systemd-detect-virt -cq && dryrun=('--dry-run') G_EXEC sysctl -p "${dryrun[@]}" /etc/sysctl.d/98-dietpi-redis.conf fi fi # Unbound if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[182\]=2' /boot/dietpi/.installed then G_DIETPI-NOTIFY 2 'Disabling Unbound ECS module, matching new upstream defaults and muting two startup warnings' G_CONFIG_INJECT 'module-config:' ' module-config: "validator iterator"' /etc/unbound/unbound.conf.d/dietpi.conf 'server:' fi fi # Check and in case prompt to change default user and software passwords, which is now enforced on first run setup as well if (( $G_DIETPI_INSTALL_STAGE == 2 )) then /boot/dietpi/func/dietpi-set_software password users check /boot/dietpi/func/dietpi-set_software password software check fi # NanoPi R2S/NEO3 if [[ $G_HW_MODEL =~ ^(55|56)$ ]] then G_DIETPI-NOTIFY 2 'Updating video related kernel module blacklist' cat << '_EOF_' > /etc/modprobe.d/dietpi-headless.conf blacklist hantro_vpu blacklist lima blacklist rockchip_rga blacklist rockchip_vdec blacklist rockchipdrm _EOF_ # ROCK Pi S elif (( $G_HW_MODEL == 73 )) then G_DIETPI-NOTIFY 2 'Limiting CMA size to 16 MiB to free more system memory' grep -q '^extraargs=.*cma=' /boot/dietpiEnv.txt || G_EXEC sed --follow-symlinks -i '/^extraargs=/s/$/ cma=16M/' /boot/dietpiEnv.txt # New U-Boot required to boot new kernel, else "ERROR: Did not find a cmdline Flattened Device Tree" despite correct device tree defined. /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc # NanoPi R6S elif (( $G_HW_MODEL == 79 )) && ! dpkg-query -s 'firmware-nanopi6' &> /dev/null then read -r model < /proc/device-tree/model if [[ $model == *'R6S'* ]] then G_DIETPI-NOTIFY 2 'Updating udev rule for NanoPi R6S 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=="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=="wan_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=="lan1_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_ fi # Orange Pi Zero 3/2W: Flash new U-Boot to fix false RAM detection: https://github.com/MichaIng/DietPi/issues/7242 elif [[ $G_HW_MODEL =~ ^(83|88)$ ]] then G_DIETPI-NOTIFY 2 'Flashing new U-Boot to fix possible false RAM size detection' /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc fi } Patch_9_14() { # Odroid XU4/C2: https://dietpi.com/forum/t/21072 if (( $G_HW_MODEL == 11 || $G_HW_MODEL == 12 )) then G_DIETPI-NOTIFY 2 'Flashing latest U-Boot to solve potential issues when booting from eMMC' /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc # Odroid HC4: Migrate to own hardware ID: https://dietpi.com/forum/t/23524 elif (( $G_HW_MODEL == 16 )) && grep -q 'HC4' /proc/device-tree/model then G_DIETPI-NOTIFY 2 'Migrating Odroid HC4 to own hardware ID and install own U-Boot package to fix USB issues' G_EXEC eval 'echo 17 > /etc/.dietpi_hw_model_identifier' /boot/dietpi/func/dietpi-obtain_hw_model /boot/dietpi/func/dietpi-set_software apt-mirror dietpi G_AGUP if dpkg-query -s 'linux-u-boot-odroidc4-current' &> /dev/null then G_AGI linux-u-boot-odroidhc4-current elif dpkg-query -s 'linux-u-boot-odroidc4-edge' &> /dev/null then G_AGI linux-u-boot-odroidhc4-edge fi /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc # ROCK64 flash new U-Boot, also to SPI: https://dietpi.com/forum/t/23426 elif (( $G_HW_MODEL == 43 )) then G_DIETPI-NOTIFY 2 'Flashing latest U-Boot to solve potential issues when booting with Linux 6.12' /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc # shellcheck disable=SC1091 . /usr/lib/u-boot/platform_install.sh # Do not mute progress and error messages eval "$(declare -f write_uboot_platform_mtd | sed -E -e 's# > /dev/null 2>&1##g' -e 's/status=(none|noxfer)/status=progress/g')" write_uboot_platform_mtd "$DIR" /dev/mtdblock0 # NanoPi NEO: https://github.com/MichaIng/DietPi/issues/7557 elif (( $G_HW_MODEL == 60 )) then G_DIETPI-NOTIFY 2 'Flashing latest U-Boot to solve potential issues when booting with Linux 6.12' /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc # Container elif (( $G_HW_MODEL == 75 )) then # Remove sysctl configs, which cannot be applied in containers anyway G_EXEC rm -f /etc/sysctl.d/*dietpi*.conf # NanoPi R5S/R6S elif { (( $G_HW_MODEL == 76 )) && grep -q 'R5S' /proc/device-tree/model && ! dpkg-query -s 'firmware-nanopi5' &> /dev/null; } || { (( $G_HW_MODEL == 79 )) && grep -q 'R6S' /proc/device-tree/model && ! dpkg-query -s 'firmware-nanopi6' &> /dev/null; } then G_DIETPI-NOTIFY 2 'Flashing latest U-Boot, which assigns a static MAC address to the 3rd Ethernet adapter as well' /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc # NanoPi R5S: Swap eth1 and eth2 on kernel upgrade if (( $G_HW_MODEL == 76 )) && dpkg --compare-versions "$(uname -r)" lt-nl '6.12' && dpkg --compare-versions "$(dpkg-query -Wf '${Version}' linux-image-current-rockchip64 2> /dev/null)" gt '25.08.0' && G_WHIP_BUTTON_OK_TEXT='Yes' G_WHIP_BUTTON_CANCEL_TEXT='Skip' G_WHIP_YESNO "[ INFO ] Latest kernel reverses eth1 and eth2 network interfaces \nSadly, compared to Linux 6.6, Linux 6.12 initiates the 1 Gbit WAN adapter before the second 2.5 Gbit LAN2 adapter. As a result, the native related network interface names eth1 and eth2 are inverted. \nShall we swap the interface names in the following known config file(s) automatically now if found? \n$(find -L /etc/network/interfaces{,.d/*} /etc/default/isc-dhcp-server /etc/iptables.ipv[46].nat /etc/wireguard/wg0.conf -type f 2> /dev/null)" then for i in /etc/network/interfaces{,.d/*} /etc/default/isc-dhcp-server /etc/iptables.ipv[46].nat /etc/wireguard/wg0.conf /etc/udev/rules.d/dietpi-eth-leds.rules do [[ -f $i ]] || continue G_EXEC sed --follow-symlinks -i -e 's/eth1/ethto2/g' -e 's/eth2/ethto1/g' "$i" G_EXEC sed --follow-symlinks -i -e 's/ethto2/eth2/g' -e 's/ethto1/eth1/g' "$i" done fi # Orange Pi Zero 2W: Expansion board Ethernet LEDs: https://github.com/MichaIng/DietPi/issues/7575 elif (( $G_HW_MODEL == 88 )) then G_DIETPI-NOTIFY 2 'Enabling Ethernet LEDs on official expansion board if attached' 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=="100m_link", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth0", ATTR{link}="1" SUBSYSTEM=="leds", KERNEL=="100m_act", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="eth0", ATTR{rx}="1", ATTR{tx}="1" _EOF_ # Radxa ZERO 3 elif [[ $G_HW_MODEL == 90 && ! -e '/dev/ttyS2' ]] then G_DIETPI-NOTIFY 2 'Disabling serial console on ttyS2, unintentionally enabled on previous fresh images' /boot/dietpi/func/dietpi-set_hardware serialconsole 0 ttyS2 fi # NanoPi R4S/R5S/R6S if (( $G_HW_MODEL == 47 )) || { (( $G_HW_MODEL == 76 )) && grep -q 'R5S' /proc/device-tree/model; } || { (( $G_HW_MODEL == 79 )) && grep -q 'R6S' /proc/device-tree/model; } then # Move from netdev to native Ethernet driver LED triggers if sufficiently recent kernel package has been installed if dpkg --compare-versions "$(dpkg-query -Wf '${Version}' linux-image-current-rockchip64 2> /dev/null)" ge '25.08.0-trunk-dietpi2' || dpkg --compare-versions "$(dpkg-query -Wf '${Version}' linux-image-edge-rockchip64 2> /dev/null)" ge '25.08.0-trunk-dietpi4' then G_DIETPI-NOTIFY 2 'Move from netdev to native Ethernet driver LED triggers' G_EXEC rm -f /etc/udev/rules.d/dietpi-eth-leds.rules /etc/modules-load.d/dietpi-eth-leds.conf fi fi # Add U-Boot PARTUUID indicator to cmdline via boot script. That way we can know from userland which device the boot script was loaded from, in case rootfs was moved elsewhere but /boot left on MMC. # It is better than assuming U-Boot was loaded from the rootfs device, but theoretically it could boot from MMC and load the boot script from another device. This is actually a preferred setup we aim to support in the future, for USB and NVMe boot without SPI storage. # However, this aligns it with how Armbian does it, and how their setup_write_uboot_platform obtains the U-Boot device. if [[ -f '/boot/boot.cmd' ]] && ! grep -Eq '^setenv bootargs .* (partuuid|ubootpart)=' /boot/boot.cmd then G_DIETPI-NOTIFY 2 'Adding U-Boot partition cmdline parameter to boot script' # shellcheck disable=SC2016 G_EXEC sed --follow-symlinks -i -e '1i\if test "${devtype}" = "mmc"; then part uuid mmc "${devnum}:1" ubootpart; fi' -e '/^setenv bootargs /s/"$/ ubootpart=${ubootpart}"/' /boot/boot.cmd local arch='arm' (( $G_HW_ARCH == 3 )) && arch='arm64' G_EXEC mkimage -C none -A "$arch" -T script -d /boot/boot.cmd /boot/boot.scr fi # Allwinner H3: Fix too low load_addr on old images: https://github.com/MichaIng/DietPi/issues/7557 if (( $G_HW_CPUID == 1 )) && [[ -f '/boot/boot.cmd' ]] && grep -q '^setenv load_addr "0x44000000"$' /boot/boot.cmd then G_DIETPI-NOTIFY 2 'Raising load_addr in boot script to avoid conflict with raised initramfs image size' G_EXEC sed --follow-symlinks -i '/^setenv load_addr "0x44000000"$/c\^setenv load_addr "0x45000000"$' /boot/boot.cmd G_AG_CHECK_INSTALL_PREREQ u-boot-tools G_EXEC mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr fi # Migrate split of RPi camera and codec toggle if [[ -f '/etc/modprobe.d/dietpi-disable_rpi_camera.conf' ]] && grep -q '^blacklist bcm2835_codec$' /etc/modprobe.d/dietpi-disable_rpi_camera.conf then G_DIETPI-NOTIFY 2 'Splitting RPi codec support into dedicated config file, to match current dietpi-config behaviour' G_EXEC eval 'echo -e '\''blacklist bcm2835_codec\nblacklist rpi_hevc_dec'\'' > /etc/modprobe.d/dietpi-disable_rpi_codec.conf' G_EXEC sed --follow-symlinks -i '/^blacklist bcm2835_codec$/d' /etc/modprobe.d/dietpi-disable_rpi_camera.conf fi # Software updates, migrations and patches if [[ -f '/boot/dietpi/.installed' ]] then # Chromium: https://dietpi.com/forum/t/22518 if [[ -f '/etc/chromium.d/dietpi' ]] && grep -q ' --use-gl=egl"' /etc/chromium.d/dietpi then G_DIETPI-NOTIFY 2 'Fixing Chromium hardware acceleration' G_EXEC sed --follow-symlinks -i 's/ --use-gl=egl"/"/' /etc/chromium.d/dietpi fi fi } Patch_9_15() { # Odroid C1 if (( $G_HW_MODEL == 10 )) && dpkg-query -s 'linux-image-edge-meson' &> /dev/null then G_DIETPI-NOTIFY 2 'Migrating to "current" kernel branch with Linux 6.12' local packages=() dpkg-query -s 'linux-headers-edge-meson' &> /dev/null && packages+=('linux-headers-current-meson') dpkg-query -s 'linux-libc-dev-edge-meson' &> /dev/null && packages+=('linux-libc-dev-current-meson') G_AGI linux-{image,dtb}-current-meson "${packages[@]}" linux-u-boot-odroidc1-current G_AGP linux-{image,dtb,headers,libc-dev}-edge-meson # NanoPi R5C/R6C elif { (( $G_HW_MODEL == 76 )) && grep -q 'R5C' /proc/device-tree/model; } || { (( $G_HW_MODEL == 79 )) && grep -q 'R6C' /proc/device-tree/model; } then # In case restore LED triggers which have been accidentally removed, which was intended for R5S/R6S only if [[ ! -f '/etc/udev/rules.d/dietpi-eth-leds.rules' ]] then if grep -q 'R5C' /proc/device-tree/model then G_DIETPI-NOTIFY 2 'Restoring udev rule for NanoPi R5C 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" SUBSYSTEM=="leds", KERNEL=="green:wlan", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="wlan0", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s wlan0 up", RUN+="/bin/ip l s wlan0 down" _EOF_ else G_DIETPI-NOTIFY 2 'Restoring udev rule for NanoPi R6C 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=="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=="user_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="wlan0", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s wlan0 up", RUN+="/bin/ip l s wlan0 down" _EOF_ fi fi fi # Software updates, migrations and patches if [[ -f '/boot/dietpi/.installed' ]] then # Nextcloud [[ -f '/etc/apache2/sites-available/dietpi-nextcloud.conf' ]] && G_EXEC mv "../DietPi-Update/DietPi-${G_GITBRANCH//\//-}/.conf/dps_114/apache.nextcloud.conf" /etc/apache2/sites-available/dietpi-nextcloud.conf # Unbound if [[ -f '/etc/unbound/unbound.conf.d/dietpi.conf' ]] then G_DIETPI-NOTIFY 2 'Removing cron job for root hints update, relying on Unbound builtin data instead' G_EXEC sed --follow-symlinks -i '\|^[[:blank:]]*root-hints:[[:blank:]]|d' /etc/unbound/unbound.conf.d/dietpi.conf G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*# DNS root server information file/d' /etc/unbound/unbound.conf.d/dietpi.conf G_EXEC sed --follow-symlinks -i '/^$/{:a;N;s/\n$//;ta}' /etc/unbound/unbound.conf.d/dietpi.conf if [[ -f '/etc/resolvconf/update.d/unbound' ]] then G_DIETPI-NOTIFY 2 'Assuring that external nameserver entries in /etc/resolv.conf are not added to the Unbound forward zone' G_EXEC chmod -x /etc/resolvconf/update.d/unbound fi fi [[ -f '/etc/cron.monthly/dietpi-unbound' ]] && G_EXEC rm /etc/cron.monthly/dietpi-unbound # Nginx if [[ -f '/etc/nginx/nginx.conf' ]] && grep -q 'php.\..-fpm\.sock' /etc/nginx/nginx.conf then G_DIETPI-NOTIFY 2 'Removing obsolete PHP FPM socket version string from Nginx config' G_EXEC sed --follow-symlinks -i 's/php.\..-fpm\.sock/php-fpm.sock/' /etc/nginx/nginx.conf fi # Docker Compose if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[134\]=2' /boot/dietpi/.installed then if command -v docker-compose > /dev/null && ! dpkg-query -s 'docker-compose-plugin' &> /dev/null then G_WHIP_MSG '[ INFO ] Migrating from obsolete "docker-compose" to "docker compose" plugin \nThe dedicated "docker-compose" application and executable is deprecated, in favor of Docker'\''s native compose plugin. We are migrating you instance to the new plugin now. \nNote that the command to call Docker Compose in turn changed from "docker-compose" to "docker compose", hence without the dash, but as an argument of the "docker" command.' G_AGI docker-compose-plugin command -v docker-compose > /dev/null && command -v pip3 > /dev/null && G_EXEC_OUTPUT=1 G_EXEC pip3 uninstall -y docker-compose # Pre-v8.2 [[ -f '/usr/local/bin/docker-compose' ]] && G_EXEC rm /usr/local/bin/docker-compose # Pre-v8.14 fi fi fi } Patch_9_16() { # Raspberry Pi if (( $G_HW_MODEL < 10 )) then # The meta nodes /dev/serial* are disabled from now on in case of CONFIG_SERIAL_CONSOLE_ENABLE=0. Pre-v9.16 images however run old dietpi-set_hardware in dietpi-firstboot where this is not done yet. Hence do no first run update, so we do not need to keep it in dietpi-software. if (( $G_DIETPI_INSTALL_STAGE == 0 )) && grep -q '^[[:blank:]]*CONFIG_SERIAL_CONSOLE_ENABLE=0' /boot/dietpi.txt then G_DIETPI-NOTIFY 2 'Disabling serial console on /dev/serial0 device node' /boot/dietpi/func/dietpi-set_hardware serialconsole disable serial0 fi fi # NanoPi 4/5/6 series: Repair faulty all component if [[ $G_HW_MODEL =~ ^(68|76|79)$ && -f '/etc/apt/sources.list.d/dietpi.list' ]] && grep -Eq ' all .*/(legacy|vendor|current|edge)$' /etc/apt/sources.list.d/dietpi.list then G_EXEC sed --follow-symlinks -Ei '/ all /s/\/(legacy|vendor|current|edge)$//' /etc/apt/sources.list.d/dietpi.list G_AGUP G_AGUG fi if [[ ! -f '/etc/apt/sources.list.d/dietpi.list' ]] || { [[ $G_HW_ARCH != 10 ]] && ! grep -q 'dietpi.com/apt all' /etc/apt/sources.list.d/dietpi.list; } then G_DIETPI-NOTIFY 2 'Updating DietPi APT repository' /boot/dietpi/func/dietpi-set_software apt-mirror dietpi if grep -q 'dietpi.com/apt all' /etc/apt/sources.list.d/dietpi.list then G_AGUP G_AGUG fi fi # Remove Armbian APT repository from all systems which have an "all" component for kernel/bootloader/firmware packages from our APT repository if [[ -f '/etc/apt/sources.list.d/dietpi-armbian.list' ]] && grep -q 'dietpi.com/apt all' /etc/apt/sources.list.d/dietpi.list then G_DIETPI-NOTIFY 2 'Removing obsolete Armbian APT repository' G_EXEC rm /etc/apt/sources.list.d/dietpi-armbian.list [[ -f '/etc/apt/preferences.d/dietpi-armbian' ]] && G_EXEC rm /etc/apt/preferences.d/dietpi-armbian [[ -f '/etc/apt/trusted.gpg.d/dietpi-armbian.gpg' ]] && G_EXEC rm /etc/apt/trusted.gpg.d/dietpi-armbian.gpg fi # openHAB pre-patch cleanup [[ -f '/etc/apt/preferences.d/dietpi-openhab-tmp' ]] && G_EXEC rm /etc/apt/preferences.d/dietpi-openhab-tmp [[ -f '/etc/apt/apt.conf.d/dietpi-openhab-tmp' ]] && G_EXEC rm /etc/apt/apt.conf.d/dietpi-openhab-tmp # Software updates, migrations and patches if [[ -f '/boot/dietpi/.installed' ]] then # Domoticz if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[140\]=2' /boot/dietpi/.installed then G_DIETPI-NOTIFY 2 'Migrating Domoticz to our new APT package' [[ -f '/etc/systemd/system/domoticz.service' ]] && G_EXEC rm /etc/systemd/system/domoticz.service [[ -d '/opt/domoticz' ]] && G_EXEC rm -R /opt/domoticz G_AGI domoticz G_EXEC apt-mark auto libusb-0.1-4 libcurl3-gnutls fi # Syncthing if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[50\]=2' /boot/dietpi/.installed then # Increase fs watcher limit: https://docs.syncthing.net/users/faq.html#inotify-limits # - 8192 until Linux 5.11, 7x RAM size in MiB since Linux 5.11, up to 1048576 # Raise UDP buffer sizes: https://github.com/quic-go/quic-go/wiki/UDP-Buffer-Sizes if (( $G_HW_MODEL == 75 )) then (( $(sysctl -n fs.inotify.max_user_watches) >= 204800 && $(sysctl -n net.core.rmem_max) >= 7500000 && $(sysctl -n net.core.wmem_max) >= 7500000 )) || G_WHIP_MSG '[WARNING] Filesystem watcher and UDP buffer size limits might be too low \nSyncthing uses filesystem (inotify) watchers to detect changes in your folders. Depending on the amount of files, the kernel version and physical RAM size of the host system, the current limit might be too low for Syncthing to start all watchers. \nAdditionally, for HTTP3/QUIC connections, the bandwidth can be limited by UDP buffer sizes. \nBoth limits can only be raised on the host of this container. E.g. add the following lines to a new sysctl config file like /etc/sysctl.d/dietpi-syncthing.conf: fs.inotify.max_user_watches=204800 net.core.rmem_max=7500000 net.core.wmem_max=7500000 \nApply them without reboot like this: sudo sysctl -p /etc/sysctl.d/dietpi-syncthing.confs \nMore info: - https://docs.syncthing.net/users/faq.html#inotify-limits - https://github.com/quic-go/quic-go/wiki/UDP-Buffer-Size' else G_EXEC eval 'echo -e '\''fs.inotify.max_user_watches=204800\nnet.core.rmem_max=7500000\nnet.core.wmem_max=7500000'\'' > /etc/sysctl.d/dietpi-syncthing.conf' local dryrun=() [[ ! -w '/proc/sys/net/core/rmem_max' ]] && systemd-detect-virt -cq && dryrun=('--dry-run') G_EXEC sysctl -p "${dryrun[@]}" /etc/sysctl.d/dietpi-syncthing.conf fi fi # PHP if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[89\]=2' /boot/dietpi/.installed then G_DIETPI-NOTIFY 2 'Enable "dietpi" PHP module, which might have been missed on installs with DietPi v9.15' G_EXEC_NOFAIL=1 G_EXEC phpenmod dietpi fi fi } Patch_9_17() { # Raspberry Pi if (( $G_HW_MODEL < 10 )) then # LightDM on Trixie requires KMS/DRM: https://github.com/MichaIng/DietPi/issues/7644#issuecomment-3229785538 if (( $G_DISTRO > 7 )) && ! grep -Eq '^[[:blank:]]*dtoverlay=vc4-f?kms-v3d' /boot/config.txt && dpkg-query -s 'lightdm' &> /dev/null then G_DIETPI-NOTIFY 2 'Enabling KMS/DRM required for LightDM since Trixie' /boot/dietpi/func/dietpi-set_hardware rpi-opengl vc4-kms-v3d fi # ZeroPi elif [[ $G_HW_MODEL == 59 && -f '/boot/dietpiEnv.txt' ]] then G_DIETPI-NOTIFY 2 'Removing device tree overlays for unwired USB controllers on ZeroPi' G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*overlays=/s/usbhost[12][[:blank:]]*//g' /boot/dietpiEnv.txt fi if [[ -f '/etc/apt/trusted.gpg.d/raspbian-archive-keyring.gpg.dpkg-new' ]] then G_DIETPI-NOTIFY 2 'Replace obsolete Raspbian key symlink with real key shipped since Trixie' G_EXEC rm /etc/apt/trusted.gpg.d/raspbian-archive-keyring.gpg G_EXEC mv /etc/apt/trusted.gpg.d/raspbian-archive-keyring.gpg{.dpkg-new,} fi # Software updates, migrations and patches if [[ -f '/boot/dietpi/.installed' ]] then # Raspotify: Remove obsolete systemd unit fixes to prevent an endless failure loop on shutdown: https://github.com/dtcooper/raspotify/pull/735 [[ -f '/etc/systemd/system/raspotify-crash-report-generator.service.d/dietpi.conf' ]] && G_EXEC rm /etc/systemd/system/raspotify-crash-report-generator.service.d/dietpi.conf [[ -d '/etc/systemd/system/raspotify-crash-report-generator.service.d' ]] && G_EXEC rmdir --ignore-fail-on-non-empty /etc/systemd/system/raspotify-crash-report-generator.service.d [[ -f '/etc/systemd/system/raspotify.service.d/dietpi.conf' ]] && G_EXEC rm /etc/systemd/system/raspotify.service.d/dietpi.conf [[ -d '/etc/systemd/system/raspotify.service.d' ]] && G_EXEC rmdir --ignore-fail-on-non-empty /etc/systemd/system/raspotify.service.d # NZBGet if [[ -f '/mnt/dietpi_userdata/nzbget/nzbget.conf' ]] && grep -q '^Server1.Cipher=RC4-MD5$' /mnt/dietpi_userdata/nzbget/nzbget.conf then G_DIETPI-NOTIFY 2 'Removing insecure and widely unsupported cipher suite from NZBGet config' G_EXEC sed --follow-symlinks -i '/^Server1.Cipher=RC4-MD5$/c\Server1.Cipher=' /mnt/dietpi_userdata/nzbget/nzbget.conf fi # ProFTPD if [[ -f '/etc/proftpd/proftpd.conf' ]] && grep -q '^[[:blank:]]*MultilineRFC2228[[:blank:]]' /etc/proftpd/proftpd.conf then G_DIETPI-NOTIFY 2 'Removing deprecated setting from ProFTPD config' G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*MultilineRFC2228[[:blank:]]/d' /etc/proftpd/proftpd.conf fi fi # RK3588 migration to vendor kernel if (( $G_HW_CPUID == 11 )) && dpkg-query -s 'linux-image-legacy-rk35xx' &> /dev/null && ! dpkg-query -s 'linux-image-vendor-rk35xx' &> /dev/null && ! dpkg-query -s 'linux-image-current-rockchip64' &> /dev/null && ! dpkg-query -s 'linux-image-edge-rockchip64' &> /dev/null then G_DIETPI-NOTIFY 2 'Migrating from legacy Linux 5.10 kernel to Linux 6.1 vendor kernel' G_AGI linux-{image,dtb}-vendor-rk35xx dpkg-query -s 'linux-headers-legacy-rk35xx' &> /dev/null && G_AGI linux-headers-vendor-rk35xx dpkg-query -s 'linux-libc-dev-legacy-rk35xx' &> /dev/null && G_AGI linux-libc-dev-vendor-rk35xx G_AGP linux-{image,dtb,headers,libc-dev}-legacy-rk35xx # The /boot/dtb symlink has been found to be missing after kernel removed, despite a newer kernel being installed already. Assure it is present and correct. [[ $(realpath '/boot/dtb') == '/boot/dtb-6.1.'* ]] || G_EXEC ln -snf /boot/dtb-6.1.* /boot/dtb # Migrate U-Boot as well case $G_HW_MODEL in 78) G_AGI linux-u-boot-rock-5b-vendor;; 79) if dpkg-query -s 'linux-u-boot-nanopi-r6s-legacy' &> /dev/null then G_AGI linux-u-boot-nanopi-r6s-vendor elif dpkg-query -s 'linux-u-boot-nanopi-r6c-legacy' &> /dev/null then G_AGI linux-u-boot-nanopi-r6c-vendor elif dpkg-query -s 'linux-u-boot-nanopct6-legacy' &> /dev/null then G_AGI linux-u-boot-nanopct6-vendor fi ;; 80) G_AGI linux-u-boot-orangepi5-vendor;; 82) G_AGI linux-u-boot-orangepi5-plus-vendor;; 85) G_AGI linux-u-boot-rock-5a-vendor;; *) :;; esac /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc # NanoPi R5S/R5C migration from legacy image with 8 partitions to Armbian-based kernel and bootloader elif (( $G_HW_MODEL == 76 )) && dpkg-query -s 'firmware-nanopi5' &> /dev/null then local model read -r model < /proc/device-tree/model case $model in *R5S*) HW_VARIANT=1 /boot/dietpi/func/dietpi-set_software apt-mirror dietpi; model='nanopi-r5s';; *R5C*) HW_VARIANT=2 /boot/dietpi/func/dietpi-set_software apt-mirror dietpi; model='nanopi-r5c';; *) G_DIETPI-NOTIFY 1 "Unknown SBC model \"$model\" detected. Aborting, please report at: https://github.com/MichaIng/DietPi/issues"; exit 1;; esac G_AGUP G_DIETPI-NOTIFY 2 'Migrating from legacy Linux 5.10 kernel to Linux 6.12 mainline kernel' # Safety checks if [[ $G_ROOTFS_DEV != *'8' ]] then G_DIETPI-NOTIFY 1 "Root filesystem is not located on partition 8 as expected, but \"$G_ROOTFS_DEV\" instead. Aborting, please report at: https://github.com/MichaIng/DietPi/issues" exit 1 elif [[ $(partx -rgo START "$G_ROOTFS_DEV") != 286720 ]] then G_DIETPI-NOTIFY 1 "Root partition does not start at sector 286720 as expected, but \"$(partx -rgo START "$G_ROOTFS_DEV")\" instead. Aborting, please report at: https://github.com/MichaIng/DietPi/issues" exit 1 fi # Install boot scripts and configs local dir="../DietPi-Update/DietPi-${G_GITBRANCH//\//-}" # GitHub translates forward slashes into dashes G_EXEC mv "$dir/.build/images/U-Boot/boot.cmd" /boot/boot.cmd G_EXEC mv "$dir/.build/images/U-Boot/dietpiEnv.txt" /boot/dietpiEnv.txt G_CONFIG_INJECT 'rootdev=' "rootdev=UUID=$(findmnt -Ufnro UUID -M /)" /boot/dietpiEnv.txt G_CONFIG_INJECT 'rootfstype=' "rootfstype=$(findmnt -Ufnro FSTYPE -M /)" /boot/dietpiEnv.txt G_EXEC mkdir -p /etc/kernel/post{inst,rm}.d /etc/initramfs/post-update.d G_EXEC mv "$dir/.build/images/U-Boot/dietpi-initramfs_cleanup" /etc/kernel/postinst.d/dietpi-initramfs_cleanup G_EXEC ln -sf /etc/kernel/post{inst,rm}.d/dietpi-initramfs_cleanup G_EXEC mv "$dir/.build/images/U-Boot/99-dietpi-uboot" /etc/initramfs/post-update.d/99-dietpi-uboot G_EXEC sed --follow-symlinks -Ei '/^setenv (kernel|fdt)_addr_r/d' /boot/boot.cmd G_CONFIG_INJECT 'setenv scriptaddr ' 'setenv scriptaddr "0x9000000"' /boot/boot.cmd G_CONFIG_INJECT 'overlay_path=' 'overlay_path=rockchip' /boot/dietpiEnv.txt # Overlay prefix G_CONFIG_INJECT 'overlay_prefix=' 'overlay_prefix=rockchip' /boot/dietpiEnv.txt # Console args G_EXEC sed --follow-symlinks -i 's/ttyAML0,115200/ttyS2,1500000/' /boot/dietpiEnv.txt # Packages G_EXEC eval 'echo '\''do_symlinks=0'\'' > /etc/kernel-img.conf' G_AGI armbian-firmware initramfs-tools u-boot-tools zstd G_AGI linux-{image,dtb}-current-rockchip64 "linux-u-boot-$model-current" # Build boot script G_EXEC_OUTPUT=1 G_EXEC mkimage -C none -A arm64 -T script -d /boot/boot.cmd /boot/boot.scr # Flash bootloader /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc G_EXEC apt-mark auto firmware-nanopi5 # Redo partitioning G_DIETPI-NOTIFY 2 'Rewriting partition table to have root filesystem in partition 1' local rootdrive=$(lsblk -npo PKNAME "$G_ROOTFS_DEV") G_EXEC_OUTPUT=1 G_EXEC sfdisk --no-reread --delete "$rootdrive" 1 2 3 4 5 6 7 8 G_EXEC_OUTPUT=1 G_EXEC sfdisk --no-reread -N1 "$rootdrive" <<< '286720' G_EXEC_OUTPUT=1 G_EXEC sfdisk --no-reread -N1 "$rootdrive" <<< ',+' # Needed, since above command and '286720,+' somehow create the partition 2015 sectors smaller, resulting in too large filesystem size. Only a subsequent ',+' expands it to the true end of the drive. # LAN interface migration for i in /etc/network/interfaces{,.d/*} /etc/default/isc-dhcp-server /etc/iptables.ipv[46].nat /etc/wireguard/wg0.conf do [[ -f $i ]] || continue G_EXEC sed --follow-symlinks -i -e 's/eth0/ethto1/g' -e 's/eth1/ethto0/g' "$i" G_EXEC sed --follow-symlinks -i -e 's/ethto1/eth1/g' -e 's/ethto0/eth0/g' "$i" done # Adjust Ethernet port LEDs if [[ $model == 'nanopi-r5s' ]] then G_DIETPI-NOTIFY 2 'Move from netdev to native Ethernet driver LED triggers' G_EXEC rm -f /etc/udev/rules.d/dietpi-eth-leds.rules /etc/modules-load.d/dietpi-eth-leds.conf else G_DIETPI-NOTIFY 2 'Updating udev rule for NanoPi R5C 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" SUBSYSTEM=="leds", KERNEL=="green:wlan", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="wlan0", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s wlan0 up", RUN+="/bin/ip l s wlan0 down" _EOF_ fi # NanoPi 6 series migration from legacy image with 8 partitions to Armbian-based kernel and bootloader elif (( $G_HW_MODEL == 79 )) && dpkg-query -s 'firmware-nanopi6' &> /dev/null then local model read -r model < /proc/device-tree/model case $model in *R6S*) HW_VARIANT=1 /boot/dietpi/func/dietpi-set_software apt-mirror dietpi; model='nanopi-r6s';; *R6C*) HW_VARIANT=2 /boot/dietpi/func/dietpi-set_software apt-mirror dietpi; model='nanopi-r6c';; *T6*) HW_VARIANT=3 /boot/dietpi/func/dietpi-set_software apt-mirror dietpi; model='nanopct6';; *) G_DIETPI-NOTIFY 1 "Unknown SBC model \"$model\" detected. Aborting, please report at: https://github.com/MichaIng/DietPi/issues"; exit 1;; esac G_AGUP G_DIETPI-NOTIFY 2 'Migrating from legacy Linux 5.10 kernel to Linux 6.1 vendor kernel' # Safety checks if [[ $G_ROOTFS_DEV != *'8' ]] then G_DIETPI-NOTIFY 1 "Root filesystem is not located on partition 8 as expected, but \"$G_ROOTFS_DEV\" instead. Aborting, please report at: https://github.com/MichaIng/DietPi/issues" exit 1 elif [[ $(partx -rgo START "$G_ROOTFS_DEV") != 286720 ]] then G_DIETPI-NOTIFY 1 "Root partition does not start at sector 286720 as expected, but \"$(partx -rgo START "$G_ROOTFS_DEV")\" instead. Aborting, please report at: https://github.com/MichaIng/DietPi/issues" exit 1 fi # Install boot scripts and configs local dir="../DietPi-Update/DietPi-${G_GITBRANCH//\//-}" # GitHub translates forward slashes into dashes G_EXEC mv "$dir/.build/images/U-Boot/boot.cmd" /boot/boot.cmd G_EXEC mv "$dir/.build/images/U-Boot/dietpiEnv.txt" /boot/dietpiEnv.txt G_CONFIG_INJECT 'rootdev=' "rootdev=UUID=$(findmnt -Ufnro UUID -M /)" /boot/dietpiEnv.txt G_CONFIG_INJECT 'rootfstype=' "rootfstype=$(findmnt -Ufnro FSTYPE -M /)" /boot/dietpiEnv.txt G_EXEC mkdir -p /etc/kernel/post{inst,rm}.d /etc/initramfs/post-update.d G_EXEC mv "$dir/.build/images/U-Boot/dietpi-initramfs_cleanup" /etc/kernel/postinst.d/dietpi-initramfs_cleanup G_EXEC ln -sf /etc/kernel/post{inst,rm}.d/dietpi-initramfs_cleanup G_EXEC mv "$dir/.build/images/U-Boot/99-dietpi-uboot" /etc/initramfs/post-update.d/99-dietpi-uboot G_EXEC sed --follow-symlinks -Ei '/^setenv (kernel|fdt)_addr_r/d' /boot/boot.cmd G_CONFIG_INJECT 'setenv scriptaddr ' 'setenv scriptaddr "0x9000000"' /boot/boot.cmd G_CONFIG_INJECT 'overlay_path=' 'overlay_path=rockchip' /boot/dietpiEnv.txt # Device tree case $model in 'nanopi-r6s') G_CONFIG_INJECT 'fdtfile=' 'fdtfile=rockchip/rk3588s-nanopi-r6s.dtb' /boot/dietpiEnv.txt;; 'nanopi-r6c') G_CONFIG_INJECT 'fdtfile=' 'fdtfile=rockchip/rk3588s-nanopi-r6c.dtb' /boot/dietpiEnv.txt;; *) :;; esac # Overlay prefix G_CONFIG_INJECT 'overlay_prefix=' 'overlay_prefix=rockchip-rk3588 rk3588' /boot/dietpiEnv.txt # Console args G_EXEC sed --follow-symlinks -i 's/ttyAML0,115200/ttyFIQ0,1500000/' /boot/dietpiEnv.txt # Packages G_EXEC eval 'echo '\''do_symlinks=0'\'' > /etc/kernel-img.conf' G_AGI armbian-firmware initramfs-tools u-boot-tools zstd G_AGI linux-{image,dtb}-vendor-rk35xx "linux-u-boot-$model-vendor" # Build boot script G_EXEC_OUTPUT=1 G_EXEC mkimage -C none -A arm64 -T script -d /boot/boot.cmd /boot/boot.scr # Flash bootloader /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc G_EXEC apt-mark auto firmware-nanopi6 # Redo partitioning G_DIETPI-NOTIFY 2 'Rewriting partition table to have root filesystem in partition 1' local rootdrive=$(lsblk -npo PKNAME "$G_ROOTFS_DEV") G_EXEC_OUTPUT=1 G_EXEC sfdisk --no-reread --delete "$rootdrive" 1 2 3 4 5 6 7 8 G_EXEC_OUTPUT=1 G_EXEC sfdisk --no-reread -N1 "$rootdrive" <<< '286720' G_EXEC_OUTPUT=1 G_EXEC sfdisk --no-reread -N1 "$rootdrive" <<< ',+' # Needed, since above command and '286720,+' somehow create the partition 2015 sectors smaller, resulting in too large filesystem size. Only a subsequent ',+' expands it to the true end of the drive. # LAN interface migration if [[ $model == 'nanopi-r6s' ]] then G_DIETPI-NOTIFY 2 'Migrating LAN interface configs' for i in /etc/network/interfaces{,.d/*} /etc/default/isc-dhcp-server /etc/iptables.ipv[46].nat /etc/wireguard/wg0.conf do [[ -f $i ]] || continue G_EXEC sed --follow-symlinks -i -e 's/eth1/ethto2/g' -e 's/eth2/ethto1/g' "$i" G_EXEC sed --follow-symlinks -i -e 's/ethto2/eth2/g' -e 's/ethto1/eth1/g' "$i" done fi # Adjust Ethernet port LEDs if [[ $model == 'nanopi-r6s' ]] then G_DIETPI-NOTIFY 2 'Updating udev rule for NanoPi R6S 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=="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=="wan_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=="lan1_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_ elif [[ $model == 'nanopi-r6c' ]] then G_DIETPI-NOTIFY 2 'Updating udev rule for NanoPi R6C 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=="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=="user_led", ACTION=="add", ATTR{trigger}="netdev", ATTR{device_name}="wlan0", ATTR{link}="1", ATTR{rx}="1", ATTR{tx}="1", RUN+="/bin/ip l s wlan0 up", RUN+="/bin/ip l s wlan0 down" _EOF_ fi fi } Patch_9_18() { # Raspberry Pi if (( $G_HW_MODEL < 10 )) then G_DIETPI-NOTIFY 2 'Revert now obsolete workaround for hanging task vchiq-keep errors and (visual-only) +1.0 load average' # https://github.com/MichaIng/DietPi/issues/7610 [[ -f '/etc/modprobe.d/dietpi-disable_vcsm.conf' ]] && ! grep -vq '^vc_sm_cma$' /etc/modprobe.d/dietpi-disable_vcsm.conf && G_EXEC rm /etc/modprobe.d/dietpi-disable_vcsm.conf # Get current memory split # - Get override setting: gpu_mem_1024 is effective for all models with >= 1 GiB RAM local size=1024 default=76 (( $G_HW_MEMORY_SIZE < 1024 )) && size=$G_HW_MEMORY_SIZE default=64 local gpu_mem_current=$(sed -n "/^[[:blank:]]*gpu_mem_$size=/{s/^[^=]*=//p;q}" /boot/config.txt) # override setting [[ $gpu_mem_current ]] || gpu_mem_current=$(sed -n '/^[[:blank:]]*gpu_mem=/{s/^[^=]*=//p;q}' /boot/config.txt) # base setting [[ $gpu_mem_current ]] || gpu_mem_current=$default # default value (( $gpu_mem_current < 32 )) && G_EXEC eval 'echo '\''blacklist vc_sm_cma'\'' > /etc/modprobe.d/dietpi-disable_vcsm.conf' elif [[ -f '/boot/boot.cmd' ]] && ! grep -q ' ubootpart=' /boot/boot.cmd then G_DIETPI-NOTIFY 2 'Aligning U-Boot partition cmdline parameter in boot script' G_EXEC sed --follow-symlinks -i '/^setenv bootargs /s/ partuuid=/ ubootpart=/' /boot/boot.cmd local arch='arm' (( $G_HW_ARCH == 3 )) && arch='arm64' G_EXEC mkimage -C none -A "$arch" -T script -d /boot/boot.cmd /boot/boot.scr fi } Patch_9_19() { # Raspberry Pi with new kernel stack if (( $G_HW_MODEL < 10 )) && dpkg-query -s 'raspi-firmware' &> /dev/null && ! grep '^[[:blank:]]*SKIP_INITRAMFS_GEN=yes' /etc/default/raspi-firmware && ! grep -q '^[[:blank:]]*auto_initramfs=' /boot/config.txt && ! grep -q '^[[:blank:]]*initramfs[[:blank:]]' /boot/config.txt then G_DIETPI-NOTIFY 2 'Disabling initramfs generation, since it is not explicitly enabled in config.txt' G_CONFIG_INJECT 'SKIP_INITRAMFS_GEN=' 'SKIP_INITRAMFS_GEN=yes' /etc/default/raspi-firmware G_EXEC rm -f /boot/initrd.img-* /boot/firmware/initramfs* fi # Software updates, migrations and patches if [[ -f '/boot/dietpi/.installed' ]] then # ProFTPD if [[ -f '/etc/ftpusers' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[94\]=2' /boot/dietpi/.installed then G_DIETPI-NOTIFY 2 'Do not allow root user to use ProFTPD' G_CONFIG_INJECT 'root' 'root' /etc/ftpusers fi fi } Patch_9_20() { # Remove obsolete configs from pre-patches [[ -f '/etc/apt/preferences.d/dietpi-armbian-tmp' ]] && G_EXEC rm /etc/apt/preferences.d/dietpi-armbian-tmp [[ -f '/etc/apt/apt.conf.d/dietpi-armbian-tmp' ]] && G_EXEC rm /etc/apt/apt.conf.d/dietpi-armbian-tmp # Radxa ZERO 3 if (( $G_HW_MODEL == 90 )) && dpkg-query -l | grep -Eq '^ii[[:blank:]]*linux-image-(legacy|vendor)-rk35xx[[:blank:]:]' && ! dpkg-query -l | grep -Eq '^ii[[:blank:]]*linux-image-(current|edge)-rockchip64[[:blank:]:]' then G_DIETPI-NOTIFY 2 'Migrating to "current" kernel branch with Linux 6.12' local packages=() dpkg-query -l | grep -Eq '^ii[[:blank:]]*linux-headers-(legacy|vendor)-rk35xx[[:blank:]:]' && packages+=('linux-headers-current-rockchip64') dpkg-query -l | grep -Eq '^ii[[:blank:]]*linux-libc-dev-(legacy|vendor)-rk35xx[[:blank:]:]' && packages+=('linux-libc-dev-current-rockchip64') G_AGI linux-{image,dtb}-current-rockchip64 "${packages[@]}" linux-u-boot-radxa-zero3-current G_EXEC_OUTPUT=1 G_EXEC /boot/dietpi/func/dietpi-set_hardware flash-u-boot-mmc G_AGP linux-{image,dtb,headers,libc-dev}-{legacy,vendor}-rk35xx # The /boot/dtb symlink has been found to be missing after kernel removed, despite a newer kernel being installed already. Assure it is present and correct. [[ -d '/boot/dtb' ]] || G_EXEC ln -snf /boot/dtb-6.12.* /boot/dtb fi G_DIETPI-NOTIFY 2 'Masking unnecessary systemd-firstboot service' G_EXEC systemctl --no-reload mask systemd-firstboot # Software updates, migrations and patches if [[ -f '/boot/dietpi/.installed' ]] then # Aria2 if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[132\]=2' /boot/dietpi/.installed then if grep -q '^[[:blank:]]*log=/var/log/aria2.log' /mnt/dietpi_userdata/aria2/aria2.conf then G_DIETPI-NOTIFY 2 'Disabling redundant Aria2 file logging' G_EXEC sed --follow-symlinks -i -e '\|^[[:blank:]]*log=/var/log/aria2.log|c\console-log-level=notice' -e '/^[[:blank:]]*log-level=/d' /mnt/dietpi_userdata/aria2/aria2.conf G_EXEC rm -f /var/log/aria2.log fi if [[ -f '/usr/local/bin/aria2c' ]] then G_DIETPI-NOTIFY 2 'Replacing ancient own aria2c builds used up to Debian Jessie' G_AG_CHECK_INSTALL_PREREQ aria2 G_EXEC rm /usr/local/bin/aria2c fi fi # LazyLibrarian if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[169\]=2' /boot/dietpi/.installed && [[ -f '/etc/systemd/system/lazylibrarian.service' ]] then G_DIETPI-NOTIFY 2 'Fixing LazyLibrarian "Restart" button' G_CONFIG_INJECT 'ExitType=' 'ExitType=cgroup' /etc/systemd/system/lazylibrarian.service '\[Service\]' fi # Fail2Ban # - Debian Trixie's /etc/fail2ban/jail.d/defaults-debian.conf sets the [DEFAULT] banaction = nftables. This makes sense if the upstream default iptables was otherwise used, but it must not override any explicit choice. # - If /etc/fail2ban/jail.conf sets anything different than [DEFAULT] banaction = iptables, it was obviously explicitly changed by admin or dietpi-software, and this choice must not be overridden. if dpkg-query -l | grep -q '^ii[[:blank:]]*fail2ban[[:blank:]:]' then # jail.conf [DEFAULT] banaction # shellcheck disable=SC2016 local conf_banaction=$(sed -n '/^\[DEFAULT\]/,/^\[/{/^banaction[[:blank:]=]/h};${g;s/^banaction[[:blank:]=]*//p}' /etc/fail2ban/jail.conf) # Effective [DEFAULT] banaction # shellcheck disable=SC2016 local used_banaction=$(sed -n '/^\[DEFAULT\]/,/^\[/{/^banaction[[:blank:]=]/h};${g;s/^banaction[[:blank:]=]*//p}' /etc/fail2ban/jail.{conf,d/*.conf,local,d/*.local} 2> /dev/null) # If jail.conf does not set [DEFAULT] banaction = iptables, it is intentional, hence delete defaults-debian.conf to prevent override with nftables on Trixie if [[ $conf_banaction != 'iptables'* ]] then G_DIETPI-NOTIFY 2 'Deleting conflicting Debian Fail2Ban jail config override' G_EXEC rm -f /etc/fail2ban/jail.d/defaults-debian.conf [[ $used_banaction == 'nftables'* ]] && ! dpkg-query -l | grep -q '^ii[[:blank:]]*nftables[[:blank:]:]' && G_EXEC systemctl restart fail2ban # Else, if the effective [DEFAULT] banaction is nftables, assure that userland tools are installed elif [[ $used_banaction == 'nftables'* ]] && ! dpkg-query -l | grep -q '^ii[[:blank:]]*nftables[[:blank:]:]' then G_DIETPI-NOTIFY 2 'Installing missing nftables userland tools for Fail2Ban' G_AGI nftables fi fi # BirdNET-Go if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[127\]=2' /boot/dietpi/.installed then G_DIETPI-NOTIFY 2 'Fixing local sound card detection for BirdNET-Go' G_EXEC usermod -aG audio birdnet G_EXEC sed --follow-symlinks -i '/^PrivateDevices=/d' /etc/systemd/system/birdnet.service fi # Update Allo GUI if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[160\]=2' /boot/dietpi/.installed then G_DIETPI-NOTIFY 2 'Scheduling Allo GUI update to latest version' G_EXEC eval 'echo 160 >> /var/tmp/dietpi/dietpi-update_reinstalls' fi fi } Patch_10_0() { # dietpi.txt migration if grep -q '^[[:blank:]]*SOFTWARE_OWNCLOUD_NEXTCLOUD_USERNAME=' /boot/dietpi.txt then G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*SOFTWARE_NEXTCLOUD_USERNAME=/d' /boot/dietpi.txt G_EXEC sed --follow-symlinks -i 's/SOFTWARE_OWNCLOUD_NEXTCLOUD_USERNAME=/SOFTWARE_NEXTCLOUD_USERNAME=/' /boot/dietpi.txt fi G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*SOFTWARE_OWNCLOUD_DATADIR=/d' /boot/dietpi.txt # UNISOC/Spreadtrum WiFi driver loading: https://github.com/MichaIng/DietPi/issues/7878 if [[ $G_HW_MODEL =~ ^(83|87|88|89|99)$ && -f '/etc/modules-load.d/dietpi-enable_wifi.conf' ]] then # Orange Pi 3B v2.1 uses a different chip if [[ $G_HW_MODEL == 87 && $G_HW_REVISION != '1.1' ]] then G_DIETPI-NOTIFY 2 'Removing UNISOC/Spreadtrum WiFi driver load config as the driver is not used on Orange Pi 3B v2.1 but can cause a crash at boot' G_EXEC rm /etc/modules-load.d/dietpi-enable_wifi.conf else G_DIETPI-NOTIFY 2 'Update UNISOC/Spreadtrum WiFi driver load config to rule out crash at boot' G_EXEC eval 'echo -e '\''cpufreq_dt\nsprdwl_ng'\'' > /etc/modules-load.d/dietpi-enable_wifi.conf' fi fi # Software updates, migrations and patches if [[ -f '/boot/dietpi/.installed' ]] then # ownCloud if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[47\]=2' /boot/dietpi/.installed && [[ ! -f '/opt/ocis/ocis' ]] then G_WHIP_MSG '[ INFO ] ownCloud 10 installation detected \nownCloud 10 does not support PHP 8.x and hence cannot run on Debian Bookworm or above with its native PHP version. \nAs a replacement, we implemented ownCloud Infinite Scale with DietPi 10.0, ownCloud'\''s successor written in Go. A direct data migration however is not possible. The easiest way to port data is probably to upload them back into a new instance from clients. \nAn alternative is to migrate to Nextcloud, a ~10 years old very actively developed fork, which still supports seamless migration from ownCloud, preserving most settings and metadata, and offers also most of the apps (and a lot more) found in ownCloud'\''s app market. \nRead more details here: https://github.com/MichaIng/DietPi/pull/7886' G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[47\]=/d' /boot/dietpi/.installed fi # RPi Cam Web Interface grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[59\]=' /boot/dietpi/.installed && G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[59\]=/d' /boot/dietpi/.installed # Pydio grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[48\]=' /boot/dietpi/.installed && G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[48\]=/d' /boot/dietpi/.installed # Pi-hole v6 migration # - /etc/pihole/pihole.toml indicates that Pi-hole has been upgraded to v6 already. # - The /var/www/pihole symlink indicates that an instance installed via dietpi-software has not been migrated yet. if [[ -f '/etc/pihole/pihole.toml' && -L '/var/www/pihole' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[93\]=2' /boot/dietpi/.installed then # Remove DietPi specific v5 files # - Symlinks G_EXEC rm /var/www/pihole [[ -L '/var/www/admin' ]] && G_EXEC rm /var/www/admin # - Webserver configs [[ -d '/etc/apache2/sites-available' ]] && G_EXEC rm -f /etc/apache2/sites-{available,enabled}/dietpi-pihole* [[ -d '/etc/lighttpd/conf-available' ]] && G_EXEC rm -f /etc/lighttpd/conf-{available,enabled}/99-dietpi-pihole* [[ -d '/etc/nginx/sites-dietpi' ]] && G_EXEC rm -f /etc/nginx/sites-dietpi/dietpi-pihole* # Remove www-data user from pihole group getent group pihole | grep -Eq '(:|,)www-data(,|$)' && G_EXEC gpasswd -d www-data pihole # Change web UI port to 8089 and 8489 (HTTPS) to avoid conflict with webservers and other web applications G_EXEC pihole-FTL --config webserver.port 8089,8489s # Inform user about differences to stock Pi-hole installation G_WHIP_MSG "[ INFO ] Pi-hole network ports changed to 8089 and 8489 \nTo align migrated Pi-hole v6 instances with fresh installs, and avoid possible conflicts with dedicated webservers, the network ports have been changed to 8089 and 8489 (HTTPS). Your Pi-hole instance will hence be available at: - http://$(G_GET_NET ip):8089/admin/ - https://$(G_GET_NET ip):8489/admin/ \nThis can be changed via web UI or following console command, e.g. for ports 80 and 443 (HTTPS): - sudo pihole-FTL --config webserver.port 80,443s" # Offer to uninstall webserver and PHP if no dependant is installed # - If only PHP or only a webserver is installed, one has been uninstalled already, and the other is assumed to be still needed for something else. if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[89\]=2' /boot/dietpi/.installed && grep -Eq '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[(83|84|85)\]=2' /boot/dietpi/.installed then G_WHIP_CHECKLIST_ARRAY=() # - webserver if ! /boot/dietpi/dietpi-software list | grep -q '| =2 |.*+webserver' then grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[83\]=2' /boot/dietpi/.installed && G_WHIP_CHECKLIST_ARRAY+=(83 'Apache webserver' off) grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[84\]=2' /boot/dietpi/.installed && G_WHIP_CHECKLIST_ARRAY+=(84 'Lighttpd webserver' off) grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[85\]=2' /boot/dietpi/.installed && G_WHIP_CHECKLIST_ARRAY+=(85 'Nginx webserver' off) fi # - PHP: Exclude webserver stacks which are meta selections only /boot/dietpi/dietpi-software list | grep '| =2 |.*+PHP' | grep -vEq '^.\[32mID (75|76|78|79|81|82)' || G_WHIP_CHECKLIST_ARRAY+=(89 'PHP server' off) if (( ${#G_WHIP_CHECKLIST_ARRAY[@]} )) then G_WHIP_BUTTON_CANCEL_TEXT='Skip' # shellcheck disable=SC2086 G_WHIP_CHECKLIST '[ INFO ] Possibly obsolete webserver and/or PHP installation detected \nYou recently updated Pi-hole to v6, which now does not require any webserver or PHP anymore. \nWe detected a webserver and/or PHP installation on your system, but no dependant among installed dietpi-software options. \nIf you are sure that you do not require the webserver and/or PHP anymore, you can select them for uninstall below. Use the space bar to (de)select the ones which shall be uninstalled:' && /boot/dietpi/dietpi-software uninstall $G_WHIP_RETURNED_VALUE fi fi fi fi # RPi firmware migration: Do after all other patches if (( $G_HW_MODEL < 10 )) && ! dpkg-query -s 'raspi-firmware' &> /dev/null then G_WHIP_MSG '[ INFO ] Raspberry Pi kernel/firmware migration will be applied \nA migration to the new RPi Linux 6.12+ kernel and firmware stack will be applied. Please report any error at our forum or GitHub. The DietPi update will finish in any case, and you can retry the migration with: $ /boot/dietpi/func/dietpi-set_software rpi_firmware_migration' G_EXEC_OUTPUT=1 G_EXEC /boot/dietpi/func/dietpi-set_software rpi_firmware_migration fi } # Failsafe: Error out on invalid version if ! (( $G_DIETPI_VERSION_CORE > 7 )) then G_DIETPI-NOTIFY 1 "Unsupported DietPi version $G_DIETPI_VERSION_CORE.$G_DIETPI_VERSION_SUB.$G_DIETPI_VERSION_RC. Aborting ..." G_DIETPI-NOTIFY 2 'Please run "dietpi-update" to repeat the regular update path.' exit 1 fi # Main loop G_DIETPI_VERSION_RC=0 while : do if declare -F "Patch_${G_DIETPI_VERSION_CORE}_$(( $G_DIETPI_VERSION_SUB + 1 ))" > /dev/null then ((G_DIETPI_VERSION_SUB++)) elif declare -F "Patch_$(( $G_DIETPI_VERSION_CORE + 1 ))_0" > /dev/null then ((G_DIETPI_VERSION_CORE++)) G_DIETPI_VERSION_SUB=0 else break fi G_DIETPI-NOTIFY 2 "Patching to DietPi v$G_DIETPI_VERSION_CORE.$G_DIETPI_VERSION_SUB ..." "Patch_${G_DIETPI_VERSION_CORE}_$G_DIETPI_VERSION_SUB" G_VERSIONDB_SAVE G_DIETPI-NOTIFY 0 "Patched to DietPi v$G_DIETPI_VERSION_CORE.$G_DIETPI_VERSION_SUB" done # Performing reinstalls if [[ -f '/var/tmp/dietpi/dietpi-update_reinstalls' ]] then G_DIETPI-NOTIFY 2 'Performing DietPi-Software reinstalls...' # Coders NB: Assigning to array is not easily possible here since we need to split at newline AND space. # shellcheck disable=SC2046 (( $G_DIETPI_INSTALL_STAGE == 2 )) && /boot/dietpi/dietpi-software reinstall $(