From 76b25a3c2dd3fd0aab29cf2b28bafb06e23fd5c1 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Mon, 3 Aug 2026 23:29:09 +0200 Subject: [PATCH 01/10] changelog: add release PR URL --- CHANGELOG.txt | 2 +- dietpi/func/dietpi-globals | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 2b5651044c..312530bc25 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,7 +19,7 @@ Bug fixes: - DietPi-Software | Immich: Resolved an issue where the installation failed due to breaking changes in the recent Immich v3 release. Our code has been updated to support Immich v3. As always, existing instances can apply the update via "dietpi-software reinstall 215 216", which includes Immich Machine Learning, (only) if installed. - DietPi-Software | BirdNET-Go: Resolved an issue where the installer did not detect recent releases, since the URLs got an additional date suffix. Many thanks to @oradke for reporting this issue: https://github.com/MichaIng/DietPi/discussions/8215 -As always, many smaller code performance and stability improvements, visual and spelling fixes have been done, too much to list all of them here. Check out all code changes of this release on GitHub: https://github.com/MichaIng/DietPi/pull/XXXX +As always, many smaller code performance and stability improvements, visual and spelling fixes have been done, too much to list all of them here. Check out all code changes of this release on GitHub: https://github.com/MichaIng/DietPi/pull/8235 ----------------------------------------------------------------------------------------------------------- diff --git a/dietpi/func/dietpi-globals b/dietpi/func/dietpi-globals index c8332d70ef..8ce2b4b887 100644 --- a/dietpi/func/dietpi-globals +++ b/dietpi/func/dietpi-globals @@ -183,7 +183,6 @@ $(ps f -eo pid,user,tty,cmd | grep -i 'dietpi')" && continue # alphab # alpha # ... and so on - G_TRUNCATE_MID() { local s=$1 max=$2 From df30ab6ee067d6014eec8bfaddd1317537140542 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Mon, 3 Aug 2026 23:40:16 +0200 Subject: [PATCH 02/10] changelog: add entry about Orange Pi Zero 2W stability fix --- CHANGELOG.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 312530bc25..f0e4af6eb7 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -13,6 +13,7 @@ Enhancements: Bug fixes: - Odroid N2/HC4 | Support for petitboot has been fixed. Changes in our base boot script caused some petitboot workarounds to not be applied as intended. Many thanks to @vlix and @tigersky for reporting this issue: https://dietpi.com/forum/t/24902, https://dietpi.com/forum/t/25296 +- Orange Pi Zero 2W | The stability of the system has been significantly increased by assuring the WiFi driver is loaded only when explicitly enabled, and adding CPU voltage ramp delays. Many thanks to @b3ll, @Totof, and many others for reporting the issue and testing many attempts to fix it. And many thanks to @EvilOlaf from Armbian for helping with debugging, and moving the driver from a complex patch series into a dedicated GitHub repository: https://github.com/MichaIng/DietPi/issues/8220 - DietPi-Benchmark | Resolved an issue where a "/dietpi-benchmark_testfile" directory was unintentionally created, if a "Full" benchmark was done first, and a "Custom Filesystem" Benchmark afterwards, for which no mount selection menu was shown either. - DietPi-Config | Resolved an issue where scanning for WiFi networks could result in an empty list, if a single hidden network (with an empty SSID) was in range. Many thanks to @miraz1300 for reporting this issue: https://github.com/MichaIng/DietPi/issues/8199 - DietPi-Config | Resolved a v10.5 regression where Bluetooth was always shown as enabled, hence could not be actually enabled anymore. Many thanks to @z3huti for reporting this issue: https://github.com/MichaIng/DietPi/issues/8213 From c6a9f586bd6cbd04c8f6e66e1fefc5ba41aa69e8 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Tue, 4 Aug 2026 16:23:31 +0200 Subject: [PATCH 03/10] Raspberry Pi: satisfy RPi kernel dependency with initramfs-tools Other implementations keep generating initramfs images on "update-initramfs" trigger, even if none exist and the kernel declares not to require it. From Debian Forky on, dracut implements and uses the `update-initramfs` command, to behave like initramfs-tools does now, to now create and new initramfs images on this trigger, but only refresh existing ones. --- .build/images/dietpi-installer | 4 +++- .update/patches | 11 ++++++++++- dietpi/func/dietpi-set_software | 4 ++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.build/images/dietpi-installer b/.build/images/dietpi-installer index 5bcc5b8cbf..46c43d4729 100755 --- a/.build/images/dietpi-installer +++ b/.build/images/dietpi-installer @@ -1410,10 +1410,12 @@ _EOF_ *) { G_DIETPI-NOTIFY 1 "Unexpected hardware model passed: \"$G_HW_MODEL\". Aborting ..."; exit 1; };; esac # Install raspi-firmware first, configure it to skip initramfs generation, and remove possibly existing initramfs images - G_AGI raspi-firmware + # Install initramfs-tools to satisfy dependency, since dracut and tiny-initramfs both always create an initramfs image on "update-initramfs" trigger. From Debian Forky on, dracut only refreshes existing images, like initramfs-tools does. + G_AGI raspi-firmware initramfs-tools G_CONFIG_INJECT 'SKIP_INITRAMFS_GEN=' 'SKIP_INITRAMFS_GEN=yes' /etc/default/raspi-firmware G_EXEC rm -f /boot/initrd.img-* /boot/firmware/initramfs* G_AGI "${akernel[@]}" raspi-utils-core raspberrypi-sys-mods raspberrypi-archive-keyring "${a32bit[@]}" + G_EXEC apt-mark auto initramfs-tools # https://github.com/RPi-Distro/raspberrypi-sys-mods/pull/60 [[ -f '/etc/apt/trusted.gpg.d/microsoft.gpg' ]] && G_EXEC rm /etc/apt/trusted.gpg.d/microsoft.gpg diff --git a/.update/patches b/.update/patches index 4c20bbac91..249aaf8a2a 100755 --- a/.update/patches +++ b/.update/patches @@ -2046,7 +2046,7 @@ Patch_9_19() { # Raspberry Pi with new kernel stack if (( $G_HW_MODEL < 10 )) && dpkg-query -s 'raspi-firmware' 2> /dev/null | grep -q '^Status: install ok installed$' && - ! grep '^[[:blank:]]*SKIP_INITRAMFS_GEN=yes' /etc/default/raspi-firmware && + ! grep -q '^[[:blank:]]*SKIP_INITRAMFS_GEN=yes' /etc/default/raspi-firmware && ! grep -q '^[[:blank:]]*auto_initramfs=' /boot/firmware/config.txt && ! grep -q '^[[:blank:]]*initramfs[[:blank:]]' /boot/firmware/config.txt then @@ -2493,6 +2493,15 @@ Patch_10_6() # Assure "mount" is not autoremoved on Forky, just install/mark as manual on all versions, as it is required even for systemd mount units, but degraded to recommendation on Forky G_AGI mount + # Raspberry Pi with initramfs disabled and not initramfs-tools installed + if (( $G_HW_MODEL < 10 )) && grep -q '^[[:blank:]]*SKIP_INITRAMFS_GEN=yes' /etc/default/raspi-firmware && ! dpkg-query -s 'initramfs-tools' 2> /dev/null | grep -q '^Status: install ok installed$' + then + G_DIETPI-NOTIFY 2 'Switching to initramfs-tools to satisfy RPi kernel dependency, since other implementations keep generating initramfs images on "update-initramfs" trigger, even if none exist and the kernel declares not to require it.' + G_AGI initramfs-tools + G_EXEC rm -f /boot/initrd.img-* /boot/firmware/initramfs* + G_EXEC apt-mark auto initramfs-tools + fi + # dietpi-banner migrations if [[ -f '/boot/dietpi/.dietpi-banner' ]] then diff --git a/dietpi/func/dietpi-set_software b/dietpi/func/dietpi-set_software index da4ff4c65b..650d7df06d 100755 --- a/dietpi/func/dietpi-set_software +++ b/dietpi/func/dietpi-set_software @@ -879,6 +879,9 @@ deb $INPUT_MODE_VALUE $G_DISTRO_NAME-backports main contrib non-free non-free-fi G_EXEC systemctl daemon-reload findmnt /boot/firmware &> /dev/null || G_EXEC mount /boot/firmware + # Install initramfs-tools to satisfy dependency, since dracut and tiny-initramfs both always create an initramfs image on "update-initramfs" trigger. From Debian Forky on, dracut only refreshes existing images, like initramfs-tools does. + G_AGI initramfs-tools + # Show kernel choice dialogue: This installs the required kernel and firmware packages and allows to select optional kernel packages for other RPi models. until INPUT_MODE_VALUE='dietpi-rpi-firmware-migration' RPi_Kernel_Choice; do G_WHIP_MSG '[ INFO ] A selection is required!'; done @@ -887,6 +890,7 @@ deb $INPUT_MODE_VALUE $G_DISTRO_NAME-backports main contrib non-free non-free-fi then G_CONFIG_INJECT 'SKIP_INITRAMFS_GEN=' 'SKIP_INITRAMFS_GEN=yes' /etc/default/raspi-firmware G_EXEC rm -f /boot/initrd.img-* /boot/firmware/initramfs* + G_EXEC apt-mark auto initramfs-tools fi # Remove obsolete files From b7080a163d88c3aa58496e88e51e6a0464bf49c6 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Tue, 4 Aug 2026 17:30:26 +0200 Subject: [PATCH 04/10] dietpi-installer: fix /boot/dietpi/.installed generation --- .build/images/dietpi-installer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.build/images/dietpi-installer b/.build/images/dietpi-installer index 46c43d4729..3d0d3e2870 100755 --- a/.build/images/dietpi-installer +++ b/.build/images/dietpi-installer @@ -2354,7 +2354,7 @@ _EOF_ fi G_DIETPI-NOTIFY 2 'Setting initial dietpi-software install states' - G_CONFIG_INJECT 'aSOFTWARE_INSTALL_STATE\[103\]' 'aSOFTWARE_INSTALL_STATE[103]=2' /boot/dietpi/.installed + G_EXEC eval 'echo '\''aSOFTWARE_INSTALL_STATE[103]=2'\'' > /boot/dietpi/.installed' G_CONFIG_INJECT 'AUTO_SETUP_LOGGING_INDEX=' 'AUTO_SETUP_LOGGING_INDEX=-1' /boot/dietpi.txt if (( $G_HW_MODEL == 75 )) then From 17bb18f30060e13d007dbd1cb7f4dce42b36e5d7 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Tue, 4 Aug 2026 23:29:00 +0200 Subject: [PATCH 05/10] dietpi-installer: remove old /mnt/ftp_client directory We used to provide CurlFtpFS as network filesystem option, but it has been removed a long time ago for security reasons. Remove leftovers to avoid confusion. --- .build/images/dietpi-installer | 6 +++--- .update/patches | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.build/images/dietpi-installer b/.build/images/dietpi-installer index 3d0d3e2870..a3954b85c7 100755 --- a/.build/images/dietpi-installer +++ b/.build/images/dietpi-installer @@ -1886,9 +1886,9 @@ _EOF_ # Dirs G_DIETPI-NOTIFY 2 'Generating DietPi directories' G_EXEC mkdir -p /var/lib/dietpi/{postboot.d,dietpi-software/installed,logs/dietpi-ramlog_store} - G_EXEC mkdir -p /mnt/{dietpi_userdata,samba,ftp_client,nfs_client} - G_EXEC chgrp -R dietpi /mnt/{dietpi_userdata,samba,ftp_client,nfs_client} - G_EXEC find /mnt/{dietpi_userdata,samba,ftp_client,nfs_client} -type d -exec chmod 0775 {} + + G_EXEC mkdir -p /mnt/{dietpi_userdata,samba,nfs_client} + G_EXEC chgrp -R dietpi /mnt/{dietpi_userdata,samba,nfs_client} + G_EXEC find /mnt/{dietpi_userdata,samba,nfs_client} -type d -exec chmod 0775 {} + #----------------------------------------------------------------------------------- # Services diff --git a/.update/patches b/.update/patches index 249aaf8a2a..2a986d3901 100755 --- a/.update/patches +++ b/.update/patches @@ -2502,6 +2502,13 @@ Patch_10_6() G_EXEC apt-mark auto initramfs-tools fi + # Remove old FTP client dir, which is not used anymore since years + if [[ -d '/mnt/ftp_client' ]] + then + [[ -f '/mnt/ftp_client/readme.txt' ]] && G_EXEC rm /mnt/ftp_client/readme.txt + find /mnt/ftp_client -maxdepth 0 -empty -exec rmdir -v /mnt/ftp_client + fi + # dietpi-banner migrations if [[ -f '/boot/dietpi/.dietpi-banner' ]] then From 2974caa2a7fa97ae2e0a8db06fbd290dca0377ef Mon Sep 17 00:00:00 2001 From: MichaIng Date: Tue, 4 Aug 2026 23:46:28 +0200 Subject: [PATCH 06/10] dietpi-patches: fix find -exec termination --- .update/patches | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.update/patches b/.update/patches index 2a986d3901..121fbb3ee8 100755 --- a/.update/patches +++ b/.update/patches @@ -2506,7 +2506,7 @@ Patch_10_6() if [[ -d '/mnt/ftp_client' ]] then [[ -f '/mnt/ftp_client/readme.txt' ]] && G_EXEC rm /mnt/ftp_client/readme.txt - find /mnt/ftp_client -maxdepth 0 -empty -exec rmdir -v /mnt/ftp_client + find /mnt/ftp_client -maxdepth 0 -empty -exec rmdir -v /mnt/ftp_client + fi # dietpi-banner migrations From 9672668cfaf76c6687420ef7e4e4483bb3305cba Mon Sep 17 00:00:00 2001 From: MichaIng Date: Thu, 6 Aug 2026 13:43:33 +0200 Subject: [PATCH 07/10] dietpi-banner: enable rootfs disk usage by default The general disk usage option is enabled by default, but no default mount point exists. The banner shows a yellow warning in this case. The rootfs mount point is hence added as default now. During the migration, it was assumed that the general disk usage option is disabled by default, hence only its explicit enabled state was preserved. Now, the disabled state is preseved as well. The userdata disk usage option is now migrated more explicitly to the mount point array indices 0 or 1, depending on whether the rootfs disk usage option was previously enabled or not, to either replace or be added to the default rootfs entry. --- .update/patches | 33 ++++++++++++++++++++++++--------- dietpi/func/dietpi-banner | 2 +- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/.update/patches b/.update/patches index 121fbb3ee8..e605856854 100755 --- a/.update/patches +++ b/.update/patches @@ -2506,7 +2506,7 @@ Patch_10_6() if [[ -d '/mnt/ftp_client' ]] then [[ -f '/mnt/ftp_client/readme.txt' ]] && G_EXEC rm /mnt/ftp_client/readme.txt - find /mnt/ftp_client -maxdepth 0 -empty -exec rmdir -v /mnt/ftp_client + + find /mnt/ftp_client -maxdepth 0 -empty -exec rmdir -v {} + fi # dietpi-banner migrations @@ -2516,22 +2516,37 @@ Patch_10_6() G_DIETPI-NOTIFY 2 'Migrating /boot/dietpi/.dietpi-banner to new named arrays and options' - # Migrate legacy numeric-indexed aENABLED to named form, skipping disk usage (7 and 8) + # Migrate legacy numeric-indexed aENABLED to named form, skipping userdata disk usage (8) mapping=( - device_model uptime cpu_temp hostname nis_domainname lan_ip wan_ip '' '' + device_model uptime cpu_temp hostname nis_domainname lan_ip wan_ip disk_usage '' weather custom_commands dietpi_commands motd vpn_status large_hostname credits letsencrypt ram_usage load_average word_wrap kernel ) - for i in {0..6} {9..20} + for i in {0..7} {9..20} do G_EXEC sed --follow-symlinks -i "s/^[[:blank:]]*aENABLED\[$i\]=/aENABLED[${mapping[i]}]=/" /boot/dietpi/.dietpi-banner done - # Migrate legacy disk usage options - G_EXEC sed --follow-symlinks -i '\|^[[:blank:]]*aENABLED\[7\]=1|c\aDISK_SPACE_MOUNTS+=(/)' /boot/dietpi/.dietpi-banner - userdata=$(findmnt -Ufvnro TARGET -T /mnt/dietpi_userdata) - [[ $userdata == '/' ]] || G_EXEC sed --follow-symlinks -i "\|^[[:blank:]]*aENABLED\[8\]=1|c\aDISK_SPACE_MOUNTS+=('${userdata//\'/\'\\\'\'}')" /boot/dietpi/.dietpi-banner - grep -q '^aDISK_SPACE_MOUNTS+=' /boot/dietpi/.dietpi-banner && G_CONFIG_INJECT 'aENABLED\[disk_usage\]=' 'aENABLED[disk_usage]=1' /boot/dietpi/.dietpi-banner + # Migrate userdata disk usage option to new array + if grep -q '^[[:blank:]]*aENABLED\[8\]=1' /boot/dietpi/.dietpi-banner + then + userdata=$(findmnt -Ufvnro TARGET -T /mnt/dietpi_userdata) + # Enable only if userdata are located below an own mount point + if [[ $userdata && $userdata != '/' ]] + then + # Escape single quotes to be used within single quotation + userdata=${userdata//\'/\'\\\'\'} + if grep -q '^[[:blank:]]*aENABLED\[disk_usage\]=0' /boot/dietpi/.dietpi-banner + then + # If rootfs disk usage was disabled, add userdata as index 0, to replace the default rootfs entry, and enable the general disk usage option + G_CONFIG_INJECT 'aDISK_SPACE_MOUNTS\[0\]=' "aDISK_SPACE_MOUNTS[0]='$userdata'" /boot/dietpi/.dietpi-banner + G_CONFIG_INJECT 'aENABLED\[disk_usage\]=' 'aENABLED[disk_usage]=1' /boot/dietpi/.dietpi-banner + else + # If rootfs disk usage was enabled, add userdata as index 1, to be shown below the default rootfs entry + G_CONFIG_INJECT 'aDISK_SPACE_MOUNTS\[1\]=' "aDISK_SPACE_MOUNTS[1]='$userdata'" /boot/dietpi/.dietpi-banner + fi + fi + fi # Migrate legacy custom command file to aCUSTOM_COMMANDS array if present if [[ -f '/boot/dietpi/.dietpi-banner_custom' ]] diff --git a/dietpi/func/dietpi-banner b/dietpi/func/dietpi-banner index 6da5432591..0371e39ac9 100755 --- a/dietpi/func/dietpi-banner +++ b/dietpi/func/dietpi-banner @@ -118,7 +118,7 @@ declare -A aCUSTOM_COMMANDS=() # Default disk mounts (explicit paths) and patterns (globs/regex) - aDISK_SPACE_MOUNTS=() + aDISK_SPACE_MOUNTS=('/') aDISK_SPACE_PATTERNS=() # Load settings here, to have chosen custom CLI colours applied From 29e665832834518e64cb47b981410f29858e73bb Mon Sep 17 00:00:00 2001 From: MichaIng Date: Thu, 6 Aug 2026 14:01:43 +0200 Subject: [PATCH 08/10] dietpi-installer: Odroid N2/HC4: add boot label for petitboot The petitboot boot menu shows the value of the `bootlabel` environment variable, if set, else "NO LABEL", which makes it difficult to identify the correct partition in multi-boot cases, with kernel device name and UUID only. Add "DietPi" as simple label. --- .build/images/dietpi-installer | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.build/images/dietpi-installer b/.build/images/dietpi-installer index a3954b85c7..22c7aca5c4 100755 --- a/.build/images/dietpi-installer +++ b/.build/images/dietpi-installer @@ -688,12 +688,14 @@ _EOF_ \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 +setenv rootuuid "true"\ +setenv bootlabel "DietPi"' /boot/boot.cmd # shellcheck disable=SC2016 (( $G_HW_MODEL == 17 )) && G_EXEC sed --follow-symlinks -i '/^setenv fdt_addr_r/a\ \n# petitboot workarounds\ setenv fdtfile "amlogic/meson-sm1-odroid-${variant}.dtb"\ -setenv rootuuid "true"' /boot/boot.cmd +setenv rootuuid "true"\ +setenv bootlabel "DietPi"' /boot/boot.cmd # shellcheck disable=SC2016 G_EXEC sed --follow-symlinks -i '/env import/c\ ini main ${scriptaddr} || env import -t ${scriptaddr} ${filesize}' /boot/boot.cmd # shellcheck disable=SC2016 From 60d0bcc12dba4e196a63225ddbdd41d9f7209cd6 Mon Sep 17 00:00:00 2001 From: MichaIng Date: Thu, 6 Aug 2026 14:51:33 +0200 Subject: [PATCH 09/10] dietpi-software: remove world-read access for vaultwarden.env It can be used to provide the ADMIN_TOKEN hash to enable the admin panel. It is an Argon2ID hash, hence practically impossible to brute-force off site with current computing power. But if a dictionary password is used, the strongest hashing algorithm does not help, and the information that the admin panel is enabled at all, should not be made public too lightly. --- .build/software/vaultwarden/build.bash | 1 + .update/patches | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/.build/software/vaultwarden/build.bash b/.build/software/vaultwarden/build.bash index d01d5e5ce0..fc7b970abb 100755 --- a/.build/software/vaultwarden/build.bash +++ b/.build/software/vaultwarden/build.bash @@ -124,6 +124,7 @@ _EOF_ # - Permissions G_EXEC find "$DIR" -type f -exec chmod 0644 {} + G_EXEC find "$DIR" -type d -exec chmod 0755 {} + +G_EXEC chmod 0640 "$DIR/mnt/dietpi_userdata/vaultwarden/vaultwarden.env" G_EXEC chmod +x "$DIR/opt/vaultwarden/vaultwarden" # Control files diff --git a/.update/patches b/.update/patches index e605856854..7b67fdc53b 100755 --- a/.update/patches +++ b/.update/patches @@ -2574,6 +2574,13 @@ Patch_10_6() # Software updates, migrations and patches if [[ -f '/boot/dietpi/.installed' ]] then + # vaultwarden + if [[ -f '/mnt/dietpi_userdata/vaultwarden/vaultwarden.env' ]] + then + G_DIETPI-NOTIFY 2 'Applying stricter mode to vaultwarden.env, as it can be used to provide secret hashes like ADMIN_TOKEN. Use the "vaultwarden" group if any other user requires read access.' + G_EXEC chmod 'o-r' /mnt/dietpi_userdata/vaultwarden/vaultwarden.env + fi + # Pi-hole v6 migration # - /etc/pihole/pihole.toml indicates that Pi-hole has been upgraded to v6 already. # - The /var/www/pihole symlink indicates that an instance installed via dietpi-software has not been migrated yet. From 0034cc4c280ebcb51b77752b9a72ffe3bedf4c5c Mon Sep 17 00:00:00 2001 From: MichaIng Date: Fri, 7 Aug 2026 01:31:00 +0200 Subject: [PATCH 10/10] RC up and some format alignment Unset syntax_error function after G_CONFIG_INJECT finished. Not sure what the idea was to unset the syntax_error *variable* at the end of the syntax_error function call. Probably some late night brain failure :). --- .update/version | 2 +- dietpi/func/dietpi-globals | 64 ++++++++++++++++---------------------- 2 files changed, 28 insertions(+), 38 deletions(-) diff --git a/.update/version b/.update/version index 52934ca2b1..df82c0f5cf 100644 --- a/.update/version +++ b/.update/version @@ -3,7 +3,7 @@ # Available DietPi version G_REMOTE_VERSION_CORE=10 G_REMOTE_VERSION_SUB=6 -G_REMOTE_VERSION_RC=0 +G_REMOTE_VERSION_RC=1 # Minimum DietPi version to allow update G_MIN_VERSION_CORE=8 G_MIN_VERSION_SUB=0 diff --git a/dietpi/func/dietpi-globals b/dietpi/func/dietpi-globals index 8ce2b4b887..c6247f97ab 100644 --- a/dietpi/func/dietpi-globals +++ b/dietpi/func/dietpi-globals @@ -55,7 +55,7 @@ # - Assign defaults/code version as fallback [[ $G_DIETPI_VERSION_CORE ]] || G_DIETPI_VERSION_CORE=10 [[ $G_DIETPI_VERSION_SUB ]] || G_DIETPI_VERSION_SUB=6 - [[ $G_DIETPI_VERSION_RC ]] || G_DIETPI_VERSION_RC=0 + [[ $G_DIETPI_VERSION_RC ]] || G_DIETPI_VERSION_RC=1 [[ $G_GITBRANCH ]] || G_GITBRANCH='master' [[ $G_GITOWNER ]] || G_GITOWNER='MichaIng' # - Save current version and Git branch @@ -2132,8 +2132,8 @@ Press any key to continue...' # \ . + * ? [ ( { ^ & $ | # Example: # - G_CONFIG_INJECT 'prefer-family[[:blank:]=]' 'prefer-family = IPv4' /etc/wgetrc - G_CONFIG_INJECT(){ - + G_CONFIG_INJECT() + { [[ $G_PROGRAM_NAME ]] || local G_PROGRAM_NAME='G_CONFIG_INJECT' local pattern=${1//\//\\\/} local setting_raw=$2 @@ -2149,16 +2149,15 @@ Press any key to continue...' [[ -t 0 || -t 1 ]] && yellow='\e[33m' reset='\e[0m' # Replace password string by asterisks in output string - if [[ $GCI_PASSWORD == 1 ]]; then - + if [[ $GCI_PASSWORD == 1 ]] + then local password=$(sed -E "s/^.*${pattern}[[:blank:]]*//" <<< "$setting_raw") setting_raw="$(sed -E "s/(^.*${pattern}[[:blank:]]*).*$/\1/" <<< "$setting_raw")${password//?/*}" unset -v password - fi - syntax_error(){ - + syntax_error() + { [[ $after ]] && after="after line \$4\n $after (raw escaped input)\n" [[ $error ]] && error="\n\"grep\" or \"sed\" reported the following error:\n $error\n" @@ -2177,33 +2176,31 @@ NB: - Additionally in case of extended regular expression support (\$1 and \$4), the following characters need to be escaped via backslash \, if wanted literally: \ . + * ? [ ( { ^ & $ | - Do not escape forward slashes /, which will be done internally for all arguments!" - - unset -v syntax_error - } - if [[ ! -w $file ]]; then - + if [[ ! -w $file ]] + then G_WHIP_MSG "[FAILED] File does not exist or cannot be written to by current user \nPlease verify the existence of the file \$3 $file \nRetry with proper permissions or apply the setting manually: $setting_raw" - elif error=$(grep -Eq "^[[:blank:]]*$pattern" "$file" 2>&1); then - # As an error within the condition leads to result "false", it can be caught only in next "elif"/"else" statement. - - if [[ $GCI_PRESERVE == 1 ]]; then - + # As an error within the condition leads to result "false", it can be caught only in next "elif"/"else" statement. + elif error=$(grep -Eq "^[[:blank:]]*$pattern" "$file" 2>&1) + then + if [[ $GCI_PRESERVE == 1 ]] + then # shellcheck disable=SC2015 G_DIETPI-NOTIFY 0 "Current setting in $yellow$file$reset will be preserved: $yellow$([[ $GCI_PASSWORD == 1 ]] && echo "${setting_raw//\\/\\\\}" || grep -Em1 "^[[:blank:]]*$pattern" "$file" | sed 's|\\|\\\\|g')$reset" - elif error=$(grep -Eq "^[[:blank:]]*$setting$" "$file" 2>&1); then - + elif error=$(grep -Eq "^[[:blank:]]*$setting$" "$file" 2>&1) + then # shellcheck disable=SC2015 G_DIETPI-NOTIFY 0 "Desired setting in $yellow$file$reset was already set: $yellow$([[ $GCI_PASSWORD == 1 ]] && echo "${setting_raw//\\/\\\\}" || grep -Em1 "^[[:blank:]]*$pattern" "$file" | sed 's|\\|\\\\|g')$reset" - elif error=$( (( $(grep -Ec "^[[:blank:]]*$pattern" "$file" 2>&1) > 1 )) 2>&1); then + elif error=$( (( $(grep -Ec "^[[:blank:]]*$pattern" "$file" 2>&1) > 1 )) 2>&1) + then [[ $error ]] && { syntax_error; return 1; } G_WHIP_MSG "[FAILED] Setting was found multiple times @@ -2217,34 +2214,31 @@ ____________ \nEither the pattern \$1 needs to be more specific or the desired setting can appear multiple times by design and it cannot be predicted which instance to edit. Please retry with more specific parameter \$1 or apply the setting manually: $setting_raw" - else [[ $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 --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 - elif error=$(grep -Eq "^[[:blank:]#;]*$pattern" "$file" 2>&1); then + elif error=$(grep -Eq "^[[:blank:]#;]*$pattern" "$file" 2>&1) + then [[ $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 --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 [[ $error ]] && { syntax_error; return 1; } - if [[ $after ]]; then - - if error=$(grep -Eq "^[[:blank:]]*$after" "$file" 2>&1); then - + if [[ $after ]] + then + 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 --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 [[ $error ]] && { syntax_error; return 1; } @@ -2255,21 +2249,17 @@ could not be found in file \$3 $file \nPlease retry with valid parameter \$4 or apply the setting manually: $setting_raw" - fi - else - [[ $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" + # The following sed does not work on empty files, hence add some dummy comment in case: + [[ -s $file ]] || echo '# Added by DietPi:' >> "$file" 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 - fi + unset -f syntax_error } # Subprocess-less sleep