From a0a50ceeaad3253607d2911a15074a3d22703ac1 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Thu, 7 Dec 2023 21:37:38 +0100 Subject: [PATCH] v8.25 - General | Follow symlink with all sed calls on files. This is required for the new RPi firmware packages which have /boot/config.txt etc symlinks to /boot/firmware/config.txt. But it is generally useful and the expected behaviour. --- .build/images/dietpi-build | 8 +- .build/images/dietpi-imager | 6 +- .build/images/dietpi-installer | 74 +++--- .build/software/Amiberry/container_build.bash | 2 +- .build/software/dietpi-software-build.bash | 2 +- .build/software/gmediarender/build.bash | 2 +- .../software/raspberrypi-sys-mods/build.bash | 2 +- .build/software/vaultwarden/build.bash | 2 +- .github/workflows/dietpi-software.bash | 16 +- .github/workflows/quartz64.yml | 16 +- .meta/dietpi-bookworm-upgrade | 18 +- .update/patches | 152 ++++++------ .update/pre-patches | 24 +- dietpi/dietpi-backup | 10 +- dietpi/dietpi-cleaner | 2 +- dietpi/dietpi-config | 22 +- dietpi/dietpi-drive_manager | 28 +-- dietpi/dietpi-led_control | 2 +- dietpi/dietpi-letsencrypt | 8 +- dietpi/dietpi-services | 8 +- dietpi/dietpi-software | 218 +++++++++--------- dietpi/dietpi-vpn | 8 +- dietpi/func/dietpi-globals | 10 +- dietpi/func/dietpi-set_hardware | 120 +++++----- dietpi/func/dietpi-set_software | 26 +-- dietpi/func/dietpi-set_swapfile | 2 +- dietpi/misc/dietpi-justboom | 12 +- dietpi/patch_file | 154 ++++++------- dietpi/pre-patch_file | 12 +- .../lib/dietpi/services/dietpi-firstboot.bash | 68 +++--- 30 files changed, 517 insertions(+), 517 deletions(-) diff --git a/.build/images/dietpi-build b/.build/images/dietpi-build index 5af9fc39ef..3df67896c6 100755 --- a/.build/images/dietpi-build +++ b/.build/images/dietpi-build @@ -595,10 +595,10 @@ _EOF_ G_CONFIG_INJECT 'AUTO_SETUP_AUTOSTART_TARGET_INDEX=' 'AUTO_SETUP_AUTOSTART_TARGET_INDEX=0' rootfs/boot/dietpi.txt # Force ARMv6 arch on Raspbian - (( $HW_ARCH == 1 )) && echo 'sed -i -e '\''/^G_HW_ARCH=/c\G_HW_ARCH=1'\'' -e '\''/^G_HW_ARCH_NAME=/c\G_HW_ARCH_NAME=armv6l'\'' /boot/dietpi/.hw_model' > rootfs/boot/Automation_Custom_PreScript.sh + (( $HW_ARCH == 1 )) && echo 'sed --follow-symlinks -i -e '\''/^G_HW_ARCH=/c\G_HW_ARCH=1'\'' -e '\''/^G_HW_ARCH_NAME=/c\G_HW_ARCH_NAME=armv6l'\'' /boot/dietpi/.hw_model' > rootfs/boot/Automation_Custom_PreScript.sh # Temporary fix for failing NAA Daemon install on Trixie - (( $DISTRO == 8 )) && G_EXEC sed -i '\|www.signalyst.eu|s|bookworm/bullseye|trixie/bullseye|' rootfs/boot/dietpi/dietpi-software + (( $DISTRO == 8 )) && G_EXEC sed --follow-symlinks -i '\|www.signalyst.eu|s|bookworm/bullseye|trixie/bullseye|' rootfs/boot/dietpi/dietpi-software # Skip filesystem expansion G_EXEC rm rootfs/etc/systemd/system/local-fs.target.wants/dietpi-fs_partition_resize.service @@ -627,7 +627,7 @@ then systemctl mask serial-getty@ttyS0 /boot/dietpi/func/dietpi-set_hardware serialconsole 1 serial0 G_CONFIG_INJECT 'temp_limit=' 'temp_limit=75' /boot/config.txt # since most RPis are now RPi 4 and Allo ships the CM3 with USBridge Sig and Allo GUI image - G_EXEC sed -Ei 's/^(arm_freq|over_voltage)=/#\1=/' /boot/config.txt + G_EXEC sed --follow-symlinks -Ei 's/^(arm_freq|over_voltage)=/#\1=/' /boot/config.txt fi # FirstBoot @@ -658,7 +658,7 @@ G_EXEC rm /etc/bashrc.d/00-dietpi-build.sh /boot/Automation_Custom_Script.sh poweroff } _EOF_ - (( $HW_ARCH == 1 )) && G_EXEC sed -i 's/Custom_Script/Custom_{Pre,}Script/' rootfs/boot/Automation_Custom_Script.sh + (( $HW_ARCH == 1 )) && G_EXEC sed --follow-symlinks -i 's/Custom_Script/Custom_{Pre,}Script/' rootfs/boot/Automation_Custom_Script.sh # Start container # - Bind mounts required to allow container reading its own drive info, /dev/disk for GRUB and probably other tools to detect UUIDs diff --git a/.build/images/dietpi-imager b/.build/images/dietpi-imager index 5679df1b30..e69025bf47 100755 --- a/.build/images/dietpi-imager +++ b/.build/images/dietpi-imager @@ -667,7 +667,7 @@ _EOF_ sed '/^menuentry /,$d' tmpiso/boot/grub/clonezilla.cfg > tmpiso/boot/grub/grub.cfg sed -n '/menuentry .*Safe graphic/,/}/s/^ //p' tmpiso/boot/grub/clonezilla.cfg >> tmpiso/boot/grub/grub.cfg # shellcheck disable=SC2016 - sed -i -e '/^set timeout=/c\set timeout="-1"' -e '/^set pref=/a\set theme=\$pref/theme.txt' -e '/^menuentry /c\menuentry "Install DietPi" {' \ + sed --follow-symlinks -i -e '/^set timeout=/c\set timeout="-1"' -e '/^set pref=/a\set theme=\$pref/theme.txt' -e '/^menuentry /c\menuentry "Install DietPi" {' \ -e 's/locales= /locales=C.UTF-8 /' -e 's/keyboard-layouts= /keyboard-layouts=gb /' -e 's/ocs-live-general/ocs-live-restore/' \ -e "s|ocs_live_extra_param=\"\"|ocs_live_extra_param=\"-icds -k1 -r -e2 -j2 -b -p poweroff restoredisk $OUTPUT_IMG_NAME ask_user\"|" \ -e 's/ocs_live_batch="no"/ocs_live_batch="yes"/' tmpiso/boot/grub/grub.cfg @@ -680,10 +680,10 @@ _EOF_ G_EXEC curl -sSf "$DIETPI_REPO/.build/images/Clonezilla/dietpi-background_480p.png" -o tmpiso/syslinux/dietpibg.png G_EXEC cp /usr/lib/syslinux/modules/bios/poweroff.c32 tmpiso/syslinux/ G_EXEC mv tmpiso/syslinux/{syslinux,clonezilla}.cfg - sed -i '/^MENU TITLE/c\MENU TITLE Clonezilla live' tmpiso/syslinux/clonezilla.cfg + sed --follow-symlinks -i '/^MENU TITLE/c\MENU TITLE Clonezilla live' tmpiso/syslinux/clonezilla.cfg sed '/^label /,$d' tmpiso/syslinux/clonezilla.cfg > tmpiso/syslinux/syslinux.cfg sed -n '/^label .*framebuffer/,/ENDTEXT/p' tmpiso/syslinux/clonezilla.cfg >> tmpiso/syslinux/syslinux.cfg - sed -i -e '/^timeout /c\timeout 0' -e 's|\(MENU BACKGROUND\) .*|\1 dietpibg.png|' -e '/^MENU TITLE /c\MENU TABMSG' \ + sed --follow-symlinks -i -e '/^timeout /c\timeout 0' -e 's|\(MENU BACKGROUND\) .*|\1 dietpibg.png|' -e '/^MENU TITLE /c\MENU TABMSG' \ -e '/menu title/d' -e '/^say /d' -e '/MENU MARGIN/a\MENU HSHIFT 80\n MENU COLOR BORDER 0 #00000000 #00000000 none' \ -e '/^label /c\label Install DietPi' -e '/^ MENU LABEL /c\ MENU LABEL Install DietPi' -e '/^ TEXT HELP/,/^ ENDTEXT/d' \ -e 's/locales= /locales=C.UTF-8 /' -e 's/keyboard-layouts= /keyboard-layouts=gb /' -e 's/ocs-live-general/ocs-live-restore/' \ diff --git a/.build/images/dietpi-installer b/.build/images/dietpi-installer index 40cdb71324..cab8f40399 100755 --- a/.build/images/dietpi-installer +++ b/.build/images/dietpi-installer @@ -578,13 +578,13 @@ _EOF_ local model='OdroidC1' (( $G_HW_MODEL == 11 )) && model='OdroidXU4' G_EXEC mv "DietPi-$G_GITBRANCH/.build/images/$model/boot.ini" /boot/boot.ini - G_EXEC sed -i "s/root=[^[:blank:]]*/root=UUID=$(findmnt -Ufnro UUID -M /)/" /boot/boot.ini - G_EXEC sed -i "s/rootfstype=[^[:blank:]]*/rootfstype=$(findmnt -Ufnro FSTYPE -M /)/" /boot/boot.ini + G_EXEC sed --follow-symlinks -i "s/root=[^[:blank:]]*/root=UUID=$(findmnt -Ufnro UUID -M /)/" /boot/boot.ini + G_EXEC sed --follow-symlinks -i "s/rootfstype=[^[:blank:]]*/rootfstype=$(findmnt -Ufnro FSTYPE -M /)/" /boot/boot.ini G_EXEC mkdir -p /etc/kernel/post{inst,rm}.d /etc/initramfs/post-update.d G_EXEC mv "DietPi-$G_GITBRANCH/.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 "DietPi-$G_GITBRANCH/.build/images/U-Boot/99-dietpi-uboot" /etc/initramfs/post-update.d/99-dietpi-uboot - G_EXEC sed -i 's/arm64/arm/' /etc/initramfs/post-update.d/99-dietpi-uboot + G_EXEC sed --follow-symlinks -i 's/arm64/arm/' /etc/initramfs/post-update.d/99-dietpi-uboot elif [[ $G_HW_MODEL =~ ^(12|15|16|40|42|43|44|45|46|47|48|52|54|55|56|57|58|59|60|62|63|64|65|66|67|68|72|73|74|77|78|80|82|83|85|86)$ ]] then @@ -600,28 +600,28 @@ _EOF_ # Odroid C2: Fix USB device detection: https://github.com/MichaIng/DietPi/issues/5963 if (( $G_HW_MODEL == 12 )) then - G_EXEC sed -i 's/coherent_pool=2M/coherent_pool=2M usbcore.autosuspend=-1/' /boot/boot.cmd + G_EXEC sed --follow-symlinks -i 's/coherent_pool=2M/coherent_pool=2M usbcore.autosuspend=-1/' /boot/boot.cmd # Odroid N2/HC4 elif [[ $G_HW_MODEL =~ ^(15|16)$ ]] then # Enable USB boot via petitboot support: https://github.com/MichaIng/DietPi/issues/5634 - G_EXEC sed -i '1i[main]' /boot/dietpiEnv.txt + G_EXEC sed --follow-symlinks -i '1i[main]' /boot/dietpiEnv.txt # shellcheck disable=SC2016 - (( $G_HW_MODEL == 15 )) && G_EXEC sed -i '/^setenv overlay_error/a\ + (( $G_HW_MODEL == 15 )) && G_EXEC sed --follow-symlinks -i '/^setenv overlay_error/a\ \n# petitboot workarounds\ if test "${variant}" = "n2_plus"; then setenv variant "n2-plus"; fi\ setenv fdtfile "amlogic/meson-g12b-odroid-${variant}.dtb"\ setenv rootuuid "true"' /boot/boot.cmd # shellcheck disable=SC2016 - (( $G_HW_MODEL == 16 )) && G_EXEC sed -i '/^setenv overlay_error/a\ + (( $G_HW_MODEL == 16 )) && G_EXEC sed --follow-symlinks -i '/^setenv overlay_error/a\ \n# petitboot workarounds\ setenv fdtfile "amlogic/meson-sm1-odroid-${variant}.dtb"\ setenv rootuuid "true"' /boot/boot.cmd # shellcheck disable=SC2016 - G_EXEC sed -i '/env import/c\ ini main ${scriptaddr} || env import -t ${scriptaddr} ${filesize}' /boot/boot.cmd + G_EXEC sed --follow-symlinks -i '/env import/c\ ini main ${scriptaddr} || env import -t ${scriptaddr} ${filesize}' /boot/boot.cmd # shellcheck disable=SC2016 - G_EXEC sed -i '/test -e/s/fixup.scr;/fixup.scr || test "${petitboot_active}" = "1";/' /boot/boot.cmd + G_EXEC sed --follow-symlinks -i '/test -e/s/fixup.scr;/fixup.scr || test "${petitboot_active}" = "1";/' /boot/boot.cmd # 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' @@ -629,7 +629,7 @@ setenv rootuuid "true"' /boot/boot.cmd # Rockchip 64-bit (configs work with Amlogic OOTB) elif [[ $G_HW_MODEL =~ ^(42|43|46|47|55|56|58|68|72|73|77|78|80|82|85|86)$ ]] then - G_EXEC sed -Ei '/^setenv (kernel|fdt)_addr_r/d' /boot/boot.cmd + 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 case $G_HW_MODEL in @@ -650,29 +650,29 @@ setenv rootuuid "true"' /boot/boot.cmd case $G_HW_MODEL in 73) G_CONFIG_INJECT 'consoleargs=' 'consoleargs=console=ttyS0,1500000' /boot/dietpiEnv.txt;; # headless 47|55|56) G_CONFIG_INJECT 'consoleargs=' 'consoleargs=console=ttyS2,1500000' /boot/dietpiEnv.txt;; # headless - 78|80|82) G_EXEC sed -i 's/ttyAML0,115200/ttyFIQ0,1500000/' /boot/dietpiEnv.txt;; - *) G_EXEC sed -i 's/ttyAML0,115200/ttyS2,1500000/' /boot/dietpiEnv.txt;; + 78|80|82) G_EXEC sed --follow-symlinks -i 's/ttyAML0,115200/ttyFIQ0,1500000/' /boot/dietpiEnv.txt;; + *) G_EXEC sed --follow-symlinks -i 's/ttyAML0,115200/ttyS2,1500000/' /boot/dietpiEnv.txt;; esac # ASUS Tinker Board (32-bit) elif (( $G_HW_MODEL == 52 )) then - G_EXEC sed -i 's/arm64/arm/' /etc/initramfs/post-update.d/99-dietpi-uboot /boot/boot.cmd - G_EXEC sed -Ei '/^setenv (kernel_addr_r|fdt_addr_r|overlay_path)/d' /boot/boot.cmd + G_EXEC sed --follow-symlinks -i 's/arm64/arm/' /etc/initramfs/post-update.d/99-dietpi-uboot /boot/boot.cmd + G_EXEC sed --follow-symlinks -Ei '/^setenv (kernel_addr_r|fdt_addr_r|overlay_path)/d' /boot/boot.cmd G_CONFIG_INJECT 'setenv scriptaddr ' 'setenv scriptaddr "0x39000000"' /boot/boot.cmd G_CONFIG_INJECT 'setenv ramdisk_addr_r ' 'setenv ramdisk_addr_r "0x21000000"' /boot/boot.cmd '^setenv scriptaddr' # shellcheck disable=SC2016 - G_EXEC sed -i -e 's|\${prefix}Image|${prefix}zImage|' -e 's/booti/bootz/' -e 's|\${overlay_path}/||' /boot/boot.cmd - G_EXEC sed -i '/^overlay_path/d' /boot/dietpiEnv.txt + G_EXEC sed --follow-symlinks -i -e 's|\${prefix}Image|${prefix}zImage|' -e 's/booti/bootz/' -e 's|\${overlay_path}/||' /boot/boot.cmd + G_EXEC sed --follow-symlinks -i '/^overlay_path/d' /boot/dietpiEnv.txt G_CONFIG_INJECT 'overlay_prefix=' 'overlay_prefix=rockchip' /boot/dietpiEnv.txt G_CONFIG_INJECT 'overlays=' 'overlays=uart2' /boot/dietpiEnv.txt # ASUS Tinker Board: https://github.com/MichaIng/DietPi/issues/5554 - G_EXEC sed -i -e 's/ttyAML0/ttyS2/' -e '/^extraargs=/s/$/ systemd.unified_cgroup_hierarchy=0/' /boot/dietpiEnv.txt + G_EXEC sed --follow-symlinks -i -e 's/ttyAML0/ttyS2/' -e '/^extraargs=/s/$/ systemd.unified_cgroup_hierarchy=0/' /boot/dietpiEnv.txt # Allwinner 64-bit elif [[ $G_HW_MODEL =~ ^(40|44|45|57|65|67|83)$ ]] then - G_EXEC sed -Ei '/^setenv (kernel|fdt)_addr_r/d' /boot/boot.cmd + G_EXEC sed --follow-symlinks -Ei '/^setenv (kernel|fdt)_addr_r/d' /boot/boot.cmd G_CONFIG_INJECT 'setenv scriptaddr ' 'setenv scriptaddr "0x45000000"' /boot/boot.cmd G_CONFIG_INJECT 'overlay_path=' 'overlay_path=allwinner' /boot/dietpiEnv.txt case $G_HW_MODEL in @@ -693,18 +693,18 @@ setenv rootuuid "true"' /boot/boot.cmd esac case $G_HW_MODEL in 57|65) G_CONFIG_INJECT 'consoleargs=' 'consoleargs=console=ttyS0,115200' /boot/dietpiEnv.txt;; # headless - *) G_EXEC sed -i 's/ttyAML0/ttyS0/' /boot/dietpiEnv.txt;; + *) G_EXEC sed --follow-symlinks -i 's/ttyAML0/ttyS0/' /boot/dietpiEnv.txt;; esac # Allwinner H3 (32-bit) elif [[ $G_HW_MODEL =~ ^(48|59|60|63|64|66)$ ]] then - G_EXEC sed -i 's/arm64/arm/' /etc/initramfs/post-update.d/99-dietpi-uboot /boot/boot.cmd - G_EXEC sed -Ei '/^setenv (kernel_addr_r|fdt_addr_r|overlay_path)/d' /boot/boot.cmd + G_EXEC sed --follow-symlinks -i 's/arm64/arm/' /etc/initramfs/post-update.d/99-dietpi-uboot /boot/boot.cmd + G_EXEC sed --follow-symlinks -Ei '/^setenv (kernel_addr_r|fdt_addr_r|overlay_path)/d' /boot/boot.cmd G_CONFIG_INJECT 'setenv scriptaddr ' 'setenv scriptaddr "0x45000000"' /boot/boot.cmd # shellcheck disable=SC2016 - G_EXEC sed -i -e 's|\${prefix}Image|${prefix}zImage|' -e 's/booti/bootz/' -e 's|\${overlay_path}/||' /boot/boot.cmd - G_EXEC sed -i '/^overlay_path/d' /boot/dietpiEnv.txt + G_EXEC sed --follow-symlinks -i -e 's|\${prefix}Image|${prefix}zImage|' -e 's/booti/bootz/' -e 's|\${overlay_path}/||' /boot/boot.cmd + G_EXEC sed --follow-symlinks -i '/^overlay_path/d' /boot/dietpiEnv.txt G_CONFIG_INJECT 'overlay_prefix=' 'overlay_prefix=sun8i-h3' /boot/dietpiEnv.txt case $G_HW_MODEL in 48) G_CONFIG_INJECT 'overlays=' 'overlays=usbhost1 usbhost2 uart1' /boot/dietpiEnv.txt;; @@ -715,20 +715,20 @@ setenv rootuuid "true"' /boot/boot.cmd case $G_HW_MODEL in 48) G_CONFIG_INJECT 'consoleargs=' 'consoleargs=console=ttyS1,115200' /boot/dietpiEnv.txt;; # headless 59|60|64) G_CONFIG_INJECT 'consoleargs=' 'consoleargs=console=ttyS0,115200' /boot/dietpiEnv.txt;; # headless - *) G_EXEC sed -i 's/ttyAML0/ttyS0/' /boot/dietpiEnv.txt;; + *) G_EXEC sed --follow-symlinks -i 's/ttyAML0/ttyS0/' /boot/dietpiEnv.txt;; esac # NanoPi M3/T3/Fire3 (64-bit) elif (( $G_HW_MODEL == 62 )) then G_EXEC mv "DietPi-$G_GITBRANCH/.build/images/NanoPiM3/boot.cmd" /boot/boot.cmd - G_EXEC sed -i '/overlay/d' /boot/dietpiEnv.txt - G_EXEC sed -i 's/ttyAML0/ttySAC0/' /boot/dietpiEnv.txt + G_EXEC sed --follow-symlinks -i '/overlay/d' /boot/dietpiEnv.txt + G_EXEC sed --follow-symlinks -i 's/ttyAML0/ttySAC0/' /boot/dietpiEnv.txt fi fi # shellcheck disable=SC2016 - [[ -f '/etc/initramfs/post-update.d/99-dietpi-uboot' && $(findmnt -t vfat -M /boot) ]] && G_EXEC sed -i '/^ln -s/c\mv -v "/boot/uInitrd-$1" /boot/uInitrd' /etc/initramfs/post-update.d/99-dietpi-uboot # FAT does not support symlinks + [[ -f '/etc/initramfs/post-update.d/99-dietpi-uboot' && $(findmnt -t vfat -M /boot) ]] && G_EXEC sed --follow-symlinks -i '/^ln -s/c\mv -v "/boot/uInitrd-$1" /boot/uInitrd' /etc/initramfs/post-update.d/99-dietpi-uboot # FAT does not support symlinks G_EXEC mv "DietPi-$G_GITBRANCH/dietpi.txt" /boot/ G_EXEC mv "DietPi-$G_GITBRANCH/README.md" /boot/dietpi-README.md @@ -1251,8 +1251,8 @@ _EOF_ done G_EXEC_OUTPUT=1 G_EXEC dpkg -i package.deb G_EXEC rm package.deb - G_EXEC sed -i "s/root=[^[:blank:]]*/root=PARTUUID=$(findmnt -Ufnro PARTUUID -M /)/" /boot/extlinux/extlinux.conf - G_EXEC sed -i "s/rootfstype=[^[:blank:]]*/rootfstype=$(findmnt -Ufnro FSTYPE -M /)/" /boot/extlinux/extlinux.conf + G_EXEC sed --follow-symlinks -i "s/root=[^[:blank:]]*/root=PARTUUID=$(findmnt -Ufnro PARTUUID -M /)/" /boot/extlinux/extlinux.conf + G_EXEC sed --follow-symlinks -i "s/rootfstype=[^[:blank:]]*/rootfstype=$(findmnt -Ufnro FSTYPE -M /)/" /boot/extlinux/extlinux.conf aPACKAGES_REQUIRED_INSTALL+=('libubootenv-tool') # Star64 @@ -1265,8 +1265,8 @@ _EOF_ done G_EXEC_OUTPUT=1 G_EXEC dpkg -i package.deb G_EXEC rm package.deb - G_EXEC sed -i "s/root=[^[:blank:]]*/root=PARTUUID=$(findmnt -Ufnro PARTUUID -M /)/" /boot/extlinux/extlinux.conf - G_EXEC sed -i "s/rootfstype=[^[:blank:]]*/rootfstype=$(findmnt -Ufnro FSTYPE -M /)/" /boot/extlinux/extlinux.conf + G_EXEC sed --follow-symlinks -i "s/root=[^[:blank:]]*/root=PARTUUID=$(findmnt -Ufnro PARTUUID -M /)/" /boot/extlinux/extlinux.conf + G_EXEC sed --follow-symlinks -i "s/rootfstype=[^[:blank:]]*/rootfstype=$(findmnt -Ufnro FSTYPE -M /)/" /boot/extlinux/extlinux.conf aPACKAGES_REQUIRED_INSTALL+=('libubootenv-tool') # Orange Pi Zero 3 @@ -1292,7 +1292,7 @@ _EOF_ # Apply device tree adjustment for Ethernet adapter # shellcheck disable=SC2016 - sed -i -e '/^setenv bootargs /s/"$/ ethernet_phy=${ethernet_phy}"/' -e '/^# Boot/i\ + sed --follow-symlinks -i -e '/^setenv bootargs /s/"$/ ethernet_phy=${ethernet_phy}"/' -e '/^# Boot/i\ if test "${ethernet_phy}" = "rtl8211f"; then\ echo "Ethernet adapter: ${ethernet_phy}, adjusting device tree ..."\ fdt set "/soc/ethernet@5020000" "allwinner,rx-delay-ps" "<3100>"\ @@ -1742,7 +1742,7 @@ _EOF_ #----------------------------------------------------------------------------------- # Bash Profiles # - Enable /etc/bashrc.d/ support for custom interactive non-login shell scripts: - sed -i '\#/etc/bashrc\.d/#d' /etc/bash.bashrc + sed --follow-symlinks -i '\#/etc/bashrc\.d/#d' /etc/bash.bashrc # shellcheck disable=SC2016 echo 'for i in /etc/bashrc.d/*.sh /etc/bashrc.d/*.bash; do [ -r "$i" ] && . $i; done; unset -v i' >> /etc/bash.bashrc # - Enable bash-completion for non-login shells: @@ -2098,14 +2098,14 @@ rm -v /tmp/ax88179_178a.ko || exit 0 _EOF_ G_EXEC chmod +x /etc/kernel/postinst.d/dietpi-USBridgeSig # Force upgrade now, regardless of current host machine - G_EXEC sed -i 's/^grep/#grep/' /etc/kernel/postinst.d/dietpi-USBridgeSig + G_EXEC sed --follow-symlinks -i 's/^grep/#grep/' /etc/kernel/postinst.d/dietpi-USBridgeSig for i in /lib/modules/*-v7+ do [[ -d $i ]] || continue i=${i##*/} /etc/kernel/postinst.d/dietpi-USBridgeSig "$i" done - G_EXEC sed -i 's/^#grep/grep/' /etc/kernel/postinst.d/dietpi-USBridgeSig + G_EXEC sed --follow-symlinks -i 's/^#grep/grep/' /etc/kernel/postinst.d/dietpi-USBridgeSig # For backwards compatibility with software compiled against older libraspberrypi0, create symlinks from old to new filenames if (( $G_HW_ARCH < 3 )) @@ -2192,7 +2192,7 @@ _EOF_ then G_CONFIG_INJECT 'CONFIG_NTP_MODE=' 'CONFIG_NTP_MODE=0' /boot/dietpi.txt else - G_EXEC_DESC='Enable Dropbear autostart' G_EXEC sed -i '/NO_START=1/c\NO_START=0' /etc/default/dropbear + G_EXEC_DESC='Enable Dropbear autostart' G_EXEC sed --follow-symlinks -i '/NO_START=1/c\NO_START=0' /etc/default/dropbear G_EXEC systemctl unmask dropbear G_EXEC systemctl enable dropbear fi @@ -2209,7 +2209,7 @@ _EOF_ # Re-enable for next run (( $G_HW_MODEL == 75 )) || G_CONFIG_INJECT 'AUTO_SETUP_SWAPFILE_SIZE=' 'AUTO_SETUP_SWAPFILE_SIZE=1' /boot/dietpi.txt # Reset /tmp size to default (512 MiB) - sed -i '\|/tmp|s|size=[^,]*,||' /etc/fstab + sed --follow-symlinks -i '\|/tmp|s|size=[^,]*,||' /etc/fstab # Set WiFi local tmp_info='Disabling' diff --git a/.build/software/Amiberry/container_build.bash b/.build/software/Amiberry/container_build.bash index 67c9d5f874..45da9337b6 100755 --- a/.build/software/Amiberry/container_build.bash +++ b/.build/software/Amiberry/container_build.bash @@ -84,7 +84,7 @@ G_EXEC mkdir rootfs G_EXEC mount "${FP_LOOP}p1" rootfs # Enforce ARMv6 arch on Raspbian -(( $arch > 1 )) || echo 'sed -i -e '\''/^G_HW_ARCH=/c\G_HW_ARCH=1'\'' -e '\''/^G_HW_ARCH_NAME=/c\G_HW_ARCH_NAME=armv6l'\'' /boot/dietpi/.hw_model' > rootfs/boot/Automation_Custom_PreScript.sh || Error_Exit 'Failed to generate Automation_Custom_PreScript.sh' +(( $arch > 1 )) || echo 'sed --follow-symlinks -i -e '\''/^G_HW_ARCH=/c\G_HW_ARCH=1'\'' -e '\''/^G_HW_ARCH_NAME=/c\G_HW_ARCH_NAME=armv6l'\'' /boot/dietpi/.hw_model' > rootfs/boot/Automation_Custom_PreScript.sh || Error_Exit 'Failed to generate Automation_Custom_PreScript.sh' # Enable automated setup G_CONFIG_INJECT 'AUTO_SETUP_AUTOMATED=' 'AUTO_SETUP_AUTOMATED=1' rootfs/boot/dietpi.txt diff --git a/.build/software/dietpi-software-build.bash b/.build/software/dietpi-software-build.bash index cc05c7d281..f5346d543e 100644 --- a/.build/software/dietpi-software-build.bash +++ b/.build/software/dietpi-software-build.bash @@ -89,7 +89,7 @@ G_EXEC mkdir rootfs G_EXEC mount "${FP_LOOP}p1" rootfs # Enforce ARMv6 arch on Raspbian -(( $arch > 1 )) || echo 'sed -i -e '\''/^G_HW_ARCH=/c\G_HW_ARCH=1'\'' -e '\''/^G_HW_ARCH_NAME=/c\G_HW_ARCH_NAME=armv6l'\'' /boot/dietpi/.hw_model' > rootfs/boot/Automation_Custom_PreScript.sh || Error_Exit 'Failed to generate Automation_Custom_PreScript.sh' +(( $arch > 1 )) || echo 'sed --follow-symlinks -i -e '\''/^G_HW_ARCH=/c\G_HW_ARCH=1'\'' -e '\''/^G_HW_ARCH_NAME=/c\G_HW_ARCH_NAME=armv6l'\'' /boot/dietpi/.hw_model' > rootfs/boot/Automation_Custom_PreScript.sh || Error_Exit 'Failed to generate Automation_Custom_PreScript.sh' # Enable automated setup G_CONFIG_INJECT 'AUTO_SETUP_AUTOMATED=' 'AUTO_SETUP_AUTOMATED=1' rootfs/boot/dietpi.txt diff --git a/.build/software/gmediarender/build.bash b/.build/software/gmediarender/build.bash index 47e20c747b..a75b6da683 100755 --- a/.build/software/gmediarender/build.bash +++ b/.build/software/gmediarender/build.bash @@ -98,7 +98,7 @@ then INTERFACE=$(ip r l 0/0 | awk '{print $5;exit}') [ "$INTERFACE" ] || INTERFACE=$(ip -br a | awk '$2=="UP"{print $1;exit}') [ "$INTERFACE" ] || exit 1 - sed -i "s/-u UUID -f HOSTNAME -I eth0/-u $G_HW_UUID -f $HOSTNAME -I $INTERFACE/" /etc/default/gmediarender + sed --follow-symlinks -i "s/-u UUID -f HOSTNAME -I eth0/-u $G_HW_UUID -f $HOSTNAME -I $INTERFACE/" /etc/default/gmediarender fi if getent passwd gmediarender > /dev/null diff --git a/.build/software/raspberrypi-sys-mods/build.bash b/.build/software/raspberrypi-sys-mods/build.bash index 2e9ba2badb..ac91cd6ef2 100755 --- a/.build/software/raspberrypi-sys-mods/build.bash +++ b/.build/software/raspberrypi-sys-mods/build.bash @@ -37,7 +37,7 @@ G_EXEC curl -sSfo raspberrypi-sys-mods/lib/udev/rules.d/15-i2c-modprobe.rules 'h G_EXEC curl -sSfo raspberrypi-sys-mods/lib/udev/rules.d/99-com.rules 'https://raw.githubusercontent.com/RPi-Distro/raspberrypi-sys-mods/master/etc.armhf/udev/rules.d/99-com.rules' # The original rule uses the "strings" command from binutils, which we do not want to have pre-installed (it is huge!). So we use cat, which is safe for the node values read here. -G_EXEC sed -i 's/(strings/(cat/g' raspberrypi-sys-mods/lib/udev/rules.d/99-com.rules +G_EXEC sed --follow-symlinks -i 's/(strings/(cat/g' raspberrypi-sys-mods/lib/udev/rules.d/99-com.rules cat << '_EOF_' > raspberrypi-sys-mods/DEBIAN/preinst #!/bin/dash diff --git a/.build/software/vaultwarden/build.bash b/.build/software/vaultwarden/build.bash index d269988f76..dd09f2cc07 100755 --- a/.build/software/vaultwarden/build.bash +++ b/.build/software/vaultwarden/build.bash @@ -134,7 +134,7 @@ cat << '_EOF_' > "$DIR/DEBIAN/postinst" if [[ ! $2 ]] && grep -q '^# ROCKET_ADDRESS=0.0.0.0$' /mnt/dietpi_userdata/vaultwarden/vaultwarden.env then echo 'Enabling web vault remote access ...' - sed -i '/^# ROCKET_ADDRESS=0.0.0.0$/c\ROCKET_ADDRESS=0.0.0.0' /mnt/dietpi_userdata/vaultwarden/vaultwarden.env + sed --follow-symlinks -i '/^# ROCKET_ADDRESS=0.0.0.0$/c\ROCKET_ADDRESS=0.0.0.0' /mnt/dietpi_userdata/vaultwarden/vaultwarden.env fi if [[ -d '/run/systemd/system' ]] diff --git a/.github/workflows/dietpi-software.bash b/.github/workflows/dietpi-software.bash index 682ed31106..8b4c6f43aa 100644 --- a/.github/workflows/dietpi-software.bash +++ b/.github/workflows/dietpi-software.bash @@ -285,7 +285,7 @@ G_EXEC mkdir rootfs G_EXEC mount "${FP_LOOP}p1" rootfs # Force ARMv6 arch on Raspbian -(( $arch == 1 )) && G_EXEC sed -i '/# Start DietPi-Software/iG_EXEC sed -i -e '\''/^G_HW_ARCH=/cG_HW_ARCH=1'\'' -e '\''/^G_HW_ARCH_NAME=/cG_HW_ARCH_NAME=armv6l'\'' /boot/dietpi/.hw_model' rootfs/boot/dietpi/dietpi-login +(( $arch == 1 )) && G_EXEC sed --follow-symlinks -i '/# Start DietPi-Software/iG_EXEC sed -i -e '\''/^G_HW_ARCH=/cG_HW_ARCH=1'\'' -e '\''/^G_HW_ARCH_NAME=/cG_HW_ARCH_NAME=armv6l'\'' /boot/dietpi/.hw_model' rootfs/boot/dietpi/dietpi-login # Force RPi on ARM systems if requested if [[ $RPI == 'true' ]] && (( $arch < 10 )) @@ -298,7 +298,7 @@ then esac G_EXEC rm rootfs/etc/.dietpi_hw_model_identifier G_EXEC touch rootfs/boot/{bcm-rpi-dummy.dtb,config.txt,cmdline.txt} - G_EXEC sed -i "/# Start DietPi-Software/iG_EXEC sed -i -e '/^G_HW_MODEL=/cG_HW_MODEL=$model' -e '/^G_HW_MODEL_NAME=/cG_HW_MODEL_NAME=\"RPi $model ($ARCH)\"' /boot/dietpi/.hw_model" rootfs/boot/dietpi/dietpi-login + G_EXEC sed --follow-symlinks -i "/# Start DietPi-Software/iG_EXEC sed -i -e '/^G_HW_MODEL=/cG_HW_MODEL=$model' -e '/^G_HW_MODEL_NAME=/cG_HW_MODEL_NAME=\"RPi $model ($ARCH)\"' /boot/dietpi/.hw_model" rootfs/boot/dietpi/dietpi-login G_EXEC curl -sSfo keyring.deb 'https://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-archive-keyring/raspberrypi-archive-keyring_2021.1.1+rpt1_all.deb' G_EXEC dpkg --root=rootfs -i keyring.deb G_EXEC rm keyring.deb @@ -312,7 +312,7 @@ fi # Install test builds from dietpi.com if requested # shellcheck disable=SC2016 -[[ $TEST == 'true' ]] && G_EXEC sed -i '/# Start DietPi-Software/a\sed -i '\''s|dietpi.com/downloads/binaries/$G_DISTRO_NAME/|dietpi.com/downloads/binaries/$G_DISTRO_NAME/testing/|'\'' /boot/dietpi/dietpi-software' rootfs/boot/dietpi/dietpi-login +[[ $TEST == 'true' ]] && G_EXEC sed --follow-symlinks -i '/# Start DietPi-Software/a\sed -i '\''s|dietpi.com/downloads/binaries/$G_DISTRO_NAME/|dietpi.com/downloads/binaries/$G_DISTRO_NAME/testing/|'\'' /boot/dietpi/dietpi-software' rootfs/boot/dietpi/dietpi-login # Workaround invalid TERM on login # shellcheck disable=SC2016 @@ -368,7 +368,7 @@ G_EXEC eval 'echo -e '\''[Service]\nAmbientCapabilities='\'' > rootfs/etc/system # - Type=notify leads to a service start timeout while mysqld has actually fully started. However, with Type=exec, /etc/mysql/debian-start starts too soon after mysqld, so that the UNIX socket is not yet ready to listen. Hence add a second to wait for it. if [[ $DISTRO == 'buster' ]] then - G_EXEC sed -i '/# Start DietPi-Software/a\sed -i -e '\''s|rm -Rf /var/lib/mysql|rm -Rf /mnd/dietpi_userdata/mysql|'\'' -e '\''s|ln -s /mnt/dietpi_userdata/mysql /var/lib/mysql|ln -s /var/lib/mysql /mnt/dietpi_userdata/mysql|'\'' /boot/dietpi/dietpi-software' rootfs/boot/dietpi/dietpi-login + G_EXEC sed --follow-symlinks -i '/# Start DietPi-Software/a\sed -i -e '\''s|rm -Rf /var/lib/mysql|rm -Rf /mnd/dietpi_userdata/mysql|'\'' -e '\''s|ln -s /mnt/dietpi_userdata/mysql /var/lib/mysql|ln -s /var/lib/mysql /mnt/dietpi_userdata/mysql|'\'' /boot/dietpi/dietpi-software' rootfs/boot/dietpi/dietpi-login G_EXEC mkdir rootfs/etc/systemd/system/mariadb.service.d cat << '_EOF_' > rootfs/etc/systemd/system/mariadb.service.d/dietpi-container.conf || exit 1 [Service] @@ -384,15 +384,15 @@ fi (( $arch < 3 && $G_HW_ARCH > 9 )) && G_EXEC eval 'echo -e '\''tmpfs /mnt/dietpi_userdata tmpfs size=3G,noatime,lazytime\ntmpfs /root tmpfs size=3G,noatime,lazytime'\'' >> rootfs/etc/fstab' # Workaround for Node.js on ARMv6 -(( $arch == 1 )) && G_EXEC sed -i '/# Start DietPi-Software/a\sed -i '\''/G_EXEC chmod +x node-install.sh/a\\sed -i "/^ARCH=/c\\ARCH=armv6l" node-install.sh'\'' /boot/dietpi/dietpi-software' rootfs/boot/dietpi/dietpi-login +(( $arch == 1 )) && G_EXEC sed --follow-symlinks -i '/# Start DietPi-Software/a\sed -i '\''/G_EXEC chmod +x node-install.sh/a\\sed -i "/^ARCH=/c\\ARCH=armv6l" node-install.sh'\'' /boot/dietpi/dietpi-software' rootfs/boot/dietpi/dietpi-login # Workaround for sysctl: permission denied on key "net.core.rmem_max" in containers -G_EXEC sed -i '/# Start DietPi-Software/a\sed -i '\''/G_EXEC sysctl -w net\.core\.rmem_max/d'\'' /boot/dietpi/dietpi-software' rootfs/boot/dietpi/dietpi-login +G_EXEC sed --follow-symlinks -i '/# Start DietPi-Software/a\sed -i '\''/G_EXEC sysctl -w net\.core\.rmem_max/d'\'' /boot/dietpi/dietpi-software' rootfs/boot/dietpi/dietpi-login # Check for service status, ports and commands # shellcheck disable=SC2016 # - Start all services -G_EXEC sed -i '/# Start DietPi-Software/a\sed -i '\''/# Custom 1st run script/a\\for i in "${aSTART_SERVICES[@]}"; do G_EXEC_NOHALT=1 G_EXEC systemctl start "$i"; done'\'' /boot/dietpi/dietpi-software' rootfs/boot/dietpi/dietpi-login +G_EXEC sed --follow-symlinks -i '/# Start DietPi-Software/a\sed -i '\''/# Custom 1st run script/a\\for i in "${aSTART_SERVICES[@]}"; do G_EXEC_NOHALT=1 G_EXEC systemctl start "$i"; done'\'' /boot/dietpi/dietpi-software' rootfs/boot/dietpi/dietpi-login delay=10 for i in "${aDELAY[@]}"; do (( $i > $delay )) && delay=$i; done G_EXEC eval "echo -e '#!/bin/dash\nexit_code=0; /boot/dietpi/dietpi-services start || exit_code=1; echo Waiting $delay seconds for service starts; sleep $delay' > rootfs/boot/Automation_Custom_Script.sh" @@ -437,7 +437,7 @@ done G_EXEC eval 'echo '\''[ $exit_code = 0 ] && > /success || { journalctl -n 50; ss -tlpn; df -h; free -h; poweroff; }; poweroff'\'' >> rootfs/boot/Automation_Custom_Script.sh' # Shutdown as well on failure -G_EXEC sed -i 's|Prompt_on_Failure$|{ journalctl -n 50; ss -tulpn; df -h; free -h; poweroff; }|' rootfs/boot/dietpi/dietpi-login +G_EXEC sed --follow-symlinks -i 's|Prompt_on_Failure$|{ journalctl -n 50; ss -tulpn; df -h; free -h; poweroff; }|' rootfs/boot/dietpi/dietpi-login ########################################## # Boot container diff --git a/.github/workflows/quartz64.yml b/.github/workflows/quartz64.yml index 259f5a3071..c508f04166 100644 --- a/.github/workflows/quartz64.yml +++ b/.github/workflows/quartz64.yml @@ -45,7 +45,7 @@ jobs: export BL31='bl31.elf' cd "u-boot-$uboot_version" # Patch kernel_comp_addr_r being too narrow for our kernel image - sed -i 's/kernel_comp_addr_r=0x08000000/kernel_comp_addr_r=0x10000000/' include/configs/rk3568_common.h + sed --follow-symlinks -i 's/kernel_comp_addr_r=0x08000000/kernel_comp_addr_r=0x10000000/' include/configs/rk3568_common.h make quartz64-a-rk3566_defconfig make -j$(nproc) mv u-boot-rockchip.bin ../firmware-quartz64a/boot/u-boot.bin @@ -98,9 +98,9 @@ jobs: append root=/dev/mmcblk0p1 rootfstype=ext4 rootwait earlycon=uart8250,mmio32,0xfe660000 console=ttyS2,1500000n8 console=tty1 consoleblank=0 net.ifnames=0 _EOF_ cp firmware-quartz64a/boot/extlinux/extlinux.conf firmware-quartz64b/boot/extlinux/ - sed -i 's/quartz64-a.dtb/quartz64-b.dtb/' firmware-quartz64b/boot/extlinux/extlinux.conf + sed --follow-symlinks -i 's/quartz64-a.dtb/quartz64-b.dtb/' firmware-quartz64b/boot/extlinux/extlinux.conf cp firmware-quartz64a/boot/extlinux/extlinux.conf firmware-soquartz/boot/extlinux/ - sed -i 's/quartz64-a.dtb/soquartz-cm4.dtb/' firmware-soquartz/boot/extlinux/extlinux.conf + sed --follow-symlinks -i 's/quartz64-a.dtb/soquartz-cm4.dtb/' firmware-soquartz/boot/extlinux/extlinux.conf echo '/boot/extlinux/extlinux.conf' > firmware-quartz64a/DEBIAN/conffiles echo '/boot/extlinux/extlinux.conf' > firmware-quartz64b/DEBIAN/conffiles echo '/boot/extlinux/extlinux.conf' > firmware-soquartz/DEBIAN/conffiles @@ -127,7 +127,7 @@ jobs: echo 'ERROR: Unable to detect root filessystem PARTUUID, aborting' exit 1 fi - sed -i "s|root=/dev/mmcblk0p1|root=PARTUUID=$ROOT_PARTUUID|" /boot/extlinux/extlinux.conf + sed --follow-symlinks -i "s|root=/dev/mmcblk0p1|root=PARTUUID=$ROOT_PARTUUID|" /boot/extlinux/extlinux.conf ROOT_FSTYPE=$(findmnt -Ufnro FSTYPE -M /) if [ $ROOT_FSTYPE ] then @@ -136,7 +136,7 @@ jobs: echo 'ERROR: Unable to detect root filesystem type, aborting' exit 1 fi - sed -i "s|rootfstype=ext4|rootfstype=$ROOT_FSTYPE|" /boot/extlinux/extlinux.conf + sed --follow-symlinks -i "s|rootfstype=ext4|rootfstype=$ROOT_FSTYPE|" /boot/extlinux/extlinux.conf fi exit 0 _EOF_ @@ -158,11 +158,11 @@ jobs: Priority: optional Description: Linux kernel and U-Boot bootloader for Quartz64 Model A _EOF_ - sed -i "/^Installed-Size:/c\Installed-Size: $(du -sk 'firmware-quartz64a' | mawk '{print $1}')" firmware-quartz64a/DEBIAN/control + sed --follow-symlinks -i "/^Installed-Size:/c\Installed-Size: $(du -sk 'firmware-quartz64a' | mawk '{print $1}')" firmware-quartz64a/DEBIAN/control cp firmware-quartz64a/DEBIAN/control firmware-quartz64b/DEBIAN/ - sed -i -e 's/quartz64a/quartz64b/' -e 's/Model A$/Model B/' -e "/^Installed-Size:/c\Installed-Size: $(du -sk 'firmware-quartz64b' | mawk '{print $1}')" firmware-quartz64b/DEBIAN/control + sed --follow-symlinks -i -e 's/quartz64a/quartz64b/' -e 's/Model A$/Model B/' -e "/^Installed-Size:/c\Installed-Size: $(du -sk 'firmware-quartz64b' | mawk '{print $1}')" firmware-quartz64b/DEBIAN/control cp firmware-quartz64a/DEBIAN/control firmware-soquartz/DEBIAN/ - sed -i -e 's/quartz64a/soquartz/' -e 's/Quartz64 Model A$/SOQuartz/' -e "/^Installed-Size:/c\Installed-Size: $(du -sk 'firmware-soquartz' | mawk '{print $1}')" firmware-soquartz/DEBIAN/control + sed --follow-symlinks -i -e 's/quartz64a/soquartz/' -e 's/Quartz64 Model A$/SOQuartz/' -e "/^Installed-Size:/c\Installed-Size: $(du -sk 'firmware-soquartz' | mawk '{print $1}')" firmware-soquartz/DEBIAN/control sudo chown -R root:root firmware-quartz64a firmware-quartz64b firmware-soquartz dpkg-deb -b -Zxz -z9 -Sextreme firmware-quartz64a dpkg-deb -b -Zxz -z9 -Sextreme firmware-quartz64b diff --git a/.meta/dietpi-bookworm-upgrade b/.meta/dietpi-bookworm-upgrade index 736a62ec0b..ac630cc000 100755 --- a/.meta/dietpi-bookworm-upgrade +++ b/.meta/dietpi-bookworm-upgrade @@ -55,16 +55,16 @@ mapfile -t apackages < <(apt-mark showhold) unset -v apackages G_DIETPI-NOTIFY 2 'Migrating package lists to Bookworm suite' -G_EXEC sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list -(( $G_RASPBIAN )) || G_EXEC sed -i 's/ non-free$/ non-free non-free-firmware/' /etc/apt/sources.list -[[ $(find /etc/apt/sources.list.d/*.list 2> /dev/null) ]] && G_EXEC sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list.d/*.list -[[ -f '/etc/apt/sources.list.d/dietpi-mympd.list' ]] && G_EXEC sed -i 's/Debian_11/Debian_12/' /etc/apt/sources.list.d/dietpi-mympd.list +G_EXEC sed --follow-symlinks -i 's/bullseye/bookworm/g' /etc/apt/sources.list +(( $G_RASPBIAN )) || G_EXEC sed --follow-symlinks -i 's/ non-free$/ non-free non-free-firmware/' /etc/apt/sources.list +[[ $(find /etc/apt/sources.list.d/*.list 2> /dev/null) ]] && G_EXEC sed --follow-symlinks -i 's/bullseye/bookworm/g' /etc/apt/sources.list.d/*.list +[[ -f '/etc/apt/sources.list.d/dietpi-mympd.list' ]] && G_EXEC sed --follow-symlinks -i 's/Debian_11/Debian_12/' /etc/apt/sources.list.d/dietpi-mympd.list G_DIETPI-NOTIFY 2 'Reverting some package lists to Bullseye which have no Bookworm suite (yet)' -[[ -f '/etc/apt/sources.list.d/radxa.list' ]] && G_EXEC sed -i 's/bookworm/bullseye/g' /etc/apt/sources.list.d/radxa.list -[[ -f '/etc/apt/sources.list.d/dietpi-radxa.list' ]] && G_EXEC sed -i 's/bookworm/bullseye/g' /etc/apt/sources.list.d/dietpi-radxa.list -[[ -f '/etc/apt/sources.list.d/influxdb.list' ]] && G_EXEC sed -i 's/bookworm/bullseye/' /etc/apt/sources.list.d/influxdb.list -[[ -f '/etc/apt/sources.list.d/mopidy.list' ]] && G_EXEC sed -i 's/bookworm/bullseye/' /etc/apt/sources.list.d/mopidy.list +[[ -f '/etc/apt/sources.list.d/radxa.list' ]] && G_EXEC sed --follow-symlinks -i 's/bookworm/bullseye/g' /etc/apt/sources.list.d/radxa.list +[[ -f '/etc/apt/sources.list.d/dietpi-radxa.list' ]] && G_EXEC sed --follow-symlinks -i 's/bookworm/bullseye/g' /etc/apt/sources.list.d/dietpi-radxa.list +[[ -f '/etc/apt/sources.list.d/influxdb.list' ]] && G_EXEC sed --follow-symlinks -i 's/bookworm/bullseye/' /etc/apt/sources.list.d/influxdb.list +[[ -f '/etc/apt/sources.list.d/mopidy.list' ]] && G_EXEC sed --follow-symlinks -i 's/bookworm/bullseye/' /etc/apt/sources.list.d/mopidy.list if (( $G_HW_MODEL == 4 )) && dpkg-query -s rpi-eeprom &> /dev/null then @@ -111,7 +111,7 @@ G_EXEC rm -Rf /etc/php/7.4 /usr/local/lib/python3.9 /usr/local/bin/pip3* # Install (mark as manually installed) root trust anchors for Unbound, which was degraded from dependency to recommendation: https://github.com/MichaIng/DietPi/issues/5612 dpkg-query -s unbound &> /dev/null && G_AGI dns-root-data # Allow IPv6 port binding failure explicitly, not implicit anymore since Bookworm: https://github.com/MichaIng/DietPi/pull/6103#issuecomment-1407749720 -[[ -f '/etc/redis/redis.conf' ]] && G_EXEC sed -i '/^bind 127.0.0.1 ::1$/c\bind 127.0.0.1 -::1' /etc/redis/redis.conf +[[ -f '/etc/redis/redis.conf' ]] && G_EXEC sed --follow-symlinks -i '/^bind 127.0.0.1 ::1$/c\bind 127.0.0.1 -::1' /etc/redis/redis.conf # Reinstall all PHP applications which require non-standard PHP modules, webservers which did access a versioned PHP-FPM socket, Python applications installed via pip, ... G_PROMPT_BACKUP_DISABLED=1 /boot/dietpi/dietpi-software reinstall 38 40 47 48 83 84 85 89 93 114 118 125 130 134 136 139 143 153 155 157 180 diff --git a/.update/patches b/.update/patches index bd1455177d..068faa74ea 100755 --- a/.update/patches +++ b/.update/patches @@ -54,13 +54,13 @@ Patch_7_1() [[ -d '/var/lib/dietpi/dietpi-software/installed/dietpi-nordvpn' ]] && G_EXEC mv /var/lib/dietpi/dietpi-software/installed/dietpi-nordvpn /var/lib/dietpi/dietpi-vpn if [[ -f '/var/lib/dietpi/dietpi-vpn/settings_dietpi.conf' ]] then - G_EXEC sed -Ei 's/^NORDVPN_(SERVER|USERNAME|PASSWORD)=/VPN_\1=/' /var/lib/dietpi/dietpi-vpn/settings_dietpi.conf + G_EXEC sed --follow-symlinks -Ei 's/^NORDVPN_(SERVER|USERNAME|PASSWORD)=/VPN_\1=/' /var/lib/dietpi/dietpi-vpn/settings_dietpi.conf local PROTOCOL VPN_SERVER # shellcheck disable=SC1091 . /var/lib/dietpi/dietpi-vpn/settings_dietpi.conf [[ -f '/etc/openvpn/client.ovpn' ]] || G_EXEC cp -a "/etc/openvpn/ovpn_$PROTOCOL/$VPN_SERVER" /etc/openvpn/client.ovpn unset -v VPN_SERVER PROTOCOL VPN_USERNAME VPN_PASSWORD - G_EXEC sed -i 's|/var/lib/dietpi/dietpi-software/installed/dietpi-nordvpn/|/var/lib/dietpi/dietpi-vpn/|' /etc/openvpn/client.ovpn + G_EXEC sed --follow-symlinks -i 's|/var/lib/dietpi/dietpi-software/installed/dietpi-nordvpn/|/var/lib/dietpi/dietpi-vpn/|' /etc/openvpn/client.ovpn fi if [[ -f '/etc/systemd/system/dietpi-nordvpn.service' ]] then @@ -84,7 +84,7 @@ Patch_7_1() \nSimply run "dietpi-ddns" from console, select "No-IP" as provider, enter domain and credentials, then select "Apply". The old No-IP client and service will be removed automatically as last step, once a final DDNS update test succeeded.' # Remove obsolete DietPi-NordVPN and No-IP install states - [[ -f '/boot/dietpi/.installed' ]] && grep -qE '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[(67|171)\]=' /boot/dietpi/.installed && G_EXEC sed -Ei '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[(67|171)\]=/d' /boot/dietpi/.installed + [[ -f '/boot/dietpi/.installed' ]] && grep -qE '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[(67|171)\]=' /boot/dietpi/.installed && G_EXEC sed --follow-symlinks -Ei '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[(67|171)\]=/d' /boot/dietpi/.installed # Inform user about possible Sonarr v2 => v3 upgrade [[ -f '/mnt/dietpi_userdata/sonarr/nzbdrone.pid' ]] && G_WHIP_MSG '[ INFO ] Sonarr v3 has been released @@ -144,14 +144,14 @@ Patch_7_2() fi # Fix disabling dietpi-desktop_setup - [[ -f '/var/lib/dietpi/dietpi-software/installed/desktop/dietpi-desktop_setup.sh' ]] && grep -q 'echo -e' /var/lib/dietpi/dietpi-software/installed/desktop/dietpi-desktop_setup.sh && G_EXEC sed -i 's/echo -e/echo/' /var/lib/dietpi/dietpi-software/installed/desktop/dietpi-desktop_setup.sh + [[ -f '/var/lib/dietpi/dietpi-software/installed/desktop/dietpi-desktop_setup.sh' ]] && grep -q 'echo -e' /var/lib/dietpi/dietpi-software/installed/desktop/dietpi-desktop_setup.sh && G_EXEC sed --follow-symlinks -i 's/echo -e/echo/' /var/lib/dietpi/dietpi-software/installed/desktop/dietpi-desktop_setup.sh for i in /{root,home/*}/.config/autostart/dietpi-desktop_setup.desktop do - [[ -f $i ]] && grep -q '^-e ' "$i" && G_EXEC sed -i 's/^-e //' "$i" + [[ -f $i ]] && grep -q '^-e ' "$i" && G_EXEC sed --follow-symlinks -i 's/^-e //' "$i" done # LibSSL1.0.0: Remove obsolete install state - [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[126\]=' /boot/dietpi/.installed && G_EXEC sed -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[126\]=/d' /boot/dietpi/.installed + [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[126\]=' /boot/dietpi/.installed && G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[126\]=/d' /boot/dietpi/.installed # Roon Extension Manager: Inform users about available upgrade: https://github.com/MichaIng/DietPi/pull/4399 [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[86\]=2' /boot/dietpi/.installed && G_WHIP_MSG '[ INFO ] Roon Extension Manager: Major upgrade available @@ -203,10 +203,10 @@ _EOF_ fi # RPi: Remove deprecated I2C setting from config.txt - (( $G_HW_MODEL > 9 )) || G_EXEC sed -i '/dtparam=i2c1=/d' /boot/config.txt + (( $G_HW_MODEL > 9 )) || G_EXEC sed --follow-symlinks -i '/dtparam=i2c1=/d' /boot/config.txt # Tomcat 8: Remove obsolete install state - [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[125\]=' /boot/dietpi/.installed && G_EXEC sed -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[125\]=/d' /boot/dietpi/.installed + [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[125\]=' /boot/dietpi/.installed && G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[125\]=/d' /boot/dietpi/.installed # Remove license (flag) file if AUTO_SETUP_AUTOMATED=1 is set, which would otherwise never happen on pre-v7.2 images, and if AUTO_SETUP_ACCEPT_LICENSE=1 is set, to assure the prompt is skipped when for some reason the script is reloaded between update and first installs. [[ -f '/var/lib/dietpi/license.txt' ]] && grep -Eq '^[[:blank:]]*AUTO_SETUP_A(UTOMATED|CCEPT_LICENSE)=1' /boot/dietpi.txt && G_EXEC rm /var/lib/dietpi/license.txt @@ -239,8 +239,8 @@ Patch_7_5() if [[ $G_HW_MODEL -le 9 && -f '/boot/dietpi/.dietpi-autostart_index' && $( 4 )) then G_DIETPI-NOTIFY 2 'Removing obsolete "elevator" entry from /boot/cmdline.txt' - G_EXEC sed -Ei 's/elevator=[^[:blank:]]*[[:blank:]]+//' /boot/cmdline.txt - G_EXEC sed -Ei 's/[[:blank:]]*elevator=[^[:blank:]]*//' /boot/cmdline.txt + G_EXEC sed --follow-symlinks -Ei 's/elevator=[^[:blank:]]*[[:blank:]]+//' /boot/cmdline.txt + G_EXEC sed --follow-symlinks -Ei 's/[[:blank:]]*elevator=[^[:blank:]]*//' /boot/cmdline.txt fi # https://github.com/jirka-h/haveged/pull/7 https://github.com/MichaIng/DietPi/issues/3689#issuecomment-678322767 @@ -290,8 +290,8 @@ Patch_7_6() Patch_7_7() { G_DIETPI-NOTIFY 2 'Reverting Mosquitto and Webmin repositories back to HTTPS' - G_EXEC sed -Ei 's#http://(repo.mosquitto.org|download.webmin.com)#https://\1#' /etc/apt/sources.list - [[ $(find /etc/apt/sources.list/*.list 2> /dev/null) ]] && G_EXEC sed -Ei 's#http://(repo.mosquitto.org|download.webmin.com)#https://\1#' /etc/apt/sources.list.d/*.list + G_EXEC sed --follow-symlinks -Ei 's#http://(repo.mosquitto.org|download.webmin.com)#https://\1#' /etc/apt/sources.list + [[ $(find /etc/apt/sources.list/*.list 2> /dev/null) ]] && G_EXEC sed --follow-symlinks -Ei 's#http://(repo.mosquitto.org|download.webmin.com)#https://\1#' /etc/apt/sources.list.d/*.list # Inform users about abandoned CouchPotato and in case add service to DietPi-Services includes, as it has been removed from the hardcoded list if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[142\]=2' /boot/dietpi/.installed @@ -309,13 +309,13 @@ Patch_7_7() fi fi # Remove obsolete CouchPotato install state - [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[142\]=' /boot/dietpi/.installed && G_EXEC sed -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[142\]=/d' /boot/dietpi/.installed + [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[142\]=' /boot/dietpi/.installed && G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[142\]=/d' /boot/dietpi/.installed # Fix Deluge web interface service on Bullseye: https://github.com/MichaIng/DietPi/issues/4785 if [[ $G_DISTRO -ge 6 && -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[45\]=2' /boot/dietpi/.installed && ! grep -q 'ExecStart.* -d ' /etc/systemd/system/deluge-web.service then G_DIETPI-NOTIFY 2 'Patching Deluge web interface service to fix startup at Bullseye' - G_EXEC sed -i 's/deluge-web -l/deluge-web -d -l/' /etc/systemd/system/deluge-web.service + G_EXEC sed --follow-symlinks -i 's/deluge-web -l/deluge-web -d -l/' /etc/systemd/system/deluge-web.service fi # Mono: Migrate APT list and key to new location and naming @@ -331,8 +331,8 @@ Patch_7_7() if [[ -f '/etc/wireguard/wg0.conf' ]] then G_DIETPI-NOTIFY 2 'Updating WireGuard wg0 configuration' - G_EXEC sed -i '\|/boot/dietpi/func/obtain_network_details|d' /etc/wireguard/wg0.conf - G_EXEC sed -Ei "s#mawk .NR==3. /(run|boot|DietPi)/dietpi/.network#ip r l 0/0 | mawk '{print \$5;exit}'#g" /etc/wireguard/wg0.conf + G_EXEC sed --follow-symlinks -i '\|/boot/dietpi/func/obtain_network_details|d' /etc/wireguard/wg0.conf + G_EXEC sed --follow-symlinks -Ei "s#mawk .NR==3. /(run|boot|DietPi)/dietpi/.network#ip r l 0/0 | mawk '{print \$5;exit}'#g" /etc/wireguard/wg0.conf fi # GMediaRender: Patch service @@ -379,7 +379,7 @@ _EOF_ then /boot/dietpi/func/dietpi-set_software boot_wait_for_network 1 fi - G_EXEC sed -i '/^[[:blank:]]*CONFIG_BOOT_WAIT_FOR_NETWORK=/d' /boot/dietpi.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*CONFIG_BOOT_WAIT_FOR_NETWORK=/d' /boot/dietpi.txt # Enable systemd-timesyncd on oneshot modes to start early at boot local time_sync_mode=$(sed -n '/^[[:blank:]]*CONFIG_NTP_MODE=/{s/^[^=]*=//p;q}' /boot/dietpi.txt) @@ -392,8 +392,8 @@ _EOF_ then [[ -d '/root/.ssh' ]] || G_EXEC mkdir -p /root/.ssh [[ -f '/root/.ssh/known_hosts' ]] || > /root/.ssh/known_hosts - G_EXEC sed -i '/^dietpi.com/d' /root/.ssh/known_hosts - G_EXEC sed -i '/^185.101.93.93/d' /root/.ssh/known_hosts + G_EXEC sed --follow-symlinks -i '/^dietpi.com/d' /root/.ssh/known_hosts + G_EXEC sed --follow-symlinks -i '/^185.101.93.93/d' /root/.ssh/known_hosts G_CONFIG_INJECT '\[?ssh.dietpi.com(]:29248)?[[:blank:]]' '[ssh.dietpi.com]:29248 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDE6aw3r6aOEqendNu376iiCHr9tGBIWPgfrLkzjXjEsHGyVSUFNnZt6pftrDeK7UX+qX4FxOwQlugG4fymOHbimRCFiv6cf7VpYg1Ednquq9TLb7/cIIbX8a6AuRmX4fjdGuqwmBq3OG7ZksFcYEFKt5U4mAJIaL8hXiM2iXjgY02LqiQY/QWATsHI4ie9ZOnwrQE+Rr6mASN1BVFuIgyHIbwX54jsFSnZ/7CdBMkuAd9B8JkxppWVYpYIFHE9oWNfjh/epdK8yv9Oo6r0w5Rb+4qaAc5g+RAaknHeV6Gp75d2lxBdCm5XknKKbGma2+/DfoE8WZTSgzXrYcRlStYN' /root/.ssh/known_hosts fi @@ -407,8 +407,8 @@ _EOF_ Patch_7_8() { # Remove IPv4 preference - G_EXEC sed -i '/CONFIG_PREFER_IPV4/d' /boot/dietpi.txt - [[ -f '/etc/wgetrc' ]] && G_EXEC sed -i 's/^[[:blank:]]*prefer-family[[:blank:]]*=/#&/' /etc/wgetrc + G_EXEC sed --follow-symlinks -i '/CONFIG_PREFER_IPV4/d' /boot/dietpi.txt + [[ -f '/etc/wgetrc' ]] && G_EXEC sed --follow-symlinks -i 's/^[[:blank:]]*prefer-family[[:blank:]]*=/#&/' /etc/wgetrc [[ -f '/etc/apt/apt.conf.d/99-dietpi-force-ipv4' ]] && G_EXEC rm /etc/apt/apt.conf.d/99-dietpi-force-ipv4 # Inform users about removed Subsonic and in case add service to DietPi-Services includes, as it has been removed from the hardcoded list @@ -427,7 +427,7 @@ Patch_7_8() fi fi # Remove obsolete Subsonic install state - [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[34\]=' /boot/dietpi/.installed && G_EXEC sed -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[34\]=/d' /boot/dietpi/.installed + [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[34\]=' /boot/dietpi/.installed && G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[34\]=/d' /boot/dietpi/.installed # Inform users about removed emonHub and in case add service to DietPi-Services includes, as it has been removed from the hardcoded list if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[99\]=2' /boot/dietpi/.installed @@ -445,9 +445,9 @@ Patch_7_8() fi fi # Remove obsolete emonHub install state - [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[99\]=' /boot/dietpi/.installed && G_EXEC sed -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[99\]=/d' /boot/dietpi/.installed + [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[99\]=' /boot/dietpi/.installed && G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[99\]=/d' /boot/dietpi/.installed # Remove obsolete emonHub API key setting from dietpi.txt - grep -q 'SOFTWARE_EMONHUB_APIKEY' /boot/dietpi.txt && G_EXEC sed -Ei '/(SOFTWARE_EMONHUB_APIKEY|^#.*EmonCMS)/d' /boot/dietpi.txt + grep -q 'SOFTWARE_EMONHUB_APIKEY' /boot/dietpi.txt && G_EXEC sed --follow-symlinks -Ei '/(SOFTWARE_EMONHUB_APIKEY|^#.*EmonCMS)/d' /boot/dietpi.txt # Reinstall Roon Server if [[ -f '/boot/dietpi/.installed' && ! -d '/opt/roonserver' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[154\]=2' /boot/dietpi/.installed @@ -471,7 +471,7 @@ Patch_7_8() if (( $G_HW_MODEL < 10 )) && grep -Eq '(^|[[:blank:]])rootwait([[:blank:]]|$)' /boot/cmdline.txt && grep -Eq '(^|[[:blank:]])rootdelay=' /boot/cmdline.txt then G_DIETPI-NOTIFY 2 'Removing ineffective "rootdelay" argument from /boot/cmdline.txt' - G_EXEC sed -i -e 's/^rootdelay=[^[:blank:]]*[[:blank:]]*//g' -e 's/[[:blank:]]*[[:blank:]]rootdelay=[^[:blank:]]*//g' /boot/cmdline.txt + G_EXEC sed --follow-symlinks -i -e 's/^rootdelay=[^[:blank:]]*[[:blank:]]*//g' -e 's/[[:blank:]]*[[:blank:]]rootdelay=[^[:blank:]]*//g' /boot/cmdline.txt fi # DietPi-Backup: Move logs to persistent backup location @@ -500,7 +500,7 @@ Patch_7_9() fi # Update choice and preference index variables - [[ -f '/boot/dietpi/.installed' ]] && G_EXEC sed -Ei -e 's/INDEX_(LOGGING|WEBSERVER|DESKTOP|BROWSER)_CURRENT/INDEX_\1/g' -e '/INDEX_(LOGGING|WEBSERVER|DESKTOP|BROWSER|SSHSERVER|FILESERVER)_TARGET/d' -e '/INDEX_(SSHSERVER|FILESERVER)_CURRENT/d' /boot/dietpi/.installed + [[ -f '/boot/dietpi/.installed' ]] && G_EXEC sed --follow-symlinks -Ei -e 's/INDEX_(LOGGING|WEBSERVER|DESKTOP|BROWSER)_CURRENT/INDEX_\1/g' -e '/INDEX_(LOGGING|WEBSERVER|DESKTOP|BROWSER|SSHSERVER|FILESERVER)_TARGET/d' -e '/INDEX_(SSHSERVER|FILESERVER)_CURRENT/d' /boot/dietpi/.installed # Offer to update DietPi-Dashboard TCP port: https://github.com/MichaIng/DietPi/issues/4966 if [[ -f '/opt/dietpi-dashboard/config.toml' ]] && grep -Eq '^[[:blank:]]*port[[:blank:]]+=[[:blank:]]+8088$' /opt/dietpi-dashboard/config.toml @@ -513,8 +513,8 @@ Patch_7_9() fi # ownCloud/Nextcloud: Disable maintenance mode once manually, since DietPi-Services enabled of before this update but doesn't handle/disable it anymore afterwards. - [[ -f '/var/www/owncloud/config/config.php' ]] && grep -Eq "^[[:blank:]]*'maintenance'[[:blank:]]+=>[[:blank:]]+true,\$" /var/www/owncloud/config/config.php && G_EXEC sed -Ei "s/^[[:blank:]]*'maintenance'[[:blank:]]+=>[[:blank:]]+true,\$/ 'maintenance' => false,/" /var/www/owncloud/config/config.php - [[ -f '/var/www/nextcloud/config/config.php' ]] && grep -Eq "^[[:blank:]]*'maintenance'[[:blank:]]+=>[[:blank:]]+true,\$" /var/www/nextcloud/config/config.php && G_EXEC sed -Ei "s/^[[:blank:]]*'maintenance'[[:blank:]]+=>[[:blank:]]+true,\$/ 'maintenance' => false,/" /var/www/nextcloud/config/config.php + [[ -f '/var/www/owncloud/config/config.php' ]] && grep -Eq "^[[:blank:]]*'maintenance'[[:blank:]]+=>[[:blank:]]+true,\$" /var/www/owncloud/config/config.php && G_EXEC sed --follow-symlinks -Ei "s/^[[:blank:]]*'maintenance'[[:blank:]]+=>[[:blank:]]+true,\$/ 'maintenance' => false,/" /var/www/owncloud/config/config.php + [[ -f '/var/www/nextcloud/config/config.php' ]] && grep -Eq "^[[:blank:]]*'maintenance'[[:blank:]]+=>[[:blank:]]+true,\$" /var/www/nextcloud/config/config.php && G_EXEC sed --follow-symlinks -Ei "s/^[[:blank:]]*'maintenance'[[:blank:]]+=>[[:blank:]]+true,\$/ 'maintenance' => false,/" /var/www/nextcloud/config/config.php } Patch_8_0() @@ -525,7 +525,7 @@ Patch_8_0() G_DIETPI-NOTIFY 2 'Fixing doubled CMA size in KMS overlay setting' while grep -Eq 'dtoverlay=vc4-f?kms-v3d.*,cma-.*,cma-' /boot/config.txt do - G_EXEC sed -Ei '/dtoverlay=vc4-f?kms-v3d.*,cma-.*,cma-/s/,cma-[^,]*//' /boot/config.txt + G_EXEC sed --follow-symlinks -Ei '/dtoverlay=vc4-f?kms-v3d.*,cma-.*,cma-/s/,cma-[^,]*//' /boot/config.txt done fi @@ -551,10 +551,10 @@ Patch_8_0() fi # RPi: Fix forced max frequencies: https://github.com/MichaIng/DietPi/issues/5088 - (( $G_HW_MODEL < 10 )) && grep -Eq '(.){100}' /boot/config.txt && G_EXEC sed -Ei 's/^((.){99})..*$/\1/' /boot/config.txt + (( $G_HW_MODEL < 10 )) && grep -Eq '(.){100}' /boot/config.txt && G_EXEC sed --follow-symlinks -Ei 's/^((.){99})..*$/\1/' /boot/config.txt # Blynk Server: Apply Log4Shell mitigation - [[ -f '/etc/systemd/system/blynkserver.service' ]] && ! grep -q '\-Dlog4j2.formatMsgNoLookups=true' /etc/systemd/system/blynkserver.service && G_EXEC sed -i 's/java -jar/java -Dlog4j2.formatMsgNoLookups=true -jar/' /etc/systemd/system/blynkserver.service + [[ -f '/etc/systemd/system/blynkserver.service' ]] && ! grep -q '\-Dlog4j2.formatMsgNoLookups=true' /etc/systemd/system/blynkserver.service && G_EXEC sed --follow-symlinks -i 's/java -jar/java -Dlog4j2.formatMsgNoLookups=true -jar/' /etc/systemd/system/blynkserver.service } Patch_8_1() @@ -566,7 +566,7 @@ Patch_8_1() # RPi: Remove obsolete VCSM overlay since the device node has been removed if (( $G_HW_MODEL < 10 )) then - grep -q 'dtoverlay=dietpi-disable_vcsm' /boot/config.txt && G_EXEC sed -i '/dtoverlay=dietpi-disable_vcsm/d' /boot/config.txt + grep -q 'dtoverlay=dietpi-disable_vcsm' /boot/config.txt && G_EXEC sed --follow-symlinks -i '/dtoverlay=dietpi-disable_vcsm/d' /boot/config.txt [[ -f '/boot/overlays/dietpi-disable_vcsm.dtbo' ]] && G_EXEC rm /boot/overlays/dietpi-disable_vcsm.dtbo fi @@ -587,10 +587,10 @@ _EOF_ Patch_8_2() { # Remove obsolete quotation from armbianEnv.txt - [[ -f '/boot/armbianEnv.txt' ]] && grep -q '^[[:blank:]]*extraargs="' /boot/armbianEnv.txt && G_EXEC sed -i -e 's/^[[:blank:]]*extraargs="[[:blank:]]*/extraargs=/' -e 's/[[:blank:]]*"[[:blank:]]*$//' /boot/armbianEnv.txt + [[ -f '/boot/armbianEnv.txt' ]] && grep -q '^[[:blank:]]*extraargs="' /boot/armbianEnv.txt && G_EXEC sed --follow-symlinks -i -e 's/^[[:blank:]]*extraargs="[[:blank:]]*/extraargs=/' -e 's/[[:blank:]]*"[[:blank:]]*$//' /boot/armbianEnv.txt # RPi: Remove multiple cgroup_enable=memory entries from cmdline.txt: https://github.com/MichaIng/DietPi/issues/5225#issuecomment-1033056312 - [[ -f '/boot/cmdline.txt' ]] && while grep -q 'cgroup_enable=memory cgroup_enable=memory' /boot/cmdline.txt; do G_EXEC sed -i 's/cgroup_enable=memory cgroup_enable=memory/cgroup_enable=memory/g' /boot/cmdline.txt; done + [[ -f '/boot/cmdline.txt' ]] && while grep -q 'cgroup_enable=memory cgroup_enable=memory' /boot/cmdline.txt; do G_EXEC sed --follow-symlinks -i 's/cgroup_enable=memory cgroup_enable=memory/cgroup_enable=memory/g' /boot/cmdline.txt; done # Apply cgroups-v2 workaround if the kernel does not support it: https://github.com/MichaIng/DietPi/issues/4705 # - This is required on Bullseye only, but we'll apply it on Buster as well to cover later distro upgrades, since the logic is too complicated for our upgrade blog article. @@ -600,19 +600,19 @@ Patch_8_2() if [[ $G_HW_MODEL -gt 9 && $G_HW_MODEL -le 16 && -f '/boot/boot.ini' ]] && ! grep -q 'systemd.unified_cgroup_hierarchy=0' /boot/boot.ini then G_DIETPI-NOTIFY 2 'Forcing legacy cgroups v1 hierarchy on old kernel device' - G_EXEC sed -i '/^setenv bootargs "/s/"$/ systemd.unified_cgroup_hierarchy=0"/' /boot/boot.ini + G_EXEC sed --follow-symlinks -i '/^setenv bootargs "/s/"$/ systemd.unified_cgroup_hierarchy=0"/' /boot/boot.ini # Sparky SBC elif [[ $G_HW_MODEL == 70 && -f '/boot/uenv.txt' ]] && ! grep -q 'systemd.unified_cgroup_hierarchy=0' /boot/uenv.txt then G_DIETPI-NOTIFY 2 'Forcing legacy cgroups v1 hierarchy on old kernel device' - G_EXEC sed -i '/^bootargs=/s/$/ systemd.unified_cgroup_hierarchy=0/' /boot/uenv.txt + G_EXEC sed --follow-symlinks -i '/^bootargs=/s/$/ systemd.unified_cgroup_hierarchy=0/' /boot/uenv.txt # ROCK Pi S elif [[ $G_HW_MODEL == 73 && -f '/boot/boot.cmd' ]] && ! grep -q 'systemd.unified_cgroup_hierarchy=0' /boot/boot.cmd then G_DIETPI-NOTIFY 2 'Forcing legacy cgroups v1 hierarchy on old kernel device' - G_EXEC sed -i '/^setenv bootargs "/s/"$/ systemd.unified_cgroup_hierarchy=0"/' /boot/boot.cmd + G_EXEC sed --follow-symlinks -i '/^setenv bootargs "/s/"$/ systemd.unified_cgroup_hierarchy=0"/' /boot/boot.cmd G_AG_CHECK_INSTALL_PREREQ u-boot-tools G_EXEC mkimage -C none -A arm64 -T script -d /boot/boot.cmd /boot/boot.scr fi @@ -622,7 +622,7 @@ Patch_8_2() if [[ $G_HW_MODEL == 40 && $(uname -r) == '5'* ]] then [[ -f '/etc/bashrc.d/dietpi-pine64-cursorfix.sh' ]] && G_EXEC rm /etc/bashrc.d/dietpi-pine64-cursorfix.sh - grep -q '^8723bs$' /etc/modules && G_EXEC sed -i '/^8723bs$/d' /etc/modules + grep -q '^8723bs$' /etc/modules && G_EXEC sed --follow-symlinks -i '/^8723bs$/d' /etc/modules fi # Remove and migrate Chromium config files @@ -635,7 +635,7 @@ Patch_8_2() [[ -f '/etc/chromium.d/custom_flags' ]] && G_EXEC mv /etc/chromium.d/{custom_flags,dietpi} # Remove obsolete Nvidia install state - [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[151\]=' /boot/dietpi/.installed && G_EXEC sed -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[151\]=/d' /boot/dietpi/.installed + [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[151\]=' /boot/dietpi/.installed && G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[151\]=/d' /boot/dietpi/.installed # Deluge: Apply autoconnect for web interface if [[ -f '/mnt/dietpi_userdata/deluge/.config/deluge/hostlist.conf' && -f '/mnt/dietpi_userdata/deluge/.config/deluge/web.conf' ]] && grep -q '"default_daemon": "",' /mnt/dietpi_userdata/deluge/.config/deluge/web.conf @@ -653,11 +653,11 @@ Patch_8_4() if [[ -f '/boot/armbianEnv.txt' ]] && grep -q 'extraargs="net.ifnames=0"' /boot/armbianEnv.txt then G_DIETPI-NOTIFY 2 'Fixing syntax for legacy network interface nameing (eth0/wlan0). \e[33mNB: If you rely on "predictable" interface naming (enp0s0/wlp0s0), remove "net.ifnames=0" from /boot/armbianEnv.txt!' - G_EXEC sed -i 's/extraargs="net.ifnames=0"/extraargs=net.ifnames=0/' /boot/armbianEnv.txt + G_EXEC sed --follow-symlinks -i 's/extraargs="net.ifnames=0"/extraargs=net.ifnames=0/' /boot/armbianEnv.txt fi # Update workaround for numpy on ARMv6/7 Buster - (( $G_HW_ARCH < 3 && $G_DISTRO == 5 )) && [[ -f '/etc/pip-constraints.txt' ]] && G_EXEC sed -i '/^numpy!=1.21.5; python_version=='\''3.7'\''$/c\numpy<1.21.5; python_version=='\''3.7'\' /etc/pip-constraints.txt + (( $G_HW_ARCH < 3 && $G_DISTRO == 5 )) && [[ -f '/etc/pip-constraints.txt' ]] && G_EXEC sed --follow-symlinks -i '/^numpy!=1.21.5; python_version=='\''3.7'\''$/c\numpy<1.21.5; python_version=='\''3.7'\' /etc/pip-constraints.txt # https://github.com/MichaIng/DietPi/issues/5441 if [[ -f '/etc/sudoers.d/dietpi' ]] @@ -667,11 +667,11 @@ Patch_8_4() fi # Remove obsolete software preference indices - [[ -f '/boot/dietpi/.installed' ]] && G_EXEC sed -Ei '/^[[:blank:]]*INDEX_(WEBSERVER|DESKTOP|BROWSER)=/d' /boot/dietpi/.installed + [[ -f '/boot/dietpi/.installed' ]] && G_EXEC sed --follow-symlinks -Ei '/^[[:blank:]]*INDEX_(WEBSERVER|DESKTOP|BROWSER)=/d' /boot/dietpi/.installed # Remove obsolete license file and setting [[ -f '/var/lib/dietpi/license.txt' ]] && G_EXEC rm /var/lib/dietpi/license.txt - G_EXEC sed -i '/^[[:blank:]]*AUTO_SETUP_ACCEPT_LICENSE=/d' /boot/dietpi.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*AUTO_SETUP_ACCEPT_LICENSE=/d' /boot/dietpi.txt # Update DietPi initramfs cleanup script, following reasonable changes done by Armbian if [[ -f '/etc/kernel/preinst.d/dietpi-initramfs_cleanup' ]] @@ -695,7 +695,7 @@ Patch_8_4() fi # Remove obsolete OpenBazaar install state - [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[58\]=' /boot/dietpi/.installed && G_EXEC sed -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[58\]=/d' /boot/dietpi/.installed + [[ -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(){ :; } @@ -731,7 +731,7 @@ Patch_8_7() (( $G_HW_MODEL > 9 )) || while grep -q 'cgroup_enable=memory.* cgroup_enable=memory' /boot/cmdline.txt do G_DIETPI-NOTIFY 2 'Removing duplicate "cgroup_enable=memory" kernel command-line argument...' - G_EXEC sed -i 's/ cgroup_enable=memory//' /boot/cmdline.txt + G_EXEC sed --follow-symlinks -i 's/ cgroup_enable=memory//' /boot/cmdline.txt done } @@ -765,8 +765,8 @@ Patch_8_9() if [[ -f '/etc/turnserver.conf' && -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[168\]=2' /boot/dietpi/.installed then G_DIETPI-NOTIFY 2 'Removing obsolete Coturn settings...' - grep -q '^[[:blank:]]*use-auth-secret' /etc/turnserver.conf && grep -q '^[[:blank:]]*lt-cred-mech' /etc/turnserver.conf && G_EXEC sed -i 's/^[[:blank:]]*lt-cred-mech/#lt-cred-mech/' /etc/turnserver.conf - grep -q '^[[:blank:]]*no-loopback-peers' /etc/turnserver.conf && G_EXEC sed -i -e '/^[[:blank:]]*no-loopback-peers/d' -e 's/^[[:blank:]]*allow-loopback-peers/#allow-loopback-peers/' /etc/turnserver.conf + 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 } @@ -809,12 +809,12 @@ Patch_8_11() if [[ -f '/etc/apt/sources.list.d/armbian.list' ]] && grep -q 'http://apt.armbian.com' /etc/apt/sources.list.d/armbian.list then G_DIETPI-NOTIFY 2 'Connecting to apt.armbian.com via secure HTTPS since their router now handles HTTPS redirects reliably' - G_EXEC sed -i 's|http://apt.armbian.com|https://apt.armbian.com|' /etc/apt/sources.list.d/armbian.list + G_EXEC sed --follow-symlinks -i 's|http://apt.armbian.com|https://apt.armbian.com|' /etc/apt/sources.list.d/armbian.list fi if [[ -f '/etc/apt/sources.list.d/dietpi-armbian.list' ]] && grep -q 'http://apt.armbian.com' /etc/apt/sources.list.d/dietpi-armbian.list then G_DIETPI-NOTIFY 2 'Connecting to apt.armbian.com via secure HTTPS since their router now handles HTTPS redirects reliably' - G_EXEC sed -i 's|http://apt.armbian.com|https://apt.armbian.com|' /etc/apt/sources.list.d/dietpi-armbian.list + G_EXEC sed --follow-symlinks -i 's|http://apt.armbian.com|https://apt.armbian.com|' /etc/apt/sources.list.d/dietpi-armbian.list fi if (( $G_HW_MODEL == 56 )) @@ -823,7 +823,7 @@ Patch_8_11() if [[ -f '/boot/dtb/rockchip/rk3328-nanopi-neo3-rev02.dtb' ]] && grep -q 'rk3328-nanopi-r2-rev00.dtb' /boot/armbianEnv.txt then G_DIETPI-NOTIFY 2 'Switching back to NEO3 device tree, which is available again' - G_EXEC sed -i 's/rk3328-nanopi-r2-rev00.dtb/rk3328-nanopi-neo3-rev02.dtb/' /boot/armbianEnv.txt + G_EXEC sed --follow-symlinks -i 's/rk3328-nanopi-r2-rev00.dtb/rk3328-nanopi-neo3-rev02.dtb/' /boot/armbianEnv.txt fi fi @@ -847,11 +847,11 @@ Patch_8_11() elif (( $G_HW_MODEL == 52 )) then # https://github.com/MichaIng/DietPi/issues/5554 - grep -q 'systemd.unified_cgroup_hierarchy=0' /boot/armbianEnv.txt || G_EXEC sed -i '/^extraargs=/s/$/ systemd.unified_cgroup_hierarchy=0/' /boot/armbianEnv.txt + 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 -i 's/^curl -6or4/curl/' /var/lib/dietpi/dietpi-ddns/update.sh + [[ -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 } @@ -893,7 +893,7 @@ _EOF_ if [[ $G_HW_MODEL == 12 && -f '/boot/boot.cmd' ]] && ! grep -q 'usbcore.autosuspend=-1' /boot/boot.cmd then G_DIETPI-NOTIFY 2 'Fixing USB device detection on Odroid C2' - G_EXEC sed -i 's/coherent_pool=2M/coherent_pool=2M usbcore.autosuspend=-1/' /boot/boot.cmd + G_EXEC 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 } @@ -951,7 +951,7 @@ Patch_8_15() [[ -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 -i '/^append /s/ systemd.unified_cgroup_hierarchy=0//' /boot/extlinux/extlinux.conf + 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 (( $G_DISTRO > 6 )) || for i in '/etc/systemd/system/serial-getty@'*'.service.d/dietpi-baudrate.conf' @@ -971,7 +971,7 @@ _EOF_ grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[60\]=2' /boot/dietpi/.installed && G_EXEC systemctl enable hostapd isc-dhcp-server # Remove obsolete Build-Essential install state - grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[16\]=' /boot/dietpi/.installed && G_EXEC sed -i '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[16\]=/d' /boot/dietpi/.installed + 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 @@ -985,7 +985,7 @@ Patch_8_16() if systemctl -q is-enabled 'serial-getty@ttyS2' then G_DIETPI-NOTIFY 2 'Fixing UART console on ttyFIQ0 instead of ttyS2' - G_EXEC sed -i '/^consoleargs=console=ttyS2,1500000 console=tty1$/c\consoleargs=console=ttyFIQ0,1500000 console=tty1' /boot/dietpiEnv.txt + 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 @@ -1096,7 +1096,7 @@ Patch_8_16() 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 -i '\|^tmpfs /var/log tmpfs |s|,mode=1777$||' /etc/fstab + 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 )) @@ -1127,13 +1127,13 @@ Patch_8_17() [[ -f '/etc/modprobe.d/dietpi-disable_rpi_sound.conf' ]] && G_EXEC mv /etc/modprobe.d/dietpi-disable_rpi_{sound,audio}.conf if grep -q '^[[:blank:]]*dtoverlay=dietpi-disable_hdmi_audio' /boot/config.txt then - G_EXEC sed -i '/^[[:blank:]]*dtoverlay=dietpi-disable_hdmi_audio/d' /boot/config.txt - G_EXEC sed -i '/root=/s/$/ snd_bcm2835.enable_hdmi=0/' /boot/cmdline.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*dtoverlay=dietpi-disable_hdmi_audio/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/root=/s/$/ snd_bcm2835.enable_hdmi=0/' /boot/cmdline.txt fi if grep -q '^[[:blank:]]*dtoverlay=dietpi-disable_headphones' /boot/config.txt then - G_EXEC sed -i '/^[[:blank:]]*dtoverlay=dietpi-disable_headphones/d' /boot/config.txt - G_EXEC sed -i '/root=/s/$/ snd_bcm2835.enable_headphones=0/' /boot/cmdline.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*dtoverlay=dietpi-disable_headphones/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/root=/s/$/ snd_bcm2835.enable_headphones=0/' /boot/cmdline.txt fi [[ -f '/boot/overlays/dietpi-disable_hdmi_audio.dtbo' ]] && G_EXEC rm /boot/overlays/dietpi-disable_hdmi_audio.dtbo [[ -f '/boot/overlays/dietpi-disable_headphones.dtbo' ]] && G_EXEC rm /boot/overlays/dietpi-disable_headphones.dtbo @@ -1142,13 +1142,13 @@ Patch_8_17() if (( $G_DISTRO > 5 )) && grep -q '^[[:blank:]]*dtoverlay=rpivid-v4l2$' /boot/config.txt then G_DIETPI-NOTIFY 2 'Removing deprecated device tree overlay: rpivid-v4l2' - G_EXEC sed -i '/^[[:blank:]]*dtoverlay=rpivid-v4l2$/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*dtoverlay=rpivid-v4l2$/d' /boot/config.txt fi # Sparky SBC: Fix Roonbridge: https://dietpi.com/forum/t/allogui-not-working-apache-service-doesnt-start/15708/13 elif (( $G_HW_MODEL == 70 )) then - [[ -f '/etc/systemd/system/roonbridge.service' ]] && G_EXEC sed -i '/^AmbientCapabilities=/d' /etc/systemd/system/roonbridge.service + [[ -f '/etc/systemd/system/roonbridge.service' ]] && G_EXEC sed --follow-symlinks -i '/^AmbientCapabilities=/d' /etc/systemd/system/roonbridge.service [[ -f '/etc/systemd/system/roonbridge.service.d/dietpi-no-caps.conf' ]] && G_EXEC rm /etc/systemd/system/roonbridge.service.d/dietpi-no-caps.conf [[ -f '/etc/systemd/system/roonbridge.service.d' ]] && G_EXEC rmdir --ignore-fail-on-non-empty /etc/systemd/system/roonbridge.service.d @@ -1253,10 +1253,10 @@ Patch_8_19() 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 -Ei '/^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[(141|177)\]=/d' /boot/dietpi/.installed + 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 - (( $G_DISTRO > 5 )) && [[ -f '/etc/apt/sources.list.d/mopidy.list' ]] && grep -q buster /etc/apt/sources.list.d/mopidy.list && G_EXEC sed -i 's/buster/bullseye/' /etc/apt/sources.list.d/mopidy.list + (( $G_DISTRO > 5 )) && [[ -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 # GMediaRender grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[163\]=2' /boot/dietpi/.installed && dpkg --compare-versions "$(dpkg-query -Wf '${Version}' gmediarender 2> /dev/null)" lt 0.1-dietpi1 && G_WHIP_MSG '[ INFO ] GMediaRender update available @@ -1323,22 +1323,22 @@ Patch_8_20() # - Apache if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[83\]=2' /boot/dietpi/.installed then - [[ -f '/etc/apache2/conf-available/dietpi.conf' ]] && G_EXEC sed -i '/^Header set X-XSS-Protection "/c\Header set X-XSS-Protection "0"' /etc/apache2/conf-available/dietpi.conf + [[ -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 # Nextcloud: Revert to mute Nextcloud's outdated admin panel warning - [[ -f '/etc/apache2/sites-available/dietpi-nextcloud.conf' ]] && G_EXEC sed -i '/<\/IfModule>/a\\n\t# Mute outdated admin panel warning\n\tHeader set X-XSS-Protection "1; mode=block"' /etc/apache2/sites-available/dietpi-nextcloud.conf + [[ -f '/etc/apache2/sites-available/dietpi-nextcloud.conf' ]] && G_EXEC sed --follow-symlinks -i '/<\/IfModule>/a\\n\t# Mute outdated admin panel warning\n\tHeader set X-XSS-Protection "1; mode=block"' /etc/apache2/sites-available/dietpi-nextcloud.conf fi # - ownCloud if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[47\]=2' /boot/dietpi/.installed then - [[ -f '/etc/nginx/sites-dietpi/dietpi-owncloud.conf' ]] && G_EXEC sed -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 -i 's/"X-XSS-Protection" => "1; mode=block"/"X-XSS-Protection" => "0"/' /etc/lighttpd/conf-available/99-dietpi-owncloud.conf + [[ -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 fi # - Pi-hole if grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[93\]=2' /boot/dietpi/.installed then - [[ -f '/etc/nginx/sites-dietpi/dietpi-pihole.conf' ]] && G_EXEC sed -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 -i 's/"X-XSS-Protection" => "1; mode=block"/"X-XSS-Protection" => "0"/' /etc/lighttpd/conf-available/99-dietpi-pihole.conf + [[ -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 fi # DietPi-Dashboard: https://github.com/ravenclaw900/DietPi-Dashboard/releases/tag/v0.6.2 @@ -1365,7 +1365,7 @@ Patch_8_21() 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 -i '/^[[:blank:]]*fdtfile=/d' /boot/dietpiEnv.txt + (( $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 } @@ -1398,7 +1398,7 @@ _EOF_ 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 -i '/^fdtfile=$/d' /boot/dietpiEnv.txt + G_EXEC sed --follow-symlinks -i '/^fdtfile=$/d' /boot/dietpiEnv.txt fi } @@ -1563,7 +1563,7 @@ Release notes: https://github.com/BlitterStudio/amiberry/releases 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 -i -e '/^Type=/d' -e '/^ExecStart=/c\ExecStart=/mnt/dietpi_userdata/nzbget/nzbget -so OutputMode=log' /etc/systemd/system/nzbget.service + [[ -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 fi diff --git a/.update/pre-patches b/.update/pre-patches index 5396af247f..56dd60e582 100755 --- a/.update/pre-patches +++ b/.update/pre-patches @@ -66,7 +66,7 @@ fi if (( $G_DIETPI_VERSION_CORE < 7 || ( $G_DIETPI_VERSION_CORE == 7 && $G_DIETPI_VERSION_SUB < 6 ) )) && (( $G_HW_MODEL < 10 )) && [[ -f '/etc/apt/preferences.d/dietpi-lxde' ]] && ! grep -q ' lx\*$' /etc/apt/preferences.d/dietpi-lxde then G_DIETPI-NOTIFY 2 'Updating the Raspberry Pi desktop package blocks' - G_EXEC sed -i '/^Package:/c\Package: openbox* obconf* libob* pcmanfm* libfm* gtk-* libgtk* libgail* gir1.2-gtk-* lx*' /etc/apt/preferences.d/dietpi-lxde + G_EXEC sed --follow-symlinks -i '/^Package:/c\Package: openbox* obconf* libob* pcmanfm* libfm* gtk-* libgtk* libgail* gir1.2-gtk-* lx*' /etc/apt/preferences.d/dietpi-lxde fi # v7.7 @@ -97,8 +97,8 @@ _EOF_ fi G_DIETPI-NOTIFY 2 'Connecting to Mosquitto and Webmin repositories via plain HTTP once until latest OpenSSL has been installed: https://github.com/MichaIng/DietPi/issues/4795' - G_EXEC sed -Ei 's#https://(repo.mosquitto.org|download.webmin.com)#http://\1#' /etc/apt/sources.list - [[ $(find /etc/apt/sources.list/*.list 2> /dev/null) ]] && G_EXEC sed -Ei 's#https://(repo.mosquitto.org|download.webmin.com)#http://\1#' /etc/apt/sources.list.d/*.list + G_EXEC sed --follow-symlinks -Ei 's#https://(repo.mosquitto.org|download.webmin.com)#http://\1#' /etc/apt/sources.list + [[ $(find /etc/apt/sources.list/*.list 2> /dev/null) ]] && G_EXEC sed --follow-symlinks -Ei 's#https://(repo.mosquitto.org|download.webmin.com)#http://\1#' /etc/apt/sources.list.d/*.list # Add execute permissions to kernel/initramfs hooks [[ -f '/etc/initramfs/post-update.d/99-dietpi-uboot' && ! -x '/etc/initramfs/post-update.d/99-dietpi-uboot' ]] && G_EXEC chmod +x /etc/initramfs/post-update.d/99-dietpi-uboot @@ -209,12 +209,12 @@ then if (( $G_DISTRO > 6 )) && [[ -f '/etc/apt/sources.list.d/dietpi-jellyfin.list' ]] && grep -q 'bullseye' /etc/apt/sources.list.d/dietpi-jellyfin.list then G_DIETPI-NOTIFY 2 'Updating Jellyfin APT repo suite' - G_EXEC sed -i 's/bullseye/bookworm/' /etc/apt/sources.list.d/dietpi-jellyfin.list + G_EXEC sed --follow-symlinks -i 's/bullseye/bookworm/' /etc/apt/sources.list.d/dietpi-jellyfin.list fi if (( $G_DISTRO > 6 )) && [[ -f '/etc/apt/sources.list.d/docker.list' ]] && grep -q 'bullseye' /etc/apt/sources.list.d/docker.list then G_DIETPI-NOTIFY 2 'Updating Docker APT repo suite' - G_EXEC sed -i 's/bullseye/bookworm/' /etc/apt/sources.list.d/docker.list + G_EXEC sed --follow-symlinks -i 's/bullseye/bookworm/' /etc/apt/sources.list.d/docker.list fi fi @@ -225,13 +225,13 @@ then then # https://www.debian.org/releases/bookworm/amd64/release-notes/ch-information.en.html#non-free-split G_DIETPI-NOTIFY 2 'Adding new non-free-firmware component to APT lists, to re-enable firmware upgrades' - G_EXEC sed -i '/non-free/s/$/ non-free-firmware/' /etc/apt/sources.list + G_EXEC sed --follow-symlinks -i '/non-free/s/$/ non-free-firmware/' /etc/apt/sources.list fi if (( $G_DISTRO > 6 )) && [[ -f '/etc/apt/sources.list.d/dietpi-armbian.list' || -f '/etc/apt/sources.list.d/armbian.list' ]] then G_DIETPI-NOTIFY 2 'Updating Armbian APT repo list with Bookworm suite' - [[ -f '/etc/apt/sources.list.d/dietpi-armbian.list' ]] && G_EXEC sed -i 's/bullseye/bookworm/' /etc/apt/sources.list.d/dietpi-armbian.list - [[ -f '/etc/apt/sources.list.d/armbian.list' ]] && G_EXEC sed -i 's/bullseye/bookworm/' /etc/apt/sources.list.d/armbian.list + [[ -f '/etc/apt/sources.list.d/dietpi-armbian.list' ]] && G_EXEC sed --follow-symlinks -i 's/bullseye/bookworm/' /etc/apt/sources.list.d/dietpi-armbian.list + [[ -f '/etc/apt/sources.list.d/armbian.list' ]] && G_EXEC sed --follow-symlinks -i 's/bullseye/bookworm/' /etc/apt/sources.list.d/armbian.list fi fi @@ -310,7 +310,7 @@ then [[ -f '/etc/apt/preferences.d/dietpi-ffmpeg' ]] && G_EXEC rm /etc/apt/preferences.d/dietpi-ffmpeg G_DIETPI-NOTIFY 2 'Removing faulty non-free-firmware component if present' - (( $G_RASPBIAN )) && G_EXEC sed -i 's/ non-free-firmware$//' /etc/apt/sources.list + (( $G_RASPBIAN )) && G_EXEC sed --follow-symlinks -i 's/ non-free-firmware$//' /etc/apt/sources.list fi # Migrate Armbian keyring from /etc/apt/trusted.gpg to /etc/apt/trusted.gpg.d for old images @@ -340,12 +340,12 @@ then if [[ $G_DISTRO -ge 7 && -f '/etc/apt/sources.list.d/dietpi-mosquitto.list' ]] then G_DIETPI-NOTIFY 2 'Migrating Mosquitto APT repository to Bookworm' - G_EXEC sed -i 's/bullseye/bookworm/' /etc/apt/sources.list.d/dietpi-mosquitto.list + G_EXEC sed --follow-symlinks -i 's/bullseye/bookworm/' /etc/apt/sources.list.d/dietpi-mosquitto.list fi if [[ $G_DISTRO == 7 && -f '/etc/apt/sources.list.d/dietpi-mympd.list' ]] then G_DIETPI-NOTIFY 2 'Migrating myMPD APT repository from testing suite to Bookworm suite' - G_EXEC sed -i 's/Debian_Testing/Debian_12/' /etc/apt/sources.list.d/dietpi-mympd.list + G_EXEC sed --follow-symlinks -i 's/Debian_Testing/Debian_12/' /etc/apt/sources.list.d/dietpi-mympd.list fi if [[ $G_DISTRO == 7 && -f '/etc/apt/sources.list.d/raspi.list' && -f '/etc/apt/preferences.d/dietpi-ffmpeg' ]] then @@ -355,7 +355,7 @@ then if [[ -f '/etc/apt/sources.list.d/dietpi-openhab.list' ]] then G_DIETPI-NOTIFY 2 'Migrating openHAB APT repository from testing suite to stable suite' - G_EXEC sed -i 's/ testing / stable /' /etc/apt/sources.list.d/dietpi-openhab.list + G_EXEC sed --follow-symlinks -i 's/ testing / stable /' /etc/apt/sources.list.d/dietpi-openhab.list (( $G_DISTRO < 6 )) && G_EXEC eval 'echo -e '\''Package: openhab*\nPin: version 3.*\nPin-Priority: 501'\'' > /etc/apt/preferences.d/dietpi-openhab' fi if [[ $G_DISTRO -ge 7 && -f '/etc/apt/sources.list.d/raspi.list' ]] && dpkg-query -s 'kodi-repository-kodi' &> /dev/null diff --git a/dietpi/dietpi-backup b/dietpi/dietpi-backup index 7ad4fea2b6..143a91cc4a 100755 --- a/dietpi/dietpi-backup +++ b/dietpi/dietpi-backup @@ -306,9 +306,9 @@ However, this check is a rough estimation in reasonable time, thus it could be m do [[ $mountpoint ]] || continue local uuid=$(findmnt -Ufnro UUID -M "$mountpoint") - [[ $uuid ]] && G_EXEC sed -i "\|[[:blank:]]${mountpoint}[[:blank:]]|s|^[[:blank:]]*UUID=[^[:blank:]]*|UUID=$uuid|" /etc/fstab + [[ $uuid ]] && G_EXEC sed --follow-symlinks -i "\|[[:blank:]]${mountpoint}[[:blank:]]|s|^[[:blank:]]*UUID=[^[:blank:]]*|UUID=$uuid|" /etc/fstab local partuuid=$(findmnt -Ufnro PARTUUID -M "$mountpoint") - [[ $partuuid ]] && G_EXEC sed -i "\|[[:blank:]]${mountpoint}[[:blank:]]|s|^[[:blank:]]*PARTUUID=[^[:blank:]]*|PARTUUID=$partuuid|" /etc/fstab + [[ $partuuid ]] && G_EXEC sed --follow-symlinks -i "\|[[:blank:]]${mountpoint}[[:blank:]]|s|^[[:blank:]]*PARTUUID=[^[:blank:]]*|PARTUUID=$partuuid|" /etc/fstab done < <(lsblk -no MOUNTPOINT "$(lsblk -npo PKNAME "$G_ROOTFS_DEV")") @@ -324,7 +324,7 @@ However, this check is a rough estimation in reasonable time, thus it could be m # - RPi elif (( $UPDATE_RPI == 1 )) then - G_EXEC sed -Ei "s/(^|[[:blank:]])root=[^[:blank:]]*/\1root=PARTUUID=$PARTUUID_ROOT/" /boot/cmdline.txt + G_EXEC sed --follow-symlinks -Ei "s/(^|[[:blank:]])root=[^[:blank:]]*/\1root=PARTUUID=$PARTUUID_ROOT/" /boot/cmdline.txt # - DietPi modern U-Boot elif (( $UPDATE_DIETPI == 1 )) @@ -341,12 +341,12 @@ However, this check is a rough estimation in reasonable time, thus it could be m # - Odroids / classic U-Boot elif (( $UPDATE_ODROID == 1 )) then - G_EXEC sed -Ei -e "s/(\"|root=)UUID=[^[:blank:]\"]*/\1UUID=$UUID_ROOT/" -e "s/(\"|root=)PARTUUID=[^[:blank:]\"]*/\1PARTUUID=$PARTUUID_ROOT/" /boot/boot.ini + G_EXEC sed --follow-symlinks -Ei -e "s/(\"|root=)UUID=[^[:blank:]\"]*/\1UUID=$UUID_ROOT/" -e "s/(\"|root=)PARTUUID=[^[:blank:]\"]*/\1PARTUUID=$PARTUUID_ROOT/" /boot/boot.ini # - Modern U-Boot elif (( $UPDATE_UBOOT == 1 )) then - G_EXEC sed -Ei -e "s/(\"|root=)UUID=[^[:blank:]\"]*/\1UUID=$UUID_ROOT/" -e "s/(\"|root=)PARTUUID=[^[:blank:]\"]*/\1PARTUUID=$PARTUUID_ROOT/" /boot/boot.cmd + G_EXEC sed --follow-symlinks -Ei -e "s/(\"|root=)UUID=[^[:blank:]\"]*/\1UUID=$UUID_ROOT/" -e "s/(\"|root=)PARTUUID=[^[:blank:]\"]*/\1PARTUUID=$PARTUUID_ROOT/" /boot/boot.cmd G_EXEC mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr fi } diff --git a/dietpi/dietpi-cleaner b/dietpi/dietpi-cleaner index 774d63601e..1609ee9c48 100755 --- a/dietpi/dietpi-cleaner +++ b/dietpi/dietpi-cleaner @@ -336,7 +336,7 @@ $G_PROGRAM_NAME simulation has finished: Press any key to continue..." # Mark for autoremoval [[ ${apackages[0]} ]] && { apt-mark auto "${apackages[@]}"; G_AGA; } - sed -i '/^aSOFTWARE_INSTALL_STATE\[16\]=/d' /boot/dietpi/.installed + sed --follow-symlinks -i '/^aSOFTWARE_INSTALL_STATE\[16\]=/d' /boot/dietpi/.installed fi diff --git a/dietpi/dietpi-config b/dietpi/dietpi-config index 38bbc8e5bc..085e905655 100755 --- a/dietpi/dietpi-config +++ b/dietpi/dietpi-config @@ -285,7 +285,7 @@ G_CONFIG_INJECT 'disable_overscan=' 'disable_overscan=1' /boot/config.txt for i in "${overscan_options[@]}" do - sed -i "/^[[:blank:]]*$i=/c\#$i=0" /boot/config.txt + sed --follow-symlinks -i "/^[[:blank:]]*$i=/c\#$i=0" /boot/config.txt done fi @@ -550,8 +550,8 @@ A long (or insufficiently manufactured) cable may required a higher boost settin if [[ $G_WHIP_RETURNED_VALUE == 'System default' ]]; then - sed -i 's/^[[:blank:]]*GRUB_GFXMODE=/#GRUB_GFXMODE=/' /etc/default/grub - sed -i 's/^[[:blank:]]*GRUB_GFXPAYLOAD_LINUX=/#GRUB_GFXPAYLOAD_LINUX=/' /etc/default/grub + sed --follow-symlinks -i 's/^[[:blank:]]*GRUB_GFXMODE=/#GRUB_GFXMODE=/' /etc/default/grub + sed --follow-symlinks -i 's/^[[:blank:]]*GRUB_GFXPAYLOAD_LINUX=/#GRUB_GFXPAYLOAD_LINUX=/' /etc/default/grub else @@ -691,8 +691,8 @@ Re-enabling HDMI requires a reboot. If you need emergency HDMI output, edit the # Disable composite if not chosen if [[ $G_WHIP_RETURNED_VALUE != 'sdtv_mode'* ]]; then - sed -i '/sdtv_mode=/c\#sdtv_mode=0' /boot/config.txt - sed -i '/enable_tvout=/c\#enable_tvout=0' /boot/config.txt + sed --follow-symlinks -i '/sdtv_mode=/c\#sdtv_mode=0' /boot/config.txt + sed --follow-symlinks -i '/enable_tvout=/c\#enable_tvout=0' /boot/config.txt fi @@ -849,7 +849,7 @@ Re-enabling HDMI requires a reboot. If you need emergency HDMI output, edit the [[ $current_resolution != "$G_WHIP_RETURNED_VALUE" ]] && REBOOT_REQUIRED=1 # Always reset vga/dvi options - sed -Ei 's/^[[:blank:]]*(setenv[[:blank:]]+vout[[:blank:]].*$)/#\1/' /boot/boot.ini + sed --follow-symlinks -Ei 's/^[[:blank:]]*(setenv[[:blank:]]+vout[[:blank:]].*$)/#\1/' /boot/boot.ini # DVI / VU7+ if [[ $G_WHIP_RETURNED_VALUE == '1024x600p 60hz' ]]; then @@ -1645,7 +1645,7 @@ If unsure, set any value, 'Ondemand Down Factor' option on the next screen will else - G_EXEC sed -i "/^[[:blank:]]*arm_freq_min=/c\#arm_freq_min=$DEF_VALUE" /boot/config.txt + G_EXEC sed --follow-symlinks -i "/^[[:blank:]]*arm_freq_min=/c\#arm_freq_min=$DEF_VALUE" /boot/config.txt fi REBOOT_REQUIRED=1 @@ -1666,7 +1666,7 @@ If unsure, set any value, 'Ondemand Down Factor' option on the next screen will else - sed -i '/^[[:blank:]]*initial_turbo=/c\#initial_turbo=20' /boot/config.txt + sed --follow-symlinks -i '/^[[:blank:]]*initial_turbo=/c\#initial_turbo=20' /boot/config.txt fi REBOOT_REQUIRED=1 @@ -2058,7 +2058,7 @@ _EOF_ # Remove wireless-power setting if not supported by adapter/firmware # shellcheck disable=SC2015 - (( $WIFI_HARDWARE )) && iw dev "$WIFI_DEV_IFACE" set power_save on 2> /dev/null && iw dev "$WIFI_DEV_IFACE" set power_save off 2> /dev/null || G_EXEC sed -i '/ iw dev .* set power_save /d' /etc/network/interfaces + (( $WIFI_HARDWARE )) && iw dev "$WIFI_DEV_IFACE" set power_save on 2> /dev/null && iw dev "$WIFI_DEV_IFACE" set power_save off 2> /dev/null || G_EXEC sed --follow-symlinks -i '/ iw dev .* set power_save /d' /etc/network/interfaces # Update WiFi db/wpa_supplicant if enabled (( $WIFI_DISABLED )) || /boot/dietpi/func/dietpi-wifidb 1 @@ -3057,11 +3057,11 @@ Additional benchmarks: Reset_Overclocking() { - sed -i -e '/^[[:blank:]]*over_voltage=/c\#over_voltage=0' \ + sed --follow-symlinks -i -e '/^[[:blank:]]*over_voltage=/c\#over_voltage=0' \ -e '/^[[:blank:]]*over_voltage_min=/c\#over_voltage_min=0' \ -e "/^[[:blank:]]*arm_freq=/c\#arm_freq=$arm_freq_default" \ -e "/^[[:blank:]]*core_freq=/c\#core_freq=$core_freq_default" /boot/config.txt - (( $G_HW_MODEL == 4 )) || sed -i "/^[[:blank:]]*sdram_freq=/c\#sdram_freq=$sdram_freq_default" /boot/config.txt + (( $G_HW_MODEL == 4 )) || sed --follow-symlinks -i "/^[[:blank:]]*sdram_freq=/c\#sdram_freq=$sdram_freq_default" /boot/config.txt REBOOT_REQUIRED=1 } diff --git a/dietpi/dietpi-drive_manager b/dietpi/dietpi-drive_manager index c457f3f70d..06e5b6728d 100755 --- a/dietpi/dietpi-drive_manager +++ b/dietpi/dietpi-drive_manager @@ -372,7 +372,7 @@ $swap_mounts # - Container: Assume host supports it (relevant for network drives) if (( $G_HW_MODEL != 75 )) && ! modprobe -nq autofs4 then - sed -Ei '/x-systemd\.automount/s/,(noauto|x-systemd\.automount)//g' "$fp_fstab_tmp" + sed --follow-symlinks -Ei '/x-systemd\.automount/s/,(noauto|x-systemd\.automount)//g' "$fp_fstab_tmp" G_DIETPI-NOTIFY 2 'autofs4 module not available in kernel, x-systemd.automount has been disabled, all drives will be mounted at boot instead' fi @@ -489,7 +489,7 @@ Do you wish to ignore this warning, and, mount the drive regardless?" || return local target=$1 G_EXEC_NOEXIT=1 G_EXEC umount "$target" || return 1 - sed -i "\#[[:blank:]]${target}[[:blank:]]#d" /etc/fstab # Only needed for network drives currently, as unmounted physical drives won't be re-added via Init_Drives_and_Refresh + sed --follow-symlinks -i "\#[[:blank:]]${target}[[:blank:]]#d" /etc/fstab # Only needed for network drives currently, as unmounted physical drives won't be re-added via Init_Drives_and_Refresh # Stop automount to unlock mount point local automount=${target#/} [[ $automount ]] && { automount=${automount//-/\\x2d}; automount=${automount//\//-}; } @@ -726,29 +726,29 @@ Do you wish to ignore this warning, and, mount the drive regardless?" || return # Update fstab # - Remove automatic entry for target drive - G_EXEC sed -i "\@[[:blank:]]${aDRIVE_MOUNT_TARGET[$MENU_DRIVE_INDEX]}[[:blank:]]@d" "${aDRIVE_MOUNT_TARGET[$MENU_DRIVE_INDEX]}/etc/fstab" + G_EXEC sed --follow-symlinks -i "\@[[:blank:]]${aDRIVE_MOUNT_TARGET[$MENU_DRIVE_INDEX]}[[:blank:]]@d" "${aDRIVE_MOUNT_TARGET[$MENU_DRIVE_INDEX]}/etc/fstab" # - Replace old with new rootfs entry local dev_entry="UUID=${aDRIVE_UUID[$MENU_DRIVE_INDEX]}" (( $G_HW_MODEL < 10 )) && dev_entry="PARTUUID=${aDRIVE_PART_UUID[$MENU_DRIVE_INDEX]}" - G_EXEC sed -i "\@[[:blank:]]/[[:blank:]]@c$dev_entry / ${aDRIVE_FSTYPE[$MENU_DRIVE_INDEX]} noatime,lazytime,rw 0 1" "${aDRIVE_MOUNT_TARGET[$MENU_DRIVE_INDEX]}/etc/fstab" + G_EXEC sed --follow-symlinks -i "\@[[:blank:]]/[[:blank:]]@c$dev_entry / ${aDRIVE_FSTYPE[$MENU_DRIVE_INDEX]} noatime,lazytime,rw 0 1" "${aDRIVE_MOUNT_TARGET[$MENU_DRIVE_INDEX]}/etc/fstab" # Find and replace current root and rootfstype kernel command line entries # - RPi: /boot/cmdline.txt if (( $G_HW_MODEL < 10 )) then local rootfs_current=$(mawk '{for(i=1;i<=NF;i++) if($i~/^root=/) {print $i;exit}}' /boot/cmdline.txt) - G_EXEC sed -i "s#$rootfs_current#root=$dev_entry#g" /boot/cmdline.txt + G_EXEC sed --follow-symlinks -i "s#$rootfs_current#root=$dev_entry#g" /boot/cmdline.txt local rootfstype_current=$(mawk '{for(i=1;i<=NF;i++) if($i~/^rootfstype=/) {print $i;exit}}' /boot/cmdline.txt) - [[ $rootfstype_current ]] && G_EXEC sed -i "s#$rootfstype_current#rootfstype=${aDRIVE_FSTYPE[$MENU_DRIVE_INDEX]}#g" /boot/cmdline.txt + [[ $rootfstype_current ]] && G_EXEC sed --follow-symlinks -i "s#$rootfstype_current#rootfstype=${aDRIVE_FSTYPE[$MENU_DRIVE_INDEX]}#g" /boot/cmdline.txt # - Odroids: /boot/boot.ini else local rootfs_current=$(mawk '-F[" ]' '{for(i=1;i<=NF;i++) if($i~/^root=/) {print $i;exit}}' /boot/boot.ini) - G_EXEC sed -i "s#$rootfs_current#root=$dev_entry#g" /boot/boot.ini + G_EXEC sed --follow-symlinks -i "s#$rootfs_current#root=$dev_entry#g" /boot/boot.ini local rootfstype_current=$(mawk '-F[" ]' '{for(i=1;i<=NF;i++) if($i~/^rootfstype=/) {print $i;exit}}' /boot/boot.ini) - [[ $rootfstype_current ]] && G_EXEC sed -i "s#$rootfstype_current#rootfstype=${aDRIVE_FSTYPE[$MENU_DRIVE_INDEX]}#g" /boot/boot.ini + [[ $rootfstype_current ]] && G_EXEC sed --follow-symlinks -i "s#$rootfstype_current#rootfstype=${aDRIVE_FSTYPE[$MENU_DRIVE_INDEX]}#g" /boot/boot.ini fi G_EXEC systemctl daemon-reload @@ -777,7 +777,7 @@ Do you wish to ignore this warning, and, mount the drive regardless?" || return if [[ ${aDRIVE_MOUNT_TARGET[$MENU_DRIVE_INDEX]} == '/' ]]; then local line_number=$(grep -n "[[:blank:]]${aDRIVE_MOUNT_TARGET[$MENU_DRIVE_INDEX]}[[:blank:]].*,rw" /etc/fstab | cut -d : -f 1) - sed -i "${line_number}s/,rw/,ro/" /etc/fstab + sed --follow-symlinks -i "${line_number}s/,rw/,ro/" /etc/fstab fi message_result=$(mount -v -o remount,ro "${aDRIVE_MOUNT_SOURCE[$MENU_DRIVE_INDEX]}" 2>&1) @@ -1502,7 +1502,7 @@ Read more about I/O scheduling: https://wiki.archlinux.org/index.php/Improving_p if [[ $G_WHIP_RETURNED_VALUE == 'Reset' ]]; then - sed -i "/KERNEL==\"${aDRIVE_SOURCE_DEVICE[$MENU_DRIVE_INDEX]}\"/d" "$udev_rules" + sed --follow-symlinks -i "/KERNEL==\"${aDRIVE_SOURCE_DEVICE[$MENU_DRIVE_INDEX]}\"/d" "$udev_rules" grep -q '^ACTION' "$udev_rules" || rm "$udev_rules" G_WHIP_YESNO '[ INFO ] A reboot is required to reset the I/O scheduler to default.\n\nDo you wish to reboot now?' && reboot @@ -1779,7 +1779,7 @@ username=$samba_clientuser password=$samba_clientpassword _EOF_ # Apply to fstab - sed -i "\#[[:blank:]]${samba_fp_mount_target}[[:blank:]]#d" /etc/fstab + sed --follow-symlinks -i "\#[[:blank:]]${samba_fp_mount_target}[[:blank:]]#d" /etc/fstab # - NB: Convert spaces to '\040': https://github.com/MichaIng/DietPi/issues/1201#issuecomment-339720271 echo "//$samba_clientname/${samba_clientshare//[[:blank:]]/\\040} $samba_fp_mount_target cifs cred=$cred,iocharset=utf8,uid=dietpi,gid=dietpi,file_mode=0770,dir_mode=0770,vers=$i,nofail,noauto,x-systemd.automount" >> /etc/fstab @@ -1795,7 +1795,7 @@ _EOF_ done # Failure - sed -i '1i\[FAILED] Samba mount failed with the following error output:\n' "$fp_tmp" + sed --follow-symlinks -i '1i\[FAILED] Samba mount failed with the following error output:\n' "$fp_tmp" G_WHIP_VIEWFILE "$fp_tmp" rm "$fp_tmp" rmdir --ignore-fail-on-non-empty "$samba_fp_mount_target" @@ -1893,7 +1893,7 @@ _EOF_ if mount -vt nfs -o port=2049 "$nfs_server_ip:$nfs_fp_server_share" "$nfs_fp_mount_target" &> "$fp_tmp" then # Apply to fstab - sed -i "\#[[:blank:]]${nfs_fp_mount_target}[[:blank:]]#d" /etc/fstab + sed --follow-symlinks -i "\#[[:blank:]]${nfs_fp_mount_target}[[:blank:]]#d" /etc/fstab echo "$nfs_server_ip:$nfs_fp_server_share $nfs_fp_mount_target nfs nofail,noauto,x-systemd.automount" >> /etc/fstab MENU_DRIVE_TARGET=$nfs_fp_mount_target @@ -1906,7 +1906,7 @@ _EOF_ fi # Failure - sed -i '1i\[FAILED] NFS mount failed with the following error output:\n' "$fp_tmp" + sed --follow-symlinks -i '1i\[FAILED] NFS mount failed with the following error output:\n' "$fp_tmp" G_WHIP_VIEWFILE "$fp_tmp" rm "$fp_tmp" rmdir --ignore-fail-on-non-empty "$nfs_fp_mount_target" diff --git a/dietpi/dietpi-led_control b/dietpi/dietpi-led_control index 94d32ba298..bde7caa361 100755 --- a/dietpi/dietpi-led_control +++ b/dietpi/dietpi-led_control @@ -118,7 +118,7 @@ elif [[ $G_WHIP_RETURNED_VALUE == 'Reset' ]]; then - G_EXEC_NOHALT=1 G_EXEC sed -i "/KERNEL==\"${aNAME[$SELECTED_LED]}\"/d" "$FP_UDEV_RULES" || return 1 + G_EXEC_NOHALT=1 G_EXEC sed --follow-symlinks -i "/KERNEL==\"${aNAME[$SELECTED_LED]}\"/d" "$FP_UDEV_RULES" || return 1 unset -v "aTRIGGER_SELECTED[$SELECTED_LED]" G_WHIP_MSG "LED trigger for ${aNAME[$SELECTED_LED]} has been reset to system defaults.\n\nThis will become active from next reboot." [[ ${aTRIGGER_SELECTED[*]} || ! -f $FP_UDEV_RULES ]] || G_EXEC_NOHALT=1 G_EXEC rm "$FP_UDEV_RULES" || return 1 diff --git a/dietpi/dietpi-letsencrypt b/dietpi/dietpi-letsencrypt index 46b42713dc..73055f5473 100755 --- a/dietpi/dietpi-letsencrypt +++ b/dietpi/dietpi-letsencrypt @@ -157,7 +157,7 @@ _EOF_ if (( $G_DISTRO > 5 )) then G_AG_CHECK_INSTALL_PREREQ lighttpd-mod-openssl - G_EXEC sed -i 's/,-SessionTicket//' /etc/lighttpd/conf-available/50-dietpi-https.conf + G_EXEC sed --follow-symlinks -i 's/,-SessionTicket//' /etc/lighttpd/conf-available/50-dietpi-https.conf fi [[ -f '/etc/lighttpd/conf-enabled/50-dietpi-https.conf' ]] || G_EXEC lighty-enable-mod dietpi-https @@ -238,7 +238,7 @@ _EOF_ fi # Enable HTTP/2: https://github.com/certbot/certbot/issues/3646 - grep -q 'http2' /etc/nginx/sites-available/default || G_EXEC sed -i '/^[[:blank:]]*listen /s/443 ssl/443 ssl http2/' /etc/nginx/sites-available/default + grep -q 'http2' /etc/nginx/sites-available/default || G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*listen /s/443 ssl/443 ssl http2/' /etc/nginx/sites-available/default Apply_To_Web_Applications @@ -361,8 +361,8 @@ _EOF_ # Skip this if HTTP access is still possible (( $LETSENCRYPT_REDIRECT || $LETSENCRYPT_HSTS )) || return G_DIETPI-NOTIFY 2 'Applying HTTPS domain to known web application configs' - [[ -f '/var/www/nextcloud/config/config.php' ]] && G_EXEC sed -i "s|'http://localhost/nextcloud'|'https://$primary_domain/nextcloud'|" /var/www/nextcloud/config/config.php - [[ -f '/var/www/owncloud/config/config.php' ]] && G_EXEC sed -i "s|'http://localhost/owncloud'|'https://$primary_domain/owncloud'|" /var/www/owncloud/config/config.php + [[ -f '/var/www/nextcloud/config/config.php' ]] && G_EXEC sed --follow-symlinks -i "s|'http://localhost/nextcloud'|'https://$primary_domain/nextcloud'|" /var/www/nextcloud/config/config.php + [[ -f '/var/www/owncloud/config/config.php' ]] && G_EXEC sed --follow-symlinks -i "s|'http://localhost/owncloud'|'https://$primary_domain/owncloud'|" /var/www/owncloud/config/config.php } #///////////////////////////////////////////////////////////////////////////////////// diff --git a/dietpi/dietpi-services b/dietpi/dietpi-services index dee7d3e2e0..b597d02137 100755 --- a/dietpi/dietpi-services +++ b/dietpi/dietpi-services @@ -481,7 +481,7 @@ _EOF_ elif [[ $value == 'reset' ]] then unset -v "${aarray[$setting]}[$index]" - [[ -f $fp ]] && G_EXEC sed -i "/^${asetting[$setting]}=/d" "$fp" + [[ -f $fp ]] && G_EXEC sed --follow-symlinks -i "/^${asetting[$setting]}=/d" "$fp" # Apply process tool setting else @@ -768,13 +768,13 @@ This affects starts/stops/restarts during DietPi-Software installs, DietPi-Updat if [[ $G_WHIP_RETURNED_VALUE == 'Include' ]] then # If service is listed here, it was excluded via include/exclude file. - G_EXEC sed -i "/^- ${aSERVICE_NAME[$MENU_SERVICE_INDEX]}/d" "$FP_INCLUDE_EXCLUDE" + G_EXEC sed --follow-symlinks -i "/^- ${aSERVICE_NAME[$MENU_SERVICE_INDEX]}/d" "$FP_INCLUDE_EXCLUDE" aSERVICE_CONTROL["$MENU_SERVICE_INDEX"]='included' else # Remove include entry if existent, else add exclude entry. if grep -q "^+ ${aSERVICE_NAME[$MENU_SERVICE_INDEX]}" "$FP_INCLUDE_EXCLUDE" then - G_EXEC sed -i "/^+ ${aSERVICE_NAME[$MENU_SERVICE_INDEX]}/d" "$FP_INCLUDE_EXCLUDE" + G_EXEC sed --follow-symlinks -i "/^+ ${aSERVICE_NAME[$MENU_SERVICE_INDEX]}/d" "$FP_INCLUDE_EXCLUDE" unset -v "aSERVICE_NAME[$MENU_SERVICE_INDEX]" # Service needs to be re-added from main menu MENU_TARGETID=0 # Return to main menu @@ -805,7 +805,7 @@ Please uncomment and edit only the lines that you need to change.\n\nTo undo cha - rm $fp\n - systemctl daemon-reload\n - systemctl restart ${aSERVICE_NAME[$MENU_SERVICE_INDEX]}\n\nDo you want to continue?" || return 0 G_EXEC mkdir -p "$dp" G_EXEC cp -a "${aFP_SERVICE[$MENU_SERVICE_INDEX]}" "$fp" - G_EXEC sed -Ei 's/^([^[#])/#\1/' "$fp" + G_EXEC sed --follow-symlinks -Ei 's/^([^[#])/#\1/' "$fp" fi nano "$fp" SYSTEMD_RELOAD_REQUIRED=1 diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index ac9bc4c214..9f46bfadee 100755 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -149,7 +149,7 @@ Available commands: else encrypt=1 GLOBAL_PW=$(sed -n '/^[[:blank:]]*AUTO_SETUP_GLOBAL_PASSWORD=/{s/^[^=]*=//p;q}' /boot/dietpi.txt) - grep -q '^[[:blank:]]*AUTO_SETUP_GLOBAL_PASSWORD=' /boot/dietpi.txt && G_EXEC sed -i '/^[[:blank:]]*AUTO_SETUP_GLOBAL_PASSWORD=/c\#AUTO_SETUP_GLOBAL_PASSWORD= # Password has been encrypted and saved to rootfs' /boot/dietpi.txt + grep -q '^[[:blank:]]*AUTO_SETUP_GLOBAL_PASSWORD=' /boot/dietpi.txt && G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*AUTO_SETUP_GLOBAL_PASSWORD=/c\#AUTO_SETUP_GLOBAL_PASSWORD= # Password has been encrypted and saved to rootfs' /boot/dietpi.txt fi # Fallback @@ -2295,7 +2295,7 @@ done if ! [ -f ~/.gtk-bookmarks ] then cp /var/lib/dietpi/dietpi-software/installed/desktop/.gtk-bookmarks ~/.gtk-bookmarks - sed -i "s|/root|$HOME|g" ~/.gtk-bookmarks + sed --follow-symlinks -i "s|/root|$HOME|g" ~/.gtk-bookmarks fi # Disable this autostart entry @@ -2630,7 +2630,7 @@ _EOF_ { if (( $G_HW_MODEL < 10 )) then - grep -Eq '(^|[[:blank:]])cgroup_enable=memory([[:blank:]]|$)' /boot/cmdline.txt || G_EXEC sed -i '/root=/s/[[:blank:]]*$/ cgroup_enable=memory/' /boot/cmdline.txt + grep -Eq '(^|[[:blank:]])cgroup_enable=memory([[:blank:]]|$)' /boot/cmdline.txt || G_EXEC sed --follow-symlinks -i '/root=/s/[[:blank:]]*$/ cgroup_enable=memory/' /boot/cmdline.txt elif [[ -f '/boot/boot.scr' ]] && grep -q 'docker_optimizations' /boot/boot.scr then @@ -2899,7 +2899,7 @@ unix_socket_directories = '/run/postgresql'" > "$i/00dietpi.conf" then # Install persistent tmpfs local var_log_size=$(sed -n '/^[[:blank:]]*AUTO_SETUP_RAMLOG_MAXSIZE=/{s/^[^=]*=//p;q}' /boot/dietpi.txt) - sed -i '/[[:blank:]]\/var\/log[[:blank:]]/d' /etc/fstab + sed --follow-symlinks -i '/[[:blank:]]\/var\/log[[:blank:]]/d' /etc/fstab echo "tmpfs /var/log tmpfs size=${var_log_size:-50}M,noatime,lazytime,nodev,nosuid" >> /etc/fstab # Apply logging choice index @@ -3147,9 +3147,9 @@ _EOF_ then local chromium='chromium' (( $G_HW_MODEL > 9 )) || chromium='chromium-browser' - G_EXEC sed -i "s/firefox-esr/$chromium/" /etc/xdg/lxpanel/LXDE/panels/panel + G_EXEC sed --follow-symlinks -i "s/firefox-esr/$chromium/" /etc/xdg/lxpanel/LXDE/panels/panel else - G_EXEC sed -i 's/firefox-esr/mousepad/' /etc/xdg/lxpanel/LXDE/panels/panel + G_EXEC sed --follow-symlinks -i 's/firefox-esr/mousepad/' /etc/xdg/lxpanel/LXDE/panels/panel fi fi @@ -3430,10 +3430,10 @@ _EOF_ dps_index=$software_id Download_Install 'conf' /etc/proftpd/proftpd.conf # Do not allow root access via FTP - G_EXEC sed -i 's/^[[:blank:]]*root/#root/' /etc/ftpusers + G_EXEC sed --follow-symlinks -i 's/^[[:blank:]]*root/#root/' /etc/ftpusers # Bullseye: Fix ident lookup: https://github.com/MichaIng/DietPi/issues/4666 - (( $G_DISTRO < 6 )) || G_EXEC sed -i '/IdentLookups/c\\nIdentLookups off\n' /etc/proftpd/proftpd.conf + (( $G_DISTRO < 6 )) || G_EXEC sed --follow-symlinks -i '/IdentLookups/c\\nIdentLookups off\n' /etc/proftpd/proftpd.conf fi if To_Install 96 nmbd smbd # Samba Server @@ -3470,7 +3470,7 @@ _EOF_ G_EXEC systemctl stop vsftpd # Do not allow root access via FTP - G_EXEC sed -i 's/^[[:blank:]]*root/#root/' /etc/ftpusers + G_EXEC sed --follow-symlinks -i 's/^[[:blank:]]*root/#root/' /etc/ftpusers fi if To_Install 109 nfs-kernel-server # NFS Server @@ -3496,7 +3496,7 @@ _EOF_ _EOF_ # Otherwise assure that the webroot is changed, as all our install options depend on it. else - G_EXEC sed -i 's|/var/www/html|/var/www|g' /etc/apache2/sites-available/000-default.conf + G_EXEC sed --follow-symlinks -i 's|/var/www/html|/var/www|g' /etc/apache2/sites-available/000-default.conf fi local apackages=('apache2') @@ -3581,10 +3581,10 @@ _EOF_ G_BACKUP_FP /etc/nginx/nginx.conf dps_index=$software_id Download_Install 'nginx.conf' /etc/nginx/nginx.conf # Adjust socket name to PHP version - G_EXEC sed -i "s#/run/php/php.*-fpm.sock#/run/php/php$PHP_VERSION-fpm.sock#g" /etc/nginx/nginx.conf + G_EXEC sed --follow-symlinks -i "s#/run/php/php.*-fpm.sock#/run/php/php$PHP_VERSION-fpm.sock#g" /etc/nginx/nginx.conf # CPU core count - G_EXEC sed -i "/worker_processes/c\worker_processes $G_HW_CPU_CORES;" /etc/nginx/nginx.conf + G_EXEC sed --follow-symlinks -i "/worker_processes/c\worker_processes $G_HW_CPU_CORES;" /etc/nginx/nginx.conf # Default site dps_index=$software_id Download_Install 'nginx.default' /etc/nginx/sites-available/default @@ -3608,15 +3608,15 @@ _EOF_ if grep -q 'create-mime\.assign\.pl' /etc/lighttpd/lighttpd.conf then G_DIETPI-NOTIFY 2 'Buster upgrade detected: Migrating from "create-mime.assign.pl" to "create-mime.conf.pl"' - G_EXEC sed -i 's/create-mime\.assign\.pl/create-mime.conf.pl/' /etc/lighttpd/lighttpd.conf + G_EXEC sed --follow-symlinks -i 's/create-mime\.assign\.pl/create-mime.conf.pl/' /etc/lighttpd/lighttpd.conf fi # Bullseye: mod_compress has been superseded by mod_deflate if (( $G_DISTRO > 5 )) && grep -q '^[[:blank:]]*"mod_compress",$' /etc/lighttpd/lighttpd.conf then G_DIETPI-NOTIFY 2 'Bullseye upgrade detected: Migrating from mod_compress to mod_deflate' - G_EXEC sed -Ei '/^compress\..*=[[:blank:]]*["(].*[")]$/d' /etc/lighttpd/lighttpd.conf - G_EXEC sed -i '/^[[:blank:]]*"mod_compress",$/d' /etc/lighttpd/lighttpd.conf + G_EXEC sed --follow-symlinks -Ei '/^compress\..*=[[:blank:]]*["(].*[")]$/d' /etc/lighttpd/lighttpd.conf + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*"mod_compress",$/d' /etc/lighttpd/lighttpd.conf deflate=('lighttpd-mod-deflate') fi @@ -3625,14 +3625,14 @@ _EOF_ then G_DIETPI-NOTIFY 2 'DietPi-LetsEncrypt usage detected: Installing OpenSSL module' openssl=('lighttpd-mod-openssl') - [[ -f '/etc/lighttpd/conf-available/50-dietpi-https.conf' ]] && ! grep -q '"mod_openssl"' /etc/lighttpd/conf-available/50-dietpi-https.conf && G_EXEC sed -i '1iserver.modules += ( "mod_openssl" )' /etc/lighttpd/conf-available/50-dietpi-https.conf + [[ -f '/etc/lighttpd/conf-available/50-dietpi-https.conf' ]] && ! grep -q '"mod_openssl"' /etc/lighttpd/conf-available/50-dietpi-https.conf && G_EXEC sed --follow-symlinks -i '1iserver.modules += ( "mod_openssl" )' /etc/lighttpd/conf-available/50-dietpi-https.conf fi # Bullseye: Remove obsolete socket version string from FPM module if [[ $G_DISTRO -gt 5 && -f '/etc/lighttpd/conf-available/15-fastcgi-php-fpm.conf' ]] && grep -q 'php.\..-fpm\.sock' /etc/lighttpd/conf-available/15-fastcgi-php-fpm.conf then G_DIETPI-NOTIFY 2 'Bullseye upgrade detected: Removing obsolete socket version string from FPM module' - G_EXEC sed -i 's/php.\..-fpm\.sock/php-fpm.sock/' /etc/lighttpd/conf-available/15-fastcgi-php-fpm.conf + G_EXEC sed --follow-symlinks -i 's/php.\..-fpm\.sock/php-fpm.sock/' /etc/lighttpd/conf-available/15-fastcgi-php-fpm.conf fi fi @@ -3650,7 +3650,7 @@ _EOF_ if [[ -f '/var/www/html/index.lighttpd.html' ]] then G_EXEC mv /var/www/html/index.lighttpd.html /var/www/ - G_EXEC sed -i 's|/var/www/html|/var/www|' /etc/lighttpd/lighttpd.conf + G_EXEC sed --follow-symlinks -i 's|/var/www/html|/var/www|' /etc/lighttpd/lighttpd.conf fi [[ -d '/var/www/html' ]] && G_EXEC rmdir --ignore-fail-on-non-empty /var/www/html @@ -4029,8 +4029,8 @@ _EOF_ G_CONFIG_INJECT 'bind_addresses:[[:blank:]]' " bind_addresses: ['::']" homeserver.yaml # Log to journal with log level WARNING - G_EXEC sed -i 's/ handlers: \[.*\]$/ handlers: [console]/' "$servername.log.config" - G_EXEC sed -i 's/ level: .*/ level: WARNING/' "$servername.log.config" + G_EXEC sed --follow-symlinks -i 's/ handlers: \[.*\]$/ handlers: [console]/' "$servername.log.config" + G_EXEC sed --follow-symlinks -i 's/ level: .*/ level: WARNING/' "$servername.log.config" # Permissions G_EXEC chown -R synapse:synapse . @@ -4075,14 +4075,14 @@ _EOF_ G_CONFIG_INJECT 'playlist_directory[[:blank:]]' 'playlist_directory "/mnt/dietpi_userdata/Music"' /etc/mpd.conf G_CONFIG_INJECT 'db_file[[:blank:]]' 'db_file "/mnt/dietpi_userdata/.mpd_cache/db_file"' /etc/mpd.conf # - Log to journal - G_EXEC sed -Ei 's/^[[:blank:]]*log_file[[:blank:]]+/#log_file /' /etc/mpd.conf + G_EXEC sed --follow-symlinks -Ei 's/^[[:blank:]]*log_file[[:blank:]]+/#log_file /' /etc/mpd.conf # - PID file is not required for systemd - G_EXEC sed -Ei 's/^[[:blank:]]*pid_file[[:blank:]]+/#pid_file /' /etc/mpd.conf + G_EXEC sed --follow-symlinks -Ei 's/^[[:blank:]]*pid_file[[:blank:]]+/#pid_file /' /etc/mpd.conf G_CONFIG_INJECT 'state_file[[:blank:]]' 'state_file "/mnt/dietpi_userdata/.mpd_cache/state"' /etc/mpd.conf G_CONFIG_INJECT 'sticker_file[[:blank:]]' 'sticker_file "/mnt/dietpi_userdata/.mpd_cache/sticker.sql"' /etc/mpd.conf # - Our service starts as "mpd" user already - G_EXEC sed -Ei 's/^[[:blank:]]*user[[:blank:]]+/#user /' /etc/mpd.conf - G_EXEC sed -Ei 's/^[[:blank:]]*group[[:blank:]]+/#group /' /etc/mpd.conf + G_EXEC sed --follow-symlinks -Ei 's/^[[:blank:]]*user[[:blank:]]+/#user /' /etc/mpd.conf + G_EXEC sed --follow-symlinks -Ei 's/^[[:blank:]]*group[[:blank:]]+/#group /' /etc/mpd.conf # - Enable UNIX socket G_CONFIG_INJECT 'bind_to_address[[:blank:]]+"/run/mpd/socket"' 'bind_to_address "/run/mpd/socket"' /etc/mpd.conf # - Add simple ALSA output, if none present yet @@ -4247,8 +4247,8 @@ _EOF_ then G_EXEC_OUTPUT=1 G_EXEC git clone 'https://git.sr.ht/~tsileo/microblog.pub' "$micro_data_dir" # Enable remote access on port 8007 - G_EXEC sed -i 's/uvicorn app/uvicorn --host 0.0.0.0 --port 8007 app/' "$micro_data_dir/misc/supervisord.conf" - G_EXEC sed -i 's/8000/8007/' "$micro_data_dir/data/tests.toml" + G_EXEC sed --follow-symlinks -i 's/uvicorn app/uvicorn --host 0.0.0.0 --port 8007 app/' "$micro_data_dir/misc/supervisord.conf" + G_EXEC sed --follow-symlinks -i 's/8000/8007/' "$micro_data_dir/data/tests.toml" fi # Disable pip cache @@ -4604,13 +4604,13 @@ The install script will now exit. After applying one of the the above, rerun die # If "1 => '" does not exist, the config.php is not copied e.g. from older instance, so we add entries. if ! grep -q "1 => '" "$config_php"; then - sed -i "/0 => 'localhost'/a 1 => '$(G_GET_NET ip)'," "$config_php" - sed -i "/1 => '/a 2 => '$HOSTNAME'," "$config_php" + sed --follow-symlinks -i "/0 => 'localhost'/a 1 => '$(G_GET_NET ip)'," "$config_php" + sed --follow-symlinks -i "/1 => '/a 2 => '$HOSTNAME'," "$config_php" fi # Set CLI URL to ownCloud sub directory: - G_EXEC sed -i "s|'http://localhost'|'http://localhost/owncloud'|" "$config_php" + G_EXEC sed --follow-symlinks -i "s|'http://localhost'|'http://localhost/owncloud'|" "$config_php" # Set pretty URLs (without /index.php/) on Apache: if (( ${aSOFTWARE_INSTALL_STATE[83]} > 0 )); then @@ -4687,9 +4687,9 @@ The install script will now exit. After applying one of the the above, rerun die \nWe are patching the PHP version check, but this has two implications: - You will see an integrity check error on Nextcloud admin panel. - You will need to redo the patch after Nextcloud updates to future 25.x versions: -# sed -i '\''s/>= 80200/>= 80300/'\'' /var/www/nextcloud/lib/versioncheck.php +# sed --follow-symlinks -i '\''s/>= 80200/>= 80300/'\'' /var/www/nextcloud/lib/versioncheck.php \nWe recommend to update to Nextcloud 26 as fast as possible to get official PHP 8.2 support.' - G_EXEC sed -i 's/>= 80200/>= 80300/' /var/www/nextcloud/lib/versioncheck.php + G_EXEC sed --follow-symlinks -i 's/>= 80200/>= 80300/' /var/www/nextcloud/lib/versioncheck.php fi [[ ${aDEPS[0]} ]] && { G_DIETPI-NOTIFY 2 'Installing required PHP modules'; G_AGI "${aDEPS[@]}"; aDEPS=(); } @@ -4879,10 +4879,10 @@ The install script will now exit. After applying one of the the above, rerun die G_CONFIG_INJECT "'mysql.utf8mb4'" "'mysql.utf8mb4' => true," "$config_php" "'dbpassword'" # Disable trusted_domains. - grep -q "1 => '*'" "$config_php" || sed -i "/0 => 'localhost'/a 1 => '*'," "$config_php" + grep -q "1 => '*'" "$config_php" || sed --follow-symlinks -i "/0 => 'localhost'/a 1 => '*'," "$config_php" # Set CLI URL to Nextcloud sub directory: - G_EXEC sed -i "s|'http://localhost'|'http://localhost/nextcloud'|" "$config_php" + G_EXEC sed --follow-symlinks -i "s|'http://localhost'|'http://localhost/nextcloud'|" "$config_php" # Set pretty URLs (without /index.php/) on Apache: if (( ${aSOFTWARE_INSTALL_STATE[83]} > 0 )); then @@ -4984,7 +4984,7 @@ The install script will now exit. After applying one of the the above, rerun die GCI_PRESERVE=1 G_CONFIG_INJECT 'total-quota=' 'total-quota=100' /etc/turnserver.conf GCI_PRESERVE=1 G_CONFIG_INJECT 'bps-capacity=' 'bps-capacity=0' /etc/turnserver.conf G_CONFIG_INJECT 'stale-nonce' 'stale-nonce' /etc/turnserver.conf - G_EXEC sed -i 's/^[[:blank:]]*allow-loopback-peers/#allow-loopback-peers/' /etc/turnserver.conf + G_EXEC sed --follow-symlinks -i 's/^[[:blank:]]*allow-loopback-peers/#allow-loopback-peers/' /etc/turnserver.conf G_CONFIG_INJECT 'no-multicast-peers' 'no-multicast-peers' /etc/turnserver.conf # Install Nextcloud Talk app @@ -5112,7 +5112,7 @@ PrivateTmp=true WantedBy=multi-user.target _EOF_ # Sparky SBC: Workaround for failing service start: https://dietpi.com/forum/t/allogui-not-working-apache-service-doesnt-start/15708 - (( $G_HW_MODEL == 70 )) && G_EXEC sed -i '/^AmbientCapabilities=/d' /etc/systemd/system/roonbridge.service + (( $G_HW_MODEL == 70 )) && G_EXEC sed --follow-symlinks -i '/^AmbientCapabilities=/d' /etc/systemd/system/roonbridge.service fi if To_Install 119 # CAVA @@ -5495,7 +5495,7 @@ _EOF_ G_EXEC cp etc/raspimjpeg/raspimjpeg.1 /etc/raspimjpeg G_EXEC ln -sf /etc/raspimjpeg /var/www/rpicam/raspimjpeg # - Web base dir - grep -q '/rpicam' /etc/raspimjpeg || G_EXEC sed -i 's|/var/www|/var/www/rpicam|g' /etc/raspimjpeg + grep -q '/rpicam' /etc/raspimjpeg || G_EXEC sed --follow-symlinks -i 's|/var/www|/var/www/rpicam|g' /etc/raspimjpeg # - Service dps_index=$software_id Download_Install 'raspimjpeg.sh' /var/lib/dietpi/dietpi-software/installed/raspimjpeg.sh G_EXEC chmod +x /var/lib/dietpi/dietpi-software/installed/raspimjpeg.sh @@ -5577,7 +5577,7 @@ _EOF_ local id=$(tr -dc '0-9a-f' < /dev/random | head -c32) G_EXEC chmod 0600 /mnt/dietpi_userdata/deluge/.config/deluge/hostlist.conf G_CONFIG_INJECT '"[0-9a-f]{32}"' " \"$id\"," /mnt/dietpi_userdata/deluge/.config/deluge/hostlist.conf - sed -i "/\"[0-9a-f]\{40\}\"/c\ \"$localpass\"" /mnt/dietpi_userdata/deluge/.config/deluge/hostlist.conf + sed --follow-symlinks -i "/\"[0-9a-f]\{40\}\"/c\ \"$localpass\"" /mnt/dietpi_userdata/deluge/.config/deluge/hostlist.conf G_CONFIG_INJECT '"default_daemon":' " \"default_daemon\": \"$id\"," /mnt/dietpi_userdata/deluge/.config/deluge/web.conf unset -v localpass id RESTART_DELUGE_WEB=1 @@ -5711,9 +5711,9 @@ _EOF_ G_EXEC systemctl stop darkice icecast2 # IceCast: Set passwords if not yet done (default found) - sed -i "/hackme/c\ $GLOBAL_PW" /etc/icecast2/icecast.xml - sed -i "/hackme/c\ $GLOBAL_PW" /etc/icecast2/icecast.xml - sed -i "/hackme/c\ $GLOBAL_PW" /etc/icecast2/icecast.xml + sed --follow-symlinks -i "/hackme/c\ $GLOBAL_PW" /etc/icecast2/icecast.xml + sed --follow-symlinks -i "/hackme/c\ $GLOBAL_PW" /etc/icecast2/icecast.xml + sed --follow-symlinks -i "/hackme/c\ $GLOBAL_PW" /etc/icecast2/icecast.xml # - Remove default service config [[ -f '/etc/default/icecast2' ]] && G_EXEC rm /etc/default/icecast2 @@ -5956,7 +5956,7 @@ ExitPolicy reject *:* _EOF_ [[ $ipv6 ]] && echo 'IPv6Exit 1' >> /etc/tor/torrc # Apply Unbound as local DNS resolver for privacy reasons - command -v resolvconf > /dev/null && G_EXEC sed -i 's/dns-nameservers.*$/dns-nameservers 127.0.0.1/' /etc/network/interfaces + command -v resolvconf > /dev/null && G_EXEC sed --follow-symlinks -i 's/dns-nameservers.*$/dns-nameservers 127.0.0.1/' /etc/network/interfaces G_EXEC eval "echo 'nameserver 127.0.0.1' > /etc/resolv.conf" # Unbound is running and configured in the very next config step, so it is safe to switch the DNS nameserver right now. fi @@ -6014,14 +6014,14 @@ _EOF_ G_DIETPI-NOTIFY 2 'Configuring Pi-hole to use Unbound' if [[ -f '/etc/dnsmasq.d/01-pihole.conf' ]] then - G_EXEC sed -i '/^[[:blank:]]*server=/d' /etc/dnsmasq.d/01-pihole.conf + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*server=/d' /etc/dnsmasq.d/01-pihole.conf G_CONFIG_INJECT 'server=' 'server=127.0.0.1#5335' /etc/dnsmasq.d/01-pihole.conf systemctl -q is-active pihole-FTL && G_EXEC systemctl restart pihole-FTL fi if [[ -f '/etc/pihole/setupVars.conf' ]] then G_CONFIG_INJECT 'PIHOLE_DNS_1=' 'PIHOLE_DNS_1=127.0.0.1#5335' /etc/pihole/setupVars.conf - G_EXEC sed -i '/^[[:blank:]]*PIHOLE_DNS_2=/d' /etc/pihole/setupVars.conf + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*PIHOLE_DNS_2=/d' /etc/pihole/setupVars.conf fi fi @@ -6074,8 +6074,8 @@ _EOF_ # - Skip supported OS check. We do not support Debian testing but we are testing it already now. # - Workaround "dialog" issues with "xterm" by faking "linux" terminal # - Skip web server install, since we allow to choose and install it prior to Pi-hole - G_EXEC sed -Ei '/^[[:blank:]]*set(AdminFla|Loggin)g$/d' install.sh - G_EXEC sed -i 's/QUERY_LOGGING=true/QUERY_LOGGING=false/' install.sh + G_EXEC sed --follow-symlinks -Ei '/^[[:blank:]]*set(AdminFla|Loggin)g$/d' install.sh + G_EXEC sed --follow-symlinks -i 's/QUERY_LOGGING=true/QUERY_LOGGING=false/' install.sh export PIHOLE_SKIP_OS_CHECK=true local retry TERM_old= [[ $TERM == 'xterm' ]] && { TERM_old=$TERM; export TERM=linux; } @@ -6102,11 +6102,11 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[182]} > 0 )) then G_DIETPI-NOTIFY 2 'Configuring Pi-hole to use Unbound' - G_EXEC sed -i '/^[[:blank:]]*server=/d' /etc/dnsmasq.d/01-pihole.conf + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*server=/d' /etc/dnsmasq.d/01-pihole.conf G_CONFIG_INJECT 'server=' 'server=127.0.0.1#5335' /etc/dnsmasq.d/01-pihole.conf systemctl -q is-active pihole-FTL && G_EXEC systemctl restart pihole-FTL G_CONFIG_INJECT 'PIHOLE_DNS_1=' 'PIHOLE_DNS_1=127.0.0.1#5335' /etc/pihole/setupVars.conf - G_EXEC sed -i '/^[[:blank:]]*PIHOLE_DNS_2=/d' /etc/pihole/setupVars.conf + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*PIHOLE_DNS_2=/d' /etc/pihole/setupVars.conf fi # Enable required PHP modules: https://github.com/pi-hole/pi-hole/blob/development/automated%20install/basic-install.sh#L250 @@ -6856,10 +6856,10 @@ _EOF_ # Config: /etc/mosquitto/conf.d exists, but doubled settings do not override each other and lead to a startup failure instead, which breaks the purpose we want to use it for. # - Disable PID file, not required for systemd handling - G_EXEC sed -i '/^[[:blank:]]*pid_file[[:blank:]]/d' /etc/mosquitto/mosquitto.conf + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*pid_file[[:blank:]]/d' /etc/mosquitto/mosquitto.conf [[ -d '/run/mosquitto' ]] && G_EXEC rm -R /run/mosquitto # - Log to default STDERR > systemd-journald - G_EXEC sed -i '/^[[:blank:]]*log_dest[[:blank:]]/d' /etc/mosquitto/mosquitto.conf + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*log_dest[[:blank:]]/d' /etc/mosquitto/mosquitto.conf [[ -d '/var/log/mosquitto' ]] && G_EXEC rm -R /var/log/mosquitto # - Add default password file for authenticated requests: https://github.com/MichaIng/DietPi/issues/4133 GCI_PRESERVE=1 G_CONFIG_INJECT 'password_file[[:blank:]]' 'password_file /etc/mosquitto/passwd' /etc/mosquitto/mosquitto.conf @@ -6922,7 +6922,7 @@ _EOF_ if [[ ! -f '/mnt/dietpi_userdata/blynk/client-tcp-local.js' ]] then G_EXEC curl -sSfL 'https://raw.githubusercontent.com/vshymanskyy/blynk-library-js/master/examples/nodejs/client-tcp-local.js' -o /mnt/dietpi_userdata/blynk/client-tcp-local.js - G_EXEC sed -i "s|require('blynk-library')|require('/usr/local/lib/node_modules/blynk-library')|" /mnt/dietpi_userdata/blynk/client-tcp-local.js + G_EXEC sed --follow-symlinks -i "s|require('blynk-library')|require('/usr/local/lib/node_modules/blynk-library')|" /mnt/dietpi_userdata/blynk/client-tcp-local.js G_EXEC chmod +x /mnt/dietpi_userdata/blynk/client-tcp-local.js fi @@ -6996,10 +6996,10 @@ _EOF_ G_EXEC_OUTPUT=1 G_EXEC patch -p1 -i webiopi-pi2bplus.patch # Install for Python 3 only - G_EXEC sed -i '/SEARCH="python python3"/c\SEARCH="python3"' setup.sh + G_EXEC sed --follow-symlinks -i '/SEARCH="python python3"/c\SEARCH="python3"' setup.sh # Skip Weaved install prompt - G_EXEC sed -i '/read response/c\response="n"' setup.sh + G_EXEC sed --follow-symlinks -i '/read response/c\response="n"' setup.sh # Run setup script, skipping APT installs G_EXEC_OUTPUT=1 G_EXEC ./setup.sh skip-apt @@ -7010,7 +7010,7 @@ _EOF_ G_EXEC rm -R WebIOPi-master # On fresh installs, change port to 8002 to avoid conflict with IceCast - (( $reinstall )) || G_EXEC sed -i 's/^port = 8000$/port = 8002/' /etc/webiopi/config + (( $reinstall )) || G_EXEC sed --follow-symlinks -i 's/^port = 8000$/port = 8002/' /etc/webiopi/config # Service Remove_SysV webiopi 1 @@ -7923,12 +7923,12 @@ _EOF_ G_EXEC curl -sSfL 'https://raw.githubusercontent.com/pivpn/pivpn/master/auto_install/install.sh' -o install.bash G_EXEC chmod +x install.bash G_DIETPI-NOTIFY 2 'Preventing reboot from within PiVPN installer' - G_EXEC sed -i '/^Thank you for using PiVPN./a\exit 0' install.bash + G_EXEC sed --follow-symlinks -i '/^Thank you for using PiVPN./a\exit 0' install.bash G_DIETPI-NOTIFY 2 'Preventing install of unattended-upgrades' - G_EXEC sed -i '/^[[:blank:]]*askUnattendedUpgrades$/c\UNATTUPG=0' install.bash + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*askUnattendedUpgrades$/c\UNATTUPG=0' install.bash G_DIETPI-NOTIFY 2 'Prevent dhcpcd from being installed' - G_EXEC sed -i '/^checkStaticIpSupported() {$/,/^}$/d' install.bash - G_EXEC sed -i '/^####### FUNCTIONS ##########$/a\checkStaticIpSupported(){ return 1; }' install.bash + G_EXEC sed --follow-symlinks -i '/^checkStaticIpSupported() {$/,/^}$/d' install.bash + G_EXEC sed --follow-symlinks -i '/^####### FUNCTIONS ##########$/a\checkStaticIpSupported(){ return 1; }' install.bash # Unattended install local options=() @@ -8018,7 +8018,7 @@ _EOF_ echo "INTERFACESv4=\"$wifi_iface\"" > /etc/default/isc-dhcp-server # Remove all entries below wlan, so we can recreate them - G_EXEC sed -Ei '/(allow-hotplug|auto)[[:blank:]]+wlan/q0' /etc/network/interfaces + G_EXEC sed --follow-symlinks -Ei '/(allow-hotplug|auto)[[:blank:]]+wlan/q0' /etc/network/interfaces # Enable up wlan G_CONFIG_INJECT 'allow-hotplug wlan' "allow-hotplug $wifi_iface" /etc/network/interfaces @@ -8039,7 +8039,7 @@ up ip6tables-restore < /etc/iptables.ipv6.nat _EOF_ # Remove wireless-power setting if not supported by adapter/firmware # shellcheck disable=SC2015 - iw dev "$wifi_iface" set power_save on 2> /dev/null && iw dev "$wifi_iface" set power_save off 2> /dev/null || G_EXEC sed -i '/ iw dev .* set power_save /d' /etc/network/interfaces + iw dev "$wifi_iface" set power_save on 2> /dev/null && iw dev "$wifi_iface" set power_save off 2> /dev/null || G_EXEC sed --follow-symlinks -i '/ iw dev .* set power_save /d' /etc/network/interfaces # Access point config # - Parse dietpi.txt @@ -8193,7 +8193,7 @@ _EOF_ G_CONFIG_INJECT 'SOFTWARE_SHAIRPORT_SYNC_AIRPLAY=' 'SOFTWARE_SHAIRPORT_SYNC_AIRPLAY=2' /boot/dietpi.txt airplay2='-airplay2' else - G_EXEC sed -i '/^[[:blank:]]*SOFTWARE_SHAIRPORT_SYNC_AIRPLAY=/c\#SOFTWARE_SHAIRPORT_SYNC_AIRPLAY=2' /boot/dietpi.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*SOFTWARE_SHAIRPORT_SYNC_AIRPLAY=/c\#SOFTWARE_SHAIRPORT_SYNC_AIRPLAY=2' /boot/dietpi.txt airplay2= fi @@ -8338,7 +8338,7 @@ web.statistics.1.content.9.ds_graph_options.usbhdd_used.label=USB HDD used space web.statistics.1.content.9.ds_graph_options.usbhdd_used.lines={ fill: true } web.statistics.1.content.9.ds_graph_options.usbhdd_used.color="#7777FF" _EOF_ - G_EXEC sed -i '\|include=/etc/rpimonitor/template/sdcard.conf|a\include=/etc/rpimonitor/template/usb_hdd.conf' /etc/rpimonitor/data.conf + G_EXEC sed --follow-symlinks -i '\|include=/etc/rpimonitor/template/sdcard.conf|a\include=/etc/rpimonitor/template/usb_hdd.conf' /etc/rpimonitor/data.conf fi fi @@ -8416,13 +8416,13 @@ location = /.well-known/caldav { return 301 /baikal/html/dav.php; }' > /etc/ngi # Cap total connections local max_users=$(( $G_HW_CPU_CORES * 8 )) - G_EXEC sed -i "/users=/c\users=$max_users" /etc/mumble-server.ini + G_EXEC sed --follow-symlinks -i "/users=/c\users=$max_users" /etc/mumble-server.ini # Name the root channel - G_EXEC sed -i '/registerName=/c\registerName=DietPi Mumble Server' /etc/mumble-server.ini + G_EXEC sed --follow-symlinks -i '/registerName=/c\registerName=DietPi Mumble Server' /etc/mumble-server.ini # Disable DB logging - G_EXEC sed -i '/logdays=/c\logdays=-1' /etc/mumble-server.ini + G_EXEC sed --follow-symlinks -i '/logdays=/c\logdays=-1' /etc/mumble-server.ini # Set Superuser passwd: https://dietpi.com/forum/t/mumble-murmur-server-superuser-error/1371 murmurd -ini /etc/mumble-server.ini -supw "$GLOBAL_PW" @@ -8729,7 +8729,7 @@ _EOF_ fi # Since v4.2.0, PBKDF2 needs to be used: https://github.com/MichaIng/DietPi/issues/4711 - (( $G_DISTRO < 6 )) || G_EXEC sed -i '/^WebUI\\Password_ha1/c\WebUI\\Password_PBKDF2="@ByteArray(tpgNK76AcpP14rjOZP9vwg==:rQNtOB0P4HfNj20pJtxiTBi9miduS6L1Xqqazc4Y6Gpm3Rn02jMXnPPT3KH2JMDKhFQjAaTGVJz0dz5JVw2QUQ==)"' /home/qbittorrent/.config/qBittorrent/qBittorrent.conf + (( $G_DISTRO < 6 )) || G_EXEC sed --follow-symlinks -i '/^WebUI\\Password_ha1/c\WebUI\\Password_PBKDF2="@ByteArray(tpgNK76AcpP14rjOZP9vwg==:rQNtOB0P4HfNj20pJtxiTBi9miduS6L1Xqqazc4Y6Gpm3Rn02jMXnPPT3KH2JMDKhFQjAaTGVJz0dz5JVw2QUQ==)"' /home/qbittorrent/.config/qBittorrent/qBittorrent.conf # Service cat << _EOF_ > /etc/systemd/system/qbittorrent.service @@ -8835,7 +8835,7 @@ _EOF_ [[ -f '/etc/.rutorrent-htaccess' ]] || echo "root:rtorrent:$(echo -n "root:rtorrent:$GLOBAL_PW" | md5sum | mawk '{print $1}')" > /etc/.rutorrent-htaccess # Pre-v7.2: Remove obsolete entries from /etc/lighttpd/lighttpd.conf - grep -q '^#RUTORRENT_DIETPI' /etc/lighttpd/lighttpd.conf && G_EXEC sed -i '/#RUTORRENT_DIETPI/,/#RUTORRENT_DIETPI/d' /etc/lighttpd/lighttpd.conf + grep -q '^#RUTORRENT_DIETPI' /etc/lighttpd/lighttpd.conf && G_EXEC sed --follow-symlinks -i '/#RUTORRENT_DIETPI/,/#RUTORRENT_DIETPI/d' /etc/lighttpd/lighttpd.conf cat << '_EOF_' > /etc/lighttpd/conf-available/98-dietpi-rtorrent.conf server.modules += ( "mod_auth", "mod_authn_file", "mod_scgi" ) @@ -8933,7 +8933,7 @@ _EOF_ # In case dist-upgraded systems, assure that daemon mode is enabled G_CONFIG_INJECT 'system.daemon.set[[:blank:]=]' 'system.daemon.set = true' /mnt/dietpi_userdata/rtorrent/.rtorrent.rc # Reinstall: Assure that rpi.socket is used, else ruTorrent connection would fail - G_EXEC sed -i '/^[[:blank:]]*network.scgi.open_port[[:blank:]=]/d' /mnt/dietpi_userdata/rtorrent/.rtorrent.rc + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*network.scgi.open_port[[:blank:]=]/d' /mnt/dietpi_userdata/rtorrent/.rtorrent.rc G_CONFIG_INJECT 'network.scgi.open_local[[:blank:]=]' 'network.scgi.open_local = /mnt/dietpi_userdata/downloads/.session/rpc.socket' /mnt/dietpi_userdata/rtorrent/.rtorrent.rc G_CONFIG_INJECT 'execute.nothrow[[:blank:]]*=[[:blank:]]*chmod,666,/mnt/dietpi_userdata/downloads/.session/rpc.socket' 'execute.nothrow = chmod,666,/mnt/dietpi_userdata/downloads/.session/rpc.socket' /mnt/dietpi_userdata/rtorrent/.rtorrent.rc 'network.scgi.open_local[[:blank:]=]' else @@ -9125,7 +9125,7 @@ _EOF_ G_CONFIG_INJECT 'StartLimitIntervalSec=' 'StartLimitIntervalSec=600' /etc/systemd/system/medusa.service '\[Unit\]' G_CONFIG_INJECT 'StartLimitBurst=' 'StartLimitBurst=3' /etc/systemd/system/medusa.service 'StartLimitIntervalSec=' # - Remove "Group=medusa" which does not exist, instead fallback to primary group "dietpi" - G_EXEC sed -i '/^[[:blank:]]*Group=/d' /etc/systemd/system/medusa.service + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*Group=/d' /etc/systemd/system/medusa.service # - Launch from our install and data directory G_CONFIG_INJECT 'ExecStart=' 'ExecStart=/usr/bin/python3 /mnt/dietpi_userdata/medusa/start.py -q --nolaunch --datadir=/mnt/dietpi_userdata/medusa' /etc/systemd/system/medusa.service @@ -9168,13 +9168,13 @@ _EOF_ G_EXEC_OUTPUT=1 G_EXEC sudo -u dietpi /opt/syncthing/syncthing -generate=/mnt/dietpi_userdata/syncthing # Allow remote access: https://docs.syncthing.net/users/faq.html#how-do-i-access-the-web-gui-from-another-computer - G_EXEC sed -i '\|:8384|c\
0.0.0.0:8384
' /mnt/dietpi_userdata/syncthing/config.xml + G_EXEC sed --follow-symlinks -i '\|:8384|c\
0.0.0.0:8384
' /mnt/dietpi_userdata/syncthing/config.xml # Set default data directory G_EXEC mkdir -p /mnt/dietpi_userdata/syncthing_data G_EXEC chown -R dietpi:dietpi /mnt/dietpi_userdata/syncthing_data - G_EXEC sed -i '\|[0-9]+<\/Port>/{s/^.*([0-9]+)<\/Port>.*$/\1/p;q}' /mnt/dietpi_userdata/sonarr/config.xml) local apikey=$(sed -nE '/.+<\/ApiKey>/{s/^.*(.+)<\/ApiKey>.*$/\1/p;q}' /mnt/dietpi_userdata/sonarr/config.xml) - G_EXEC sed -i '/\[sonarr\]/,/^$/s/^ip = .*$/ip = 127.0.0.1/' /mnt/dietpi_userdata/bazarr/config/config.ini - G_EXEC sed -i "/\[sonarr\]/,/^$/s/^port = .*$/port = $port/" /mnt/dietpi_userdata/bazarr/config/config.ini - G_EXEC sed -i '/\[sonarr\]/,/^$/s/^base_url = .*$/base_url = \//' /mnt/dietpi_userdata/bazarr/config/config.ini - G_EXEC sed -i "/\[sonarr\]/,/^$/s/^apikey = .*$/apikey = $apikey/" /mnt/dietpi_userdata/bazarr/config/config.ini + G_EXEC sed --follow-symlinks -i '/\[sonarr\]/,/^$/s/^ip = .*$/ip = 127.0.0.1/' /mnt/dietpi_userdata/bazarr/config/config.ini + G_EXEC sed --follow-symlinks -i "/\[sonarr\]/,/^$/s/^port = .*$/port = $port/" /mnt/dietpi_userdata/bazarr/config/config.ini + G_EXEC sed --follow-symlinks -i '/\[sonarr\]/,/^$/s/^base_url = .*$/base_url = \//' /mnt/dietpi_userdata/bazarr/config/config.ini + G_EXEC sed --follow-symlinks -i "/\[sonarr\]/,/^$/s/^apikey = .*$/apikey = $apikey/" /mnt/dietpi_userdata/bazarr/config/config.ini G_CONFIG_INJECT 'use_sonarr[[:blank:]]*=' 'use_sonarr = True' /mnt/dietpi_userdata/bazarr/config/config.ini '\[general\]' fi # Radarr @@ -9998,10 +9998,10 @@ _EOF_ then local port=$(sed -nE '/[0-9]+<\/Port>/{s/^.*([0-9]+)<\/Port>.*$/\1/p;q}' /mnt/dietpi_userdata/radarr/config.xml) local apikey=$(sed -nE '/.+<\/ApiKey>/{s/^.*(.+)<\/ApiKey>.*$/\1/p;q}' /mnt/dietpi_userdata/radarr/config.xml) - G_EXEC sed -i '/\[radarr\]/,/^$/s/^ip = .*$/ip = 127.0.0.1/' /mnt/dietpi_userdata/bazarr/config/config.ini - G_EXEC sed -i "/\[radarr\]/,/^$/s/^port = .*$/port = $port/" /mnt/dietpi_userdata/bazarr/config/config.ini - G_EXEC sed -i '/\[radarr\]/,/^$/s/^base_url = .*$/base_url = \//' /mnt/dietpi_userdata/bazarr/config/config.ini - G_EXEC sed -i "/\[radarr\]/,/^$/s/^apikey = .*$/apikey = $apikey/" /mnt/dietpi_userdata/bazarr/config/config.ini + G_EXEC sed --follow-symlinks -i '/\[radarr\]/,/^$/s/^ip = .*$/ip = 127.0.0.1/' /mnt/dietpi_userdata/bazarr/config/config.ini + G_EXEC sed --follow-symlinks -i "/\[radarr\]/,/^$/s/^port = .*$/port = $port/" /mnt/dietpi_userdata/bazarr/config/config.ini + G_EXEC sed --follow-symlinks -i '/\[radarr\]/,/^$/s/^base_url = .*$/base_url = \//' /mnt/dietpi_userdata/bazarr/config/config.ini + G_EXEC sed --follow-symlinks -i "/\[radarr\]/,/^$/s/^apikey = .*$/apikey = $apikey/" /mnt/dietpi_userdata/bazarr/config/config.ini G_CONFIG_INJECT 'use_radarr[[:blank:]]*=' 'use_radarr = True' /mnt/dietpi_userdata/bazarr/config/config.ini '\[general\]' fi fi @@ -10984,7 +10984,7 @@ _EOF_ (( $G_HW_ARCH == 2 )) && G_EXEC_OUTPUT=1 G_EXEC env/bin/pip install 'google-assistant-library~=1.0' # Services - G_EXEC sed -i 's|/home/pi|/mnt/dietpi_userdata|g' systemd/voice-recognizer.service + G_EXEC sed --follow-symlinks -i 's|/home/pi|/mnt/dietpi_userdata|g' systemd/voice-recognizer.service G_CONFIG_INJECT 'User=' 'User=dietpi' systemd/voice-recognizer.service '\[Service\]' G_EXEC cp systemd/{alsa-init,voice-recognizer}.service /etc/systemd/system/ @@ -11044,7 +11044,7 @@ _EOF_ G_EXEC cd /mnt/dietpi_userdata/mycroft-core # -sm: Skip mimic build which is time intense and can be manually done any time later. # - Remove PulseAudio from dependencies, we use ALSA - G_EXEC sed -Ei 's/[^[:blank:]"'\'']*pulseaudio[^[:blank:]"'\'']*//g' ./dev_setup.sh + G_EXEC sed --follow-symlinks -Ei 's/[^[:blank:]"'\'']*pulseaudio[^[:blank:]"'\'']*//g' ./dev_setup.sh G_EXEC_OUTPUT=1 G_EXEC sudo -u mycroft ./dev_setup.sh -sm G_EXEC cd "$G_WORKING_DIR" @@ -11409,12 +11409,12 @@ _EOF_ G_CONFIG_INJECT 'OPENHAB_HTTP_PORT=' 'OPENHAB_HTTP_PORT=0' /etc/default/openhab # Do all logs to STDOUT => journalctl -u openhab - G_EXEC sed -i 's|||' /var/lib/openhab/etc/log4j2.xml + G_EXEC sed --follow-symlinks -i 's|||' /var/lib/openhab/etc/log4j2.xml local line='' last='' grep -n '' /var/lib/openhab/etc/log4j2.xml | while read -r line do line=${line%%:*} - (( $line == ${last:-$line} + 1 )) && G_EXEC sed -i "${last}d" /var/lib/openhab/etc/log4j2.xml + (( $line == ${last:-$line} + 1 )) && G_EXEC sed --follow-symlinks -i "${last}d" /var/lib/openhab/etc/log4j2.xml last=$line done G_EXEC rm -f /var/log/openhab/* @@ -11709,7 +11709,7 @@ _EOF_ G_EXEC systemctl stop snapserver # Disable JSON RPC by default if setting was never touched yet - [[ -f '/etc/snapserver.conf' ]] && G_EXEC sed -i '/^\[tcp\]/,/^\[/s/^#enabled = true$/enabled = false/' /etc/snapserver.conf + [[ -f '/etc/snapserver.conf' ]] && G_EXEC sed --follow-symlinks -i '/^\[tcp\]/,/^\[/s/^#enabled = true$/enabled = false/' /etc/snapserver.conf fi if To_Install 192 snapclient # Snapcast Client @@ -13261,7 +13261,7 @@ If no WireGuard (auto)start is included, but you require it, please do the follo G_DIETPI-NOTIFY 2 'Reconfiguring Unbound to work on its own' G_CONFIG_INJECT 'port:[[:blank:]]' ' port: 53' /etc/unbound/unbound.conf.d/dietpi.conf G_CONFIG_INJECT 'interface:[[:blank:]]' ' interface: 0.0.0.0' /etc/unbound/unbound.conf.d/dietpi.conf - grep -E '^[[:blank:]]*nameserver[[:blank:]]+127.0.0.1:5335$' /etc/resolv.conf && sed -Ei '/^[[:blank:]]*nameserver[[:blank:]]+127.0.0.1:5335$/c\nameserver 127.0.0.1' /etc/resolv.conf # Failsafe + grep -E '^[[:blank:]]*nameserver[[:blank:]]+127.0.0.1:5335$' /etc/resolv.conf && sed --follow-symlinks -Ei '/^[[:blank:]]*nameserver[[:blank:]]+127.0.0.1:5335$/c\nameserver 127.0.0.1' /etc/resolv.conf # Failsafe G_EXEC_NOEXIT=1 G_EXEC systemctl restart unbound else grep '^[[:blank:]]*nameserver[[:blank:]]' /etc/resolv.conf | grep -qvE '[[:blank:]]127.0.0.1(:53)?$' || echo 'nameserver 9.9.9.9' >> /etc/resolv.conf # Failsafe @@ -13281,7 +13281,7 @@ If no WireGuard (auto)start is included, but you require it, please do the follo G_DIETPI-NOTIFY 2 'Reconfiguring Unbound to work on its own' G_CONFIG_INJECT 'port:[[:blank:]]' ' port: 53' /etc/unbound/unbound.conf.d/dietpi.conf G_CONFIG_INJECT 'interface:[[:blank:]]' ' interface: 0.0.0.0' /etc/unbound/unbound.conf.d/dietpi.conf - grep -E '^[[:blank:]]*nameserver[[:blank:]]+127.0.0.1:5335$' /etc/resolv.conf && sed -Ei '/^[[:blank:]]*nameserver[[:blank:]]+127.0.0.1:5335$/c\nameserver 127.0.0.1' /etc/resolv.conf # Failsafe + grep -E '^[[:blank:]]*nameserver[[:blank:]]+127.0.0.1:5335$' /etc/resolv.conf && sed --follow-symlinks -Ei '/^[[:blank:]]*nameserver[[:blank:]]+127.0.0.1:5335$/c\nameserver 127.0.0.1' /etc/resolv.conf # Failsafe G_EXEC_NOEXIT=1 G_EXEC systemctl restart unbound else grep '^[[:blank:]]*nameserver[[:blank:]]' /etc/resolv.conf | grep -qvE '[[:blank:]]127.0.0.1(:53)?$' || echo 'nameserver 9.9.9.9' >> /etc/resolv.conf # Failsafe @@ -13412,7 +13412,7 @@ If no WireGuard (auto)start is included, but you require it, please do the follo if To_Uninstall 117 # PiVPN then - [[ -f '/opt/pivpn/uninstall.sh' ]] && G_EXEC sed -i 's/ askreboot;//' /opt/pivpn/uninstall.sh + [[ -f '/opt/pivpn/uninstall.sh' ]] && G_EXEC sed --follow-symlinks -i 's/ askreboot;//' /opt/pivpn/uninstall.sh command -v pivpn > /dev/null && G_EXEC_OUTPUT=1 G_EXEC pivpn -u getent passwd pivpn > /dev/null && G_EXEC userdel pivpn getent group pivpn > /dev/null && G_EXEC groupdel pivpn @@ -13534,9 +13534,9 @@ If no WireGuard (auto)start is included, but you require it, please do the follo # Set WiFi interface back to inactive and ready for use with dietpi-config. local wifi_iface=$(G_GET_NET -t wlan iface) # - Remove WLAN block, so we can recreate it - G_EXEC sed -Ei '/(allow-hotplug|auto)[[:blank:]]+wlan/q0' /etc/network/interfaces + G_EXEC sed --follow-symlinks -Ei '/(allow-hotplug|auto)[[:blank:]]+wlan/q0' /etc/network/interfaces # - Disable - G_EXEC sed -i "/allow-hotplug wlan/c\#allow-hotplug $wifi_iface" /etc/network/interfaces + G_EXEC sed --follow-symlinks -i "/allow-hotplug wlan/c\#allow-hotplug $wifi_iface" /etc/network/interfaces # - Add default WiFi settings to network interfaces config cat << _EOF_ >> /etc/network/interfaces iface $wifi_iface inet dhcp @@ -13549,7 +13549,7 @@ post-down iw dev $wifi_iface set power_save on wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf _EOF_ # shellcheck disable=SC2015 - iw dev "$wifi_iface" set power_save on 2> /dev/null && iw dev "$wifi_iface" set power_save off 2> /dev/null || G_EXEC sed -i '/ iw dev .* set power_save /d' /etc/network/interfaces + iw dev "$wifi_iface" set power_save on 2> /dev/null && iw dev "$wifi_iface" set power_save off 2> /dev/null || G_EXEC sed --follow-symlinks -i '/ iw dev .* set power_save /d' /etc/network/interfaces # - Flush iptables iptables -F iptables -t nat -F @@ -13703,7 +13703,7 @@ _EOF_ [[ -f '/etc/.rutorrent-htaccess' ]] && G_EXEC rm /etc/.rutorrent-htaccess # - Lighttpd # Pre-v7.2: Remove from #RUTORRENT_DIETPI to #RUTORRENT_DIETPI in /etc/lighttpd/lighttpd.conf if exist - [[ -f '/etc/lighttpd/lighttpd.conf' ]] && grep -q '^#RUTORRENT_DIETPI' /etc/lighttpd/lighttpd.conf && G_EXEC sed -i '/#RUTORRENT_DIETPI/,/#RUTORRENT_DIETPI/d' /etc/lighttpd/lighttpd.conf + [[ -f '/etc/lighttpd/lighttpd.conf' ]] && grep -q '^#RUTORRENT_DIETPI' /etc/lighttpd/lighttpd.conf && G_EXEC sed --follow-symlinks -i '/#RUTORRENT_DIETPI/,/#RUTORRENT_DIETPI/d' /etc/lighttpd/lighttpd.conf # Remove rTorrent config from Lighttpd [[ -f '/etc/lighttpd/conf-enabled/98-dietpi-rtorrent.conf' ]] && G_EXEC lighty-disable-mod dietpi-rtorrent @@ -13796,7 +13796,7 @@ _EOF_ Remove_Service pi-spc [[ -d '/var/lib/dietpi/dietpi-software/installed/pi-spc' ]] && G_EXEC rm -R /var/lib/dietpi/dietpi-software/installed/pi-spc - G_EXEC sed -Ei '/^[[:blank:]]*dtoverlay=gpio-(shutdown|poweroff)/d' /boot/config.txt + G_EXEC sed --follow-symlinks -Ei '/^[[:blank:]]*dtoverlay=gpio-(shutdown|poweroff)/d' /boot/config.txt fi if To_Uninstall 167 # Raspotify @@ -14102,7 +14102,7 @@ _EOF_ findmnt /mnt/samba > /dev/null && G_EXEC umount -Rfl /mnt/samba # Remove from fstab - G_EXEC sed -i '\|/mnt/samba|d' /etc/fstab + G_EXEC sed --follow-symlinks -i '\|/mnt/samba|d' /etc/fstab G_AGP cifs-utils smbclient @@ -14115,7 +14115,7 @@ _EOF_ findmnt /mnt/nfs_client > /dev/null && G_EXEC umount -Rfl /mnt/nfs_client # Remove from fstab - G_EXEC sed -i '\|/mnt/nfs_client|d' /etc/fstab + G_EXEC sed --follow-symlinks -i '\|/mnt/nfs_client|d' /etc/fstab # nfs-kernel-server depends on nfs-common dpkg-query -s 'nfs-common' &> /dev/null && G_EXEC apt-mark auto nfs-common @@ -14235,7 +14235,7 @@ _EOF_ if To_Uninstall 103 # DietPi-RAMlog then - G_EXEC sed -i '/[[:blank:]]\/var\/log[[:blank:]]/d' /etc/fstab + G_EXEC sed --follow-symlinks -i '/[[:blank:]]\/var\/log[[:blank:]]/d' /etc/fstab G_EXEC mkdir -p /var/lib/dietpi/dietpi-ramlog cat << '_EOF_' > /var/lib/dietpi/dietpi-ramlog/disable.sh @@ -14246,9 +14246,9 @@ _EOF_ rm -R /var/tmp/dietpi/logs/dietpi-ramlog_store if systemctl -q is-enabled rsyslog 2> /dev/null then - sed -i '/^[[:blank:]]*INDEX_LOGGING=/c\INDEX_LOGGING=-3' /boot/dietpi/.installed + sed --follow-symlinks -i '/^[[:blank:]]*INDEX_LOGGING=/c\INDEX_LOGGING=-3' /boot/dietpi/.installed else - sed -i '/^[[:blank:]]*INDEX_LOGGING=/c\INDEX_LOGGING=0' /boot/dietpi/.installed + sed --follow-symlinks -i '/^[[:blank:]]*INDEX_LOGGING=/c\INDEX_LOGGING=0' /boot/dietpi/.installed fi systemctl --no-reload disable dietpi-ramlog_disable rm /etc/systemd/system/dietpi-ramlog_disable.service @@ -14697,9 +14697,9 @@ _EOF_ then if [[ $( /dev/null && G_EXEC mount -o remount /var/log # Set time sync mode if no container system @@ -14842,9 +14842,9 @@ _EOF_ # Apply current network settings statically G_CONFIG_INJECT "iface[[:blank:]]+eth$eth_index" "iface eth$eth_index inet static" /etc/network/interfaces - sed -i "0,\|^.*address[[:blank:]].*\$|s||address $eth_ip|" /etc/network/interfaces - sed -i "0,\|^.*netmask[[:blank:]].*\$|s||netmask $eth_mask|" /etc/network/interfaces - sed -i "0,\|^.*gateway[[:blank:]].*\$|s||gateway $eth_gateway|" /etc/network/interfaces + sed --follow-symlinks -i "0,\|^.*address[[:blank:]].*\$|s||address $eth_ip|" /etc/network/interfaces + sed --follow-symlinks -i "0,\|^.*netmask[[:blank:]].*\$|s||netmask $eth_mask|" /etc/network/interfaces + sed --follow-symlinks -i "0,\|^.*gateway[[:blank:]].*\$|s||gateway $eth_gateway|" /etc/network/interfaces fi # Get WiFi index @@ -14862,9 +14862,9 @@ _EOF_ # Apply current network settings statically G_CONFIG_INJECT "iface[[:blank:]]+wlan$wlan_index" "iface wlan$wlan_index inet static" /etc/network/interfaces - sed -i "\|^iface wlan|,\$s|^.*address[[:blank:]].*\$|address $wlan_ip|" /etc/network/interfaces - sed -i "\|^iface wlan|,\$s|^.*netmask[[:blank:]].*\$|netmask $wlan_mask|" /etc/network/interfaces - sed -i "\|^iface wlan|,\$s|^.*gateway[[:blank:]].*\$|gateway $wlan_gateway|" /etc/network/interfaces + sed --follow-symlinks -i "\|^iface wlan|,\$s|^.*address[[:blank:]].*\$|address $wlan_ip|" /etc/network/interfaces + sed --follow-symlinks -i "\|^iface wlan|,\$s|^.*netmask[[:blank:]].*\$|netmask $wlan_mask|" /etc/network/interfaces + sed --follow-symlinks -i "\|^iface wlan|,\$s|^.*gateway[[:blank:]].*\$|gateway $wlan_gateway|" /etc/network/interfaces fi unset -f cidr2mask @@ -14875,9 +14875,9 @@ _EOF_ if command -v resolvconf > /dev/null then - sed -i "/dns-nameservers[[:blank:]]/c\dns-nameservers ${nameservers% }" /etc/network/interfaces + sed --follow-symlinks -i "/dns-nameservers[[:blank:]]/c\dns-nameservers ${nameservers% }" /etc/network/interfaces else - sed -i "/dns-nameservers[[:blank:]]/c\#dns-nameservers ${nameservers% }" /etc/network/interfaces + sed --follow-symlinks -i "/dns-nameservers[[:blank:]]/c\#dns-nameservers ${nameservers% }" /etc/network/interfaces > /etc/resolv.conf for i in $nameservers; do echo "nameserver $i" >> /etc/resolv.conf; done fi diff --git a/dietpi/dietpi-vpn b/dietpi/dietpi-vpn index a2a8563dc7..9c052ca47a 100755 --- a/dietpi/dietpi-vpn +++ b/dietpi/dietpi-vpn @@ -232,7 +232,7 @@ _EOF_ G_CONFIG_INJECT 'ca[[:blank:]]' "ca $FP_IPVANISH/ca.ipvanish.com.crt" "$FP_CLIENT_OVPN" # Set protocol and port: UDP port 443 is default, but TCP 1194 and UDP 1194 are supported as well. G_CONFIG_INJECT 'proto[[:blank:]]' "proto $PROTOCOL" "$FP_CLIENT_OVPN" - G_EXEC sed -i '/^[[:blank:]]*remote[[:blank:]]/s/[[:blank:]][0-9][0-9]*$/ 1194/' "$FP_CLIENT_OVPN" + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*remote[[:blank:]]/s/[[:blank:]][0-9][0-9]*$/ 1194/' "$FP_CLIENT_OVPN" elif [[ $VPN_PROVIDER == 'PIA' ]] then @@ -240,7 +240,7 @@ _EOF_ # Set protocol and port: UDP on 1197 is default but TCP on 501 is supported as well. G_CONFIG_INJECT 'proto[[:blank:]]' "proto $PROTOCOL" "$FP_CLIENT_OVPN" [[ $PROTOCOL == 'udp' ]] && VPN_PORT=1197 || VPN_PORT=501 - G_EXEC sed -i "/^[[:blank:]]*remote[[:blank:]]/s/[[:blank:]][0-9][0-9]*\$/ $VPN_PORT/" "$FP_CLIENT_OVPN" + G_EXEC sed --follow-symlinks -i "/^[[:blank:]]*remote[[:blank:]]/s/[[:blank:]][0-9][0-9]*\$/ $VPN_PORT/" "$FP_CLIENT_OVPN" fi cat << _EOF_ > "$FP_SETTINGS_OVPN" @@ -269,9 +269,9 @@ _EOF_ # Apply or remove custom up/down scripts from client config # shellcheck disable=SC2015 - [[ -f $FP_CUSTOM_UP ]] && G_CONFIG_INJECT 'route-up[[:blank:]]' "route-up $FP_CUSTOM_UP" "$FP_CLIENT_OVPN" 'up[[:blank:]]' || G_EXEC sed -i '/^[[:blank:]]*route-up[[:blank:]]/d' "$FP_CLIENT_OVPN" + [[ -f $FP_CUSTOM_UP ]] && G_CONFIG_INJECT 'route-up[[:blank:]]' "route-up $FP_CUSTOM_UP" "$FP_CLIENT_OVPN" 'up[[:blank:]]' || G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*route-up[[:blank:]]/d' "$FP_CLIENT_OVPN" # shellcheck disable=SC2015 - [[ -f $FP_CUSTOM_DOWN ]] && G_CONFIG_INJECT 'route-pre-down[[:blank:]]' "route-pre-down $FP_CUSTOM_DOWN" "$FP_CLIENT_OVPN" 'down[[:blank:]]' || G_EXEC sed -i '/^[[:blank:]]*route-pre-down[[:blank:]]/d' "$FP_CLIENT_OVPN" + [[ -f $FP_CUSTOM_DOWN ]] && G_CONFIG_INJECT 'route-pre-down[[:blank:]]' "route-pre-down $FP_CUSTOM_DOWN" "$FP_CLIENT_OVPN" 'down[[:blank:]]' || G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*route-pre-down[[:blank:]]/d' "$FP_CLIENT_OVPN" # Establish and test connection G_AG_CHECK_INSTALL_PREREQ openvpn diff --git a/dietpi/func/dietpi-globals b/dietpi/func/dietpi-globals index a37985401a..793676ccea 100644 --- a/dietpi/func/dietpi-globals +++ b/dietpi/func/dietpi-globals @@ -1002,7 +1002,7 @@ Press any key to continue...' if [[ -f $fp_error_report ]]; then # Add bug report ID if it was sent - [[ $sent_bug_report == 1 ]] && sed -i "/^- Date | /a\- Bug report | $G_HW_UUID" "$fp_error_report" + [[ $sent_bug_report == 1 ]] && sed --follow-symlinks -i "/^- Date | /a\- Bug report | $G_HW_UUID" "$fp_error_report" cat "$fp_error_report" fi @@ -2089,7 +2089,7 @@ Please retry with more specific parameter \$1 or apply the setting manually: [[ $error ]] && { syntax_error; return 1; } [[ $GCI_BACKUP == 1 && ! -f $file.bak ]] && cp -a "$file" "$file.bak" && G_DIETPI-NOTIFY 2 "Config file backup created: $yellow$file.bak$reset" - error=$(sed -Ei "0,/^[[:blank:]]*$pattern.*$/s//$setting/" "$file" 2>&1) || { syntax_error; return 1; } + error=$(sed --follow-symlinks -Ei "0,/^[[:blank:]]*$pattern.*$/s//$setting/" "$file" 2>&1) || { syntax_error; return 1; } G_DIETPI-NOTIFY 0 "Setting in $yellow$file$reset adjusted: $yellow${setting_raw//\\/\\\\}$reset" fi @@ -2098,7 +2098,7 @@ Please retry with more specific parameter \$1 or apply the setting manually: [[ $error ]] && { syntax_error; return 1; } [[ $GCI_BACKUP == 1 && ! -f $file.bak ]] && cp -a "$file" "$file.bak" && G_DIETPI-NOTIFY 2 "Config file backup created: $yellow$file.bak$reset" - error=$(sed -Ei "0,/^[[:blank:]#;]*$pattern.*$/s//$setting/" "$file" 2>&1) || { syntax_error; return 1; } + error=$(sed --follow-symlinks -Ei "0,/^[[:blank:]#;]*$pattern.*$/s//$setting/" "$file" 2>&1) || { syntax_error; return 1; } G_DIETPI-NOTIFY 0 "Comment in $yellow$file$reset converted to setting: $yellow${setting_raw//\\/\\\\}$reset" else @@ -2109,7 +2109,7 @@ Please retry with more specific parameter \$1 or apply the setting manually: if error=$(grep -Eq "^[[:blank:]]*$after" "$file" 2>&1); then [[ $GCI_BACKUP == 1 && ! -f $file.bak ]] && cp -a "$file" "$file.bak" && G_DIETPI-NOTIFY 2 "Config file backup created: $yellow$file.bak$reset" - error=$(sed -Ei "0,/^[[:blank:]]*$after.*$/s//&\n$setting/" "$file" 2>&1) || { syntax_error; return 1; } + error=$(sed --follow-symlinks -Ei "0,/^[[:blank:]]*$after.*$/s//&\n$setting/" "$file" 2>&1) || { syntax_error; return 1; } G_DIETPI-NOTIFY 0 "Added setting $yellow${setting_raw//\\/\\\\}$reset to $yellow$file$reset after line $yellow$(grep -Em1 "^[[:blank:]]*$after" "$file" | sed 's|\\|\\\\|g')$reset" else @@ -2130,7 +2130,7 @@ could not be found in file \$3 [[ $GCI_BACKUP == 1 && ! -f $file.bak ]] && cp -a "$file" "$file.bak" && G_DIETPI-NOTIFY 2 "Config file backup created: $yellow$file.bak$reset" # The following sed does not work on empty files: [[ ! -s $file ]] && echo '# Added by DietPi:' >> "$file" - error=$(sed -Ei "\$a\\$setting" "$file" 2>&1) || { syntax_error; return 1; } + error=$(sed --follow-symlinks -Ei "\$a\\$setting" "$file" 2>&1) || { syntax_error; return 1; } G_DIETPI-NOTIFY 0 "Added setting $yellow${setting_raw//\\/\\\\}$reset to end of file $yellow$file$reset" fi diff --git a/dietpi/func/dietpi-set_hardware b/dietpi/func/dietpi-set_hardware index 792561616d..01bf7165fa 100755 --- a/dietpi/func/dietpi-set_hardware +++ b/dietpi/func/dietpi-set_hardware @@ -129,7 +129,7 @@ $FP_SCRIPT qemu-guest-agent|qga enable/disable elif [[ $INPUT_DEVICE_VALUE == 'disable' ]]; then # Comment extended start setting - G_EXEC sed -i '/^[[:blank:]]*start_x=/c\#start_x=1' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*start_x=/c\#start_x=1' /boot/config.txt # Add modules blacklist, which are otherwise loaded by default since kernel 4.19/5.10 G_EXEC eval "echo -e 'blacklist bcm2835_v4l2\nblacklist bcm2835_isp' > /etc/modprobe.d/dietpi-disable_rpi_camera.conf" @@ -163,7 +163,7 @@ $FP_SCRIPT qemu-guest-agent|qga enable/disable G_EXEC eval "echo 'blacklist bcm2835_codec' > /etc/modprobe.d/dietpi-disable_rpi_codec.conf" # Disable HEVC decoder - grep -q '^[[:blank:]]*dtoverlay=rpivid-v4l2$' /boot/config.txt && G_EXEC sed -i '/^[[:blank:]]*dtoverlay=rpivid-v4l2$/d' /boot/config.txt + grep -q '^[[:blank:]]*dtoverlay=rpivid-v4l2$' /boot/config.txt && G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*dtoverlay=rpivid-v4l2$/d' /boot/config.txt else Unknown_Input_Mode fi @@ -187,7 +187,7 @@ Description=DietPi-rm_program_usb_boot_mode.service [Service] Type=oneshot RemainAfterExit=yes -ExecStartPre=/bin/sed -i '/^[[:blank:]]*program_usb_boot_mode=/d' /boot/config.txt +ExecStartPre=/bin/sed --follow-symlinks -i '/^[[:blank:]]*program_usb_boot_mode=/d' /boot/config.txt ExecStartPre=/bin/systemctl disable dietpi-rm_program_usb_boot_mode ExecStart=/bin/rm /etc/systemd/system/dietpi-rm_program_usb_boot_mode.service @@ -199,7 +199,7 @@ _EOF_ elif [[ $INPUT_DEVICE_VALUE == 'disable' ]]; then - G_EXEC sed -i '/^[[:blank:]]*program_usb_boot_mode=/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*program_usb_boot_mode=/d' /boot/config.txt if [[ -f '/etc/systemd/system/dietpi-rm_program_usb_boot_mode.service' ]]; then @@ -271,7 +271,7 @@ _EOF_ if disable_error=1 G_CHECK_VALIDINT "$INPUT_DEVICE_VALUE" 16 944 then # Remove overridden "gpu_mem" setting - grep -q '^[[:blank:]]*gpu_mem=' /boot/config.txt && G_EXEC sed -i '/^[[:blank:]]*gpu_mem=/d' /boot/config.txt + grep -q '^[[:blank:]]*gpu_mem=' /boot/config.txt && G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*gpu_mem=/d' /boot/config.txt local gpu_mem=$INPUT_DEVICE_VALUE G_CONFIG_INJECT 'gpu_mem_1024=' "gpu_mem_1024=$gpu_mem" /boot/config.txt @@ -313,7 +313,7 @@ _EOF_ # Disable HDMI hotplug detection, which requires it to be generally responsive/active G_CONFIG_INJECT 'hdmi_ignore_hotplug=' 'hdmi_ignore_hotplug=1' /boot/config.txt # Disable SDTV on RPi4 (default) - G_EXEC sed -i '/^[[:blank:]]*enable_tvout=/c\#enable_tvout=0' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*enable_tvout=/c\#enable_tvout=0' /boot/config.txt # Odroid C2 legacy image, provided until December 2021 elif [[ $G_HW_MODEL == 12 && -f '/boot/boot.ini' ]]; then @@ -333,11 +333,11 @@ _EOF_ # RPi if (( $G_HW_MODEL < 10 )); then - G_EXEC sed -i '/^[[:blank:]]*max_framebuffers=/c\#max_framebuffers=2' /boot/config.txt - #G_EXEC sed -i '/^[[:blank:]]*disable_splash=/c\#disable_splash=0' /boot/config.txt - #G_EXEC sed -i '/^[[:blank:]]*hdmi_blanking=/c\#hdmi_blanking=0' /boot/config.txt - G_EXEC sed -i '/^[[:blank:]]*hdmi_ignore_hotplug=/c\#hdmi_ignore_hotplug=0' /boot/config.txt - G_EXEC sed -i '/^[[:blank:]]*enable_tvout=/c\#enable_tvout=0' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*max_framebuffers=/c\#max_framebuffers=2' /boot/config.txt + #G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*disable_splash=/c\#disable_splash=0' /boot/config.txt + #G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*hdmi_blanking=/c\#hdmi_blanking=0' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*hdmi_ignore_hotplug=/c\#hdmi_ignore_hotplug=0' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*enable_tvout=/c\#enable_tvout=0' /boot/config.txt # Odroid C2 legacy image, provided until December 2021 elif [[ $G_HW_MODEL == 12 && -f '/boot/boot.ini' ]]; then @@ -378,7 +378,7 @@ _EOF_ fi [[ -d '/etc/systemd/system/justboom-ir-mpd.service.d' ]] && G_EXEC rm -R /etc/systemd/system/justboom-ir-mpd.service.d - G_EXEC sed -i '/^[[:blank:]]*dtoverlay=gpio-ir/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*dtoverlay=gpio-ir/d' /boot/config.txt # Disable Odroids elif (( $G_HW_MODEL < 20 )); then @@ -648,7 +648,7 @@ _EOF_ local params=$(sed -En '/^[[:blank:]]*dtoverlay=vc4-f?kms-v3d(-pi4)?,/{s/^[^,]*//p;q}' /boot/config.txt) # Always remove previous VC4 overlay entry - G_EXEC sed -Ei '/^[[:blank:]]*dtoverlay=vc4-f?kms-v3d/d' /boot/config.txt + G_EXEC sed --follow-symlinks -Ei '/^[[:blank:]]*dtoverlay=vc4-f?kms-v3d/d' /boot/config.txt if [[ $INPUT_DEVICE_VALUE == 'vc4-kms-v3d' || $INPUT_DEVICE_VALUE == 'vc4-fkms-v3d' ]]; then @@ -728,11 +728,11 @@ _EOF_ (( $G_HW_MODEL > 9 )) && return 0 # Skip on non-RPi - G_EXEC sed -i '/^[[:blank:]]*hdmi_force_hotplug=/c\#hdmi_force_hotplug=1' /boot/config.txt - G_EXEC sed -i '/^[[:blank:]]*hdmi_group=/c\#hdmi_group=2' /boot/config.txt - G_EXEC sed -i '/^[[:blank:]]*hdmi_mode=/c\#hdmi_mode=87' /boot/config.txt - G_EXEC sed -i '/^[[:blank:]]*hdmi_cvt=/c\#hdmi_cvt=1024 600 60 6 0 0 0' /boot/config.txt - G_EXEC sed -i '/^[[:blank:]]*hdmi_drive=/c\#hdmi_drive=1' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*hdmi_force_hotplug=/c\#hdmi_force_hotplug=1' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*hdmi_group=/c\#hdmi_group=2' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*hdmi_mode=/c\#hdmi_mode=87' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*hdmi_cvt=/c\#hdmi_cvt=1024 600 60 6 0 0 0' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*hdmi_drive=/c\#hdmi_drive=1' /boot/config.txt } @@ -776,7 +776,7 @@ _EOF_ G_EXEC curl -sSfL 'https://raw.githubusercontent.com/waveshare/LCD-show/master/waveshare32b-overlay.dtb' -o /boot/overlays/waveshare32b.dtbo #consoleblank=0 no effect - G_EXEC sed -i 's/rootwait/rootwait fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo/' /boot/cmdline.txt + G_EXEC sed --follow-symlinks -i 's/rootwait/rootwait fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo/' /boot/cmdline.txt G_CONFIG_INJECT 'dtparam=i2c_arm=' 'dtparam=i2c_arm=on' /boot/config.txt G_CONFIG_INJECT 'dtparam=spi=' 'dtparam=spi=on' /boot/config.txt @@ -849,16 +849,16 @@ _EOF_ if (( $G_HW_MODEL < 10 )); then [[ -f '/boot/overlays/waveshare32b.dtbo' ]] && G_EXEC rm /boot/overlays/waveshare32b.dtbo - G_EXEC sed -i 's/ fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo//' /boot/cmdline.txt + G_EXEC sed --follow-symlinks -i 's/ fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo//' /boot/cmdline.txt - G_EXEC sed -i '/Waveshare 32 LCD/d' /boot/config.txt - G_EXEC sed -i '/^[[:blank:]]*dtoverlay=waveshare32b/d' /boot/config.txt - G_EXEC sed -i '/^[[:blank:]]*dtoverlay=ads7846,cs=1,penirq=17/d' /boot/config.txt - G_EXEC sed -i '/^[[:blank:]]*dtoverlay=w1-gpio-pullup,gpiopin=4,extpullup=1/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/Waveshare 32 LCD/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*dtoverlay=waveshare32b/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*dtoverlay=ads7846,cs=1,penirq=17/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*dtoverlay=w1-gpio-pullup,gpiopin=4,extpullup=1/d' /boot/config.txt # Leave these enabled, just in case the user has other hardware that may use them. - #G_EXEC sed -i '/^[[:blank:]]*dtparam=i2c_arm=/c\dtparam=i2c_arm=on' /boot/config.txt - #G_EXEC sed -i '/^[[:blank:]]*dtparam=spi=/c\dtparam=spi=on' /boot/config.txt + #G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*dtparam=i2c_arm=/c\dtparam=i2c_arm=on' /boot/config.txt + #G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*dtparam=spi=/c\dtparam=spi=on' /boot/config.txt # Move fb0 xorg.conf back: https://github.com/MichaIng/DietPi/issues/767 [[ -f '/usr/share/X11/99-fbturbo.conf' && ! -f '/usr/share/X11/xorg.conf.d/99-fbturbo.conf' ]] && G_EXEC mv /usr/share/X11/99-fbturbo.conf /usr/share/X11/xorg.conf.d/99-fbturbo.conf @@ -873,8 +873,8 @@ _EOF_ fi [[ -d '/etc/systemd/system/con2fbmap.service.d' ]] && G_EXEC rm -R /etc/systemd/system/con2fbmap.service.d [[ -f '/etc/modprobe.d/waveshare32.conf' ]] && G_EXEC rm /etc/modprobe.d/waveshare32.conf - G_EXEC sed -i '/^[[:blank:]]*spicc/d' /etc/modules - G_EXEC sed -i '/^[[:blank:]]*fbtft_device/d' /etc/modules + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*spicc/d' /etc/modules + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*fbtft_device/d' /etc/modules fi @@ -894,8 +894,8 @@ _EOF_ Lcd_Panel_Odroidcloudshell_Disable(){ [[ -f '/etc/modprobe.d/odroid-cloudshell.conf' ]] && G_EXEC rm /etc/modprobe.d/odroid-cloudshell.conf - G_EXEC sed -i '/^[[:blank:]]*spi_s3c64xx/d' /etc/modules - G_EXEC sed -i '/^[[:blank:]]*fbtft_device/d' /etc/modules + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*spi_s3c64xx/d' /etc/modules + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*fbtft_device/d' /etc/modules } @@ -1106,16 +1106,16 @@ _EOF_ G_CONFIG_INJECT 'dtparam=i2c_arm=' 'dtparam=i2c_arm=on' /boot/config.txt # DietPi-Software, set installed - [[ -f '/boot/dietpi/.installed' ]] && G_EXEC sed -i '/^aSOFTWARE_INSTALL_STATE\[72\]=/c\aSOFTWARE_INSTALL_STATE\[72\]=2' /boot/dietpi/.installed + [[ -f '/boot/dietpi/.installed' ]] && G_EXEC sed --follow-symlinks -i '/^aSOFTWARE_INSTALL_STATE\[72\]=/c\aSOFTWARE_INSTALL_STATE\[72\]=2' /boot/dietpi/.installed elif [[ $INPUT_DEVICE_VALUE == 'disable' ]]; then # Kernel modules - G_EXEC sed -i '/^[[:blank:]]*i2c-bcm2708/d' /etc/modules - G_EXEC sed -i '/^[[:blank:]]*i2c-dev/d' /etc/modules + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*i2c-bcm2708/d' /etc/modules + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*i2c-dev/d' /etc/modules # config.txt - G_EXEC sed -Ei 's/^[[:blank:]]*(dtparam=i2c.*)$/#\1/' /boot/config.txt + G_EXEC sed --follow-symlinks -Ei 's/^[[:blank:]]*(dtparam=i2c.*)$/#\1/' /boot/config.txt # Set baudrate (kHz) | valid int elif disable_error=1 G_CHECK_VALIDINT "$INPUT_DEVICE_VALUE" 2 10000000; then @@ -1153,7 +1153,7 @@ _EOF_ then # config.txt G_CONFIG_INJECT 'dtparam=spi=' 'dtparam=spi=off' /boot/config.txt - G_EXEC sed -i '/^[[:blank:]]*dtoverlay=spi[0-9]-[0-9]cs/d' /boot/config.txt # Alternative SPI interfaces and chip select lines + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*dtoverlay=spi[0-9]-[0-9]cs/d' /boot/config.txt # Alternative SPI interfaces and chip select lines # Disable in runtime seems to be possible? #dtparam spi=off @@ -1167,12 +1167,12 @@ _EOF_ if [[ $INPUT_DEVICE_VALUE == 'enable' ]] then # Add overlay to dietpiEnv.txt - grep -Eq '^[[:blank:]]*overlays=(.*[[:blank:]])?spi1-cs1-spidev([[:blank:]]|$)' "$FP_UENV" || G_EXEC sed -i '/^[[:blank:]]*overlays=/s/[[:blank:]]*$/ spi1-cs1-spidev/' "$FP_UENV" + grep -Eq '^[[:blank:]]*overlays=(.*[[:blank:]])?spi1-cs1-spidev([[:blank:]]|$)' "$FP_UENV" || G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*overlays=/s/[[:blank:]]*$/ spi1-cs1-spidev/' "$FP_UENV" elif [[ $INPUT_DEVICE_VALUE == 'disable' ]] then # Remove overlay from dietpiEnv.txt - grep -Eq '^[[:blank:]]*overlays=(.*[[:blank:]])?spi1-cs1-spidev([[:blank:]]|$)' "$FP_UENV" && G_EXEC sed -Ei '/^[[:blank:]]*overlays=/s/[[:blank:]]*spi1-cs1-spidev([[:blank:]]*$)?//g' "$FP_UENV" + grep -Eq '^[[:blank:]]*overlays=(.*[[:blank:]])?spi1-cs1-spidev([[:blank:]]|$)' "$FP_UENV" && G_EXEC sed --follow-symlinks -Ei '/^[[:blank:]]*overlays=/s/[[:blank:]]*spi1-cs1-spidev([[:blank:]]*$)?//g' "$FP_UENV" else Unknown_Input_Mode fi @@ -1258,7 +1258,7 @@ Do you want to continue and disable the serial login console?' || return 1 fi # Remove dtoverlay - G_EXEC sed -i '/^[[:blank:]]*dtoverlay=disable-bt/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*dtoverlay=disable-bt/d' /boot/config.txt G_AG_CHECK_INSTALL_PREREQ pi-bluetooth else @@ -1337,9 +1337,9 @@ Do you want to continue and disable the serial login console?' || return 1 echo -e 'net.ipv6.conf.all.disable_ipv6=1\nnet.ipv6.conf.default.disable_ipv6=1' > /etc/sysctl.d/dietpi-disable_ipv6.conf sysctl -qp /etc/sysctl.d/dietpi-disable_ipv6.conf # - Comment IPv6 specific host entries - sed -i 's/^::1[[:blank:]]/#::1 /' /etc/hosts - sed -i 's/^ff02::1[[:blank:]]/#ff02::1 /' /etc/hosts - sed -i 's/^ff02::2[[:blank:]]/#ff02::2 /' /etc/hosts + sed --follow-symlinks -i 's/^::1[[:blank:]]/#::1 /' /etc/hosts + sed --follow-symlinks -i 's/^ff02::1[[:blank:]]/#ff02::1 /' /etc/hosts + sed --follow-symlinks -i 's/^ff02::2[[:blank:]]/#ff02::2 /' /etc/hosts # - dietpi.txt entry G_CONFIG_INJECT 'CONFIG_ENABLE_IPV6=' 'CONFIG_ENABLE_IPV6=0' /boot/dietpi.txt @@ -1357,7 +1357,7 @@ Do you want to continue and disable the serial login console?' || return 1 [[ $i != '/etc/sysctl.d/dietpi-disable_ipv6.conf' && -f $i ]] || continue grep -q '^[[:blank:]]*net.ipv6.conf.[^[:blank:]]*.disable_ipv6[[:blank:]]*=' "$i" || continue i=$(readlink -f "$i") # https://github.com/MichaIng/DietPi/issues/3003#issuecomment-669464255 - sed -i 's/^[[:blank:]]*net.ipv6.conf.[^[:blank:]]*.disable_ipv6[[:blank:]]*=/#&/' "$i" + sed --follow-symlinks -i 's/^[[:blank:]]*net.ipv6.conf.[^[:blank:]]*.disable_ipv6[[:blank:]]*=/#&/' "$i" done } @@ -1469,7 +1469,7 @@ Do you want to continue and disable the serial login console?' || return 1 (( $G_HW_ONBOARD_WIFI )) || { Unsupported_Input_Mode; return 1; } # Remove dtoverlay - sed -i '/^[[:blank:]]*dtoverlay=disable-wifi/d' /boot/config.txt + sed --follow-symlinks -i '/^[[:blank:]]*dtoverlay=disable-wifi/d' /boot/config.txt elif [[ $INPUT_DEVICE_VALUE == 'onboard_disable' ]]; then @@ -1542,7 +1542,7 @@ Do you want to continue and disable the serial login console?' || return 1 # - RPi elif (( $G_HW_MODEL < 10 )) then - grep -q "console=$INPUT_ADDITIONAL" /boot/cmdline.txt || sed -i "/root=/s/$/ console=$INPUT_ADDITIONAL,115200/" /boot/cmdline.txt + grep -q "console=$INPUT_ADDITIONAL" /boot/cmdline.txt || sed --follow-symlinks -i "/root=/s/$/ console=$INPUT_ADDITIONAL,115200/" /boot/cmdline.txt # - Odroid C1/C2 legacy elif [[ $G_HW_MODEL == 1[02] && -f '/boot/boot.ini' ]] @@ -1578,7 +1578,7 @@ $(sed -n '/^ExecStart=/s/ 115200/ 1500000,115200/p' '/lib/systemd/system/serial- _EOF_ G_EXEC systemctl daemon-reload fi - (( $DIETPIENV )) && ! grep -q "^consoleargs=.*console=$INPUT_ADDITIONAL" "$FP_UENV" && sed -i "/^consoleargs=/s/[[:blank:]]*$/ console=$INPUT_ADDITIONAL,$baudrate/" "$FP_UENV" + (( $DIETPIENV )) && ! grep -q "^consoleargs=.*console=$INPUT_ADDITIONAL" "$FP_UENV" && sed --follow-symlinks -i "/^consoleargs=/s/[[:blank:]]*$/ console=$INPUT_ADDITIONAL,$baudrate/" "$FP_UENV" # - Armbian: armbianEnv.txt only allows to toggle a fixed serial console depending on device elif (( $ARMBIAN )) && grep -q "console=$INPUT_ADDITIONAL" /boot/boot.* @@ -1637,17 +1637,17 @@ _EOF_ # - RPi if (( $G_HW_MODEL < 10 )) then - sed -Ei "/root=/s/[[:blank:]]*console=${INPUT_ADDITIONAL}[^[:blank:]]*([[:blank:]]*$)?//g" /boot/cmdline.txt + sed --follow-symlinks -Ei "/root=/s/[[:blank:]]*console=${INPUT_ADDITIONAL}[^[:blank:]]*([[:blank:]]*$)?//g" /boot/cmdline.txt # - Odroid C1/C2/XU4 legacy elif [[ $G_HW_MODEL -le 12 && -f '/boot/boot.ini' ]] then - sed -i "s/[[:blank:]]*console=${INPUT_ADDITIONAL}[^\"[:blank:]]*//g" /boot/boot.ini + sed --follow-symlinks -i "s/[[:blank:]]*console=${INPUT_ADDITIONAL}[^\"[:blank:]]*//g" /boot/boot.ini # - dietpiEnv.txt, Quartz64, NanoPi R5S, NanoPi R6S elif (( $DIETPIENV || $G_HW_MODEL == 49 || $G_HW_MODEL == 76 || $G_HW_MODEL == 79 )) then - (( $DIETPIENV )) && grep -q "^consoleargs=.*console=$INPUT_ADDITIONAL" "$FP_UENV" && sed -Ei -e "/^consoleargs=/s/[[:blank:]]*console=${INPUT_ADDITIONAL}[^[:blank:]]*([[:blank:]]*$)?//g" -e 's/^consoleargs=[[:blank:]]+/consoleargs=/' "$FP_UENV" + (( $DIETPIENV )) && grep -q "^consoleargs=.*console=$INPUT_ADDITIONAL" "$FP_UENV" && sed --follow-symlinks -Ei -e "/^consoleargs=/s/[[:blank:]]*console=${INPUT_ADDITIONAL}[^[:blank:]]*([[:blank:]]*$)?//g" -e 's/^consoleargs=[[:blank:]]+/consoleargs=/' "$FP_UENV" [[ -f /etc/systemd/system/serial-getty@$INPUT_ADDITIONAL.service.d/dietpi-baudrate.conf ]] && G_EXEC rm "/etc/systemd/system/serial-getty@$INPUT_ADDITIONAL.service.d/dietpi-baudrate.conf" [[ -d /etc/systemd/system/serial-getty@$INPUT_ADDITIONAL.service.d ]] && G_EXEC rmdir --ignore-fail-on-non-empty "/etc/systemd/system/serial-getty@$INPUT_ADDITIONAL.service.d" @@ -1764,7 +1764,7 @@ _EOF_ Soundcard_Reset_RPi() { # Remove device tree overlays which disable HDMI audio and 3.5mm jack and those for known sound card, disable I2S and HDMI drive - G_EXEC sed -Ei -e '/^[[:blank:]]*(dtoverlay=(allo-|applepi-dac|dionaudio-|googlevoicehat-soundcard|hifiberry-|i-sabre-q2m|iqaudio-|justboom-|rpi-dac)|dtparam=i2s)/d' -e 's/^[[:blank:]]*(hdmi_drive(:[01])?=.*$)/#\1/' /boot/config.txt + G_EXEC sed --follow-symlinks -Ei -e '/^[[:blank:]]*(dtoverlay=(allo-|applepi-dac|dionaudio-|googlevoicehat-soundcard|hifiberry-|i-sabre-q2m|iqaudio-|justboom-|rpi-dac)|dtparam=i2s)/d' -e 's/^[[:blank:]]*(hdmi_drive(:[01])?=.*$)/#\1/' /boot/config.txt # Disable onboard sound G_CONFIG_INJECT 'dtparam=audio=' 'dtparam=audio=off' /boot/config.txt @@ -1773,11 +1773,11 @@ _EOF_ G_EXEC eval 'echo '\''blacklist snd_bcm2835'\'' > /etc/modprobe.d/dietpi-disable_rpi_audio.conf' # Remove kernel module options - G_EXEC sed -Ei '/root=/s/[[:blank:]]*snd_bcm2835.enable_[^[:blank:]]*([[:blank:]]*$)?//g' /boot/cmdline.txt + G_EXEC sed --follow-symlinks -Ei '/root=/s/[[:blank:]]*snd_bcm2835.enable_[^[:blank:]]*([[:blank:]]*$)?//g' /boot/cmdline.txt # Disable full KMS HDMI audio local kms=$(grep -Em1 '^[[:blank:]]*dtoverlay=vc4-kms-v3d(-pi4)?(,|$)' /boot/config.txt) - [[ $kms && ! $kms =~ ',noaudio'(,|$) ]] && G_EXEC sed -Ei '/^[[:blank:]]*dtoverlay=vc4-kms-v3d(-pi4)?(,|$)/s/$/,noaudio/' /boot/config.txt + [[ $kms && ! $kms =~ ',noaudio'(,|$) ]] && G_EXEC sed --follow-symlinks -Ei '/^[[:blank:]]*dtoverlay=vc4-kms-v3d(-pi4)?(,|$)/s/$/,noaudio/' /boot/config.txt # Use "auto" as default [[ $INPUT_DEVICE_VALUE == 'default' ]] && INPUT_DEVICE_VALUE='rpi-bcm2835-auto' @@ -1797,7 +1797,7 @@ _EOF_ [[ -d '/etc/systemd/system/odroid-hifishield2.service.d' ]] && G_EXEC rm -R /etc/systemd/system/odroid-hifishield2.service.d # HiFi Shield Plus and 2 kernel modules - G_EXEC sed -Ei '/^[[:blank:]]*snd-soc-(odroid-dac|pcm51)/d' /etc/modules + G_EXEC sed --follow-symlinks -Ei '/^[[:blank:]]*snd-soc-(odroid-dac|pcm51)/d' /etc/modules } Soundcard_Reset_OdroidN2() @@ -1818,10 +1818,10 @@ _EOF_ Soundcard_Reset_SparkySBC() { # Allo Piano DAC - G_EXEC sed -i '/^[[:blank:]]*snd-soc-allo-piano-dac/d' /etc/modules + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*snd-soc-allo-piano-dac/d' /etc/modules # Disable USB 1.1 compat - G_EXEC sed -i 's/aotg.aotg1_speed=1/aotg.aotg1_speed=0/' "$FP_UENV" + G_EXEC sed --follow-symlinks -i 's/aotg.aotg1_speed=1/aotg.aotg1_speed=0/' "$FP_UENV" # Set HDMI SOUNDCARD_TARGET_DEVICE=1 @@ -1842,7 +1842,7 @@ _EOF_ if (( $ARMBIAN || $DIETPIENV )) then # Remove analogue 3.5mm jack device tree overlay - grep -Eq '^[[:blank:]]*overlays=(.*[[:blank:]])?analog-codec([[:blank:]]|$)' "$FP_UENV" && G_EXEC sed -Ei '/^[[:blank:]]*overlays=/s/[[:blank:]]*analog-codec([[:blank:]]*$)?//g' "$FP_UENV" + grep -Eq '^[[:blank:]]*overlays=(.*[[:blank:]])?analog-codec([[:blank:]]|$)' "$FP_UENV" && G_EXEC sed --follow-symlinks -Ei '/^[[:blank:]]*overlays=/s/[[:blank:]]*analog-codec([[:blank:]]*$)?//g' "$FP_UENV" # Legacy else @@ -1914,7 +1914,7 @@ _EOF_ if (( $G_HW_MODEL == 70 )); then # USB 1.1 compat mode - [[ $INPUT_DEVICE_VALUE == *'1.1' ]] && G_EXEC sed -i 's/aotg\.aotg1_speed=0/aotg.aotg1_speed=1/' "$FP_UENV" + [[ $INPUT_DEVICE_VALUE == *'1.1' ]] && G_EXEC sed --follow-symlinks -i 's/aotg\.aotg1_speed=0/aotg.aotg1_speed=1/' "$FP_UENV" # Odroid C2: https://github.com/MichaIng/DietPi/issues/2101 elif (( $G_HW_MODEL == 12 )) && grep -q '^[[:blank:]]*63:.*dwc_otg' /proc/interrupts; then @@ -2009,13 +2009,13 @@ _EOF_ if [[ $INPUT_DEVICE_VALUE == *'3.5mm' ]] then # Disable HDMI audio via kernel module option - G_EXEC sed -i '/root=/s/$/ snd_bcm2835.enable_hdmi=0/' /boot/cmdline.txt + G_EXEC sed --follow-symlinks -i '/root=/s/$/ snd_bcm2835.enable_hdmi=0/' /boot/cmdline.txt # Force HDMI output? elif [[ $INPUT_DEVICE_VALUE == *'hdmi' ]] then # Disable headphones via kernel module option - G_EXEC sed -i '/root=/s/$/ snd_bcm2835.enable_headphones=0/' /boot/cmdline.txt + G_EXEC sed --follow-symlinks -i '/root=/s/$/ snd_bcm2835.enable_headphones=0/' /boot/cmdline.txt # Force HDMI audio via config.txt option G_CONFIG_INJECT 'hdmi_drive=' 'hdmi_drive=2' /boot/config.txt (( $G_HW_MODEL == 4 )) && G_CONFIG_INJECT 'hdmi_drive:1=' 'hdmi_drive:1=2' /boot/config.txt 'hdmi_drive=' @@ -2025,7 +2025,7 @@ _EOF_ if [[ $INPUT_DEVICE_VALUE != *'3.5mm' ]] then local kms=$(grep -Em1 '^[[:blank:]]*dtoverlay=vc4-kms-v3d(-pi4)?,(noaudio|.+,noaudio)(,|$)' /boot/config.txt) - [[ $kms ]] && G_EXEC sed -Ei '/^[[:blank:]]*dtoverlay=vc4-kms-v3d(-pi4)?,/s/,noaudio(,|$)/\1/' /boot/config.txt + [[ $kms ]] && G_EXEC sed --follow-symlinks -Ei '/^[[:blank:]]*dtoverlay=vc4-kms-v3d(-pi4)?,/s/,noaudio(,|$)/\1/' /boot/config.txt fi ;; @@ -2172,7 +2172,7 @@ _EOF_ if (( $ARMBIAN || $DIETPIENV )) then # Add analogue 3.5mm jack device tree overlay - G_EXEC sed -i '/^[[:blank:]]*overlays=/s/[[:blank:]]*$/ analog-codec/' "$FP_UENV" + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*overlays=/s/[[:blank:]]*$/ analog-codec/' "$FP_UENV" # Legacy else diff --git a/dietpi/func/dietpi-set_software b/dietpi/func/dietpi-set_software index c2c9baa77a..4198589182 100755 --- a/dietpi/func/dietpi-set_software +++ b/dietpi/func/dietpi-set_software @@ -129,10 +129,10 @@ deb https://deb.debian.org/debian-security/ $G_DISTRO_NAME/updates main contrib deb $INPUT_MODE_VALUE $G_DISTRO_NAME-backports main contrib non-free' > /etc/apt/sources.list" # Since Bullseye, dir structure has changed: https://deb.debian.org/debian-security/dists/ - (( $G_DISTRO > 5 )) && G_EXEC sed -i '3s|/updates|-security|' /etc/apt/sources.list + (( $G_DISTRO > 5 )) && G_EXEC sed --follow-symlinks -i '3s|/updates|-security|' /etc/apt/sources.list # Since Bookworm, non-free firmware has been moved to new component: https://deb.debian.org/debian/pool/ - (( $G_DISTRO > 6 )) && G_EXEC sed -i 's/$/ non-free-firmware/' /etc/apt/sources.list + (( $G_DISTRO > 6 )) && G_EXEC sed --follow-symlinks -i 's/$/ non-free-firmware/' /etc/apt/sources.list # Update dietpi.txt entry G_CONFIG_INJECT 'CONFIG_APT_DEBIAN_MIRROR=' "CONFIG_APT_DEBIAN_MIRROR=$INPUT_MODE_VALUE" /boot/dietpi.txt @@ -178,12 +178,12 @@ deb $INPUT_MODE_VALUE $G_DISTRO_NAME-backports main contrib non-free' > /etc/apt G_CONFIG_INJECT 'Dir::Cache[[:blank:]]' 'Dir::Cache "/tmp/apt";' "$fp" GCI_PRESERVE=1 G_CONFIG_INJECT 'Dir::Cache::archives[[:blank:]]' 'Dir::Cache::archives "/var/cache/apt/archives";' "$fp" - sed -i '/pkgcache[[:blank:]]/d' "$fp" + sed --follow-symlinks -i '/pkgcache[[:blank:]]/d' "$fp" [[ -d '/var/cache/apt' ]] && G_EXEC rm -R /var/cache/apt elif [[ $INPUT_ADDITIONAL_1 == 'disk' ]]; then - sed -i '/^Dir::Cache/d' "$fp" + sed --follow-symlinks -i '/^Dir::Cache/d' "$fp" [[ -d '/tmp/apt' ]] && G_EXEC rm -R /tmp/apt fi @@ -199,7 +199,7 @@ deb $INPUT_MODE_VALUE $G_DISTRO_NAME-backports main contrib non-free' > /etc/apt elif [[ $INPUT_ADDITIONAL_1 == 'disk' ]]; then - sed -i '/^Dir::State/d' "$fp" + sed --follow-symlinks -i '/^Dir::State/d' "$fp" [[ -d '/tmp/apt' ]] && G_EXEC rm -R /tmp/apt fi @@ -354,20 +354,20 @@ deb $INPUT_MODE_VALUE $G_DISTRO_NAME-backports main contrib non-free' > /etc/apt if [[ $INPUT_MODE_VALUE == 'eth_dhcp' ]]; then G_CONFIG_INJECT 'iface eth' 'iface eth0 inet dhcp' /etc/network/interfaces - sed -i '0,/^.*dns-nameservers[[:blank:]].*$/s//#dns-nameservers 9.9.9.9 149.112.112.112/' /etc/network/interfaces + sed --follow-symlinks -i '0,/^.*dns-nameservers[[:blank:]].*$/s//#dns-nameservers 9.9.9.9 149.112.112.112/' /etc/network/interfaces elif [[ $INPUT_MODE_VALUE == 'eth_static' ]]; then G_CONFIG_INJECT 'iface eth' 'iface eth0 inet static' /etc/network/interfaces - [[ $INPUT_ADDITIONAL_1 ]] && sed -i "0,\|^.*address[[:blank:]].*\$|s||address $INPUT_ADDITIONAL_1|" /etc/network/interfaces - [[ $INPUT_ADDITIONAL_2 ]] && sed -i "0,\|^.*gateway[[:blank:]].*\$|s||gateway $INPUT_ADDITIONAL_2|" /etc/network/interfaces - [[ $INPUT_ADDITIONAL_3 ]] && sed -i "0,\|^.*netmask[[:blank:]].*\$|s||netmask $INPUT_ADDITIONAL_3|" /etc/network/interfaces + [[ $INPUT_ADDITIONAL_1 ]] && sed --follow-symlinks -i "0,\|^.*address[[:blank:]].*\$|s||address $INPUT_ADDITIONAL_1|" /etc/network/interfaces + [[ $INPUT_ADDITIONAL_2 ]] && sed --follow-symlinks -i "0,\|^.*gateway[[:blank:]].*\$|s||gateway $INPUT_ADDITIONAL_2|" /etc/network/interfaces + [[ $INPUT_ADDITIONAL_3 ]] && sed --follow-symlinks -i "0,\|^.*netmask[[:blank:]].*\$|s||netmask $INPUT_ADDITIONAL_3|" /etc/network/interfaces [[ $INPUT_ADDITIONAL_4 ]] || return 0 if command -v resolvconf > /dev/null then - sed -i "0,\|^.*dns-nameservers[[:blank:]].*\$|s||dns-nameservers $INPUT_ADDITIONAL_4|" /etc/network/interfaces + sed --follow-symlinks -i "0,\|^.*dns-nameservers[[:blank:]].*\$|s||dns-nameservers $INPUT_ADDITIONAL_4|" /etc/network/interfaces else - sed -i "0,\|^.*dns-nameservers[[:blank:]].*\$|s||#dns-nameservers $INPUT_ADDITIONAL_4|" /etc/network/interfaces + sed --follow-symlinks -i "0,\|^.*dns-nameservers[[:blank:]].*\$|s||#dns-nameservers $INPUT_ADDITIONAL_4|" /etc/network/interfaces > /etc/resolv.conf local i for i in $INPUT_ADDITIONAL_4; do echo "nameserver $i" >> /etc/resolv.conf; done @@ -444,7 +444,7 @@ deb $INPUT_MODE_VALUE $G_DISTRO_NAME-backports main contrib non-free' > /etc/apt G_EXEC_DESC='Downloading current dietpi.txt' G_EXEC curl -sSfL "https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/dietpi.txt" -o dietpi.txt_patch # Remove empty and commented lines, and do not re-add the password setting, which is intended to stay commented after first boot - sed -Ei '/^[[:blank:]]*(#|$|AUTO_SETUP_GLOBAL_PASSWORD=)/d' dietpi.txt_patch + sed --follow-symlinks -Ei '/^[[:blank:]]*(#|$|AUTO_SETUP_GLOBAL_PASSWORD=)/d' dietpi.txt_patch local line entry value while read -r line @@ -504,7 +504,7 @@ deb $INPUT_MODE_VALUE $G_DISTRO_NAME-backports main contrib non-free' > /etc/apt if [[ $pw_dietpi_software ]] then # Remove plain text password from dietpi.txt - grep -q '^[[:blank:]]*AUTO_SETUP_GLOBAL_PASSWORD=' /boot/dietpi.txt && G_EXEC sed -i '/^[[:blank:]]*AUTO_SETUP_GLOBAL_PASSWORD=/c\#AUTO_SETUP_GLOBAL_PASSWORD= # Password has been encrypted and saved to rootfs' /boot/dietpi.txt + grep -q '^[[:blank:]]*AUTO_SETUP_GLOBAL_PASSWORD=' /boot/dietpi.txt && G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*AUTO_SETUP_GLOBAL_PASSWORD=/c\#AUTO_SETUP_GLOBAL_PASSWORD= # Password has been encrypted and saved to rootfs' /boot/dietpi.txt [[ -d '/var/lib/dietpi/dietpi-software' ]] || G_EXEC mkdir -p /var/lib/dietpi/dietpi-software # Should already exist, failsafe diff --git a/dietpi/func/dietpi-set_swapfile b/dietpi/func/dietpi-set_swapfile index 0709d1b21d..700175d0bc 100755 --- a/dietpi/func/dietpi-set_swapfile +++ b/dietpi/func/dietpi-set_swapfile @@ -84,7 +84,7 @@ G_DIETPI-NOTIFY 2 'Disabling and deleting all existing swap files' (( $G_HW_MODEL == 75 )) || grep -zaq '^container=' /proc/1/environ || G_EXEC swapoff -a rm -fv "${SWAP_FILES_ACTIVE[@]}" - sed -i '/[[:blank:]]swap[[:blank:]]/d' /etc/fstab + sed --follow-symlinks -i '/[[:blank:]]swap[[:blank:]]/d' /etc/fstab # zram-swap [[ -f '/etc/modules-load.d/dietpi-zram-swap.conf' ]] && rm -v /etc/modules-load.d/dietpi-zram-swap.conf [[ -f '/etc/udev/rules.d/98-dietpi-zram-swap.rules' ]] && rm -v /etc/udev/rules.d/98-dietpi-zram-swap.rules diff --git a/dietpi/misc/dietpi-justboom b/dietpi/misc/dietpi-justboom index 36494f79b0..4f3d5d3c3c 100755 --- a/dietpi/misc/dietpi-justboom +++ b/dietpi/misc/dietpi-justboom @@ -146,29 +146,29 @@ Please select a sound card via 'dietpi-config' or install ALSA, or ideally an au if (( $MPD_INSTALLED )); then # Output format: Apply only if any value is enforced - G_EXEC sed -Ei '/^[[:blank:]]*type[[:blank:]]+"alsa"/,/^[[:blank:]]*}$/{/^[[:blank:]#]*format[[:blank:]]/d}' "$FP_MPD_CONF" - [[ $OUTPUT_FREQ$OUTPUT_BITRATE$OUTPUT_CHANNELS == '***' ]] || G_EXEC sed -Ei "/^[[:blank:]]*type[[:blank:]]+\"alsa\"/a\ format \"$OUTPUT_FREQ:$OUTPUT_BITRATE:$OUTPUT_CHANNELS\"" "$FP_MPD_CONF" + G_EXEC sed --follow-symlinks -Ei '/^[[:blank:]]*type[[:blank:]]+"alsa"/,/^[[:blank:]]*}$/{/^[[:blank:]#]*format[[:blank:]]/d}' "$FP_MPD_CONF" + [[ $OUTPUT_FREQ$OUTPUT_BITRATE$OUTPUT_CHANNELS == '***' ]] || G_EXEC sed --follow-symlinks -Ei "/^[[:blank:]]*type[[:blank:]]+\"alsa\"/a\ format \"$OUTPUT_FREQ:$OUTPUT_BITRATE:$OUTPUT_CHANNELS\"" "$FP_MPD_CONF" if (( $SOXR_ENABLED )); then G_CONFIG_INJECT 'samplerate_converter[[:blank:]]' "samplerate_converter \"soxr $SOXR_QUALITY\"" "$FP_MPD_CONF" if [[ $OUTPUT_FREQ$OUTPUT_BITRATE$OUTPUT_CHANNELS == '***' ]] then - G_EXEC sed -i '/audio_output_format[[:blank:]]/d' "$FP_MPD_CONF" + G_EXEC sed --follow-symlinks -i '/audio_output_format[[:blank:]]/d' "$FP_MPD_CONF" else G_CONFIG_INJECT 'audio_output_format[[:blank:]]' "audio_output_format \"$OUTPUT_FREQ:$OUTPUT_BITRATE:$OUTPUT_CHANNELS\"" "$FP_MPD_CONF" fi else - G_EXEC sed -i '/samplerate_converter[[:blank:]]/d' "$FP_MPD_CONF" - G_EXEC sed -i '/audio_output_format[[:blank:]]/d' "$FP_MPD_CONF" + G_EXEC sed --follow-symlinks -i '/samplerate_converter[[:blank:]]/d' "$FP_MPD_CONF" + G_EXEC sed --follow-symlinks -i '/audio_output_format[[:blank:]]/d' "$FP_MPD_CONF" fi # Buffer if [[ $MPD_AUDIO_BUFFER_SIZE == '*' ]] then - G_EXEC sed -i '/audio_buffer_size[[:blank:]]/d' "$FP_MPD_CONF" + G_EXEC sed --follow-symlinks -i '/audio_buffer_size[[:blank:]]/d' "$FP_MPD_CONF" else G_CONFIG_INJECT 'audio_buffer_size[[:blank:]]' "audio_buffer_size \"$MPD_AUDIO_BUFFER_SIZE\"" "$FP_MPD_CONF" fi diff --git a/dietpi/patch_file b/dietpi/patch_file index 3d790605fc..ed32c869e8 100755 --- a/dietpi/patch_file +++ b/dietpi/patch_file @@ -28,7 +28,7 @@ # Disable and remove service and mount systemctl disable dietpi-ramdisk umount -Rl /DietPi - sed -i '/[[:blank:]]\/DietPi[[:blank:]]/d' /etc/fstab + sed --follow-symlinks -i '/[[:blank:]]\/DietPi[[:blank:]]/d' /etc/fstab rm -Rf /DietPi /boot/dietpi/{,func/}dietpi-ramdisk /etc/systemd/system/dietpi-ramdisk.service # Create symlink for backwards compatibility @@ -42,11 +42,11 @@ [[ -d '/run/dietpi' ]] || { mkdir -p /run/dietpi; chmod 777 /run/dietpi; } # Pre-v6.22: Update Git owner due to official lead transfer from Fourdee to MichaIng: https://github.com/MichaIng/DietPi/issues/2589 - grep -q '^[[:blank:]]*DEV_GITOWNER=Fourdee' /boot/dietpi.txt && sed -i '/^[[:blank:]]*DEV_GITOWNER=/c\DEV_GITOWNER=MichaIng' /boot/dietpi.txt + grep -q '^[[:blank:]]*DEV_GITOWNER=Fourdee' /boot/dietpi.txt && sed --follow-symlinks -i '/^[[:blank:]]*DEV_GITOWNER=/c\DEV_GITOWNER=MichaIng' /boot/dietpi.txt if [[ -f '/boot/dietpi/.version' ]] && grep -q '^G_GITOWNER=Fourdee' /boot/dietpi/.version; then - sed -i '/^G_GITOWNER=/c\G_GITOWNER=MichaIng' /boot/dietpi/.version + sed --follow-symlinks -i '/^G_GITOWNER=/c\G_GITOWNER=MichaIng' /boot/dietpi/.version # Pre-v6.17: New ".version" system # - As loaded pre-v6.17 dietpi-update will overwrite ".version" to previous 2/3 line system, we need to rerun dietpi-update. @@ -242,7 +242,7 @@ _EOF_ #------------------------------------------------------------------------------- # Fix rare WiFi interface start issue: https://github.com/MichaIng/DietPi/issues/2074 # shellcheck disable=SC2016 - [[ -f '/etc/network/if-pre-up.d/wireless-tools' ]] && sed -i '\|^[[:blank:]]ifconfig "$IFACE" up$|c\\t/sbin/ip link set dev "$IFACE" up' /etc/network/if-pre-up.d/wireless-tools + [[ -f '/etc/network/if-pre-up.d/wireless-tools' ]] && sed --follow-symlinks -i '\|^[[:blank:]]ifconfig "$IFACE" up$|c\\t/sbin/ip link set dev "$IFACE" up' /etc/network/if-pre-up.d/wireless-tools #------------------------------------------------------------------------------- elif (( $G_DIETPI_VERSION_SUB == 16 )); then @@ -253,8 +253,8 @@ _EOF_ # - On v6.15 this was missing in PREP, thus images created meanwhile, so redo with v6.17 patch: [[ -d '/root/.ssh' ]] || G_EXEC mkdir /root/.ssh [[ -f '/root/.ssh/known_hosts' ]] || > /root/.ssh/known_hosts - G_EXEC sed -i '/^dietpi.com/d' /root/.ssh/known_hosts - G_EXEC sed -i '/^185.101.93.93/d' /root/.ssh/known_hosts + G_EXEC sed --follow-symlinks -i '/^dietpi.com/d' /root/.ssh/known_hosts + G_EXEC sed --follow-symlinks -i '/^185.101.93.93/d' /root/.ssh/known_hosts if (( $G_DISTRO < 7 )) then G_CONFIG_INJECT '\[?ssh.dietpi.com(]:29248)?[[:blank:]]' '[ssh.dietpi.com]:29248 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDE6aw3r6aOEqendNu376iiCHr9tGBIWPgfrLkzjXjEsHGyVSUFNnZt6pftrDeK7UX+qX4FxOwQlugG4fymOHbimRCFiv6cf7VpYg1Ednquq9TLb7/cIIbX8a6AuRmX4fjdGuqwmBq3OG7ZksFcYEFKt5U4mAJIaL8hXiM2iXjgY02LqiQY/QWATsHI4ie9ZOnwrQE+Rr6mASN1BVFuIgyHIbwX54jsFSnZ/7CdBMkuAd9B8JkxppWVYpYIFHE9oWNfjh/epdK8yv9Oo6r0w5Rb+4qaAc5g+RAaknHeV6Gp75d2lxBdCm5XknKKbGma2+/DfoE8WZTSgzXrYcRlStYN' /root/.ssh/known_hosts @@ -266,7 +266,7 @@ _EOF_ [[ $G_HW_MODEL == 43 && -f '/etc/X11/xorg.conf.d/20-armsoc.conf' ]] && G_EXEC rm /etc/X11/xorg.conf.d/20-armsoc.conf #------------------------------------------------------------------------------- # Convert and remove old dietpi.txt entry (this includes the comment) - grep -q 'CONFIG_PREFER_IPVERSION' /boot/dietpi.txt && G_EXEC sed -i '/CONFIG_PREFER_IPVERSION/d' /boot/dietpi.txt + grep -q 'CONFIG_PREFER_IPVERSION' /boot/dietpi.txt && G_EXEC sed --follow-symlinks -i '/CONFIG_PREFER_IPVERSION/d' /boot/dietpi.txt #------------------------------------------------------------------------------- # Update IPv6 handling: https://github.com/MichaIng/DietPi/issues/2027 # - Advice user to re-enable IPv6 on kernel level @@ -290,7 +290,7 @@ We strongly recommend you select "0 : Re-enable IPv6 on kernel level". By doing local i for i in /etc/modprobe.d/* do - [[ -f $i ]] && sed -i 's/^[[:blank:]]*blacklist[[:blank:]]ipv6/#&/' "$i" + [[ -f $i ]] && sed --follow-symlinks -i 's/^[[:blank:]]*blacklist[[:blank:]]ipv6/#&/' "$i" done # Remove boot cmd line entry @@ -298,20 +298,20 @@ We strongly recommend you select "0 : Re-enable IPv6 on kernel level". By doing if (( $G_HW_MODEL < 10 )); then # Separately remove with leading and trailing blank, since we don't know, if it's first or last argument and we must not remove both blanks - sed -i '/^[[:blank:]]*root=/s/[[:blank:]]ipv6.disable=1//' /boot/cmdline.txt - sed -i '/^[[:blank:]]*root=/s/ipv6.disable=1[[:blank:]]//' /boot/cmdline.txt + sed --follow-symlinks -i '/^[[:blank:]]*root=/s/[[:blank:]]ipv6.disable=1//' /boot/cmdline.txt + sed --follow-symlinks -i '/^[[:blank:]]*root=/s/ipv6.disable=1[[:blank:]]//' /boot/cmdline.txt # - Odroid elif (( $G_HW_MODEL < 20 )); then - sed -i '/^[[:blank:]]*setenv boot/s/[[:blank:]]ipv6.disable=1//' /boot/boot.ini - sed -i '/^[[:blank:]]*setenv boot/s/ipv6.disable=1[[:blank:]]//' /boot/boot.ini + sed --follow-symlinks -i '/^[[:blank:]]*setenv boot/s/[[:blank:]]ipv6.disable=1//' /boot/boot.ini + sed --follow-symlinks -i '/^[[:blank:]]*setenv boot/s/ipv6.disable=1[[:blank:]]//' /boot/boot.ini # - x86 elif (( $G_HW_ARCH == 10 )); then - sed -i '/^[[:blank:]]*GRUB_CMDLINE_LINUX_DEFAULT="/s/[[:blank:]]ipv6.disable=1//' /etc/default/grub - sed -i '/^[[:blank:]]*GRUB_CMDLINE_LINUX_DEFAULT="/s/ipv6.disable=1[[:blank:]]//' /etc/default/grub + sed --follow-symlinks -i '/^[[:blank:]]*GRUB_CMDLINE_LINUX_DEFAULT="/s/[[:blank:]]ipv6.disable=1//' /etc/default/grub + sed --follow-symlinks -i '/^[[:blank:]]*GRUB_CMDLINE_LINUX_DEFAULT="/s/ipv6.disable=1[[:blank:]]//' /etc/default/grub update-grub fi @@ -353,7 +353,7 @@ We strongly recommend you select "0 : Re-enable IPv6 on kernel level". By doing G_EXEC rm -Rf /boot/dietpi/{.patch_emr,dietpi-{obtain_hw_model,cpu_set,ramlog,logclear,banner}} #------------------------------------------------------------------------------- # Remove www-data under sudo without PW: https://github.com/MichaIng/DietPi/issues/2121 - G_EXEC sed -i '/^www-data ALL=NOPASSWD: ALL/d' /etc/sudoers + G_EXEC sed --follow-symlinks -i '/^www-data ALL=NOPASSWD: ALL/d' /etc/sudoers #------------------------------------------------------------------------------- elif (( $G_DIETPI_VERSION_SUB == 17 )); then @@ -550,15 +550,15 @@ We strongly recommend you select "0 : Re-enable IPv6 on kernel level". By doing (( $G_DIETPI_INSTALL_STAGE == 2 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[168\]=2' /boot/dietpi/.installed && G_CONFIG_INJECT 'DAEMON_ARGS=' "DAEMON_ARGS='-c /etc/turnserver.conf -o -l stdout --no-stdout-log --simple-log'" /etc/default/coturn #------------------------------------------------------------------------------- # Remove nofail and x-systemd.automount option from /boot mount: https://github.com/MichaIng/DietPi/pull/2357#issuecomment-449177715 - G_EXEC sed -i '\|[[:blank:]]/boot[[:blank:]]|s|,x-systemd.automount||' /etc/fstab - G_EXEC sed -i '\|[[:blank:]]/boot[[:blank:]]|s|,nofail||' /etc/fstab + G_EXEC sed --follow-symlinks -i '\|[[:blank:]]/boot[[:blank:]]|s|,x-systemd.automount||' /etc/fstab + G_EXEC sed --follow-symlinks -i '\|[[:blank:]]/boot[[:blank:]]|s|,nofail||' /etc/fstab #------------------------------------------------------------------------------- # Re-enable owncloud/Nextcloud Apache configs, to fix faulty v6.19 installs: https://github.com/MichaIng/DietPi/pull/2361/commits/e33ca150cf29a4f278f5df2defc495053700a91e [[ -f '/etc/apache2/sites-available/dietpi-owncloud.conf' ]] && G_EXEC a2ensite dietpi-owncloud [[ -f '/etc/apache2/sites-available/dietpi-nextcloud.conf' ]] && G_EXEC a2ensite dietpi-nextcloud #------------------------------------------------------------------------------- # Clear install state for Medusa - [[ $G_DIETPI_INSTALL_STAGE == 2 && ! -d '/mnt/dietpi_userdata/medusa' ]] && sed -i '/^aSOFTWARE_INSTALL_STATE\[116\]=/d' /boot/dietpi/.installed + [[ $G_DIETPI_INSTALL_STAGE == 2 && ! -d '/mnt/dietpi_userdata/medusa' ]] && sed --follow-symlinks -i '/^aSOFTWARE_INSTALL_STATE\[116\]=/d' /boot/dietpi/.installed # - Inform user about SickRage being replaced by Medusa if [[ -d '/etc/sickrage' || -d '/mnt/dietpi_userdata/sickrage' ]]; then @@ -579,16 +579,16 @@ Also have a look at "Sonarr", another alternative TV show manager, available for if (( $G_HW_MODEL < 10 )); then # Remove/Replace obsolete config.txt settings - G_EXEC sed -i 's/display_rotate/display_hdmi_rotate/' /boot/config.txt - G_EXEC sed -i '/disable_pvt/d' /boot/config.txt - G_EXEC sed -i '/avoid_pwm_pll/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i 's/display_rotate/display_hdmi_rotate/' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/disable_pvt/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/avoid_pwm_pll/d' /boot/config.txt # Remove doubled AUTO_SETUP_HEADLESS entry, introduced with Beta v6.20.2 if (( $(grep -c '^[[:blank:]]*AUTO_SETUP_HEADLESS=' /boot/dietpi.txt) > 1 )); then # Last match is the correct one, added by "dietpi-set_hardware headless 1" local current=$(grep '^[[:blank:]]*AUTO_SETUP_HEADLESS=' /boot/dietpi.txt | tail -1 | sed 's/^[^=]*=//') - G_EXEC sed -i '/^[[:blank:]]*AUTO_SETUP_HEADLESS=/d' /boot/dietpi.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*AUTO_SETUP_HEADLESS=/d' /boot/dietpi.txt G_EXEC eval "echo 'AUTO_SETUP_HEADLESS=$current' >> /boot/dietpi.txt" fi @@ -597,7 +597,7 @@ Also have a look at "Sonarr", another alternative TV show manager, available for grep -q '^[[:blank:]]*CONFIG_HDMI_OUTPUT=0' /boot/dietpi.txt && /boot/dietpi/func/dietpi-set_hardware headless 1 # Renamed to: AUTO_SETUP_HEADLESS (added by verify_dietpi.txt automatically) - G_EXEC sed -i '/CONFIG_HDMI_OUTPUT/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/CONFIG_HDMI_OUTPUT/d' /boot/config.txt fi #------------------------------------------------------------------------------- @@ -605,7 +605,7 @@ Also have a look at "Sonarr", another alternative TV show manager, available for G_AGI procps #------------------------------------------------------------------------------- # Remove wireless-power setting from /etc/network/interfaces, if not supported by adapter/firmware: https://github.com/MichaIng/DietPi/issues/2198 - iwconfig "$(G_GET_NET -q -t wlan iface)" power off &> /dev/null || sed -i '/^wireless-power/d' /etc/network/interfaces + iwconfig "$(G_GET_NET -q -t wlan iface)" power off &> /dev/null || sed --follow-symlinks -i '/^wireless-power/d' /etc/network/interfaces #------------------------------------------------------------------------------- # Remove Armbian banner/profiles left on ASUS TB image G_EXEC rm -f /etc/profile.d/armbian-* @@ -627,7 +627,7 @@ Also have a look at "Sonarr", another alternative TV show manager, available for #------------------------------------------------------------------------------- # Redo our /etc/bash.bashrc entry, user confirmed 4 entries: https://github.com/MichaIng/DietPi/issues/2529 # As well allow ".bash" file ending and remove obsolete dietpi-*.sh scripts: https://github.com/MichaIng/DietPi/pull/2636 - G_EXEC sed -i '\#for i in /etc/bashrc#d' /etc/bash.bashrc + G_EXEC sed --follow-symlinks -i '\#for i in /etc/bashrc#d' /etc/bash.bashrc # shellcheck disable=SC2016 G_CONFIG_INJECT '.*/etc/bashrc\.d/.*' 'for i in /etc/bashrc.d/*.sh /etc/bashrc.d/*.bash; do [ -r "$i" ] && . $i; done' /etc/bash.bashrc G_EXEC rm -f /etc/bashrc.d/dietpi-*.sh @@ -662,8 +662,8 @@ Do you still want to keep "p7zip-full"?'; then # MPD: Fix permissions issue: https://github.com/MichaIng/DietPi/issues/2462 if [[ -f '/etc/mpd.conf' ]]; then - G_EXEC sed -Ei '/^(user|group)[[:blank:]]/d' /etc/mpd.conf - G_EXEC sed -i '/^Group=/d' /lib/systemd/system/mpd.service + G_EXEC sed --follow-symlinks -Ei '/^(user|group)[[:blank:]]/d' /etc/mpd.conf + G_EXEC sed --follow-symlinks -i '/^Group=/d' /lib/systemd/system/mpd.service G_CONFIG_INJECT 'User=' 'User=mpd' /lib/systemd/system/mpd.service '\[Service\]' G_CONFIG_INJECT 'PermissionsStartOnly=' 'PermissionsStartOnly=true' /lib/systemd/system/mpd.service '^User=mpd' getent passwd mpd > /dev/null && G_EXEC usermod -aG audio,dietpi mpd @@ -707,7 +707,7 @@ _EOF_ fi #------------------------------------------------------------------------------- # RPi | Remove "framebuffer_depth" handling: https://github.com/MichaIng/DietPi/pull/2635 - (( $G_HW_MODEL < 10 )) && G_EXEC sed -i '/framebuffer_depth/d' /boot/config.txt + (( $G_HW_MODEL < 10 )) && G_EXEC sed --follow-symlinks -i '/framebuffer_depth/d' /boot/config.txt #------------------------------------------------------------------------------- # Nextcloud: Add OCM/OCS provider redirects as this is checked and printed as warning on admin panel: https://github.com/MichaIng/DietPi/issues/2638 if [[ -f '/etc/apache2/sites-available/dietpi-nextcloud.conf' ]] && @@ -805,12 +805,12 @@ NB: When accessing "deluge-console" you need to do that as user "debian-deluged" done #------------------------------------------------------------------------------- # Patch proxy settings changes: https://github.com/MichaIng/DietPi/pull/2716 - sed -i '/^[[:blank:]]*CONFIG_PROXY_ENABLED=/d' /boot/dietpi.txt + sed --follow-symlinks -i '/^[[:blank:]]*CONFIG_PROXY_ENABLED=/d' /boot/dietpi.txt local proxy='' if proxy=$(grep '^[[:blank:]]*export {http,https,ftp}_proxy=' /etc/bash.bashrc); then [[ -f '/etc/bashrc.d/dietpi-proxy.sh' ]] || echo "$proxy" > /etc/bashrc.d/dietpi-proxy.sh - G_EXEC sed -i '/^[[:blank:]]*export {http,https,ftp}_proxy=/d' /etc/bash.bashrc + G_EXEC sed --follow-symlinks -i '/^[[:blank:]]*export {http,https,ftp}_proxy=/d' /etc/bash.bashrc fi #------------------------------------------------------------------------------- @@ -832,11 +832,11 @@ Further info and usage: https://dietpi.com/forum/t/dietpi-arr-to-ram-link-sonarr if [[ -f '/etc/wireguard/wg0.conf' ]] && ! grep -q 'sysctl' /etc/wireguard/wg0.conf; then [[ -f '/etc/sysctl.d/dietpi-wireguard.conf' ]] && G_EXEC rm /etc/sysctl.d/dietpi-wireguard.conf - sed -i "/^ListenPort/a\PostUp = sysctl net.ipv4.conf.%i.forwarding=1 net.ipv4.conf.\$(ip r l 0/0 | mawk '{print \$5;exit}').forwarding=1" /etc/wireguard/wg0.conf - sed -i "/^ListenPort/a\PostUp = sysctl net.ipv6.conf.\$(ip r l 0/0 | mawk '{print \$5;exit}').accept_ra=2" /etc/wireguard/wg0.conf - sed -i "/^ListenPort/a\PostUp = sysctl net.ipv6.conf.%i.forwarding=1 net.ipv6.conf.\$(ip r l 0/0 | mawk '{print \$5;exit}').forwarding=1" /etc/wireguard/wg0.conf - sed -i "/^ListenPort/a\PostUp = ip6tables -A FORWARD -i %i -j ACCEPT; ip6tables -t nat -A POSTROUTING -o \$(ip r l 0/0 | mawk '{print \$5;exit}') -j MASQUERADE" /etc/wireguard/wg0.conf - sed -i "/^ListenPort/a\PostDown = ip6tables -D FORWARD -i %i -j ACCEPT; ip6tables -t nat -D POSTROUTING -o \$(ip r l 0/0 | mawk '{print \$5;exit}') -j MASQUERADE" /etc/wireguard/wg0.conf + sed --follow-symlinks -i "/^ListenPort/a\PostUp = sysctl net.ipv4.conf.%i.forwarding=1 net.ipv4.conf.\$(ip r l 0/0 | mawk '{print \$5;exit}').forwarding=1" /etc/wireguard/wg0.conf + sed --follow-symlinks -i "/^ListenPort/a\PostUp = sysctl net.ipv6.conf.\$(ip r l 0/0 | mawk '{print \$5;exit}').accept_ra=2" /etc/wireguard/wg0.conf + sed --follow-symlinks -i "/^ListenPort/a\PostUp = sysctl net.ipv6.conf.%i.forwarding=1 net.ipv6.conf.\$(ip r l 0/0 | mawk '{print \$5;exit}').forwarding=1" /etc/wireguard/wg0.conf + sed --follow-symlinks -i "/^ListenPort/a\PostUp = ip6tables -A FORWARD -i %i -j ACCEPT; ip6tables -t nat -A POSTROUTING -o \$(ip r l 0/0 | mawk '{print \$5;exit}') -j MASQUERADE" /etc/wireguard/wg0.conf + sed --follow-symlinks -i "/^ListenPort/a\PostDown = ip6tables -D FORWARD -i %i -j ACCEPT; ip6tables -t nat -D POSTROUTING -o \$(ip r l 0/0 | mawk '{print \$5;exit}') -j MASQUERADE" /etc/wireguard/wg0.conf fi #----------------------------------------------------------------------- @@ -848,7 +848,7 @@ Further info and usage: https://dietpi.com/forum/t/dietpi-arr-to-ram-link-sonarr . /var/lib/dietpi/dietpi-software/installed/dietpi-nordvpn/settings_dietpi.conf if [[ -f /etc/openvpn/ovpn_$PROTOCOL/$NORDVPN_SERVER && $(grep -c '^auth-user-pass' "/etc/openvpn/ovpn_$PROTOCOL/$NORDVPN_SERVER") == 2 ]]; then - sed -i '/^auth-user-pass$/d' "/etc/openvpn/ovpn_$PROTOCOL/$NORDVPN_SERVER" + sed --follow-symlinks -i '/^auth-user-pass$/d' "/etc/openvpn/ovpn_$PROTOCOL/$NORDVPN_SERVER" fi unset -v NORDVPN_USERNAME NORDVPN_PASSWORD NORDVPN_SERVER PROTOCOL @@ -865,7 +865,7 @@ Further info and usage: https://dietpi.com/forum/t/dietpi-arr-to-ram-link-sonarr fi #----------------------------------------------------------------------- # Add /etc/network/interfaces.d/ drop-in config support - grep -q 'interfaces\.d' /etc/network/interfaces || sed -i '1i\source interfaces.d/*' /etc/network/interfaces + grep -q 'interfaces\.d' /etc/network/interfaces || sed --follow-symlinks -i '1i\source interfaces.d/*' /etc/network/interfaces #----------------------------------------------------------------------- # Blynk: Fix logging and move to RAMlog: https://github.com/MichaIng/DietPi/pull/2779 if [[ -f '/etc/systemd/system/blynkserver.service' && -f '/mnt/dietpi_userdata/blynk/server.properties' ]]; then @@ -907,9 +907,9 @@ NBB: Reinstall manually installed PHP modules via: G_AGI $PHP_NAME-" # Update PHP socket # - Lighttpd - [[ -f '/etc/lighttpd/conf-available/15-fastcgi-php.conf' ]] && sed -i "s@\"socket\".*\$@\"socket\" => \"/run/php/$PHP_NAME-fpm.sock\",@" /etc/lighttpd/conf-available/15-fastcgi-php.conf + [[ -f '/etc/lighttpd/conf-available/15-fastcgi-php.conf' ]] && sed --follow-symlinks -i "s@\"socket\".*\$@\"socket\" => \"/run/php/$PHP_NAME-fpm.sock\",@" /etc/lighttpd/conf-available/15-fastcgi-php.conf # - Nginx - [[ -f '/etc/nginx/nginx.conf' ]] && sed -i "s#/run/php.*-fpm.sock#/run/php/$PHP_NAME-fpm.sock#g" /etc/nginx/nginx.conf + [[ -f '/etc/nginx/nginx.conf' ]] && sed --follow-symlinks -i "s#/run/php.*-fpm.sock#/run/php/$PHP_NAME-fpm.sock#g" /etc/nginx/nginx.conf # Mark old PHP packages for autoremoval local apackages=() @@ -958,7 +958,7 @@ NBB: Reinstall manually installed PHP modules via: G_AGI $PHP_NAME-" # Patch Lighttpd config file on ARMv6 (Buster version installed): https://github.com/MichaIng/DietPi/issues/2808 if [[ -f '/etc/lighttpd/lighttpd.conf' && ! -f '/usr/share/lighttpd/create-mime.assign.pl' && -f '/usr/share/lighttpd/create-mime.conf.pl' ]]; then - sed -i 's|/usr/share/lighttpd/create-mime\.assign\.pl|/usr/share/lighttpd/create-mime.conf.pl|g' /etc/lighttpd/lighttpd.conf + sed --follow-symlinks -i 's|/usr/share/lighttpd/create-mime\.assign\.pl|/usr/share/lighttpd/create-mime.conf.pl|g' /etc/lighttpd/lighttpd.conf fi #------------------------------------------------------------------------------- @@ -1012,17 +1012,17 @@ Use "dietpi-config" to adjust these settings to your needs.' #------------------------------------------------------------------------------- # Remove obsolete dietpi.txt entries # - https://github.com/MichaIng/DietPi/commit/b330594f0e63a40a75484647033c3b393ecd05b3#diff-aca2a37c06074a66f2588f7c9e84d07a - G_EXEC sed -i '/AUTO_SETUP_NET_WIFI/{/AUTO_SETUP_NET_WIFI_ENABLED/!d}' /boot/dietpi.txt + G_EXEC sed --follow-symlinks -i '/AUTO_SETUP_NET_WIFI/{/AUTO_SETUP_NET_WIFI_ENABLED/!d}' /boot/dietpi.txt # - https://github.com/MichaIng/DietPi/commit/814823899667e896291ed240281cfd39971463d9#diff-aca2a37c06074a66f2588f7c9e84d07a - G_EXEC sed -i '/CONFIG_SMBCLIENT/d' /boot/dietpi.txt - G_EXEC sed -i '/CONFIG_CURLFTPFS/d' /boot/dietpi.txt - G_EXEC sed -i '/CONFIG_NFSCLIENT/d' /boot/dietpi.txt + G_EXEC sed --follow-symlinks -i '/CONFIG_SMBCLIENT/d' /boot/dietpi.txt + G_EXEC sed --follow-symlinks -i '/CONFIG_CURLFTPFS/d' /boot/dietpi.txt + G_EXEC sed --follow-symlinks -i '/CONFIG_NFSCLIENT/d' /boot/dietpi.txt #------------------------------------------------------------------------------- # Transmission: Fix web UI settings not being applied to settings file: https://github.com/MichaIng/DietPi/issues/2793 [[ -f '/etc/systemd/system/transmission-daemon.service.d/dietpi-group.conf' ]] && echo -e '[Service]\nGroup=dietpi\nSupplementaryGroups=debian-transmission' > /etc/systemd/system/transmission-daemon.service.d/dietpi-group.conf #------------------------------------------------------------------------------- # RPi I-Sabre-Q2M: Switch systems to use the new integrated "i-sabre-q2m" overlay + remove obsolete "snd-bcm2835" module blacklisting (instead disable dtparam if blacklist found) - [[ -f '/boot/config.txt' ]] && sed -i 's/i-sabre-k2m/i-sabre-q2m/g' /boot/config.txt + [[ -f '/boot/config.txt' ]] && sed --follow-symlinks -i 's/i-sabre-k2m/i-sabre-q2m/g' /boot/config.txt if [[ -f '/etc/modprobe.d/rpi-bcm2708.conf' ]]; then G_CONFIG_INJECT 'dtparam=audio=' 'dtparam=audio=off' /boot/config.txt @@ -1071,7 +1071,7 @@ _EOF_ local current=$(grep '^[[:blank:]]*temp_limit=' /boot/config.txt | sed 's/^[^=]*=//' | tail -1) # Get current effective (last) value disable_error=1 G_CHECK_VALIDINT "$current" || current=75 # If none, use 75'c as DietPi default on RPi3 - G_EXEC sed -i '/^[[:blank:]#]*temp_limit=/d' /boot/config.txt # Remove all entries, including comments + G_EXEC sed --follow-symlinks -i '/^[[:blank:]#]*temp_limit=/d' /boot/config.txt # Remove all entries, including comments G_CONFIG_INJECT 'temp_limit=' "temp_limit=$current" /boot/config.txt # Re-add current effective value or default fi @@ -1083,7 +1083,7 @@ _EOF_ # MPD: Remove obsolete and wrong RuntimeDirectory definition: https://github.com/MichaIng/DietPi/commit/882ddfb533fdc1fa597231824810909770a910c9 if (( $G_DIETPI_INSTALL_STAGE == 2 )); then - [[ -f '/lib/systemd/system/mpd.service' ]] && sed -i '/^[[:blank:]]*RuntimeDirectory=/d' /lib/systemd/system/mpd.service + [[ -f '/lib/systemd/system/mpd.service' ]] && sed --follow-symlinks -i '/^[[:blank:]]*RuntimeDirectory=/d' /lib/systemd/system/mpd.service [[ -f '/var/www/ompd/include/config.inc.php' && ! -f '/var/www/ompd/include/config.local.inc.php' ]] && mv /var/www/ompd/include/config.inc.php /var/www/ompd/include/config.local.inc.php if grep -q '^aSOFTWARE_INSTALL_STATE\[148\]=2' /boot/dietpi/.installed; then @@ -1120,19 +1120,19 @@ A backup will be created to "/etc/mympd/mympd.conf.bak_DDMMYYY_N" from where you [[ -f '/etc/systemd/system/rpi-bcm2835_forced_3.5mm.service' ]] && rm /etc/systemd/system/rpi-bcm2835_forced_3.5mm.service if (( $G_HW_MODEL < 10 )); then - G_EXEC sed -i '/dtoverlay=i2s-mmap/d' /boot/config.txt - G_EXEC sed -i '/dtoverlay=i2s=/d' /boot/config.txt - G_EXEC sed -i '/dtoverlay=lirc-rpi/d' /boot/config.txt - G_EXEC sed -i '/^[[:blank:]#]*dtparam=gpio_in_pin=25/d' /boot/config.txt - G_EXEC sed -i '/^[[:blank:]#]*i2c_arm_baudrate=/d' /boot/config.txt - G_EXEC sed -i '/^[[:blank:]#]*bcm2835-v4l2/d' /etc/modules + G_EXEC sed --follow-symlinks -i '/dtoverlay=i2s-mmap/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/dtoverlay=i2s=/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/dtoverlay=lirc-rpi/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]#]*dtparam=gpio_in_pin=25/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]#]*i2c_arm_baudrate=/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/^[[:blank:]#]*bcm2835-v4l2/d' /etc/modules grep -q '^[[:blank:]]*start_x=1' /boot/config.txt || /boot/dietpi/func/dietpi-set_hardware rpi-camera disable [[ -f '/etc/modprobe.d/disable_bt.conf' ]] && G_CONFIG_INJECT 'dtoverlay=disable-bt' 'dtoverlay=disable-bt' /boot/config.txt [[ -f '/etc/modprobe.d/disable_wifi_rpi3_onboard.conf' ]] && G_CONFIG_INJECT 'dtoverlay=disable-wifi' 'dtoverlay=disable-wifi' /boot/config.txt # Offer re-adding of "initial_turbo" on RPi: https://github.com/MichaIng/DietPi/issues/3147 if ! grep -q '^[[:blank:]]*initial_turbo' /boot/config.txt; then - G_EXEC sed -i '\|issues/1836|d' /boot/config.txt # Remove obsolete comment + G_EXEC sed --follow-symlinks -i '\|issues/1836|d' /boot/config.txt # Remove obsolete comment G_WHIP_BUTTON_OKAY_TEXT='Yes' G_WHIP_BUTTON_CANCEL_TEXT='No' G_WHIP_YESNO 'Re-adding "initial_turbo" option\n The firmware issues with the "initial_turbo" option have been fixed a recent update: https://github.com/raspberrypi/firmware/issues/1005\n This option allows you to force highest CPU frequency for a set amount of seconds during boot. This significantly reduces boot time on RPi since it by default boots with lowest frequencies, until a systemd unit sets the chosen CPU governor at later boot stage. You can now set this setting again via: @@ -1183,7 +1183,7 @@ Do you want to have the recommended "initial_turbo=20" re-added to your config.t tvservice -o fi - G_EXEC sed -i '/hdmi_ignore_composite/d' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/hdmi_ignore_composite/d' /boot/config.txt G_EXEC rm -f /etc/apt/sources.list.d/{dietpi-kodi,pipplware,kodi}.list if dpkg-query -s kodi-rpi4 &> /dev/null; then @@ -1207,7 +1207,7 @@ Do you want to have the recommended "initial_turbo=20" re-added to your config.t if (( $G_DIETPI_INSTALL_STAGE == 2 )); then # Remove obsolete install states: TightVPN and SDL2 - G_EXEC sed -Ei '/^aSOFTWARE_INSTALL_STATE\[(27|140)\]=/d' /boot/dietpi/.installed + G_EXEC sed --follow-symlinks -Ei '/^aSOFTWARE_INSTALL_STATE\[(27|140)\]=/d' /boot/dietpi/.installed # Gogs: Remove /etc/__MACOSX that comes from our archive on ARMv6 if grep -q '^aSOFTWARE_INSTALL_STATE\[49\]=2' /boot/dietpi/.installed; then @@ -1318,7 +1318,7 @@ Would you like to switch back to the Nginx authentication method now?' && certbo fi # Mono: Use new Buster repo on Buster/Bullseye systems - (( $G_DISTRO > 4 )) && [[ -f '/etc/apt/sources.list.d/mono-xamarin.list' ]] && sed -i 's/stretch/buster/g' /etc/apt/sources.list.d/mono-xamarin.list + (( $G_DISTRO > 4 )) && [[ -f '/etc/apt/sources.list.d/mono-xamarin.list' ]] && sed --follow-symlinks -i 's/stretch/buster/g' /etc/apt/sources.list.d/mono-xamarin.list # Aria2: https://github.com/MichaIng/DietPi/pull/3139 if [[ -f '/var/lib/dietpi/dietpi-software/installed/aria2.conf' ]]; then @@ -1507,7 +1507,7 @@ _EOF_ G_DIETPI-NOTIFY 2 'Removing obsolete flag files' G_EXEC rm -f /boot/dietpi/.{update_available,timesync_exit_status,network} /var/lib/dietpi/.ntpd_override /tmp/.dietpi_motd #------------------------------------------------------------------------------- - [[ -f '/boot/dietpi/.dietpi-backup_settings' ]] && l_message='Adjusting changed DietPi-Backup variable name' G_EXEC sed -i 's/^FP_TARGET_BACKUP=/FP_TARGET=/' /boot/dietpi/.dietpi-backup_settings + [[ -f '/boot/dietpi/.dietpi-backup_settings' ]] && l_message='Adjusting changed DietPi-Backup variable name' G_EXEC sed --follow-symlinks -i 's/^FP_TARGET_BACKUP=/FP_TARGET=/' /boot/dietpi/.dietpi-backup_settings #------------------------------------------------------------------------------- if [[ -f '/etc/default/crda' ]]; then @@ -1516,21 +1516,21 @@ _EOF_ G_CONFIG_INJECT 'REGDOMAIN=' "REGDOMAIN=$country_code" /etc/default/crda G_CONFIG_INJECT 'AUTO_SETUP_NET_WIFI_COUNTRY_CODE=' "AUTO_SETUP_NET_WIFI_COUNTRY_CODE=$country_code" /boot/dietpi.txt # Remove from wpa_supplicant.conf - [[ -f '/etc/wpa_supplicant/wpa_supplicant.conf' ]] && sed -i '/^[[:blank:]]*country=/d' /etc/wpa_supplicant/wpa_supplicant.conf + [[ -f '/etc/wpa_supplicant/wpa_supplicant.conf' ]] && sed --follow-symlinks -i '/^[[:blank:]]*country=/d' /etc/wpa_supplicant/wpa_supplicant.conf fi #------------------------------------------------------------------------------- G_DIETPI-NOTIFY 2 'Removing obsolete dietpi.txt entries' - G_EXEC sed -i '/CONFIG_AUTO_DIETPI_UPDATES=/d' /boot/dietpi.txt - G_EXEC sed -i '/CONFIG_WIFI_COUNTRY_CODE=/d' /boot/dietpi.txt + G_EXEC sed --follow-symlinks -i '/CONFIG_AUTO_DIETPI_UPDATES=/d' /boot/dietpi.txt + G_EXEC sed --follow-symlinks -i '/CONFIG_WIFI_COUNTRY_CODE=/d' /boot/dietpi.txt #------------------------------------------------------------------------------- G_DIETPI-NOTIFY 2 'Removing obsolete dietpi-software config directory' [[ -d '/var/lib/dietpi/dietpi-software/conf' ]] && G_EXEC rm -R /var/lib/dietpi/dietpi-software/conf #------------------------------------------------------------------------------- G_DIETPI-NOTIFY 2 'Removing obsolete hint about /DietPi RAMdisk from /boot config files' - [[ -f '/boot/dietpi.txt' ]] && sed -Ei '/^# - (Modifications to \/boot\/dietpi\.txt|Please ensure you edit from the DietPi-RAMdisk)/d' /boot/dietpi.txt - [[ -f '/boot/config.txt' ]] && sed -Ei '/^# - (Modifications to \/boot\/config\.txt|Please ensure you edit from the DietPi-RAMdisk)/d' /boot/config.txt - [[ -f '/boot/boot.ini' ]] && sed -Ei '/^# - (Modifications to \/boot\/boot\.ini|Please ensure you edit from the DietPi-RAMdisk)/d' /boot/boot.ini + [[ -f '/boot/dietpi.txt' ]] && sed --follow-symlinks -Ei '/^# - (Modifications to \/boot\/dietpi\.txt|Please ensure you edit from the DietPi-RAMdisk)/d' /boot/dietpi.txt + [[ -f '/boot/config.txt' ]] && sed --follow-symlinks -Ei '/^# - (Modifications to \/boot\/config\.txt|Please ensure you edit from the DietPi-RAMdisk)/d' /boot/config.txt + [[ -f '/boot/boot.ini' ]] && sed --follow-symlinks -Ei '/^# - (Modifications to \/boot\/boot\.ini|Please ensure you edit from the DietPi-RAMdisk)/d' /boot/boot.ini #------------------------------------------------------------------------------- # Sparky SBC: Update kernel/drivers if (( $G_HW_MODEL == 70 )); then @@ -1697,8 +1697,8 @@ To reinstall now, run: "dietpi-software reinstall 106 144 145" # Fix default RPi3+ overclocking defaults: https://dietpi.com/phpbb/viewtopic.php?t=7804 if [[ $G_HW_MODEL == 3 && $G_HW_MODEL_NAME == *'+'* ]]; then - G_EXEC sed -i '/#arm_freq=/c\#arm_freq=1400' /boot/config.txt - G_EXEC sed -i '/#sdram_freq=/c\#sdram_freq=500' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/#arm_freq=/c\#arm_freq=1400' /boot/config.txt + G_EXEC sed --follow-symlinks -i '/#sdram_freq=/c\#sdram_freq=500' /boot/config.txt fi #------------------------------------------------------------------------------- @@ -1708,7 +1708,7 @@ To reinstall now, run: "dietpi-software reinstall 106 144 145" if (( $G_DIETPI_INSTALL_STAGE == 2 )); then # Reset QuiteRSS install state if the package has not actually been installed: https://github.com/MichaIng/DietPi/commit/49f960a7953f44e5571ff2dde68a93efca37ec03 - dpkg-query -s quiterss &> /dev/null || sed -i '/^aSOFTWARE_INSTALL_STATE\[22\]=2/d' /boot/dietpi/.installed + dpkg-query -s quiterss &> /dev/null || sed --follow-symlinks -i '/^aSOFTWARE_INSTALL_STATE\[22\]=2/d' /boot/dietpi/.installed if grep -q '^aSOFTWARE_INSTALL_STATE\[36\]=2' /boot/dietpi/.installed; then @@ -1738,7 +1738,7 @@ To reinstall now, run: "dietpi-software reinstall 106 144 145" # APT configs have been merged into a single file, contained in update archive rm -fv /etc/apt/apt.conf.d/{99-dietpi-norecommends,98-dietpi-no_translations,99-dietpi-forceconf} #------------------------------------------------------------------------------- - [[ -f '/boot/config.txt' ]] && G_EXEC_DESC='Removing deprecated "max_usb_current" from config.txt' G_EXEC_NOHALT=1 G_EXEC sed -i '/^[[:blank:]#]*max_usb_current=/d' /boot/config.txt + [[ -f '/boot/config.txt' ]] && G_EXEC_DESC='Removing deprecated "max_usb_current" from config.txt' G_EXEC_NOHALT=1 G_EXEC sed --follow-symlinks -i '/^[[:blank:]#]*max_usb_current=/d' /boot/config.txt #----------------------------------------------------------------------- # Recreate /etc/sysctl.d/99-sysctl.conf -> ../sysctl.conf symlink if not existent: https://github.com/MichaIng/DietPi/issues/3003#issuecomment-669464255 if [[ ! -L '/etc/sysctl.d/99-sysctl.conf' ]]; then @@ -1799,8 +1799,8 @@ To reinstall now, run: "dietpi-software reinstall 106 144 145" G_EXEC mv /opt/{plexpy,tautulli} [[ -d '/mnt/dietpi_userdata/plexpy' ]] && G_EXEC mv /mnt/dietpi_userdata/{plexpy,tautulli} [[ -f '/opt/tautulli/config.ini' ]] && G_EXEC mv /{opt,mnt/dietpi_userdata}/tautulli/config.ini - G_EXEC sed -i 's|/opt/plexpy|/opt/tautulli|' /mnt/dietpi_userdata/tautulli/config.ini - G_EXEC sed -i 's|/mnt/dietpi_userdata/plexpy|/mnt/dietpi_userdata/tautulli|' /mnt/dietpi_userdata/tautulli/config.ini + G_EXEC sed --follow-symlinks -i 's|/opt/plexpy|/opt/tautulli|' /mnt/dietpi_userdata/tautulli/config.ini + G_EXEC sed --follow-symlinks -i 's|/mnt/dietpi_userdata/plexpy|/mnt/dietpi_userdata/tautulli|' /mnt/dietpi_userdata/tautulli/config.ini [[ -f '/etc/systemd/system/plexpy.service' ]] && G_EXEC mv /etc/systemd/system/{plexpy,tautulli}.service [[ -d '/etc/systemd/system/plexpy.service.d' ]] && G_EXEC mv /etc/systemd/system/{plexpy,tautulli}.service.d getent passwd plexpy > /dev/null && G_EXEC userdel plexpy @@ -1814,7 +1814,7 @@ To reinstall now, run: "dietpi-software reinstall 106 144 145" [[ -f '/etc/lighttpd/conf-available/99-dietpi-nextcloud.conf' ]] && grep -q opcache /etc/lighttpd/conf-available/99-dietpi-nextcloud.conf; then G_DIETPI-NOTIFY 2 'Removing obsolete directive from Lighttpd Nextcloud config file' - G_EXEC sed -i '/opcache/d' /etc/lighttpd/conf-available/99-dietpi-nextcloud.conf + G_EXEC sed --follow-symlinks -i '/opcache/d' /etc/lighttpd/conf-available/99-dietpi-nextcloud.conf for i in /etc/php/7.[234]/mods-available do @@ -1865,7 +1865,7 @@ opcache.max_accelerated_files=10000\nopcache.memory_consumption=128\nopcache.sav (( $G_DIETPI_INSTALL_STAGE == 2 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[28\]=2' /boot/dietpi/.installed && grep -q '^aSOFTWARE_INSTALL_STATE\[23\]=2' /boot/dietpi/.installed && G_AGI dbus-user-session #------------------------------------------------------------------------------- # Fail2Ban: https://github.com/MichaIng/DietPi/pull/3813 - [[ ! -f '/etc/fail2ban/jail.conf' ]] || sed -n '/^\[DEFAULT\]/,/^\[/p' /etc/fail2ban/jail.conf | grep -q '^[[:blank:]]*mode[[:blank:]]*=' || sed -i '/^\[DEFAULT\]/a\mode = normal' /etc/fail2ban/jail.conf + [[ ! -f '/etc/fail2ban/jail.conf' ]] || sed -n '/^\[DEFAULT\]/,/^\[/p' /etc/fail2ban/jail.conf | grep -q '^[[:blank:]]*mode[[:blank:]]*=' || sed --follow-symlinks -i '/^\[DEFAULT\]/a\mode = normal' /etc/fail2ban/jail.conf #------------------------------------------------------------------------------- elif (( $G_DIETPI_VERSION_SUB == 33 )); then @@ -1874,16 +1874,16 @@ opcache.max_accelerated_files=10000\nopcache.memory_consumption=128\nopcache.sav # Remove Tonido install flag if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^aSOFTWARE_INSTALL_STATE\[134\]=2' /boot/dietpi/.installed then - G_EXEC sed -i '/^aSOFTWARE_INSTALL_STATE\[134\]=2/d' /boot/dietpi/.installed + G_EXEC sed --follow-symlinks -i '/^aSOFTWARE_INSTALL_STATE\[134\]=2/d' /boot/dietpi/.installed # Add service to custom includes if it has not been excluded, since it has been removed from the static DietPi-Services list grep -q '^- tonido$' /boot/dietpi/.dietpi-services_include_exclude || G_CONFIG_INJECT '+ tonido' '+ tonido' /boot/dietpi/.dietpi-services_include_exclude fi #------------------------------------------------------------------------------- # Remove CloudPrint install flag - [[ -f '/boot/dietpi/.installed' ]] && grep -q '^aSOFTWARE_INSTALL_STATE\[137\]=2' /boot/dietpi/.installed && sed -i '/^aSOFTWARE_INSTALL_STATE\[137\]=2/d' /boot/dietpi/.installed + [[ -f '/boot/dietpi/.installed' ]] && grep -q '^aSOFTWARE_INSTALL_STATE\[137\]=2' /boot/dietpi/.installed && sed --follow-symlinks -i '/^aSOFTWARE_INSTALL_STATE\[137\]=2/d' /boot/dietpi/.installed #------------------------------------------------------------------------------- # Remove DietPi-CloudShell install flag - [[ -f '/boot/dietpi/.installed' ]] && grep -q '^aSOFTWARE_INSTALL_STATE\[62\]=2' /boot/dietpi/.installed && sed -i '/^aSOFTWARE_INSTALL_STATE\[62\]=2/d' /boot/dietpi/.installed + [[ -f '/boot/dietpi/.installed' ]] && grep -q '^aSOFTWARE_INSTALL_STATE\[62\]=2' /boot/dietpi/.installed && sed --follow-symlinks -i '/^aSOFTWARE_INSTALL_STATE\[62\]=2/d' /boot/dietpi/.installed #------------------------------------------------------------------------------- if [[ -f '/boot/dietpi/.installed' ]] && grep -q '^aSOFTWARE_INSTALL_STATE\[29\]=2' /boot/dietpi/.installed && ! dpkg-query -s xorgxrdp &> /dev/null then @@ -2012,7 +2012,7 @@ _EOF_ # Beta 6.34.0+1 [[ -f '/mnt/dietpi_userdata/octoprint/pip2' ]] && G_EXEC rm /mnt/dietpi_userdata/octoprint/pip2 [[ -f '/mnt/dietpi_userdata/octoprint/pip3' ]] && G_EXEC rm /mnt/dietpi_userdata/octoprint/pip3 - [[ -f '/mnt/dietpi_userdata/octoprint/.octoprint/config.yaml' ]] && G_EXEC sed -i '/localPipCommand/d' /mnt/dietpi_userdata/octoprint/.octoprint/config.yaml + [[ -f '/mnt/dietpi_userdata/octoprint/.octoprint/config.yaml' ]] && G_EXEC sed --follow-symlinks -i '/localPipCommand/d' /mnt/dietpi_userdata/octoprint/.octoprint/config.yaml # shellcheck disable=SC2046 command -v pip2 > /dev/null && pip2 uninstall -y $(pip2 freeze | mawk '/[Oo]cto[Pp]rint/{print $1}') 2> /dev/null # shellcheck disable=SC2046 @@ -2069,7 +2069,7 @@ _EOF_ fi #------------------------------------------------------------------------------- # ReadyMedia: Fix database rebuild on service start - [[ -f '/etc/systemd/system/minidlna.service' ]] && G_EXEC sed -i '/^ExecStart=/s/ -SR / -S -R /' /etc/systemd/system/minidlna.service + [[ -f '/etc/systemd/system/minidlna.service' ]] && G_EXEC sed --follow-symlinks -i '/^ExecStart=/s/ -SR / -S -R /' /etc/systemd/system/minidlna.service #------------------------------------------------------------------------------- # Raspberry Pi Microsoft VS Code repo: https://github.com/MichaIng/DietPi/issues/4083 [[ $G_HW_MODEL -le 9 && -f '/etc/apt/sources.list.d/vscode.list' ]] && { G_WHIP_BUTTON_OK_TEXT='Keep it' G_WHIP_BUTTON_CANCEL_TEXT='Remove it' G_WHIP_YESNO 'The Microsoft Visual Studio Code APT repository has been found on your system. diff --git a/dietpi/pre-patch_file b/dietpi/pre-patch_file index f5f79078a2..2e826ae479 100755 --- a/dietpi/pre-patch_file +++ b/dietpi/pre-patch_file @@ -63,8 +63,8 @@ if (( $G_DIETPI_VERSION_SUB < 21 )) && [[ -f '/etc/mysql/mariadb.conf.d/99-dietpi-4byte.cnf' ]] && grep -qi 'buster' /etc/os-release; then echo -e '\e[90m[\e[0m INFO \e[90m]\e[0m Pre-patch 2 | Patching /etc/mysql/mariadb.conf.d/99-dietpi-4byte.cnf for MariaDB v10.3/Buster support' - sed -i '/innodb_large_prefix/d' /etc/mysql/mariadb.conf.d/99-dietpi-4byte.cnf || exit 2 - sed -i '/innodb_file_format/d' /etc/mysql/mariadb.conf.d/99-dietpi-4byte.cnf || exit 2 + sed --follow-symlinks -i '/innodb_large_prefix/d' /etc/mysql/mariadb.conf.d/99-dietpi-4byte.cnf || exit 2 + sed --follow-symlinks -i '/innodb_file_format/d' /etc/mysql/mariadb.conf.d/99-dietpi-4byte.cnf || exit 2 fi #------------------------------------------------------------------------------- @@ -91,7 +91,7 @@ echo -e '\e[90m[\e[0m INFO \e[90m]\e[0m Pre-patch 6 | Migrating Jessie systems to "jessie-support" update branch' if grep -q '^[[:blank:]]*DEV_GITBRANCH=' /DietPi/dietpi.txt; then - sed -i '/^[[:blank:]]*DEV_GITBRANCH=/c\DEV_GITBRANCH=jessie-support' /DietPi/dietpi.txt || exit 6 + sed --follow-symlinks -i '/^[[:blank:]]*DEV_GITBRANCH=/c\DEV_GITBRANCH=jessie-support' /DietPi/dietpi.txt || exit 6 else @@ -238,7 +238,7 @@ Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=bullseye\nPin- if (( $G_DIETPI_VERSION_SUB < 33 && $G_HW_MODEL > 10 && $G_HW_MODEL < 20 )); then echo -e "\e[90m[\e[0m INFO \e[90m]\e[0m Pre-patch 22 | Switch to our new Meveric's Odroid repo mirror on https://dietpi.com/meveric/" - sed -Ei 's@(http://fuzon\.co\.uk|https?://oph\.mdrjr\.net)@https://dietpi.com@' /etc/apt/sources.list{,.d/*.list} || exit 22 + sed --follow-symlinks -Ei 's@(http://fuzon\.co\.uk|https?://oph\.mdrjr\.net)@https://dietpi.com@' /etc/apt/sources.list{,.d/*.list} || exit 22 fi #------------------------------------------------------------------------------- @@ -249,13 +249,13 @@ Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=bullseye\nPin- if grep -q '/dev/disk/by-id/ata-VBOX_HARDDISK_VBeda89797-79ca820f' /var/cache/debconf/config.dat; then echo -e '\e[90m[\e[0m INFO \e[90m]\e[0m Pre-patch 23 | Fixing the grub debconf drive ID' - sed -i 's|/dev/disk/by-id/ata-VBOX_HARDDISK_VBeda89797-79ca820f|/dev/sda|' /var/cache/debconf/config.dat || exit 23 + sed --follow-symlinks -i 's|/dev/disk/by-id/ata-VBOX_HARDDISK_VBeda89797-79ca820f|/dev/sda|' /var/cache/debconf/config.dat || exit 23 # Native PC BIOS elif grep -q '/dev/disk/by-id/ata-M4-CT128M4SSD2_000000001151090024A1' /var/cache/debconf/config.dat; then echo -e '\e[90m[\e[0m INFO \e[90m]\e[0m Pre-patch 23 | Fixing the grub debconf drive ID' - sed -i 's|/dev/disk/by-id/ata-M4-CT128M4SSD2_000000001151090024A1|/dev/sda|' /var/cache/debconf/config.dat || exit 23 + sed --follow-symlinks -i 's|/dev/disk/by-id/ata-M4-CT128M4SSD2_000000001151090024A1|/dev/sda|' /var/cache/debconf/config.dat || exit 23 fi diff --git a/rootfs/var/lib/dietpi/services/dietpi-firstboot.bash b/rootfs/var/lib/dietpi/services/dietpi-firstboot.bash index 6f7b29b118..152d127a95 100755 --- a/rootfs/var/lib/dietpi/services/dietpi-firstboot.bash +++ b/rootfs/var/lib/dietpi/services/dietpi-firstboot.bash @@ -32,58 +32,58 @@ # RPi Zero/Zero 2 W if [[ $G_HW_MODEL_NAME == *'Zero'* ]] then - sed -i '/^#over_voltage=/c\#over_voltage=0' /boot/config.txt - sed -i '/^#arm_freq=/c\#arm_freq=1000' /boot/config.txt - sed -i '/^#core_freq=/c\#core_freq=400' /boot/config.txt - sed -i '/^#sdram_freq=/c\#sdram_freq=450' /boot/config.txt + sed --follow-symlinks -i '/^#over_voltage=/c\#over_voltage=0' /boot/config.txt + sed --follow-symlinks -i '/^#arm_freq=/c\#arm_freq=1000' /boot/config.txt + sed --follow-symlinks -i '/^#core_freq=/c\#core_freq=400' /boot/config.txt + sed --follow-symlinks -i '/^#sdram_freq=/c\#sdram_freq=450' /boot/config.txt # RPi 1: Apply safe overclock mode elif (( $G_HW_MODEL < 2 )) then GCI_PRESERVE=1 G_CONFIG_INJECT 'arm_freq=' 'arm_freq=900' /boot/config.txt grep -q '^arm_freq=900$' /boot/config.txt && G_CONFIG_INJECT 'over_voltage=' 'over_voltage=2' /boot/config.txt - sed -i '/^#core_freq=/c\#core_freq=250' /boot/config.txt - sed -i '/^#sdram_freq=/c\#sdram_freq=400' /boot/config.txt + sed --follow-symlinks -i '/^#core_freq=/c\#core_freq=250' /boot/config.txt + sed --follow-symlinks -i '/^#sdram_freq=/c\#sdram_freq=400' /boot/config.txt # RPi 2 elif (( $G_HW_MODEL == 2 )) then - sed -i '/^#over_voltage=/c\#over_voltage=0' /boot/config.txt - sed -i '/^#arm_freq=/c\#arm_freq=900' /boot/config.txt - sed -i '/^#core_freq=/c\#core_freq=250' /boot/config.txt - sed -i '/^#sdram_freq=/c\#sdram_freq=450' /boot/config.txt + sed --follow-symlinks -i '/^#over_voltage=/c\#over_voltage=0' /boot/config.txt + sed --follow-symlinks -i '/^#arm_freq=/c\#arm_freq=900' /boot/config.txt + sed --follow-symlinks -i '/^#core_freq=/c\#core_freq=250' /boot/config.txt + sed --follow-symlinks -i '/^#sdram_freq=/c\#sdram_freq=450' /boot/config.txt # RPi 3 elif (( $G_HW_MODEL == 3 )) then - sed -i '/^#over_voltage=/c\#over_voltage=0' /boot/config.txt - sed -i '/^#core_freq=/c\#core_freq=400' /boot/config.txt + sed --follow-symlinks -i '/^#over_voltage=/c\#over_voltage=0' /boot/config.txt + sed --follow-symlinks -i '/^#core_freq=/c\#core_freq=400' /boot/config.txt grep -q '^temp_limit=65$' /boot/config.txt && G_CONFIG_INJECT 'temp_limit=' 'temp_limit=75' /boot/config.txt # https://github.com/MichaIng/DietPi/issues/356 # A+/B+ if [[ $G_HW_MODEL_NAME == *'+'* ]] then - sed -i '/^#arm_freq=/c\#arm_freq=1400' /boot/config.txt - sed -i '/^#sdram_freq=/c\#sdram_freq=500' /boot/config.txt + sed --follow-symlinks -i '/^#arm_freq=/c\#arm_freq=1400' /boot/config.txt + sed --follow-symlinks -i '/^#sdram_freq=/c\#sdram_freq=500' /boot/config.txt else - sed -i '/^#arm_freq=/c\#arm_freq=1200' /boot/config.txt - sed -i '/^#sdram_freq=/c\#sdram_freq=450' /boot/config.txt + sed --follow-symlinks -i '/^#arm_freq=/c\#arm_freq=1200' /boot/config.txt + sed --follow-symlinks -i '/^#sdram_freq=/c\#sdram_freq=450' /boot/config.txt fi # RPi 4 elif (( $G_HW_MODEL == 4 )) then - sed -i '/^#over_voltage=/c\#over_voltage=0' /boot/config.txt - sed -i '/^#core_freq=/c\#core_freq=500' /boot/config.txt - sed -i '/^#sdram_freq=/d' /boot/config.txt # Not supported on RPi4, defaults to 3200 MHz + sed --follow-symlinks -i '/^#over_voltage=/c\#over_voltage=0' /boot/config.txt + sed --follow-symlinks -i '/^#core_freq=/c\#core_freq=500' /boot/config.txt + sed --follow-symlinks -i '/^#sdram_freq=/d' /boot/config.txt # Not supported on RPi4, defaults to 3200 MHz grep -q '^temp_limit=65$' /boot/config.txt && G_CONFIG_INJECT 'temp_limit=' 'temp_limit=75' /boot/config.txt # https://github.com/MichaIng/DietPi/issues/3019 # 400 if [[ $G_HW_MODEL_NAME == *'400'* ]] then - sed -i '/^#arm_freq=/c\#arm_freq=1800' /boot/config.txt + sed --follow-symlinks -i '/^#arm_freq=/c\#arm_freq=1800' /boot/config.txt else - sed -i '/^#arm_freq=/c\#arm_freq=1500' /boot/config.txt + sed --follow-symlinks -i '/^#arm_freq=/c\#arm_freq=1500' /boot/config.txt fi fi } @@ -276,8 +276,8 @@ _EOF_ [[ $iface_wlan ]] || iface_wlan='wlan0' # - Replace interface names with the ones obtained above - sed -i "s/eth[0-9]/$iface_eth/g" /etc/network/interfaces - sed -i "s/wlan[0-9]/$iface_wlan/g" /etc/network/interfaces + sed --follow-symlinks -i "s/eth[0-9]/$iface_eth/g" /etc/network/interfaces + sed --follow-symlinks -i "s/wlan[0-9]/$iface_wlan/g" /etc/network/interfaces # - Grab user requested settings from dietpi.txt local ethernet_enabled=$(grep -cm1 '^[[:blank:]]*AUTO_SETUP_NET_ETHERNET_ENABLED=1' /boot/dietpi.txt) @@ -293,8 +293,8 @@ _EOF_ # Enable WiFi, disable Ethernet ethernet_enabled=0 - sed -Ei "/(allow-hotplug|auto)[[:blank:]]+wlan/c\allow-hotplug $iface_wlan" /etc/network/interfaces - sed -Ei "/(allow-hotplug|auto)[[:blank:]]+eth/c\#allow-hotplug $iface_eth" /etc/network/interfaces + sed --follow-symlinks -Ei "/(allow-hotplug|auto)[[:blank:]]+wlan/c\allow-hotplug $iface_wlan" /etc/network/interfaces + sed --follow-symlinks -Ei "/(allow-hotplug|auto)[[:blank:]]+eth/c\#allow-hotplug $iface_eth" /etc/network/interfaces # Apply global SSID/keys from dietpi.txt to wpa_supplicant /boot/dietpi/func/dietpi-wifidb 1 @@ -307,8 +307,8 @@ _EOF_ # Enable Ethernet, disable WiFi wifi_enabled=0 - sed -Ei "/(allow-hotplug|auto)[[:blank:]]+eth/c\allow-hotplug $iface_eth" /etc/network/interfaces - sed -Ei "/(allow-hotplug|auto)[[:blank:]]+wlan/c\#allow-hotplug $iface_wlan" /etc/network/interfaces + sed --follow-symlinks -Ei "/(allow-hotplug|auto)[[:blank:]]+eth/c\allow-hotplug $iface_eth" /etc/network/interfaces + sed --follow-symlinks -Ei "/(allow-hotplug|auto)[[:blank:]]+wlan/c\#allow-hotplug $iface_wlan" /etc/network/interfaces # Disable WiFi kernel modules /boot/dietpi/func/dietpi-set_hardware wifimodules disable @@ -323,25 +323,25 @@ _EOF_ if (( $wifi_enabled )); then - sed -i "/iface wlan/c\iface $iface_wlan inet static" /etc/network/interfaces + sed --follow-symlinks -i "/iface wlan/c\iface $iface_wlan inet static" /etc/network/interfaces elif (( $ethernet_enabled )); then - sed -i "/iface eth/c\iface $iface_eth inet static" /etc/network/interfaces + sed --follow-symlinks -i "/iface eth/c\iface $iface_eth inet static" /etc/network/interfaces fi - sed -i "/address/c\address $static_ip" /etc/network/interfaces - sed -i "/netmask/c\netmask $static_mask" /etc/network/interfaces - sed -i "/gateway/c\gateway $static_gateway" /etc/network/interfaces + sed --follow-symlinks -i "/address/c\address $static_ip" /etc/network/interfaces + sed --follow-symlinks -i "/netmask/c\netmask $static_mask" /etc/network/interfaces + sed --follow-symlinks -i "/gateway/c\gateway $static_gateway" /etc/network/interfaces if command -v resolvconf > /dev/null; then - sed -i "/dns-nameservers/c\dns-nameservers $static_dns" /etc/network/interfaces + sed --follow-symlinks -i "/dns-nameservers/c\dns-nameservers $static_dns" /etc/network/interfaces else > /etc/resolv.conf for i in $static_dns; do echo "nameserver $i" >> /etc/resolv.conf; done - sed -i "/dns-nameservers/c\#dns-nameservers $static_dns" /etc/network/interfaces + sed --follow-symlinks -i "/dns-nameservers/c\#dns-nameservers $static_dns" /etc/network/interfaces fi