Skip to content
18 changes: 11 additions & 7 deletions .build/images/dietpi-installer
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .build/software/vaultwarden/build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
56 changes: 47 additions & 9 deletions .update/patches
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2493,29 +2493,60 @@ 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
local i mapping userdata name command

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' ]]
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion .update/version
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

-----------------------------------------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion dietpi/func/dietpi-banner
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
65 changes: 27 additions & 38 deletions dietpi/func/dietpi-globals
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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"

Expand All @@ -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
Expand All @@ -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; }

Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions dietpi/func/dietpi-set_software
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down