diff --git a/.build/images/dietpi-installer b/.build/images/dietpi-installer index 5bcc5b8cbf..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 @@ -1410,10 +1412,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 @@ -1884,9 +1888,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 @@ -2352,7 +2356,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 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 4c20bbac91..7b67fdc53b 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,22 @@ 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 + + # 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 {} + + fi + # dietpi-banner migrations if [[ -f '/boot/dietpi/.dietpi-banner' ]] then @@ -2500,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' ]] @@ -2543,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. 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/CHANGELOG.txt b/CHANGELOG.txt index 2b5651044c..f0e4af6eb7 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -13,13 +13,14 @@ 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 - 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-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 diff --git a/dietpi/func/dietpi-globals b/dietpi/func/dietpi-globals index c8332d70ef..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 @@ -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 @@ -2133,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 @@ -2150,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" @@ -2178,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 @@ -2218,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; } @@ -2256,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 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