diff --git a/.conf/desktop/lxqt/lxqt-bullseye.7z b/.conf/desktop/lxqt/lxqt-bullseye.7z new file mode 100644 index 0000000000..82f7aa2141 Binary files /dev/null and b/.conf/desktop/lxqt/lxqt-bullseye.7z differ diff --git a/.meta/dietpi-build b/.meta/dietpi-build new file mode 100644 index 0000000000..c0f1611727 --- /dev/null +++ b/.meta/dietpi-build @@ -0,0 +1,226 @@ +#!/bin/bash +# Created by MichaIng / micha@dietpi.com / dietpi.com +{ +# Load DietPi-Globals +. /boot/dietpi/func/dietpi-globals +readonly G_PROGRAM_NAME='DietPi-Build' +G_CHECK_ROOT_USER +G_CHECK_ROOTFS_RW +readonly FP_ORIGIN=$PWD # Store origin dir +G_INIT +G_EXEC cd "$FP_ORIGIN" # Process everything in origin dir instead of /tmp/$G_PROGRAM_NAME +G_EXIT_CUSTOM(){ + findmnt -M "$FP_ORIGIN/rootfs" &> /dev/null && G_EXEC umount -R "$FP_ORIGIN/rootfs" + [[ -d $FP_ORIGIN/rootfs ]] && G_EXEC rmdir "$FP_ORIGIN/rootfs" + losetup /dev/loop0 &> /dev/null && G_EXEC losetup -d /dev/loop0 + (( $mask_dbus )) && G_EXEC systemctl mask --now dbus dbus.socket +} + +# Inputs +HW_MODEL= +HW_ARCH= +PTTYPE='msdos' +FSTYPE='ext4' +ITYPE= +while (( $# )) +do + case $1 in + '-m') shift; HW_MODEL=$1;; + '-a') shift; HW_ARCH=$1;; + '-p') shift; PTTYPE=$1;; + '-f') shift; FSTYPE=$1;; + '-i') ITYPE='Installer';; + *) G_DIETPI-NOTIFY 1 "Invalid input \"$1\", aborting..."; exit 1;; + esac + shift +done + +# Check for valid target hardware model and set variables accordingly +WIFI_REQUIRED=1 +partition_start=4 +efi_size=64 +boot_size=128 +root_size=892 +CLONING_TOOL='dd' +case $HW_MODEL in + 0) iname='RPi';; + 20) iname='VM' WIFI_REQUIRED=1 boot_size=0;; + 21) iname='NativePC-BIOS' HW_ARCH=10 root_size=1152;; + *) G_DIETPI-NOTIFY 1 "Invalid hardware model \"$HW_MODEL\" passed, aborting..."; exit 1;; +esac + +# Check for valid target architecture and set variables accordingly +case $HW_ARCH in + 1) iarch='ARMv6' parch='armhf' repo='http://raspbian.raspberrypi.org/raspbian/';; + 2) iarch='ARMv7' parch='armhf' repo='https://deb.debian.org/debian/';; + 3) iarch='ARMv8' parch='arm64' repo='https://deb.debian.org/debian/';; + 10) iarch='x86_64' parch='amd64' repo='https://deb.debian.org/debian/' partition_start=1;; + *) G_DIETPI-NOTIFY 1 "Invalid architecture \"$HW_ARCH\" passed, aborting..."; exit 1;; +esac + +case $PTTYPE in + 'msdos') efi_size=0;; + 'gpt') [[ $HW_ARCH == 10 ]] && iname='NativePC-UEFI' ITYPE='Installer';; + *) G_DIETPI-NOTIFY 1 "Invalid partition table type \"$PTTYPE\" passed, aborting..."; exit 1;; +esac + +case $FSTYPE in + 'ext4'|'f2fs'|'btrfs') :;; + *) G_DIETPI-NOTIFY 1 "Invalid filesystem type \"$FSTYPE\" passed, aborting..."; exit 1;; +esac + +# Image name +OUTPUT_IMG_NAME="DietPi_$iname-$iarch-Bullseye" +[[ $ITYPE ]] && OUTPUT_IMG_NAME+="_$ITYPE" + +# For installer images, disable dedicated boot partition, as it cannot be accessed to edit dietpi.txt anyway +[[ $ITYPE == 'Installer' ]] && root_size=$((root_size+boot_size)) boot_size=0 CLONING_TOOL='Clonezilla' + +# Dependencies +G_AG_CHECK_INSTALL_PREREQ parted dosfstools debootstrap dbus systemd-container + +# Create image file +G_EXEC fallocate -l "$((partition_start+efi_size+boot_size+root_size))M" "$OUTPUT_IMG_NAME.img" + +# GPT: Create EFI partition and set partition labels instead of types +if [[ $PTTYPE == 'gpt' ]] +then + G_EXEC parted -s "$OUTPUT_IMG_NAME.img" unit MiB mklabel gpt mkpart 'EFI' fat32 $partition_start $((partition_start+efi_size)) set 1 esp on + # Create boot partition it set + (( $boot_size )) && G_EXEC parted -s "$OUTPUT_IMG_NAME.img" unit MiB mkpart 'boot' fat32 $((partition_start+efi_size)) $((partition_start+efi_size+boot_size)) + # root partition + G_EXEC parted -s "$OUTPUT_IMG_NAME.img" unit MiB mkpart 'root' "$FSTYPE" $((partition_start+efi_size+boot_size)) 100% + +# MBR: Set partition types instead of labels +else + G_EXEC parted -s "$OUTPUT_IMG_NAME.img" unit MiB mklabel msdos + # Create boot partition it set + (( $boot_size )) && G_EXEC parted -s "$OUTPUT_IMG_NAME.img" unit MiB mkpart primary fat32 $((partition_start)) $((partition_start+boot_size)) + # root partition + G_EXEC parted -s "$OUTPUT_IMG_NAME.img" unit MiB mkpart primary "$FSTYPE" $((partition_start+boot_size)) 100% + # x86_64: Set boot flag + G_EXEC parted -s "$OUTPUT_IMG_NAME.img" set 1 boot on +fi + +# Create loop device +G_EXEC losetup loop0 "$OUTPUT_IMG_NAME.img" +G_EXEC partprobe /dev/loop0 +G_EXEC partx -u /dev/loop0 + +# Create and mount filesystems and fstab +G_EXEC mkdir rootfs +if [[ $PTTYPE == 'gpt' ]] && (( $boot_size )) +then + FP_ROOT_DEV=3 + G_EXEC mkfs.fat -F 32 /dev/loop0p1 + G_EXEC mkfs.fat -F 32 /dev/loop0p2 + G_EXEC "mkfs.$FSTYPE" /dev/loop0p3 + G_EXEC mount /dev/loop0p3 rootfs + G_EXEC mkdir rootfs/boot + G_EXEC mount /dev/loop0p2 rootfs/boot + G_EXEC mkdir rootfs/boot/efi + G_EXEC mount /dev/loop0p1 rootfs/boot/efi + G_EXEC mkdir rootfs/etc + cat << _EOF_ > rootfs/etc/fstab +PARTUUID=$(lsblk -no PARTUUID /dev/loop0p3) / $FSTYPE noatime,lazytime 0 1 +PARTUUID=$(lsblk -no PARTUUID /dev/loop0p2) /boot vfat noatime,lazytime 0 2 +PARTUUID=$(lsblk -no PARTUUID /dev/loop0p1) /boot/efi vfat noatime,lazytime 0 3 +_EOF_ + +elif [[ $PTTYPE == 'gpt' ]] +then + FP_ROOT_DEV=2 + G_EXEC mkfs.fat -F 32 /dev/loop0p1 + G_EXEC "mkfs.$FSTYPE" /dev/loop0p2 + G_EXEC mount /dev/loop0p2 rootfs + G_EXEC mkdir -p rootfs/boot/efi + G_EXEC mount /dev/loop0p1 rootfs/boot/efi + G_EXEC mkdir rootfs/etc + cat << _EOF_ > rootfs/etc/fstab +PARTUUID=$(lsblk -no PARTUUID /dev/loop0p2) / $FSTYPE noatime,lazytime 0 1 +PARTUUID=$(lsblk -no PARTUUID /dev/loop0p1) /boot/efi vfat noatime,lazytime 0 2 +_EOF_ + +elif (( $boot_size )) +then + FP_ROOT_DEV=2 + G_EXEC mkfs.fat -F 32 /dev/loop0p1 + G_EXEC "mkfs.$FSTYPE" /dev/loop0p2 + G_EXEC mount /dev/loop0p2 rootfs + G_EXEC mkdir rootfs/boot + G_EXEC mount /dev/loop0p1 rootfs/boot + G_EXEC mkdir rootfs/etc + cat << _EOF_ > rootfs/etc/fstab +PARTUUID=$(lsblk -no PARTUUID /dev/loop0p2) / $FSTYPE noatime,lazytime 0 1 +PARTUUID=$(lsblk -no PARTUUID /dev/loop0p1) /boot vfat noatime,lazytime 0 2 +_EOF_ + +else + FP_ROOT_DEV=1 + G_EXEC "mkfs.$FSTYPE" /dev/loop0p1 + G_EXEC mount /dev/loop0p1 rootfs + G_EXEC mkdir rootfs/etc + cat << _EOF_ > rootfs/etc/fstab +PARTUUID=$(lsblk -no PARTUUID /dev/loop0p1) / $FSTYPE noatime,lazytime 0 1 +_EOF_ +fi + +# Create rc.local to automate DietPi-PREP +cat << '_EOF_' > rootfs/etc/rc.local +#!/bin/dash +{ +_EOF_ +G_EXEC chmod +x rootfs/etc/rc.local + +# - RPi only: https://github.com/RPi-Distro/repo/issues/253 +[[ $HW_MODEL == 0 ]] && cat << '_EOF_' >> rootfs/etc/rc.local +curl -sSfLO 'https://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-archive-keyring/raspberrypi-archive-keyring_2016.10.31_all.deb' || exit 1 +dpkg -i raspberrypi-archive-keyring_2016.10.31_all.deb || exit 1 +rm raspberrypi-archive-keyring_2016.10.31_all.deb || exit 1 +_EOF_ + +cat << _EOF_ >> rootfs/etc/rc.local +export GITBRANCH='master' HW_MODEL='$HW_MODEL' IMAGE_CREATOR=0 PREIMAGE_INFO='from scratch' WIFI_REQUIRED=$WIFI_REQUIRED DISTRO_TARGET=6 +bash -c "\$(curl -sSfL 'https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/PREP_SYSTEM_FOR_DIETPI.sh')" +poweroff +exit 0 +} > /dev/console 2>&1 < /dev/console +_EOF_ + +# Bootstrap +G_EXEC_OUTPUT=1 G_EXEC debootstrap --arch="$parch" --variant=minbase --exclude='gcc-7-base,gcc-8-base,gcc-9-base' --include='bash-completion,bzip2,ca-certificates,console-setup,cron,curl,dropbear,ethtool,fake-hwclock,fdisk,gnupg,htop,ifupdown,isc-dhcp-client,kmod,locales,nano,p7zip,parted,procps,psmisc,rfkill,sudo,systemd-sysv,systemd-timesyncd,tzdata,udev,unzip,usbutils,wget,whiptail' --no-check-gpg bullseye ./rootfs "$repo" + +# Remove cached archives and list files created by debootstrap +G_EXEC rm -Rf rootfs/var/{cache/apt,lib/apt/lists}/* + +# Start container +# - dbus required for container spawn +mask_dbus=0 +if [[ $(readlink /etc/systemd/system/dbus.socket) == '/dev/null' ]] +then + mask_dbus=1 + G_EXEC systemctl unmask dbus.socket dbus + G_EXEC systemctl start dbus.socket dbus +fi +# - Bind mounts required to allow container reading its own drive info, /dev/disk for GRUB and probably other tools to detect UUIDs +# - CAP_IPC_LOCK required for mlock/mlockall, used by vmtouch +abind=() +[[ -b '/dev/loop0p2' ]] && abind=('--bind=/dev/loop0p2') +[[ -b '/dev/loop0p3' ]] && abind+=('--bind=/dev/loop0p3') +systemd-nspawn -bD rootfs --bind=/dev/loop0 --bind=/dev/loop0p1 "${abind[@]}" --bind=/dev/disk --capability=CAP_IPC_LOCK || exit 1 +G_EXEC sync +G_EXEC sleep 1 +G_EXEC umount -R rootfs +G_EXEC rmdir rootfs +G_EXEC losetup -d /dev/loop0 +(( $mask_dbus )) && { G_EXEC systemctl mask --now dbus dbus.socket && mask_dbus=0; } + +# Imager +export FP_ROOT_DEV CLONING_TOOL OUTPUT_IMG_NAME MOUNT_IT='Off' +bash -c "$(curl -sSfL "https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH/.meta/dietpi-imager")" 'DietPi-Imager' "$OUTPUT_IMG_NAME.img" || exit 1 + +# Upload +[[ -x 'upload.sh' ]] && ./upload.sh "$OUTPUT_IMG_NAME.7z" + +exit 0 +} diff --git a/.meta/dietpi-imager b/.meta/dietpi-imager index 6fc3cf72c4..28505d1221 100755 --- a/.meta/dietpi-imager +++ b/.meta/dietpi-imager @@ -26,26 +26,40 @@ G_EXEC cd "$FP_ORIGIN" # Process everything in origin dir instead of /tmp/$G_PROGRAM_NAME # Import DietPi-Globals --------------------------------------------------------------- - readonly FP_MNT_TMP="/tmp/${G_PROGRAM_NAME}_rootfs" + readonly FP_MNT_TMP="/tmp/${G_PROGRAM_NAME}_mnt" readonly CLONEZILLA_REPO='https://sourceforge.net/projects/clonezilla/files/clonezilla_live_alternative' readonly DIETPI_REPO="https://raw.githubusercontent.com/$G_GITOWNER/DietPi/$G_GITBRANCH" - SOURCE_TYPE='Drive' - FP_SOURCE_IMG= - FP_SOURCE= + # Inputs + if [[ -b $1 ]] + then + SOURCE_TYPE='Drive' + FP_SOURCE=$1 + + elif [[ -f $1 ]] + then + SOURCE_TYPE='Image' + FP_SOURCE_IMG=$1 + + elif [[ $1 ]] + then + G_DIETPI-NOTIFY 1 "Input source $1 does not exist, aborting..." + exit 1 + fi PART_TABLE_TYPE= - FP_ROOT_DEV= + #FP_ROOT_DEV= ROOT_FS_TYPE= - CLONING_TOOL='dd' + #CLONING_TOOL= OUTPUT_IMG_EXT='img' - OUTPUT_IMG_NAME='DietPi_RPi-ARMv6-Buster' - MOUNT_IT='Off' + #OUTPUT_IMG_NAME= + [[ $MOUNT_IT == 'On' ]] || MOUNT_IT='Off' Delete_Loopback(){ [[ $FP_SOURCE ]] && losetup "$FP_SOURCE" &> /dev/null && G_EXEC losetup -d "$FP_SOURCE"; } G_EXIT_CUSTOM() { - findmnt $FP_MNT_TMP > /dev/null && G_EXEC umount -R $FP_MNT_TMP + findmnt $FP_MNT_TMP > /dev/null && Unmount_tmp + [[ -d $FP_MNT_TMP ]] && G_EXEC rmdir $FP_MNT_TMP [[ $FP_SOURCE_IMG ]] && Delete_Loopback } @@ -168,7 +182,7 @@ main_menu_choice='Target name' # On cancel, keep this entry selected G_WHIP_DEFAULT_ITEM=$OUTPUT_IMG_NAME - G_WHIP_INPUTBOX 'Please enter a name for the new image:\n - DietPi_--\n - E.g.: DietPi_RPi-ARMv6-Buster' || return + G_WHIP_INPUTBOX 'Please enter a name for the new image:\n - DietPi_--\n - E.g.: DietPi_RPi-ARMv6-Bullseye' || return OUTPUT_IMG_NAME=$G_WHIP_RETURNED_VALUE # Check for existing file, in case offer backup. Skip if source is image file and matches output file already. @@ -186,13 +200,13 @@ Menu_Main() { G_WHIP_MENU_ARRAY=( - 'Source type' ": [$SOURCE_TYPE] Select how the input OS is stored" + 'Source type' ": [${SOURCE_TYPE:=Drive}] Select how the input OS is stored" 'Source path' ": [${FP_SOURCE_IMG:-$FP_SOURCE}] Select the input $SOURCE_TYPE" ) [[ $FP_SOURCE ]] && G_WHIP_MENU_ARRAY+=('Source rootfs' ": [$FP_ROOT_DEV] Select input OS root partition") G_WHIP_MENU_ARRAY+=( - 'Target type' ": [$CLONING_TOOL] Select output image type" - 'Target name' ": [$OUTPUT_IMG_NAME] Choose the output image name" + 'Target type' ": [${CLONING_TOOL:=dd}] Select output image type" + 'Target name' ": [${OUTPUT_IMG_NAME:=DietPi_RPi-ARMv6-Bullseye}] Choose the output image name" '' '●─' 'Mount' ": [$MOUNT_IT] Review or edit drive content before image creation" ) @@ -232,15 +246,45 @@ fi } + Unmount_tmp() + { + G_EXEC sync + G_EXEC sleep 1 # Give the system 1 second to avoid "mount is busy" + G_EXEC umount -R $FP_MNT_TMP + } + Main(){ - local main_menu_choice - Menu_Source_Type - until [[ $main_menu_choice == 'Start' ]] - do - Menu_Main - done - unset -v main_menu_choice + # Skip menu if all inputs are provided via environment variables + if [[ ( $SOURCE_TYPE$FP_SOURCE == 'Drive'?* || $SOURCE_TYPE$FP_SOURCE_IMG == 'Image'?* ) && $FP_ROOT_DEV && $CLONING_TOOL =~ ^(dd|Clonezilla)$ && $OUTPUT_IMG_NAME ]] + then + if [[ $SOURCE_TYPE == 'Image' ]] + then + # Create loopback device from .img file + G_EXEC modprobe loop + Delete_Loopback # Prevent doubled loop device + FP_SOURCE=$(losetup -f) + G_EXEC_NOEXIT=1 G_EXEC losetup "$FP_SOURCE" "$FP_SOURCE_IMG" || return + G_EXEC_NOEXIT=1 G_EXEC partprobe "$FP_SOURCE" || return + G_EXEC_NOEXIT=1 G_EXEC partx -u "$FP_SOURCE" || return + G_DIETPI-NOTIFY 0 "Mounted the image ($FP_SOURCE_IMG) as loopback device: $FP_SOURCE" + FP_ROOT_DEV="${FP_SOURCE}p${FP_ROOT_DEV: -1}" + fi + [[ $CLONING_TOOL == 'dd' ]] && OUTPUT_IMG_EXT='img' || OUTPUT_IMG_EXT='iso' + G_DIETPI-NOTIFY 0 "\e[0mCreating minified image from: +- $SOURCE_TYPE: ${FP_SOURCE_IMG:-$FP_SOURCE} +- Root device: $FP_ROOT_DEV +- Via $CLONING_TOOL to $OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT +- With intermediate mounting turned $MOUNT_IT" + else + local main_menu_choice + Menu_Source_Type + until [[ $main_menu_choice == 'Start' ]] + do + Menu_Main + done + unset -v main_menu_choice + fi # Install required packages: fdisk is an own package since Debian Buster: https://packages.debian.org/fdisk local fdisk @@ -254,13 +298,10 @@ then G_DIETPI-NOTIFY 2 'MBR partition table detected' - # GPT images: - # - "GPT PMBR size mismatch (4458495 != 15523839)" - # - "Error: The backup GPT table is corrupt, but the primary appears OK, so that will be used." - # - gdisk will correct this + # Move GPT backup partition table to end of drive elif [[ $PART_TABLE_TYPE == 'gpt' ]] then - G_DIETPI-NOTIFY 2 'GPT partition table detected, applying backup table fix...' + G_DIETPI-NOTIFY 2 'GPT partition table detected, moving GPT backup partition table to end of drive...' G_AG_CHECK_INSTALL_PREREQ gdisk G_EXEC_OUTPUT=1 G_EXEC sgdisk -e "$FP_SOURCE" else @@ -274,7 +315,7 @@ Run_fsck # Remount image for any required edits - G_EXEC mkdir -p $FP_MNT_TMP + G_EXEC mkdir $FP_MNT_TMP G_EXEC mount "$FP_ROOT_DEV" $FP_MNT_TMP # - Remove bash history, which is stored on shutdown, hence cannot be removed via DietPi-PREP rm -fv $FP_MNT_TMP/{root,home/*}/.bash_history @@ -292,12 +333,10 @@ G_EXEC cd "$FP_ORIGIN" (( $reallow_dietpi_login )) && unset -v G_DIETPI_LOGIN fi - sync - sleep 1 # Give the system 1 second to avoid "mount is busy" - G_EXEC umount -R $FP_MNT_TMP - G_EXEC rmdir $FP_MNT_TMP - G_EXEC partprobe "$FP_SOURCE" # Failsafe - G_EXEC partx -u "$FP_SOURCE" # Failsafe + Unmount_tmp + # Failsafe + G_EXEC partprobe "$FP_SOURCE" + G_EXEC partx -u "$FP_SOURCE" Run_fsck # Shrink filesystem to minimum @@ -312,12 +351,15 @@ resize2fs -M "$FP_ROOT_DEV" 2>&1 | tee resize2fs_out if out=$(grep -im1 'nothing to do!' resize2fs_out) then + rm resize2fs_out FS_SIZE=$(mawk '{print $5}' <<< "$out") # blocks BLOCK_SIZE=${out%%k) *} BLOCK_SIZE=${BLOCK_SIZE##*\(} # KiB - # Re-add 4 MiB to be failsafe, was required on Raspbian Buster for successful boot - FS_SIZE=$(( $FS_SIZE + 4096/$BLOCK_SIZE )) # blocks - rm resize2fs_out - G_EXEC resize2fs "$FP_ROOT_DEV" $FS_SIZE + # Re-add 4 MiB if it would still fit into the partition, which was required on Raspbian Buster for successful boot. + if (( $( $FS_SIZE * $BLOCK_SIZE * 2 + 8 )) # 512 byte sectors + then + FS_SIZE=$(( $FS_SIZE + 4096/$BLOCK_SIZE )) # blocks + G_EXEC resize2fs "$FP_ROOT_DEV" $FS_SIZE + fi G_DIETPI-NOTIFY 0 "Reduced RootFS size to $(( $FS_SIZE * $BLOCK_SIZE / 1024 + 1 )) MiB" FS_SIZE=$(( $FS_SIZE * $BLOCK_SIZE * 2 )) # blocks => 512 byte sectors break @@ -328,12 +370,9 @@ exit 1 fi done - G_DIETPI-NOTIFY 2 'Overriding root filesystem free space with zeros to purge removed data and allow further archive size reduction...' - G_EXEC_OUTPUT=1 G_EXEC zerofree -v "$FP_ROOT_DEV" - G_EXEC sync - elif [[ $ROOT_FS_TYPE == 'f2fs' ]] #&& $(lsblk -rno FSUSE% "$FP_ROOT_DEV") =~ ^(9[5-9]|100)%$ ]] - then + #elif [[ $ROOT_FS_TYPE == 'f2fs' && ! $(lsblk -rno FSUSE% "$FP_ROOT_DEV") =~ ^(9[5-9]|100)%$ ]] + #then # F2FS does not support shrinking: https://www.reddit.com/r/archlinux/comments/bpp77f/shrinking_a_f2fs_partition/ # Hence copy all data outside, remove and re-create a smaller filesytem, then copy them back in, as long as disk usage is not >=95% already. # The UUID changes and there is currently no way to change it back... @@ -341,8 +380,8 @@ #local sector_size=$(lsblk -rnbo LOG-SEC "$FP_ROOT_DEV") # bytes #FS_SIZE=$(( ( $usage + 4*1024**2 ) / $sector_size )) # bytes + 4 MiB buffer => sectors #G_DIETPI-NOTIFY 2 'Copying root filesystem content to temporary directory' - G_EXEC mkdir -p ${FP_MNT_TMP}{,_backup} - G_EXEC mount -o ro "$FP_ROOT_DEV" $FP_MNT_TMP + #G_EXEC mkdir ${FP_MNT_TMP}_backup + #G_EXEC mount -o ro "$FP_ROOT_DEV" $FP_MNT_TMP #G_EXEC cp -a $FP_MNT_TMP/. ${FP_MNT_TMP}_backup/ #G_EXEC umount $FP_MNT_TMP #G_DIETPI-NOTIFY 2 'Purging root filesystem' @@ -353,30 +392,40 @@ #G_EXEC mount "$FP_ROOT_DEV" $FP_MNT_TMP #G_EXEC cp -a ${FP_MNT_TMP}_backup/. $FP_MNT_TMP/ #G_EXEC rm -R ${FP_MNT_TMP}_backup - G_EXEC fstrim $FP_MNT_TMP - G_EXEC sync - G_EXEC sleep 1 # Give the system 1 second to avoid "mount is busy" - G_EXEC umount $FP_MNT_TMP - G_EXEC rmdir $FP_MNT_TMP + #Unmount_tmp # Assure root filesystem size is in 512 byte sectors, as this is what sfdisk assmes #FS_SIZE=$(( $FS_SIZE * $sector_size / 512 )) + elif [[ $ROOT_FS_TYPE == 'btrfs' ]] then G_DIETPI-NOTIFY 2 'Shrinking root filesystem to minimum size...' - G_EXEC mkdir -p $FP_MNT_TMP G_EXEC mount "$FP_ROOT_DEV" $FP_MNT_TMP FS_SIZE=$(( $(btrfs inspect-internal min-dev-size $FP_MNT_TMP) + 4*1024**2 )) # bytes? + 4 MiB buffer G_EXEC_OUTPUT=1 G_EXEC btrfs filesystem resize $FS_SIZE $FP_MNT_TMP - G_EXEC fstrim $FP_MNT_TMP - G_EXEC sync - G_EXEC sleep 1 # Give the system 1 second to avoid "mount is busy" - G_EXEC umount $FP_MNT_TMP - G_EXEC rmdir $FP_MNT_TMP + Unmount_tmp FS_SIZE=$(( $FS_SIZE / 512 )) # bytes => 512 byte sectors fi Run_fsck + G_DIETPI-NOTIFY 2 'Overriding filesystems free space with zeros to purge removed data and allow better compression...' + while read -r path type + do + [[ $type ]] || continue + if [[ $type == 'ext'[234] ]] + then + G_EXEC_OUTPUT=1 G_EXEC zerofree -v "$path" + else + G_EXEC mount "$path" $FP_MNT_TMP + G_EXEC_OUTPUT=1 G_EXEC fstrim -v $FP_MNT_TMP + Unmount_tmp + # shellcheck disable=SC2015 + [[ $path == "$FP_ROOT_DEV" ]] && Run_fsck || G_EXEC_OUTPUT=1 G_EXEC fsck "$path" + fi + + done < <(lsblk -rnpo NAME,FSTYPE "$FP_SOURCE"?*) + G_EXEC rmdir $FP_MNT_TMP + # Only resize partition when new size would be less than current size if [[ $ROOT_FS_TYPE != 'f2fs' ]] && (( $( $FS_SIZE )) then @@ -400,7 +449,7 @@ G_EXEC truncate --size=$IMAGE_SIZE "$FP_SOURCE_IMG" # Rename, if source image != output image already - [[ $PWD/$OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT != "$FP_SOURCE_IMG" ]] && mv "$FP_SOURCE_IMG" "$OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT" + [[ $PWD/$OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT != "$(readlink -f "$FP_SOURCE_IMG")" ]] && G_EXEC mv "$FP_SOURCE_IMG" "$OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT" # Check if there is enough free disk space to store the 7z file NEEDED_FREE_SPACE=$(( $IMAGE_SIZE * 15/100 / 1024**2 )) @@ -420,7 +469,7 @@ else G_DIETPI-NOTIFY 2 'Creating final image with Clonezilla' # Install required packages - G_AG_CHECK_INSTALL_PREREQ clonezilla partclone xorriso isolinux syslinux-common unzip curl + G_AG_CHECK_INSTALL_PREREQ clonezilla partclone xorriso isolinux syslinux-common unzip curl pigz file # Download last version of Clonezilla Live CLONEZILLA_VERSION=$(curl -s "$CLONEZILLA_REPO/" | grep 'class="folder "' | head -n1 | cut -d\" -f2) @@ -438,30 +487,24 @@ G_CHECK_FREESPACE . $(( $NEEDED_FREE_SPACE + 100 )) || exit 1 # Assure +100 MiB left partition space # Download Clonezilla Live - if [[ ! -f $CLONEZILLA_ZIP || $(stat -c %s "$CLONEZILLA_ZIP") != "$CLONEZILLA_ZIP_SIZE" ]] - then - G_DIETPI-NOTIFY 2 "Downloading Clonezilla Live v$CLONEZILLA_VERSION..." - G_EXEC curl -sSfL "$CLONEZILLA_ZIP_URL" -o "$CLONEZILLA_ZIP" - fi + G_DIETPI-NOTIFY 2 "Downloading Clonezilla Live v$CLONEZILLA_VERSION..." + G_EXEC curl -sSfL "$CLONEZILLA_ZIP_URL" -o "$CLONEZILLA_ZIP" # Extract Clonezilla Live + [[ -e 'tmpiso' ]] && G_EXEC rm -R tmpiso G_EXEC unzip "$CLONEZILLA_ZIP" -d 'tmpiso' G_EXEC rm "$CLONEZILLA_ZIP" # Clone disk with Clonezilla - if [[ ! -d tmpiso/home/partimag/$OUTPUT_IMG_NAME ]] - then - G_EXEC mkdir -p tmpiso/home/partimag - G_DIETPI-NOTIFY 2 'Cloning disk with Clonezilla...' - ocs-sr -or "$PWD/tmpiso/home/partimag" -nogui -fsck -q2 -c -j2 -z1p -i 4096 -senc -sc savedisk "$OUTPUT_IMG_NAME" "${FP_SOURCE##*/}" || exit 1 - fi + G_EXEC mkdir -p tmpiso/home/partimag + G_EXEC_DESC='Cloning disk with Clonezilla' G_EXEC_OUTPUT=1 G_EXEC ocs-sr -or "$PWD/tmpiso/home/partimag" -nogui -fsck -q2 -c -j2 -z1p -i 4096 -senc -sc savedisk "$OUTPUT_IMG_NAME" "${FP_SOURCE##*/}" # For the sake of privacy, remove some non vital files that contain SNs and UUIDs G_EXEC rm -f "tmpiso/home/partimag/$OUTPUT_IMG_NAME/"{Info*txt,*list,clonezilla-img} # Check image G_DIETPI-NOTIFY 2 'Checking Clonezilla image...' - ocs-chkimg -or "$PWD/tmpiso/home/partimag" -nogui -b "$OUTPUT_IMG_NAME" || exit 1 + G_EXEC_OUTPUT=1 G_EXEC ocs-chkimg -or "$PWD/tmpiso/home/partimag" -nogui -b "$OUTPUT_IMG_NAME" # Prepare custom files used by the installer when booting in UEFI mode G_EXEC curl -sSfL "$DIETPI_REPO"/.meta/images/dietpi-background_768p.png -o tmpiso/boot/grub/dietpibg.png @@ -487,10 +530,10 @@ _EOF_ sed -n -e '/menuentry .*800x600/,/}/p' -e '/menuentry .*KMS/,/}/p' -e '/menuentry .*Safe/,/}/p' \ -e '/menuentry .*Failsafe/,/}/p' tmpiso/boot/grub/clonezilla.cfg >> tmpiso/boot/grub/grub.cfg # shellcheck disable=SC2016 - sed -i -e 's|set timeout=.*|set timeout="-1"|' -e '/set pref=/ a set theme=$pref/theme.txt' \ + sed -i -e 's|set timeout=.*|set timeout="-1"|' -e '/set pref=/a set theme=\$pref/theme.txt' \ -e 's|"Clonezilla live |"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 -batch -p poweroff restoredisk ask_user ask_user"|' \ + -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 cat << '_EOF_' >> tmpiso/boot/grub/grub.cfg submenu "Clonezilla live" { @@ -499,7 +542,6 @@ submenu "Clonezilla live" { } menuentry "Power off" { halt } _EOF_ - # Prepare custom files used by the installer when booting in BIOS/CSM mode G_EXEC curl -sSfL "$DIETPI_REPO"/.meta/images/dietpi-background_480p.png -o tmpiso/syslinux/dietpibg.png G_EXEC cp /usr/lib/syslinux/modules/bios/poweroff.c32 tmpiso/syslinux/ @@ -518,7 +560,7 @@ _EOF_ sed -i -e 's|^\(timeout\) .*|\1 0|' -e 's|\(MENU BACKGROUND\) .*|\1 dietpibg.png|' -e 's|MENU TITLE .*|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 's|Clonezilla live |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 -batch -p poweroff restoredisk ask_user ask_user"|' \ + -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/syslinux/syslinux.cfg cat << '_EOF_' >> tmpiso/syslinux/syslinux.cfg MENU BEGIN Clonezilla live @@ -549,13 +591,10 @@ _EOF_ [[ $SOURCE_TYPE == 'Image' ]] && Delete_Loopback fi - # GPT images: - # - "GPT PMBR size mismatch (4458495 != 15523839)" - # - "Error: The backup GPT table is corrupt, but the primary appears OK, so that will be used." - # - gdisk will correct this - if [[ $PART_TABLE_TYPE == 'gpt' ]] + # Move GPT backup partition table to end of drive + if [[ $CLONING_TOOL != 'Clonezilla' && $PART_TABLE_TYPE == 'gpt' ]] then - G_EXEC_DESC='Reapplying GPT partition backup table fix' G_EXEC_OUTPUT=1 G_EXEC sgdisk -e "$OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT" + G_EXEC_DESC='Moving GPT backup partition table to end of drive' G_EXEC_OUTPUT=1 G_EXEC sgdisk -e "$OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT" G_EXEC sync fi @@ -580,7 +619,7 @@ _EOF_ G_EXEC_DESC='Creating final 7zip archive' G_EXEC_OUTPUT=1 G_EXEC 7zr a -bsp1 -bso1 -bse2 -m0=lzma2 -mx=9 $limit_threads "$OUTPUT_IMG_NAME.7z" "$OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT" hash.txt README.md G_EXEC_NOHALT=1 G_EXEC rm hash.txt README.md - G_WHIP_MSG "[ OK ] DietPi-Imager has successfully finished.\n + G_DIETPI-NOTIFY 0 "DietPi-Imager has successfully finished. Final image file: $PWD/$OUTPUT_IMG_NAME.$OUTPUT_IMG_EXT Final 7z archive: $PWD/$OUTPUT_IMG_NAME.7z" diff --git a/.meta/dietpi-survey_report b/.meta/dietpi-survey_report index 66a36b2e75..30e85e8982 100644 --- a/.meta/dietpi-survey_report +++ b/.meta/dietpi-survey_report @@ -546,9 +546,16 @@ shopt -s extglob do aSOFTWARE_NAME7_5[$i]=${aSOFTWARE_NAME7_4[$i]} done - # shellcheck disable=SC2034 aSOFTWARE_NAME7_5[196]='Java JRE' + # v7.6 + aSOFTWARE_NAME7_6=() + for i in "${!aSOFTWARE_NAME7_5[@]}" + do + # shellcheck disable=SC2034 + aSOFTWARE_NAME7_6[$i]=${aSOFTWARE_NAME7_5[$i]} + done + # $1 = File name Process_File() { @@ -638,7 +645,7 @@ shopt -s extglob [[ ${aHW_NAME[$BENCH_HW_MODEL]} ]] || { echo "Invalid hardware ID: $BENCH_HW_MODEL"; return 1; } # CPU - if [[ $BENCH_CPU =~ ^[0-9]+\.[0-9]{2}$ && $BENCH_CPU_TEMP_START =~ ^[0-9]+$ && $BENCH_CPU_TEMP_END =~ ^[0-9]+$ ]]; then + if [[ $BENCH_CPU == *[1-9]* && $BENCH_CPU =~ ^[0-9]+\.[0-9]{2}$ && $BENCH_CPU_TEMP_START =~ ^[0-9]+$ && $BENCH_CPU_TEMP_END =~ ^[0-9]+$ ]]; then # CPU time: Remove decimal point, equals times 100 since it's always in x.xx # - Remove leading zeros to support machines with <1s CPU time: One case with 0.94s was just spotted. diff --git a/.update/patches b/.update/patches index b71770390e..1ba61ec279 100644 --- a/.update/patches +++ b/.update/patches @@ -277,7 +277,7 @@ Patch_7_4() Patch_7_5() { # Mark JRE as installed when JDK is installed - [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[8\]=' /boot/dietpi/.installed && G_CONFIG_INJECT 'aSOFTWARE_INSTALL_STATE\[196\]=' 'aSOFTWARE_INSTALL_STATE[196]=2' /boot/dietpi/.installed + [[ -f '/boot/dietpi/.installed' ]] && grep -q '^[[:blank:]]*aSOFTWARE_INSTALL_STATE\[8\]=2' /boot/dietpi/.installed && G_CONFIG_INJECT 'aSOFTWARE_INSTALL_STATE\[196\]=' 'aSOFTWARE_INSTALL_STATE[196]=2' /boot/dietpi/.installed if getent passwd blynk > /dev/null && ! getent group blynk > /dev/null then @@ -285,6 +285,37 @@ Patch_7_5() G_EXEC groupadd -r blynk G_EXEC usermod -g blynk blynk fi + + # Amiberry on RPi: Revert cmdline.txt changes we do not apply anymore + if [[ $G_HW_MODEL -le 9 && -f '/boot/dietpi/.dietpi-autostart_index' && $( /etc/apt/apt.conf.d/98dietpi-forceconf + # - During PREP only: Force new DEB package config files and tmpfs lists + archives + cat << '_EOF_' > /etc/apt/apt.conf.d/98dietpi-prep +#clear DPkg::options; +DPkg::options:: "--force-confmiss,confnew"; +Dir::Cache "/tmp/apt"; +Dir::Cache::archives "/tmp/apt/archives"; +Dir::State "/tmp/apt"; +Dir::State::extended_states "/var/lib/apt/extended_states"; +Dir::State::status "/var/lib/dpkg/status"; +Dir::Cache::pkgcache ""; +_EOF_ # - Force IPv4 by default to avoid hanging access attempts in some cases, e.g. WiFi bridges # NB: This needs to match the method in: /boot/dietpi/func/dietpi-set_hardware preferipv4 enable echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99-dietpi-force-ipv4 @@ -536,6 +545,7 @@ Currently installed: $G_DISTRO_NAME (ID: $G_DISTRO)"; then # HW specific config.txt, boot.ini uEnv.txt if (( $G_HW_MODEL < 10 )); then + echo "root=PARTUUID=$(findmnt -Ufnro PARTUUID -M /) rootfstype=ext4 rootwait fsck.repair=yes net.ifnames=0 logo.nologo quiet console=serial0,115200 console=tty1" > /boot/cmdline.txt G_EXEC mv "DietPi-$G_GITBRANCH/config.txt" /boot/ # Boot in 64-bit mode if this is a 64-bit image [[ $G_HW_ARCH == 3 ]] && G_CONFIG_INJECT 'arm_64bit=' 'arm_64bit=1' /boot/config.txt @@ -543,6 +553,7 @@ Currently installed: $G_DISTRO_NAME (ID: $G_DISTRO)"; then elif (( $G_HW_MODEL == 11 )); then G_EXEC mv "DietPi-$G_GITBRANCH/boot_xu4.ini" /boot/boot.ini + G_EXEC sed -i "s/root=UUID=[^[:blank:]]*/root=UUID=$(findmnt -Ufnro UUID -M /)/" /boot/boot.ini elif (( $G_HW_MODEL == 12 )); then @@ -551,6 +562,7 @@ Currently installed: $G_DISTRO_NAME (ID: $G_DISTRO)"; then elif (( $G_HW_MODEL == 15 )); then G_EXEC mv "DietPi-$G_GITBRANCH/boot_n2.ini" /boot/boot.ini + G_EXEC sed -i "s/root=UUID=[^[:blank:]]*/root=UUID=$(findmnt -Ufnro UUID -M /)/" /boot/boot.ini fi @@ -579,7 +591,6 @@ Currently installed: $G_DISTRO_NAME (ID: $G_DISTRO)"; then G_CONFIG_INJECT 'DEV_GITBRANCH=' "DEV_GITBRANCH=$G_GITBRANCH" /boot/dietpi.txt G_CONFIG_INJECT 'DEV_GITOWNER=' "DEV_GITOWNER=$G_GITOWNER" /boot/dietpi.txt G_VERSIONDB_SAVE - G_EXEC cp /boot/dietpi/.version /var/lib/dietpi/.dietpi_image_version # Apply live patches G_DIETPI-NOTIFY 2 'Applying DietPi live patches to fix known bugs in this version' @@ -595,9 +606,18 @@ Currently installed: $G_DISTRO_NAME (ID: $G_DISTRO)"; then fi # Store new status of live patch to /boot/dietpi/.version - G_CONFIG_INJECT "G_LIVE_PATCH_STATUS\[$i\]=" "G_LIVE_PATCH_STATUS[$i]='${G_LIVE_PATCH_STATUS[$i]}'" /boot/dietpi/.version.version + G_CONFIG_INJECT "G_LIVE_PATCH_STATUS\[$i\]=" "G_LIVE_PATCH_STATUS[$i]='${G_LIVE_PATCH_STATUS[$i]}'" /boot/dietpi/.version done + G_EXEC cp /boot/dietpi/.version /var/lib/dietpi/.dietpi_image_version + + # Temporary workaround for hanging DietPi-FirstBoot on Bullseye: https://github.com/MichaIng/DietPi/issues/4573#issuecomment-895208258 + (( $DISTRO_TARGET == 6 && $G_DIETPI_VERSION_SUB == 4 )) && G_EXEC curl -sSfL 'https://raw.githubusercontent.com/MichaIng/DietPi/1ecf972/rootfs/var/lib/dietpi/services/dietpi-firstboot.bash' -o /var/lib/dietpi/services/dietpi-firstboot.bash + + # Temporary fix for takeover of failed first run setup: https://github.com/MichaIng/DietPi/commit/a8f291caee8f1760020984a385f4831b0c954327 + # shellcheck disable=SC2016 + (( $G_DIETPI_VERSION_SUB == 4 )) && sed -i '/kill -9/a\\t\t\t\[\[ -f \$FP_DIETPI_FIRSTRUNSETUP_PID \]\] \&\& rm \$FP_DIETPI_FIRSTRUNSETUP_PID' /boot/dietpi/dietpi-login + G_EXEC systemctl daemon-reload #------------------------------------------------------------------------------------------------ @@ -634,7 +654,6 @@ Currently installed: $G_DISTRO_NAME (ID: $G_DISTRO)"; then 'console-setup' # DietPi-Config keyboard configuration + console fonts 'cron' # Background job scheduler 'curl' # Web address testing, downloading, uploading etc. - 'dirmngr' # GNU key management required for some APT installs via additional repos 'ethtool' # Force Ethernet link speed 'fake-hwclock' # Hardware clock emulation, to allow correct timestamps during boot before network time sync 'fdisk' # Partitioning tool used by DietPi-FS_partition_resize and DietPi-Imager @@ -750,7 +769,7 @@ Currently installed: $G_DISTRO_NAME (ID: $G_DISTRO)"; then local apackages=('linux-image-amd64' 'os-prober') # Grub EFI with secure boot compatibility - if dpkg-query -s 'grub-efi-amd64' &> /dev/null || [[ -d '/boot/efi' ]]; then + if [[ -d '/boot/efi' ]] || dpkg-query -s 'grub-efi-amd64' &> /dev/null; then apackages+=('grub-efi-amd64' 'grub-efi-amd64-signed' 'shim-signed') @@ -761,6 +780,10 @@ Currently installed: $G_DISTRO_NAME (ID: $G_DISTRO)"; then fi + # Skip creating kernel symlinks and remove existing ones + echo 'do_symlinks=0' > /etc/kernel-img.conf + G_EXEC rm -f /{,boot/}{initrd.img,vmlinuz}{,.old} + G_AGI "${apackages[@]}" unset -v apackages @@ -790,7 +813,6 @@ Currently installed: $G_DISTRO_NAME (ID: $G_DISTRO)"; then G_DIETPI-NOTIFY 2 "Armbian package detected and added: $line" done < <(dpkg-query -Wf '${Package}\n' | mawk -v pat="^$i" '$0~pat') - done unset -v apackages @@ -800,15 +822,17 @@ Currently installed: $G_DISTRO_NAME (ID: $G_DISTRO)"; then # Generate and cleanup uInitrd local arch='arm' (( $G_HW_ARCH == 3 )) && arch='arm64' + G_EXEC mkdir -p /etc/initramfs/post-update.d cat << _EOF_ > /etc/initramfs/post-update.d/99-dietpi-uboot -#!/bin/sh +#!/bin/dash echo 'update-initramfs: Converting to u-boot format' >&2 mkimage -A $arch -O linux -T ramdisk -C gzip -n uInitrd -d \$2 /boot/uInitrd-\$1 > /dev/null ln -sf uInitrd-\$1 /boot/uInitrd > /dev/null 2>&1 || mv /boot/uInitrd-\$1 /boot/uInitrd exit 0 _EOF_ + G_EXEC mkdir -p /etc/kernel/preinst.d cat << '_EOF_' > /etc/kernel/preinst.d/dietpi-initramfs_cleanup -#!/bin/sh +#!/bin/dash # skip if initramfs-tools is not installed [ -x /usr/sbin/update-initramfs ] || exit 0 @@ -828,20 +852,34 @@ if [ -n "$DEB_MAINT_PARAMS" ]; then fi fi +_EOF_ + # Bullseye: initramfs-tools' /var/lib/initramfs-tools state directory is not used anymore + if (( $DISTRO_TARGET > 5 )) + then + cat << '_EOF_' >> /etc/kernel/preinst.d/dietpi-initramfs_cleanup +# delete unused initrd images +find /boot -name 'initrd.img-*' -o -name 'uInitrd-*' ! -name "*-$version" -printf 'Removing obsolete file %f\n' -delete + +exit 0 +_EOF_ + else + cat << '_EOF_' >> /etc/kernel/preinst.d/dietpi-initramfs_cleanup # loop through existing initramfs images -for v in $(ls -1 /var/lib/initramfs-tools | linux-version sort --reverse) do +for v in $(ls -1 /var/lib/initramfs-tools | linux-version sort --reverse); do if ! linux-version compare $v eq $version; then # try to delete delete old initrd images via update-initramfs INITRAMFS_TOOLS_KERNEL_HOOK=y update-initramfs -d -k $v 2>/dev/null # delete unused state files find /var/lib/initramfs-tools -type f ! -name "$version" -printf 'Removing obsolete file %f\n' -delete # delete unused initrd images - find /boot -name 'initrd.img*' -o -name 'uInitrd-*' ! -name "*$version" -printf 'Removing obsolete file %f\n' -delete + find /boot -name 'initrd.img-*' -o -name 'uInitrd-*' ! -name "*-$version" -printf 'Removing obsolete file %f\n' -delete fi done exit 0 _EOF_ + fi + # Remove obsolete components from Armbian list and connect via HTTPS G_EXEC eval "echo 'deb https://apt.armbian.com/ $DISTRO_TARGET_NAME main' > /etc/apt/sources.list.d/armbian.list" @@ -852,9 +890,9 @@ _EOF_ # RPi elif (( $G_HW_MODEL < 10 )); then - # Add raspbian-archive-keyring and raspi-copies-and-fills for 32-bit images only + # ARMv6/7: Add raspi-copies-and-fills local a32bit=() - [[ $G_HW_ARCH == 3 ]] || a32bit=('raspbian-archive-keyring' 'raspi-copies-and-fills') + [[ $G_HW_ARCH == 3 ]] || a32bit=('raspi-copies-and-fills') G_AGI raspberrypi-bootloader raspberrypi-kernel libraspberrypi0 libraspberrypi-bin raspberrypi-sys-mods raspberrypi-archive-keyring "${a32bit[@]}" # Move Raspbian key to active place and remove obsolete combined keyring @@ -946,6 +984,7 @@ _EOF_ unset -v apackages fi + G_EXEC apt-get clean # Remove downloaded archives # - Firmware if dpkg-query -Wf '${Package}\n' | grep -q '^armbian-firmware'; then @@ -1010,6 +1049,7 @@ _EOF_ #------------------------------------------------------------------------------------------------ G_AGDUG + G_EXEC apt-get clean # Remove downloaded archives # Distro is now target (for APT purposes and G_AGX support due to installed binary, its here, instead of after G_AGUP) G_DISTRO=$DISTRO_TARGET @@ -1023,8 +1063,6 @@ _EOF_ G_AGA - G_EXEC_DESC='Preserving modified DEB package config files from now on' G_EXEC rm -v /etc/apt/apt.conf.d/98dietpi-forceconf - #------------------------------------------------------------------------------------------------ G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" "[$SETUP_STEP] Applying DietPi tweaks and cleanup"; ((SETUP_STEP++)) #------------------------------------------------------------------------------------------------ @@ -1053,6 +1091,20 @@ _EOF_ G_AGA fi + G_EXEC apt-get clean # Remove downloaded archives + + # RPi Bullseye workaround, until new firmware packages have been built: https://archive.raspberrypi.org/debian/pool/main/f/firmware-nonfree/?C=M;O=D + if (( $G_DISTRO == 6 && $G_HW_MODEL == 0 )) + then + G_EXEC curl -sSfLO 'https://archive.raspberrypi.org/debian/pool/main/f/firmware-nonfree/firmware-brcm80211_20190114-2+rpt1_all.deb' + G_EXEC dpkg-deb -x 'firmware-brcm80211_20190114-2+rpt1_all.deb' . + G_EXEC rm -R 'firmware-brcm80211_20190114-2+rpt1_all.deb' usr + for i in lib/firmware/brcm/* + do + [[ -f /$i ]] || G_EXEC mv {,/}"$i" + done + G_EXEC rm -R lib + fi G_DIETPI-NOTIFY 2 'Deleting list of known users and groups, not required by DietPi' @@ -1190,7 +1242,6 @@ _EOF_ [[ -d '/etc/systemd/system/rc.local.service.d' ]] && rm -Rv /etc/systemd/system/rc.local.service.d # Below required if DietPi-PREP is executed from chroot/container, so RPi firstrun scripts are not executed [[ -f '/etc/init.d/resize2fs_once' ]] && rm -v /etc/init.d/resize2fs_once # https://github.com/RPi-Distro/pi-gen/blob/master/stage2/01-sys-tweaks/files/resize2fs_once - [[ -f '/boot/cmdline.txt' ]] && sed -i 's| init=/usr/lib/raspi-config/init_resize\.sh||' /boot/cmdline.txt # https://github.com/RPi-Distro/pi-gen/blob/master/stage2/01-sys-tweaks/00-patches/07-resize-init.diff # - Remove all autologin configs for all TTYs: https://github.com/MichaIng/DietPi/issues/3570#issuecomment-648988475, https://github.com/MichaIng/DietPi/issues/3628#issuecomment-653693758 rm -fv /etc/systemd/system/*getty@*.service.d/*autologin*.conf @@ -1201,8 +1252,9 @@ _EOF_ G_DIETPI-NOTIFY 2 'Restoring default base files:' # shellcheck disable=SC2114 rm -Rfv /etc/{motd,profile,update-motd.d,issue{,.net}} /root /home /media /var/mail - G_AGI -o 'Dpkg::Options::=--force-confmiss,confnew' --reinstall base-files # Restore /etc/{update-motd.d,issue{,.net}} /root /home + G_AGI --reinstall base-files # Restore /etc/{update-motd.d,issue{,.net}} /root /home G_EXEC /var/lib/dpkg/info/base-files.postinst configure # Restore /root/.{profile,bashrc} /etc/{motd,profile} /media /var/mail + G_EXEC apt-get clean # Remove downloaded archives #----------------------------------------------------------------------------------- # https://www.debian.org/doc/debian-policy/ch-opersys.html#site-specific-programs @@ -1230,6 +1282,7 @@ _EOF_ #----------------------------------------------------------------------------------- # DietPi user G_EXEC_DESC='Creating DietPi user account' G_EXEC /boot/dietpi/func/dietpi-set_software useradd dietpi + chpasswd <<< 'root:dietpi' #----------------------------------------------------------------------------------- # UID bit for sudo: https://github.com/MichaIng/DietPi/issues/794 @@ -1286,19 +1339,8 @@ _EOF_' G_DIETPI-NOTIFY 2 'Configuring wlan/eth naming to be preferred for networked devices:' ln -sfv /dev/null /etc/systemd/network/99-default.link ln -sfv /dev/null /etc/udev/rules.d/80-net-setup-link.rules - # - RPi: Add cmdline entry, which was required on my Raspbian Bullseye system since last few APT updates - if [[ -f '/boot/cmdline.txt' ]]; then - - sed -i 's/net.ifnames=[^[:blank:]]*[[:blank:]]*//g;w /dev/stdout' /boot/cmdline.txt - sed -i '/root=/s/[[:blank:]]*$/ net.ifnames=0/;w /dev/stdout' /boot/cmdline.txt - - # - Armbian - elif [[ -f '/boot/armbianEnv.txt' ]]; then - - G_CONFIG_INJECT 'extraargs=' 'extraargs="net.ifnames=0"' /boot/armbianEnv.txt - - fi - [[ -f '/etc/udev/rules.d/70-persistent-net.rules' ]] && rm -v /etc/udev/rules.d/70-persistent-net.rules # Jessie pre-image + # - Armbian: Add cmdline entry, which was required on my Raspbian Bullseye system since last few APT updates + [[ -f '/boot/armbianEnv.txt' ]] && G_CONFIG_INJECT 'extraargs=' 'extraargs="net.ifnames=0"' /boot/armbianEnv.txt G_DIETPI-NOTIFY 2 'Configuring DNS nameserver:' # Failsafe: Assure that /etc/resolv.conf is not a symlink and disable systemd-resolved + systemd-networkd @@ -1598,8 +1640,10 @@ _EOF_ # - RPi elif (( $G_HW_MODEL < 10 )); then - # Scroll lock fix for RPi by Midwan: https://github.com/MichaIng/DietPi/issues/474#issuecomment-243215674 - echo 'ACTION=="add", SUBSYSTEM=="leds", ENV{DEVPATH}=="*/input*::scrolllock", ATTR{trigger}="kbd-scrollock"' > /etc/udev/rules.d/50-leds.rules + # Creating RPi-specific groups + G_EXEC groupadd -rf spi + G_EXEC groupadd -rf i2c + G_EXEC groupadd -rf gpio # Apply minimum GPU memory split for server usage: This applies a custom dtoverlay to disable VCSM: https://github.com/MichaIng/DietPi/pull/3900 /boot/dietpi/func/dietpi-set_hardware gpumemsplit 16 @@ -1705,11 +1749,6 @@ _EOF_ # - Reset /tmp size to default (512 MiB) sed -i '\|/tmp|s|size=[^,]*,||' /etc/fstab - G_DIETPI-NOTIFY 2 'Resetting boot.ini, config.txt, cmdline.txt etc' - - # - Set Pi cmdline.txt back to normal - [[ -f '/boot/cmdline.txt' ]] && sed -i 's/ rootdelay=10//g' /boot/cmdline.txt - G_DIETPI-NOTIFY 2 'Disabling Bluetooth by default' /boot/dietpi/func/dietpi-set_hardware bluetooth disable @@ -1734,30 +1773,39 @@ _EOF_ G_DIETPI-NOTIFY 2 "$tmp_info generic WiFi by default" /boot/dietpi/func/dietpi-set_hardware wifimodules $tmp_mode - # - x86_64: kernel cmd line with GRUB + # - x86_64: GRUB install and config if (( $G_HW_ARCH == 10 )); then - G_EXEC_DESC='Detecting additional OS installed on system' G_EXEC os-prober - # Purge "os-prober" again - G_AGP os-prober - - # - Native PC/EFI (assume x86_64 only possible) - if [[ -d '/boot/efi' ]] && dpkg-query -s 'grub-efi-amd64' &> /dev/null; then - - G_EXEC_DESC='Recreating GRUB-EFI' G_EXEC grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck + G_EXEC_DESC='Detecting additional OS installed on system' G_EXEC_OUTPUT=1 G_EXEC os-prober + # UEFI + if [[ -d '/boot/efi' ]] && dpkg-query -s 'grub-efi-amd64' &> /dev/null + then + # Force GRUB installation to the EFI removable media path, if no (other) bootloader is installed there yet + shopt -s nocaseglob + local efi_fallback= + for i in /boot/efi/EFI/boot/bootx64.efi + do + [[ -d $i ]] && break + efi_fallback='--force-extra-removable' + debconf-set-selections <<< 'grub-efi-amd64 grub2/force_efi_extra_removable boolean true' + done + shopt -u nocaseglob + G_EXEC_DESC='Installing GRUB for UEFI' G_EXEC_OUTPUT=1 G_EXEC grub-install --recheck --target=x86_64-efi --efi-directory=/boot/efi $efi_fallback --uefi-secure-boot + + # BIOS + else + G_EXEC_DESC='Installing GRUB for BIOS' G_EXEC_OUTPUT=1 G_EXEC grub-install --recheck "$(lsblk -npo PKNAME "$(findmnt -Ufnro SOURCE -M /)")" fi - # - Finalise GRUB - if [[ -f '/etc/default/grub' ]]; then - - G_CONFIG_INJECT 'GRUB_CMDLINE_LINUX_DEFAULT=' 'GRUB_CMDLINE_LINUX_DEFAULT="consoleblank=0 quiet"' /etc/default/grub - G_CONFIG_INJECT 'GRUB_CMDLINE_LINUX=' 'GRUB_CMDLINE_LINUX="net.ifnames=0"' /etc/default/grub - G_CONFIG_INJECT 'GRUB_TIMEOUT=' 'GRUB_TIMEOUT=0' /etc/default/grub - G_EXEC_DESC='Finalising GRUB' G_EXEC update-grub - - fi + # Update config + G_CONFIG_INJECT 'GRUB_CMDLINE_LINUX_DEFAULT=' 'GRUB_CMDLINE_LINUX_DEFAULT="consoleblank=0 quiet"' /etc/default/grub + G_CONFIG_INJECT 'GRUB_CMDLINE_LINUX=' 'GRUB_CMDLINE_LINUX="net.ifnames=0"' /etc/default/grub + G_CONFIG_INJECT 'GRUB_TIMEOUT=' 'GRUB_TIMEOUT=0' /etc/default/grub + G_EXEC_DESC='Regenerating GRUB config' G_EXEC_OUTPUT=1 G_EXEC grub-mkconfig -o /boot/grub/grub.cfg + # Purge "os-prober" again + G_AGP os-prober fi G_DIETPI-NOTIFY 2 'Disabling soundcards by default' @@ -1793,6 +1841,7 @@ You should have received a copy of the GNU General Public License along with thi _EOF_ G_DIETPI-NOTIFY 2 'Disabling and clearing APT cache' + G_EXEC rm /etc/apt/apt.conf.d/98dietpi-prep /boot/dietpi/func/dietpi-set_software apt-cache cache disable /boot/dietpi/func/dietpi-set_software apt-cache clean @@ -1836,9 +1885,9 @@ _EOF_ # Power off system - # Plug SDcard/drive into external DietPi system + # Plug SD card/drive into external DietPi system - # Run: bash -c "$(curl -sSL https://github.com/MichaIng/DietPi/blob/dev/.meta/dietpi-imager)" + # Run: bash -c "$(curl -sSfL https://github.com/MichaIng/DietPi/blob/master/.meta/dietpi-imager)" } diff --git a/dietpi/dietpi-autostart b/dietpi/dietpi-autostart index 3a38f490dd..45d8741a97 100644 --- a/dietpi/dietpi-autostart +++ b/dietpi/dietpi-autostart @@ -38,13 +38,7 @@ [[ -d '/etc/lightdm/lightdm.conf.d' ]] && rmdir --ignore-fail-on-non-empty /etc/lightdm/lightdm.conf.d # - Amiberry - systemctl disable --now amiberry &> /dev/null - if (( $G_HW_MODEL < 10 )) - then - sed -i '/^[[:blank:]]*boot_delay=0/d' /boot/config.txt - sed -i 's/[[:blank:]]*loglevel=3//' /boot/cmdline.txt - sed -i 's/console=tty3/console=tty1/' /boot/cmdline.txt - fi + [[ -f '/etc/systemd/system/amiberry.service' ]] && systemctl disable --now amiberry # - Custom script if [[ -f '/etc/systemd/system/dietpi-autostart_custom.service' ]] @@ -96,18 +90,6 @@ _EOF_ elif (( $ID_AUTOSTART == 6 )) then G_EXEC systemctl enable amiberry - # Enable systemd-logind to have a login console ready after exiting Amiberry from fastboot, requires dbus - G_EXEC_NOHALT=1 G_AG_CHECK_INSTALL_PREREQ dbus - G_EXEC_NOHALT=1 G_EXEC systemctl unmask systemd-logind - - # RPi tweaks - if (( $G_HW_MODEL < 10 )) - then - G_CONFIG_INJECT 'boot_delay=' 'boot_delay=0' /boot/config.txt - grep -qi ' logo.nologo' /boot/cmdline.txt || G_EXEC sed -i 's/rootwait/rootwait logo.nologo/' /boot/cmdline.txt - grep -qi ' loglevel=3' /boot/cmdline.txt || G_EXEC sed -i 's/rootwait/rootwait loglevel=3/' /boot/cmdline.txt - grep -qi ' console=tty3' /boot/cmdline.txt || G_EXEC sed -i 's/console=tty1/console=tty3/' /boot/cmdline.txt - fi # - LightDM: Install only if startx (a desktop) is already installed. This is re-applied by dietpi-software after install automatically. elif (( $ID_AUTOSTART == 16 )) diff --git a/dietpi/dietpi-config b/dietpi/dietpi-config index 270634290b..6d36125c25 100644 --- a/dietpi/dietpi-config +++ b/dietpi/dietpi-config @@ -491,7 +491,7 @@ A long (or insufficiently manufactured) cable may required a higher boost settin # https://github.com/MichaIng/DietPi/issues/1487 local current_gpu_mem=$(sed -n '/^[[:blank:]]*gpu_mem_1024/{s/^[^=]*=//p;q}' /boot/config.txt) - (( $current_gpu_mem < 128 )) && /boot/dietpi/func/dietpi-set_hardware gpumemsplit 128 + (( ${current_gpu_mem:=76} < 96 )) && /boot/dietpi/func/dietpi-set_hardware gpumemsplit 96 REBOOT_REQUIRED=1 @@ -506,7 +506,7 @@ A long (or insufficiently manufactured) cable may required a higher boost settin # https://github.com/MichaIng/DietPi/issues/1487 local current_gpu_mem=$(sed -n '/^[[:blank:]]*gpu_mem_1024/{s/^[^=]*=//p;q}' /boot/config.txt) - (( $current_gpu_mem < 128 )) && /boot/dietpi/func/dietpi-set_hardware gpumemsplit 128 + (( ${current_gpu_mem:=76} < 96 )) && /boot/dietpi/func/dietpi-set_hardware gpumemsplit 96 REBOOT_REQUIRED=1 @@ -1901,28 +1901,28 @@ Current setting: $user_frequency_min_text" && G_CONFIG_INJECT 'CONFIG_CPU_MIN_FR (( $value <= 1024 )) || value=1024 local gpu_mem_current=$(sed -n "/^[[:blank:]]*gpu_mem_$value=/{s/^[^=]*=//p;q}" /boot/config.txt) # override setting [[ $gpu_mem_current ]] || gpu_mem_current=$(sed -n "/^[[:blank:]]*gpu_mem=/{s/^[^=]*=//p;q}" /boot/config.txt) # base setting - [[ $gpu_mem_current ]] || gpu_mem_current=64 # default value + [[ $gpu_mem_current ]] || { (( $value < 1024 )) && gpu_mem_current=64 || gpu_mem_current=76; } # default value local ram_mem_current=$((G_HW_MEMORY_SIZE-gpu_mem_current)) # Create array for storing menu selectable options. G_WHIP_MENU_ARRAY=( 16 ': Server' - 64 ': Desktop (Low)' - 128 ': Desktop (High)' - 192 '' + 64 ': Desktop' + 96 ': Camera' + 128 ': Gaming' ) if (( $G_HW_MEMORY_SIZE >= 512 )); then - G_WHIP_MENU_ARRAY+=(256 ': General Gaming') - G_WHIP_MENU_ARRAY+=(320 ': Kodi') + G_WHIP_MENU_ARRAY+=(192 '') + G_WHIP_MENU_ARRAY+=(256 ': Video de/encoding') if (( $G_HW_MEMORY_SIZE >= 1024 )); then - G_WHIP_MENU_ARRAY+=(448 '') - G_WHIP_MENU_ARRAY+=(512 '') + G_WHIP_MENU_ARRAY+=(384 '') + G_WHIP_MENU_ARRAY+=(512 ': You are insane!') fi diff --git a/dietpi/dietpi-drive_manager b/dietpi/dietpi-drive_manager index 3fe0d66cad..fd1c94c1c7 100644 --- a/dietpi/dietpi-drive_manager +++ b/dietpi/dietpi-drive_manager @@ -76,14 +76,14 @@ Destroy(){ - unset aDRIVE_UUID aDRIVE_PART_UUID - unset aDRIVE_MOUNT_SOURCE aDRIVE_MOUNT_TARGET - unset aDRIVE_SOURCE_DEVICE aDRIVE_FSTYPE - unset aDRIVE_SIZE_TOTAL aDRIVE_SIZE_USED - unset aDRIVE_SIZE_PERCENTUSED - unset aDRIVE_ISFILESYSTEM aDRIVE_ISMOUNTED - unset aDRIVE_ISREADONLY_CURRENTLY aDRIVE_ISNETWORKED - unset aDRIVE_ISROM aDRIVE_ISPARTITIONTABLE + unset -v aDRIVE_UUID aDRIVE_PART_UUID + unset -v aDRIVE_MOUNT_SOURCE aDRIVE_MOUNT_TARGET + unset -v aDRIVE_SOURCE_DEVICE aDRIVE_FSTYPE + unset -v aDRIVE_SIZE_TOTAL aDRIVE_SIZE_USED + unset -v aDRIVE_SIZE_PERCENTUSED + unset -v aDRIVE_ISFILESYSTEM aDRIVE_ISMOUNTED + unset -v aDRIVE_ISREADONLY_CURRENTLY aDRIVE_ISNETWORKED + unset -v aDRIVE_ISROM aDRIVE_ISPARTITIONTABLE } @@ -345,8 +345,8 @@ $swap_mounts done # Debug drive detection, exit after first init - if [[ $G_DEBUG == 1 ]]; then - + if [[ $G_DEBUG == 1 ]] + then G_DIETPI-NOTIFY 0 'DEBUG INFO:' for i in "${!aDRIVE_MOUNT_SOURCE[@]}" do @@ -369,15 +369,13 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]} " done exit - fi # Remove x-systemd.automount if not supported by kernel: https://github.com/MichaIng/DietPi/issues/1607#issuecomment-372030565 - if ! modprobe autofs4 --dry-run &> /dev/null; then - + if ! modprobe -nq autofs4 + then sed -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 Update_Menu_Drive_Index @@ -823,37 +821,31 @@ Do you wish to ignore this warning, and, mount the drive regardless?" || return local i j for i in "${!aDRIVE_MOUNT_SOURCE[@]}" do - local new_cat=1 for j in "${!acategory_list[@]}" do - if [[ ${aDRIVE_SOURCE_DEVICE[$i]} == "${acategory_list[$j]}" ]]; then new_cat=0 break fi - done # Add (( $new_cat )) && acategory_list+=("${aDRIVE_SOURCE_DEVICE[$i]}") - done # List all available drives, if no drive found, list info for user. local drive_available=0 for i in "${!acategory_list[@]}" do - drive_available=1 G_WHIP_MENU_ARRAY+=('' "●─ ${acategory_list[$i]} ") for j in "${!aDRIVE_MOUNT_SOURCE[@]}" do - if [[ ${aDRIVE_SOURCE_DEVICE[$j]} == "${acategory_list[$i]}" ]]; then # Drive is fully mounted @@ -883,9 +875,7 @@ Do you wish to ignore this warning, and, mount the drive regardless?" || return fi fi - done - done unset acategory_list @@ -936,7 +926,6 @@ Do you wish to ignore this warning, and, mount the drive regardless?" || return local minutes seconds text for i in {12..251} do - if (( $i < 241 )); then minutes=$(( $i * 5 / 60 )) @@ -953,7 +942,6 @@ Do you wish to ignore this warning, and, mount the drive regardless?" || return fi G_WHIP_MENU_ARRAY+=("$i" ": $text") - done if G_WHIP_MENU 'Please select an idle duration of time, before each drive is powered down: @@ -1173,22 +1161,22 @@ Do you wish to ignore this warning, and, mount the drive regardless?" || return # I/O scheduler local io_schedulers="/sys/block/${aDRIVE_SOURCE_DEVICE[$MENU_DRIVE_INDEX]}/queue/scheduler" - if [[ -e $io_schedulers ]]; then - - local aio_schedulers=() + if [[ -e $io_schedulers ]] + then + local aio_schedulers=() bfq=0 for i in $(<"$io_schedulers") do - - if [[ $i == '['*']' ]]; then - + if [[ $i == '['*']' ]] + then i=${i#[}; i=${i%]} local io_scheduler_current=$i fi aio_schedulers+=("$i" '') - + [[ $i == 'bfq' ]] && bfq=1 done + # Add BFQ scheduler if module is not enabled but available + (( $bfq )) || ! modprobe -nq bfq || aio_schedulers+=('bfq' '') [[ ${aio_schedulers[0]} ]] && G_WHIP_MENU_ARRAY+=('I/O Scheduler' ": [${io_scheduler_current:-N/A}]") - fi G_WHIP_BUTTON_CANCEL_TEXT='Back' @@ -1275,7 +1263,6 @@ Please choose another drive or format this one with another filesystem, e.g. ext while : do - G_WHIP_DEFAULT_ITEM=$reserved_blocks_percent_current G_WHIP_INPUTBOX 'Ext4 formatted drives allow the reservation of drive space for the root user to assure system functionality, if filled by other users or processes, and to avoid fragmentation of large files.\n However, on modern drives, the default of 5% reserved blocks is often by orders of magnitude larger than necessary. You may want to reduce the percentage to an absolute reserved space of about 500 MiB, which should be enough, to enable root user starting and maintaining the system. Additionally, on non rootfs drives reserved blocks are not necessary at all.\n @@ -1291,7 +1278,6 @@ Please enter the desired percentage of reserved blocks, e.g. "0.05" for 0.05% or G_WHIP_MSG 'Error: Allowed are only integers or floats between "0" and "50", e.g. "10" or "0.5".\n\nPlease try again...' fi - done elif [[ $G_WHIP_RETURNED_VALUE == 'User data' ]]; then @@ -1913,7 +1899,6 @@ _EOF_ while read -r line do - G_WHIP_MENU_ARRAY+=("$(mawk '{print $6}' <<< "$line")" ": $(mawk '{print $1" | size: "$2"iB | available: "$4"iB"}' <<< "$line")") done < <(df -Ph | tail -n +2 | sed -E '/(^udev|tmpfs)/d') @@ -1949,7 +1934,6 @@ _EOF_ until (( $TARGETMENUID < 0 )) do - G_TERM_CLEAR if (( $TARGETMENUID == 1 )); then @@ -1969,7 +1953,6 @@ _EOF_ Menu_Main fi - done fi diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index f8bd3a4801..d03a7a34ff 100644 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -773,7 +773,8 @@ INDEX_BROWSER_TARGET=$INDEX_BROWSER_TARGET" aSOFTWARE_DESC[$software_id]='automatically download music' aSOFTWARE_CATX[$software_id]=3 aSOFTWARE_DOCS[$software_id]='https://dietpi.com/docs/software/bittorrent/#lidarr' - aSOFTWARE_DEPS[$software_id]='87 150' + aSOFTWARE_DEPS[$software_id]='87' + (( $G_HW_ARCH == 1 )) && aSOFTWARE_DEPS[$software_id]+=' 150' #------------------ software_id=180 @@ -1017,6 +1018,10 @@ INDEX_BROWSER_TARGET=$INDEX_BROWSER_TARGET" aSOFTWARE_DOCS[$software_id]='https://dietpi.com/docs/software/gaming/#papermc' aSOFTWARE_DEPS[$software_id]='196' aSOFTWARE_INTERACTIVE[$software_id]=1 + # As of Java 16+ need, currently only works on Bullseye and not on ARMv6 + aSOFTWARE_AVAIL_G_HW_ARCH[$software_id,1]=0 + aSOFTWARE_AVAIL_G_DISTRO[$software_id,4]=0 + aSOFTWARE_AVAIL_G_DISTRO[$software_id,5]=0 #------------------ software_id=62 @@ -2814,14 +2819,6 @@ _EOF_ fi - software_id=100 # PiJuice - if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then - - Banner_Installing - G_AGI pijuice-base - - fi - software_id=17 # Git if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then @@ -3341,7 +3338,7 @@ _EOF_ # RPi: Block packages from RPi desktop which conflict with a native LXDE desktop: https://github.com/MichaIng/DietPi/issues/1558#issuecomment-691206284 (( $G_HW_MODEL > 9 )) || cat << '_EOF_' > /etc/apt/preferences.d/dietpi-lxde -Package: pcmanfm libfm4 libfm-gtk4 lxpanel lxpanel-data +Package: pcmanfm libfm4 libfm-gtk4 lxpanel lxpanel-data libfm-modules Pin: origin archive.raspberrypi.org Pin-Priority: -1 _EOF_ @@ -3599,7 +3596,11 @@ _EOF_ # Change webroot from /var/www/html to /var/www G_CONFIG_INJECT 'server.document-root' 'server.document-root = "/var/www"' /etc/lighttpd/lighttpd.conf - [[ -f '/var/www/html/index.lighttpd.html' ]] && G_EXEC mv /var/www/html/index.lighttpd.html /var/www/ + 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 + fi [[ -d '/var/www/html' ]] && G_EXEC rmdir --ignore-fail-on-non-empty /var/www/html # Configure fastcgi for PHP-FPM @@ -4348,7 +4349,7 @@ _EOF_ elif (( $G_DISTRO == 6 )); then - local apackages=('libcec6' 'libnfs13') + local apackages=() # Fixed package dependencies fi @@ -4415,6 +4416,12 @@ amvdec_vp9' > /etc/modules-load.d/dietpi-c4-kodi.conf fi + # RPi Raspbian Bullseye + elif (( $G_HW_MODEL < 10 && $G_DISTRO == 6 )) && (( $G_RASPBIAN )) + then + /boot/dietpi/func/dietpi-set_hardware rpi-opengl vc4-fkms-v3d + Download_Install "https://dietpi.com/downloads/binaries/$G_DISTRO_NAME/kodi_$G_HW_ARCH_NAME.deb" + # Everything else else @@ -4448,10 +4455,6 @@ amvdec_vp9' > /etc/modules-load.d/dietpi-c4-kodi.conf echo -e 'Package: kodi*\nPin: origin archive.raspberrypi.org\nPin-Priority: -1' > /etc/apt/preferences.d/dietpi-kodi fi - # Apply minimal required GPU memory: https://github.com/MichaIng/DietPi/issues/3173 - local gpu_mem=$(sed -n '/^[[:blank:]]*gpu_mem_1024=/{s/^[^=]*=//p;q}' /boot/config.txt) - disable_error=1 G_CHECK_VALIDINT "$gpu_mem" 128 944 || /boot/dietpi/func/dietpi-set_hardware gpumemsplit 128 - fi fi @@ -5156,6 +5159,88 @@ _EOF_ fi + software_id=100 # PiJuice + if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then + + Banner_Installing + + # On Bullseye currently the package is not available yet. So pull and install manually, if this is the case: https://github.com/MichaIng/DietPi/issues/4643 + if apt-cache dumpavail | grep -qE '^P(ackage|rovides):.* pijuice-base(,|$)' + then + G_AGI pijuice-base + else + Download_Install 'http://archive.raspberrypi.org/debian/pool/main/p/pijuice-base/pijuice-base_1.7_all.deb' + fi + + G_EXEC mkdir -p /var/lib/dietpi/dietpi-software/installed/pijuice + echo -e '#!/bin/dash\npoweroff' > /var/lib/dietpi/dietpi-software/installed/pijuice/pijuice_func1.sh + G_EXEC chmod +x /var/lib/dietpi/dietpi-software/installed/pijuice/pijuice_func1.sh + + cat << '_EOF_' > /var/lib/pijuice/pijuice_config.JSON +{ + "system_events": { + "low_battery_voltage": { + "function": "SYS_FUNC_HALT", + "enabled": true + }, + "low_charge": { + "function": "NO_FUNC", + "enabled": true + }, + "button_power_off": { + "function": "USER_FUNC1", + "enabled": true + }, + "forced_power_off": { + "function": "USER_FUNC2", + "enabled": false + }, + "no_power": { + "function": "SYS_FUNC_HALT_POW_OFF", + "enabled": true + }, + "forced_sys_power_off": { + "function": "USER_FUNC3", + "enabled": false + }, + "watchdog_reset": { + "function": "USER_EVENT", + "enabled": true + } + }, + "user_functions": { + "USER_FUNC1": "/var/lib/dietpi/dietpi-software/installed/pijuice/pijuice_func1.sh", + "USER_FUNC2": "/var/lib/dietpi/dietpi-software/installed/pijuice/pijuice_func2.sh", + "USER_FUNC3": "/var/lib/dietpi/dietpi-software/installed/pijuice/pijuice_func3.sh", + "USER_FUNC4": "", + "USER_FUNC5": "", + "USER_FUNC6": "", + "USER_FUNC7": "", + "USER_FUNC8": "" + }, + "system_task": { + "watchdog": { + "enabled": true, + "period": "60" + }, + "min_bat_voltage": { + "threshold": "1", + "enabled": true + }, + "min_charge": { + "threshold": "1", + "enabled": true + }, + "enabled": true, + "wakeup_on_charge": { + "enabled": true, + "trigger_level": "1" + } + } +} +_EOF_ + fi + software_id=171 # frp if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then @@ -6216,8 +6301,36 @@ Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=bullseye\nPin- Download_Install "$INSTALL_URL_ADDRESS" /mnt/dietpi_userdata/cuberite - # ARMv6 workaround: https://github.com/MichaIng/DietPi/issues/3664 - (( $G_HW_MODEL == 1 )) && Download_Install 'https://dietpi.com/downloads/binaries/buster/cuberite_armv6l.7z' /mnt/dietpi_userdata/cuberite + # User + Create_User -d /mnt/dietpi_userdata/cuberite cuberite + + # Service: Needs to be Type=forking, else it shuts down automatically after startup has finished :/ ... + cat << '_EOF_' > /etc/systemd/system/cuberite.service +[Unit] +Description=Cuberite Server (DietPi) + +[Service] +Type=forking +User=cuberite +WorkingDirectory=/mnt/dietpi_userdata/cuberite +ExecStart=/mnt/dietpi_userdata/cuberite/Cuberite -d + +[Install] +WantedBy=multi-user.target +_EOF_ + # Web UI settings: Do not overwrite existing! + [[ -f '/mnt/dietpi_userdata/cuberite/webadmin.ini' ]] || cat << _EOF_ > /mnt/dietpi_userdata/cuberite/webadmin.ini +[User:admin] +Password=$GLOBAL_PW + +[WebAdmin] +Ports=1339 +Enabled=1 +_EOF_ + # Permissions + G_EXEC chmod 0600 /mnt/dietpi_userdata/cuberite/webadmin.ini + G_EXEC chown -R cuberite:cuberite /mnt/dietpi_userdata/cuberite + G_EXEC chmod +x /mnt/dietpi_userdata/cuberite/Cuberite fi @@ -6858,20 +6971,115 @@ Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=bullseye\nPin- Banner_Installing - # Reinstall: Skip download and install, advice to use internal updater from web UI - if [[ -d '/opt/Lidarr' ]]; then + # APT dependencies + DEPS_LIST='mediainfo' + # - .NET: https://packages.microsoft.com/debian/ + if (( $G_HW_ARCH != 1 )) + then + if (( $G_DISTRO < 5 )) + then + DEPS_LIST+=' libicu57' - G_DIETPI-NOTIFY 2 "${aSOFTWARE_NAME[$software_id]} install dir \"/opt/Lidarr\" already exists. Download and install steps will be skipped. + elif (( $G_DISTRO == 5 )) + then + DEPS_LIST+=' libicu63' + + elif (( $G_DISTRO == 6 )) + then + DEPS_LIST+=' libicu67' + fi + fi + + # Pre-v7.5 ARMv6: Migrate old install dir + [[ -d '/opt/Lidarr' && ! -d '/opt/lidarr' ]] && G_EXEC mv /opt/{L,l}idarr + + # Reinstall: Skip download and install, advice to use internal updater from web UI + if [[ -d '/opt/lidarr' ]] + then + # shellcheck disable=SC2086 + G_AGI $DEPS_LIST + DEPS_LIST= + G_DIETPI-NOTIFY 2 "${aSOFTWARE_NAME[$software_id]} install dir \"/opt/lidarr\" already exists. Download and install steps will be skipped. - If you want to update ${aSOFTWARE_NAME[$software_id]}, please use the internal updater from web UI. - - If you need to reinstall (e.g. broken instance), please manually remove the install dir \"/opt/Lidarr\" and rerun \"dietpi-software reinstall $software_id\"." + - If you need to reinstall (e.g. broken instance), please manually remove the install dir \"/opt/lidarr\" and rerun \"dietpi-software reinstall $software_id\"." else + # ARMv6 + if (( $G_HW_ARCH == 1 )) + then + INSTALL_URL_ADDRESS=$(curl -sSfL 'https://api.github.com/repos/Lidarr/Lidarr/releases/latest' | mawk -F\" '/"browser_download_url": .*linux\.tar\.gz"/{print $4}') + local fallback_url='https://github.com/Lidarr/Lidarr/releases/download/v0.8.1.2135/Lidarr.master.0.8.1.2135.linux.tar.gz' + + # ARMv7 + elif (( $G_HW_ARCH == 2 )) + then + INSTALL_URL_ADDRESS=$(curl -sSfL 'https://api.github.com/repos/Lidarr/Lidarr/releases/latest' | mawk -F\" '/"browser_download_url": .*linux-core-arm\.tar\.gz"/{print $4}') + local fallback_url='https://github.com/Lidarr/Lidarr/releases/download/v0.8.1.2135/Lidarr.master.0.8.1.2135.linux-core-arm.tar.gz' - local fallback_url='https://github.com/lidarr/Lidarr/releases/download/v0.8.1.2135/Lidarr.master.0.8.1.2135.linux.tar.gz' - DEPS_LIST='mediainfo' Download_Install "$(curl -sSfL 'https://api.github.com/repos/Lidarr/Lidarr/releases/latest' | mawk -F\" '/"browser_download_url": .*linux\.tar\.gz"/{print $4}')" /opt + # ARMv8 + elif (( $G_HW_ARCH == 3 )) + then + INSTALL_URL_ADDRESS=$(curl -sSfL 'https://api.github.com/repos/Lidarr/Lidarr/releases/latest' | mawk -F\" '/"browser_download_url": .*linux-core-arm64\.tar\.gz"/{print $4}') + local fallback_url='https://github.com/Lidarr/Lidarr/releases/download/v0.8.1.2135/Lidarr.master.0.8.1.2135.linux-core-arm64.tar.gz' + # x86_64 + elif (( $G_HW_ARCH == 10 )) + then + INSTALL_URL_ADDRESS=$(curl -sSfL 'https://api.github.com/repos/Lidarr/Lidarr/releases/latest' | mawk -F\" '/"browser_download_url": .*linux-core-x64\.tar\.gz"/{print $4}') + local fallback_url='https://github.com/Lidarr/Lidarr/releases/download/v0.8.1.2135/Lidarr.master.0.8.1.2135.linux-core-x64.tar.gz' + fi + + Download_Install "$INSTALL_URL_ADDRESS" + G_EXEC mv Lidarr /opt/lidarr fi + # Data dir + G_EXEC mkdir -p /mnt/dietpi_userdata/lidarr + + # User + Create_User -g dietpi -d /mnt/dietpi_userdata/lidarr lidarr + + # Service: https://github.com/lidarr/Lidarr/wiki/Autostart-on-Linux#systemd + cat << _EOF_ > /etc/systemd/system/lidarr.service +[Unit] +Description=Lidarr Daemon (DietPi) +Wants=network-online.target +After=network-online.target dietpi-boot.service + +[Service] +SyslogIdentifier=Lidarr +User=lidarr +UMask=002 +ExecStart=/opt/lidarr/Lidarr -nobrowser -data=/mnt/dietpi_userdata/lidarr +TimeoutStopSec=20 +KillMode=process +Restart=on-failure + +# Hardening +ProtectSystem=strict +ProtectHome=true +PrivateDevices=true +ProtectKernelTunables=true +ProtectControlGroups=true +ReadWritePaths=/opt/lidarr /mnt /media /var/log/lidarr /tmp + +[Install] +WantedBy=multi-user.target +_EOF_ + # - ARMv6 devices use Mono + (( $G_HW_ARCH == 1 )) && G_CONFIG_INJECT 'ExecStart=' "ExecStart=$(command -v mono) /opt/lidarr/Lidarr.exe -nobrowser -data=/mnt/dietpi_userdata/lidarr" /etc/systemd/system/lidarr.service + + # Logs to RAM + G_EXEC rm -Rf /mnt/dietpi_userdata/lidarr/logs* + G_EXEC mkdir -p /var/log/lidarr + G_EXEC ln -s /var/log/lidarr /mnt/dietpi_userdata/lidarr/logs + G_EXEC ln -s /var/log/lidarr/logs.db /mnt/dietpi_userdata/lidarr/logs.db + G_EXEC ln -s /var/log/lidarr/logs.db-shm /mnt/dietpi_userdata/lidarr/logs.db-shm + G_EXEC ln -s /var/log/lidarr/logs.db-wal /mnt/dietpi_userdata/lidarr/logs.db-wal + + # Permissions + G_EXEC chown -R lidarr:dietpi /mnt/dietpi_userdata/lidarr /opt/lidarr /var/log/lidarr + fi software_id=180 # Bazarr @@ -7715,9 +7923,7 @@ _EOF_ Banner_Installing # Make sure user agrees to the EULA - G_WHIP_BUTTON_OK_TEXT='YES' - G_WHIP_BUTTON_CANCEL_TEXT='NO' - if [[ -f '/mnt/dietpi_userdata/papermc/eula.txt' ]] || G_WHIP_YESNO 'Do you agree to the Minecraft EULA found at:\n\nhttps://account.mojang.com/documents/minecraft_eula' + if [[ -f '/mnt/dietpi_userdata/papermc/eula.txt' ]] || G_WHIP_BUTTON_OK_TEXT='Yes' G_WHIP_BUTTON_CANCEL_TEXT='Abort' G_WHIP_YESNO 'Do you agree to the Minecraft EULA found at:\n\nhttps://account.mojang.com/documents/minecraft_eula' then # Collect latest version of PaperMC local url='https://papermc.io/api/v2/projects/paper' @@ -7728,10 +7934,79 @@ _EOF_ Download_Install "$url/versions/$version/builds/$build/downloads/paper-$version-$build.jar" /opt/papermc/paperclip.jar G_EXEC mkdir -p /mnt/dietpi_userdata/papermc G_EXEC eval 'echo "eula=true" > /mnt/dietpi_userdata/papermc/eula.txt' + + # User + Create_User -d /mnt/dietpi_userdata/papermc papermc + + # Bedrock compatibility + G_WHIP_BUTTON_OK_TEXT='Yes' + G_WHIP_BUTTON_CANCEL_TEXT='Skip' + if G_WHIP_YESNO 'Would you like to install the Geyser and Floodgate plugins for compatibility with Bedrock Edition?\n\nNote that this may be buggy.' + then + Download_Install 'https://ci.opencollab.dev/job/GeyserMC/job/Geyser/job/master/lastStableBuild/artifact/bootstrap/spigot/target/Geyser-Spigot.jar' /mnt/dietpi_userdata/papermc/plugins/Geyser-Spigot.jar + Download_Install 'https://ci.opencollab.dev/job/GeyserMC/job/Floodgate/job/master/lastStableBuild/artifact/spigot/target/floodgate-spigot.jar' /mnt/dietpi_userdata/papermc/plugins/floodgate-bukkit.jar + fi + + # Minecraft rcon client for remote administration and server maintenance scripts + DEPS_LIST='gcc libc6-dev' + Download_Install 'https://github.com/Tiiffi/mcrcon/archive/master.tar.gz' + [[ -d '/usr/local/bin' ]] || G_EXEC mkdir -p /usr/local/bin + G_EXEC gcc -g0 -O3 mcrcon-master/mcrcon.c -o /usr/local/bin/mcrcon + G_EXEC rm -R mcrcon-master + G_EXEC strip --remove-section=.comment --remove-section=.note /usr/local/bin/mcrcon + + # Link logs to RAM + G_EXEC mkdir -p /var/log/papermc + G_EXEC rm -Rf /mnt/dietpi_userdata/papermc/logs + G_EXEC ln -s /var/log/papermc /mnt/dietpi_userdata/papermc/logs + + # Permissions + G_EXEC chown -R papermc:papermc /{mnt/dietpi_userdata,var/log}/papermc + + # Assure 1.5 GiB overall memory (-100 MiB to avoid tiny swap space) is available. + local heap_size='512' + if (( $RAM_TOTAL < 1436 )) + then + G_DIETPI-NOTIFY 2 'Stable PaperMC operation requires at least 1.5 GiB system memory. We will now increase your swap size to satisfy this requirement.' + /boot/dietpi/func/dietpi-set_swapfile $(( 1536 - $RAM_PHYS )) + + # On 2 GiB+ physical RAM devices, apply 1 GiB heap size by default + elif (( $RAM_PHYS > 1848 )) + then + heap_size='1024' + fi + + # Service + cat << _EOF_ > /etc/systemd/system/papermc.service +[Unit] +Description=PaperMC (DietPi) +Documentation=https://paper.readthedocs.io/ + +[Service] +SyslogIdentifier=PaperMC +User=papermc +WorkingDirectory=/mnt/dietpi_userdata/papermc +ExecStart=$(command -v java) -Xmx${heap_size}m -jar /opt/papermc/paperclip.jar --nogui --noconsole + +[Install] +WantedBy=multi-user.target +_EOF_ + # Config + if [[ -f '/mnt/dietpi_userdata/papermc/plugins/Geyser-Spigot.jar' && -f '/mnt/dietpi_userdata/papermc/plugins/floodgate-bukkit.jar' ]] + then + Create_Config /mnt/dietpi_userdata/papermc/plugins/Geyser-Spigot/config.yml papermc 1800 1 && + G_CONFIG_INJECT 'auth-type:[[:blank:]]' 'auth-type: floodgate' /mnt/dietpi_userdata/papermc/plugins/Geyser-Spigot/config.yml + else + Create_Config /mnt/dietpi_userdata/papermc/permissions.yml papermc 1800 1 + fi + G_CONFIG_INJECT 'enable-rcon=' 'enable-rcon=true' /mnt/dietpi_userdata/papermc/server.properties + GCI_PASSWORD=1 G_CONFIG_INJECT 'rcon.password=' "rcon.password=$GLOBAL_PW" /mnt/dietpi_userdata/papermc/server.properties + else aSOFTWARE_INSTALL_STATE[$software_id]=0 G_DIETPI-NOTIFY 2 "${aSOFTWARE_NAME[$software_id]} install aborted due to outstanding EULA agreement" fi + fi software_id=140 # Domoticz @@ -9160,7 +9435,10 @@ _EOF_ dps_index=$software_id Download_Install 'conf' /etc/proftpd/proftpd.conf # Do not allow root access via FTP - sed -i 's/^[[:blank:]]*root/#root/' /etc/ftpusers + G_EXEC sed -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 fi @@ -10614,7 +10892,6 @@ _EOF_ local choice_required= while : do - G_WHIP_MENU_ARRAY=( 'Server' ': Use this machine as VPN server and allow clients to connect to it.' @@ -10624,7 +10901,6 @@ _EOF_ G_WHIP_MENU "${choice_required}Please choose, if this machine should be set up as VPN server or client:" && break choice_required='[ERROR] A choice is required to finish the WireGuard install.\n\n' - done # Server choice @@ -10635,7 +10911,6 @@ _EOF_ local domain=$(hostname -f) while : do - G_WHIP_DEFAULT_ITEM=$domain if G_WHIP_INPUTBOX "${invalid_text}Please enter your servers public IP/domain for WireGuard client access:" && [[ $G_WHIP_RETURNED_VALUE ]]; then @@ -10647,13 +10922,11 @@ _EOF_ invalid_text='[ERROR] No valid entry found. Please retry...\n\n' fi - done invalid_text= local port=51820 while : do - G_WHIP_DEFAULT_ITEM=$port if G_WHIP_INPUTBOX "${invalid_text}Please enter the network port that will be used to access your WireGuard server:\n NB: This port needs to be forwarded by your router and/or opened in your firewall settings. Default value is: 51820" && disable_error=1 G_CHECK_VALIDINT "$G_WHIP_RETURNED_VALUE" 0; then @@ -10666,7 +10939,6 @@ NB: This port needs to be forwarded by your router and/or opened in your firewal invalid_text='[ERROR] No valid entry found, value needs to be a sequence of integers. Please retry...\n\n' fi - done # Create everything inside WireGuard config dir @@ -10810,7 +11082,6 @@ subnet 192.168.42.0 netmask 255.255.255.0 { option domain-name-servers 8.8.8.8, 8.8.4.4; } _EOF_ - # Assign detected WLAN interface echo "INTERFACESv4=\"wlan$wifi_index\"" > /etc/default/isc-dhcp-server @@ -10856,7 +11127,7 @@ _EOF_ dpkg-query -s hostapd-realtek &> /dev/null && G_CONFIG_INJECT 'driver=' 'driver=rtl871xdrv' /etc/hostapd/hostapd.conf # Enable access point config - echo "DAEMON_CONF=\"/etc/hostapd/hostapd.conf\"" > /etc/default/hostapd + echo 'DAEMON_CONF="/etc/hostapd/hostapd.conf"' > /etc/default/hostapd # Enable IP forwarding echo -e 'net.ipv4.ip_forward=1\nnet.ipv6.conf.all.forwarding=1\nnet.ipv6.conf.default.forwarding=1' > /etc/sysctl.d/dietpi-wifihotspot.conf @@ -10883,7 +11154,7 @@ _EOF_ Remove_SysV tor 1 # Tor config - cat << _EOF_ > /etc/tor/torrc + cat << '_EOF_' > /etc/tor/torrc Log notice stdout VirtualAddrNetwork 10.192.0.0/10 AutomapHostsSuffixes .onion,.exit @@ -10891,7 +11162,6 @@ AutomapHostsOnResolve 1 TransPort 192.168.42.1:9040 DNSPort 192.168.42.1:53 _EOF_ - # Flush IP tables iptables -F iptables -t nat -F @@ -11202,44 +11472,6 @@ location = /.well-known/caldav { return 301 /baikal/html/dav.php; }' > /etc/ngi fi - software_id=52 # Cuberite - if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then - - Banner_Configuration - - # User - Create_User -d /mnt/dietpi_userdata/cuberite cuberite - - # Service - cat << '_EOF_' > /etc/systemd/system/cuberite.service -[Unit] -Description=Cuberite Server (DietPi) - -[Service] -Type=forking -User=cuberite -WorkingDirectory=/mnt/dietpi_userdata/cuberite -ExecStart=/mnt/dietpi_userdata/cuberite/Cuberite --service - -[Install] -WantedBy=multi-user.target -_EOF_ - # Web UI settings: Do not overwrite existing! - [[ -f '/mnt/dietpi_userdata/cuberite/webadmin.ini' ]] || cat << _EOF_ > /mnt/dietpi_userdata/cuberite/webadmin.ini -[User:admin] -Password=$GLOBAL_PW - -[WebAdmin] -Ports=1339 -Enabled=1 -_EOF_ - # Permissions - G_EXEC chmod 0640 /mnt/dietpi_userdata/cuberite/webadmin.ini - G_EXEC chown -R cuberite:cuberite /mnt/dietpi_userdata/cuberite - G_EXEC chmod +x /mnt/dietpi_userdata/cuberite/Cuberite - - fi - software_id=53 # MineOS if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )) then @@ -12574,57 +12806,6 @@ _EOF_ fi - software_id=106 # Lidarr - if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then - - Banner_Configuration - - # Data dir - G_EXEC mkdir -p /mnt/dietpi_userdata/lidarr - - # User - Create_User -g dietpi -d /mnt/dietpi_userdata/lidarr lidarr - - # Service: https://github.com/lidarr/Lidarr/wiki/Autostart-on-Linux#systemd - cat << _EOF_ > /etc/systemd/system/lidarr.service -[Unit] -Description=Lidarr Daemon (DietPi) -Wants=network-online.target -After=network-online.target dietpi-boot.service - -[Service] -SyslogIdentifier=Lidarr -User=lidarr -UMask=002 -ExecStart=$(command -v mono) /opt/Lidarr/Lidarr.exe -nobrowser -data=/mnt/dietpi_userdata/lidarr -TimeoutStopSec=20 -KillMode=process -Restart=on-failure - -# Hardening -ProtectSystem=strict -ProtectHome=true -PrivateDevices=true -ProtectKernelTunables=true -ProtectControlGroups=true -ReadWritePaths=/opt/Lidarr /mnt /media /var/log/lidarr /tmp - -[Install] -WantedBy=multi-user.target -_EOF_ - # Logs to RAM - G_EXEC rm -Rf /mnt/dietpi_userdata/lidarr/logs* - G_EXEC mkdir -p /var/log/lidarr - G_EXEC ln -s /var/log/lidarr /mnt/dietpi_userdata/lidarr/logs - G_EXEC ln -s /var/log/lidarr/logs.db /mnt/dietpi_userdata/lidarr/logs.db - G_EXEC ln -s /var/log/lidarr/logs.db-shm /mnt/dietpi_userdata/lidarr/logs.db-shm - G_EXEC ln -s /var/log/lidarr/logs.db-wal /mnt/dietpi_userdata/lidarr/logs.db-wal - - # Permissions - G_EXEC chown -R lidarr:dietpi /mnt/dietpi_userdata/lidarr /opt/Lidarr /var/log/lidarr - - fi - software_id=180 # Bazarr if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then @@ -13319,151 +13500,6 @@ _EOF_ fi - software_id=181 # PaperMC - if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )) - then - Banner_Configuration - - # User - Create_User -d /mnt/dietpi_userdata/papermc papermc - - # Bedrock compatibility - G_WHIP_BUTTON_OK_TEXT='YES' - G_WHIP_BUTTON_CANCEL_TEXT='NO' - if G_WHIP_YESNO 'Would you like to install the Geyser and Floodgate plugins for compatibility with Bedrock Edition?\n\nNote that this may be buggy.' - then - Download_Install 'https://ci.opencollab.dev/job/GeyserMC/job/Geyser/job/master/lastStableBuild/artifact/bootstrap/spigot/target/Geyser-Spigot.jar' /mnt/dietpi_userdata/papermc/plugins/Geyser-Spigot.jar - Download_Install 'https://ci.opencollab.dev/job/GeyserMC/job/Floodgate/job/master/lastStableBuild/artifact/spigot/target/floodgate-spigot.jar' /mnt/dietpi_userdata/papermc/plugins/floodgate-bukkit.jar - fi - - # Minecraft rcon client for remote administration and server maintenance scripts - Download_Install 'https://github.com/Tiiffi/mcrcon/archive/master.tar.gz' - G_EXEC gcc -g0 -O3 mcrcon-master/mcrcon.c -o /usr/local/bin/mcrcon - G_EXEC rm -R mcrcon-master - G_EXEC strip --remove-section=.comment --remove-section=.note /usr/local/bin/mcrcon - - # Link logs to RAM - G_EXEC mkdir -p /var/log/papermc - G_EXEC rm -Rf /mnt/dietpi_userdata/papermc/logs - G_EXEC ln -s /var/log/papermc /mnt/dietpi_userdata/papermc/logs - - # Permissions - G_EXEC chown -R papermc:papermc /{mnt/dietpi_userdata,var/log}/papermc - - # Assure 1.5 GiB overall memory (-100 MiB to avoid tiny swap space) is available. - local heap_size='512' - if (( $RAM_TOTAL < 1436 )) - then - G_DIETPI-NOTIFY 2 'Stable PaperMC operation requires at least 1.5 GiB system memory. We will now increase your swap size to satisfy this requirement.' - /boot/dietpi/func/dietpi-set_swapfile $(( 1536 - $RAM_PHYS )) - - # On 2 GiB+ physical RAM devices, apply 1 GiB heap size by default - elif (( $RAM_PHYS > 1848 )) - then - heap_size='1024' - fi - - # Service - cat << _EOF_ > /etc/systemd/system/papermc.service -[Unit] -Description=PaperMC (DietPi) -Documentation=https://paper.readthedocs.io/ - -[Service] -SyslogIdentifier=PaperMC -User=papermc -WorkingDirectory=/mnt/dietpi_userdata/papermc -ExecStart=$(command -v java) -Xmx${heap_size}m -jar /opt/papermc/paperclip.jar --nogui --noconsole - -[Install] -WantedBy=multi-user.target -_EOF_ - # Config - if [[ -f '/mnt/dietpi_userdata/papermc/plugins/Geyser-Spigot.jar' && -f '/mnt/dietpi_userdata/papermc/plugins/floodgate-bukkit.jar' ]] - then - Create_Config /mnt/dietpi_userdata/papermc/plugins/Geyser-Spigot/config.yml papermc 1800 1 && - G_CONFIG_INJECT 'auth-type:[[:blank:]]' 'auth-type: floodgate' /mnt/dietpi_userdata/papermc/plugins/Geyser-Spigot/config.yml - else - Create_Config /mnt/dietpi_userdata/papermc/permissions.yml papermc 1800 1 - fi - G_CONFIG_INJECT 'enable-rcon=' 'enable-rcon=true' /mnt/dietpi_userdata/papermc/server.properties - GCI_PASSWORD=1 G_CONFIG_INJECT 'rcon.password=' "rcon.password=$GLOBAL_PW" /mnt/dietpi_userdata/papermc/server.properties - fi - - software_id=100 # PiJuice - if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then - - Banner_Configuration - - G_EXEC mkdir -p /var/lib/dietpi/dietpi-software/installed/pijuice - echo -e '#!/bin/dash\npoweroff' > /var/lib/dietpi/dietpi-software/installed/pijuice/pijuice_func1.sh - G_EXEC chmod +x /var/lib/dietpi/dietpi-software/installed/pijuice/pijuice_func1.sh - - cat << '_EOF_' > /var/lib/pijuice/pijuice_config.JSON -{ - "system_events": { - "low_battery_voltage": { - "function": "SYS_FUNC_HALT", - "enabled": true - }, - "low_charge": { - "function": "NO_FUNC", - "enabled": true - }, - "button_power_off": { - "function": "USER_FUNC1", - "enabled": true - }, - "forced_power_off": { - "function": "USER_FUNC2", - "enabled": false - }, - "no_power": { - "function": "SYS_FUNC_HALT_POW_OFF", - "enabled": true - }, - "forced_sys_power_off": { - "function": "USER_FUNC3", - "enabled": false - }, - "watchdog_reset": { - "function": "USER_EVENT", - "enabled": true - } - }, - "user_functions": { - "USER_FUNC1": "/var/lib/dietpi/dietpi-software/installed/pijuice/pijuice_func1.sh", - "USER_FUNC2": "/var/lib/dietpi/dietpi-software/installed/pijuice/pijuice_func2.sh", - "USER_FUNC3": "/var/lib/dietpi/dietpi-software/installed/pijuice/pijuice_func3.sh", - "USER_FUNC4": "", - "USER_FUNC5": "", - "USER_FUNC6": "", - "USER_FUNC7": "", - "USER_FUNC8": "" - }, - "system_task": { - "watchdog": { - "enabled": true, - "period": "60" - }, - "min_bat_voltage": { - "threshold": "1", - "enabled": true - }, - "min_charge": { - "threshold": "1", - "enabled": true - }, - "enabled": true, - "wakeup_on_charge": { - "enabled": true, - "trigger_level": "1" - } - } -} -_EOF_ - fi - software_id=178 # Jellyfin if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then @@ -13489,14 +13525,6 @@ _EOF_ # Permissions G_EXEC chown -R jellyfin: /mnt/dietpi_userdata/jellyfin - # RPi: Assure 128 MiB GPU memory on non-interactive installs, 320 MiB will be offered at the end of interactive installs: https://jellyfin.org/docs/general/administration/hardware-acceleration.html#raspberry-pi-3-and-4 - if (( $G_HW_MODEL < 10 )); then - - local gpu_mem=$(sed -n '/^[[:blank:]]*gpu_mem_1024=/{s/^[^=]*=//p;q}' /boot/config.txt) - disable_error=1 G_CHECK_VALIDINT "$gpu_mem" 128 944 || /boot/dietpi/func/dietpi-set_hardware gpumemsplit 128 - - fi - Download_Test_Media fi @@ -13511,20 +13539,20 @@ _EOF_ # Kodi, Jellyfin if (( ${aSOFTWARE_INSTALL_STATE[31]} == 1 || ${aSOFTWARE_INSTALL_STATE[178]} == 1 )); then - gpu_memory=320 - (( ${G_HW_MEMORY_SIZE:-0} > 512 )) || gpu_memory=256 + gpu_memory=256 + (( ${G_HW_MEMORY_SIZE:-0} > 256 )) || gpu_memory=128 - # Descent + # DXX-Rebirth elif (( ${aSOFTWARE_INSTALL_STATE[112]} == 1 )); then - gpu_memory=192 + gpu_memory=128 # RPi Cam Control, Amiberry, Chromium elif (( ${aSOFTWARE_INSTALL_STATE[59]} == 1 || ${aSOFTWARE_INSTALL_STATE[108]} == 1 || ${aSOFTWARE_INSTALL_STATE[113]} == 1 )); then - gpu_memory=128 + gpu_memory=96 # Desktops, OpenTyrian elif (( ${aSOFTWARE_INSTALL_STATE[23]} == 1 || @@ -13547,7 +13575,7 @@ _EOF_ # Never override a higher existing value local current_gpu_mem=$(sed -n '/^[[:blank:]]*gpu_mem_1024=/{s/^[^=]*=//p;q}' /boot/config.txt) - [[ $current_gpu_mem ]] || current_gpu_mem=64 + [[ $current_gpu_mem ]] || { (( $G_HW_MEMORY_SIZE < 1024 )) && current_gpu_mem=64 || current_gpu_mem=76; } (( $current_gpu_mem < $gpu_memory )) && G_WHIP_DEFAULT_ITEM='Ok' G_WHIP_YESNO "[ INFO ] DietPi has detected an increased GPU memory is required for your installed software: - Current: $current_gpu_mem MiB\n - Recommended: $gpu_memory MiB\n\nWould you like DietPi to apply the recommended GPU memory split?\n\nIf unsure, select 'Ok'." || return @@ -14460,14 +14488,14 @@ _EOF_ Banner_Uninstalling if [[ -f '/etc/systemd/system/lidarr.service' ]]; then - systemctl disable --now lidarr - rm -R /etc/systemd/system/lidarr.service* + G_EXEC systemctl disable --now lidarr + G_EXEC rm /etc/systemd/system/lidarr.service fi - [[ -d '/etc/systemd/system/lidarr.service.d' ]] && rm -R /etc/systemd/system/lidarr.service.d + [[ -d '/etc/systemd/system/lidarr.service.d' ]] && G_EXEC rm -R /etc/systemd/system/lidarr.service.d getent passwd lidarr > /dev/null && userdel lidarr getent group lidarr > /dev/null && groupdel lidarr # Pre-v6.29 - rm -Rf /opt/Lidarr /mnt/dietpi_userdata/lidarr /var/log/lidarr + G_EXEC rm -Rf /opt/{L,l}idarr /mnt/dietpi_userdata/lidarr /var/log/lidarr fi @@ -15145,10 +15173,10 @@ _EOF_ Banner_Uninstalling G_AGP 'wireguard*' - [[ -d '/etc/wireguard' ]] && rm -R /etc/wireguard - [[ -d '/etc/systemd/system/wg-quick@wg0.service.d' ]] && rm -R /etc/systemd/system/wg-quick@wg0.service.d - [[ -f '/etc/apt/sources.list.d/dietpi-wireguard.list' ]] && rm /etc/apt/sources.list.d/dietpi-wireguard.list - [[ -f '/etc/apt/preferences.d/dietpi-wireguard' ]] && rm /etc/apt/preferences.d/dietpi-wireguard + [[ -d '/etc/wireguard' ]] && G_EXEC rm -R /etc/wireguard + [[ -d '/etc/systemd/system/wg-quick@wg0.service.d' ]] && G_EXEC rm -R /etc/systemd/system/wg-quick@wg0.service.d + [[ -f '/etc/apt/sources.list.d/dietpi-wireguard.list' ]] && G_EXEC rm /etc/apt/sources.list.d/dietpi-wireguard.list + [[ -f '/etc/apt/preferences.d/dietpi-wireguard' ]] && G_EXEC rm /etc/apt/preferences.d/dietpi-wireguard fi @@ -15468,14 +15496,14 @@ _EOF_ Banner_Uninstalling if [[ -f '/etc/systemd/system/cuberite.service' ]]; then - systemctl disable --now cuberite - rm -R /etc/systemd/system/cuberite.service* + G_EXEC systemctl disable --now cuberite + G_EXEC rm /etc/systemd/system/cuberite.service fi - [[ -d '/etc/systemd/system/cuberite.service.d' ]] && rm -R /etc/systemd/system/cuberite.service.d + [[ -d '/etc/systemd/system/cuberite.service.d' ]] && G_EXEC rm -R /etc/systemd/system/cuberite.service.d getent passwd cuberite > /dev/null && userdel cuberite getent group cuberite > /dev/null && groupdel cuberite - [[ -d '/mnt/dietpi_userdata/cuberite' ]] && rm -R /mnt/dietpi_userdata/cuberite + [[ -d '/mnt/dietpi_userdata/cuberite' ]] && G_EXEC rm -R /mnt/dietpi_userdata/cuberite fi @@ -15619,15 +15647,14 @@ _EOF_ Banner_Uninstalling # Service - if [[ -f '/etc/systemd/system/amiberry.service' ]]; then - - systemctl disable --now amiberry - rm -R /etc/systemd/system/amiberry.service* - + if [[ -f '/etc/systemd/system/amiberry.service' ]] + then + G_EXEC systemctl disable --now amiberry + G_EXEC rm /etc/systemd/system/amiberry.service fi - [[ -d '/etc/systemd/system/amiberry.service.d' ]] && rm -R /etc/systemd/system/amiberry.service.d + [[ -d '/etc/systemd/system/amiberry.service.d' ]] && G_EXEC rm -R /etc/systemd/system/amiberry.service.d # Files - [[ -d '/mnt/dietpi_userdata/amiberry' ]] && rm -R /mnt/dietpi_userdata/amiberry + [[ -d '/mnt/dietpi_userdata/amiberry' ]] && G_EXEC rm -R /mnt/dietpi_userdata/amiberry # Autostart index: If currently Amiberry, revert to console login [[ -f '/boot/dietpi/.dietpi-autostart_index' && $( /dev/null && userdel papermc getent group papermc > /dev/null && groupdel papermc # Files - [[ -d '/opt/papermc' ]] && rm -R /opt/papermc - [[ -d '/var/log/papermc' ]] && rm -R /var/log/papermc - [[ -d '/mnt/dietpi_userdata/papermc' ]] && rm -R /mnt/dietpi_userdata/papermc - [[ -f '/usr/local/bin/mcrcon' ]] && rm /usr/local/bin/mcrcon + [[ -d '/opt/papermc' ]] && G_EXEC rm -R /opt/papermc + [[ -d '/var/log/papermc' ]] && G_EXEC rm -R /var/log/papermc + [[ -d '/mnt/dietpi_userdata/papermc' ]] && G_EXEC rm -R /mnt/dietpi_userdata/papermc + [[ -f '/usr/local/bin/mcrcon' ]] && G_EXEC rm /usr/local/bin/mcrcon fi software_id=103 # DietPi-RAMlog diff --git a/dietpi/dietpi-vpn b/dietpi/dietpi-vpn index 4dd905ffb8..91f6991d2c 100644 --- a/dietpi/dietpi-vpn +++ b/dietpi/dietpi-vpn @@ -68,7 +68,7 @@ Available commands: RX='N/A' TX='N/A' - Update_WAN_IP(){ WAN_IP=$(curl -sSfLm 3 https://freegeoip.app/csv/ 2>&1 | mawk -F, '($5){r=$5" "}{print $1" "r$3}'); } + Update_WAN_IP(){ WAN_IP=$(G_GET_WAN_IP); } Check_Connected() { diff --git a/dietpi/func/dietpi-banner b/dietpi/func/dietpi-banner index fed485526e..42a55a4124 100644 --- a/dietpi/func/dietpi-banner +++ b/dietpi/func/dietpi-banner @@ -227,7 +227,7 @@ $GREEN_LINE" # LAN IP [5] Print_Local_Ip # WAN IP + location info: Move this to /run/dietpi/.network? - (( ${aENABLED[6]} == 1 )) && echo -e "$GREEN_BULLET ${aCOLOUR[1]}${aDESCRIPTION[6]} $GREEN_SEPARATOR $(curl -sSfLm 3 https://freegeoip.app/csv/ 2>&1 | mawk -F, '($5){r=$5" "}{print $1" "r$3}')" + (( ${aENABLED[6]} == 1 )) && echo -e "$GREEN_BULLET ${aCOLOUR[1]}${aDESCRIPTION[6]} $GREEN_SEPARATOR $(G_GET_WAN_IP)" # DietPi-VPN connection status (( ${aENABLED[13]} == 1 )) && echo -e "$GREEN_BULLET ${aCOLOUR[1]}${aDESCRIPTION[13]} $GREEN_SEPARATOR $(/boot/dietpi/dietpi-vpn status 2>&1)" # Freespace (RootFS) diff --git a/dietpi/func/dietpi-globals b/dietpi/func/dietpi-globals index 90af43bc2d..fe40d6df1f 100644 --- a/dietpi/func/dietpi-globals +++ b/dietpi/func/dietpi-globals @@ -56,7 +56,7 @@ [[ -f '/boot/dietpi/.version' ]] && . /boot/dietpi/.version # - Assign defaults/code version as fallback [[ $G_DIETPI_VERSION_CORE ]] || G_DIETPI_VERSION_CORE=7 - [[ $G_DIETPI_VERSION_SUB ]] || G_DIETPI_VERSION_SUB=5 + [[ $G_DIETPI_VERSION_SUB ]] || G_DIETPI_VERSION_SUB=6 [[ $G_DIETPI_VERSION_RC ]] || G_DIETPI_VERSION_RC=-1 [[ $G_GITBRANCH ]] || G_GITBRANCH='master' [[ $G_GITOWNER ]] || G_GITOWNER='MichaIng' @@ -1162,6 +1162,29 @@ $log_content" || break # Exit error handler menu loop on cancel } + # Print public IP address and location info + # - Optional arguments: + # -t : Set timeout in seconds, supports floats, default: 3 + G_GET_WAN_IP() + { + # Defaults + local timeout=3 + # Inputs + while (( $# )) + do + # shellcheck disable=SC2015 + case $1 in + '-t') shift; (( ${1/.} )) && timeout=$1 || { G_DIETPI-NOTIFY 1 "Invalid timeout \"$1\", aborting..."; return 1; };; + *) G_DIETPI-NOTIFY 1 "Invalid argument \"$1\", aborting..."; return 1;; + esac + shift + done + local response=$(curl -sSfLm "$timeout" https://freegeoip.app/csv/ 2>&1 | mawk -F, '($5){r=$5" "}{print $1" "r$3}') + # https://github.com/MichaIng/DietPi/issues/4445 + [[ $response == 'curl: (60)'* ]] && response='freegeoip.app seems to be blocked via DNS, please add it to the whitelist to allow WAN IP retrieval.' + echo "$response" + } + # $1 = directory to test permissions support # Returns 0=ok >=1=failed G_CHECK_FS_PERMISSION_SUPPORT(){ diff --git a/dietpi/func/dietpi-set_hardware b/dietpi/func/dietpi-set_hardware index f91715e4d8..19f0b0a3cc 100644 --- a/dietpi/func/dietpi-set_hardware +++ b/dietpi/func/dietpi-set_hardware @@ -119,7 +119,7 @@ $FP_SCRIPT rpi-eeprom # Requires 128 MiB memory split at least local gpu_mem=$(sed -n '/^[[:blank:]]*gpu_mem[_0-9]*=/{s/^[^=]*=//p;q}' /boot/config.txt) - (( ${gpu_mem:-64} < 128 )) && INPUT_DEVICE_VALUE=128 Gpu_Memory_Split_Main + (( ${gpu_mem:-76} < 96 )) && INPUT_DEVICE_VALUE=96 Gpu_Memory_Split_Main elif [[ $INPUT_DEVICE_VALUE == 'disable' ]]; then diff --git a/rootfs/var/lib/dietpi/services/dietpi-firstboot.bash b/rootfs/var/lib/dietpi/services/dietpi-firstboot.bash index 1846de7f27..2d5f862d76 100755 --- a/rootfs/var/lib/dietpi/services/dietpi-firstboot.bash +++ b/rootfs/var/lib/dietpi/services/dietpi-firstboot.bash @@ -33,58 +33,58 @@ # RPi Zero 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 -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 # RPi 1: Apply safe overclock mode elif (( $G_HW_MODEL < 2 )) then G_CONFIG_INJECT 'over_voltage=' 'over_voltage=2' /boot/config.txt G_CONFIG_INJECT 'arm_freq=' 'arm_freq=900' /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 -i '/#core_freq=/c\#core_freq=250' /boot/config.txt + sed -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 -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 # 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 -i '/#over_voltage=/c\#over_voltage=0' /boot/config.txt + sed -i '/#core_freq=/c\#core_freq=400' /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 -i '/#arm_freq=/c\#arm_freq=1400' /boot/config.txt + sed -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 -i '/#arm_freq=/c\#arm_freq=1200' /boot/config.txt + sed -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 -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 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 -i '/#arm_freq=/c\#arm_freq=1800' /boot/config.txt else - sed -i '/arm_freq=/c\#arm_freq=1500' /boot/config.txt + sed -i '/#arm_freq=/c\#arm_freq=1500' /boot/config.txt fi fi } @@ -201,16 +201,14 @@ _EOF_ /boot/dietpi/func/dietpi-set_software apt-mirror "$(sed -n "/^[[:blank:]]*$target_repo=/{s/^[^=]*=//p;q}" /boot/dietpi.txt)" # Regenerate unique Dropbear host keys - rm -fv /etc/dropbear/dropbear_*_host_key - if (( $G_DISTRO < 6 )); then - - dpkg-reconfigure -f noninteractive dropbear-run - - else - - dpkg-reconfigure -f noninteractive dropbear - - fi + local i type + for i in /etc/dropbear/dropbear_*_host_key + do + type=${i#/etc/dropbear/dropbear_} + type=${type%_host_key} + rm -v "$i" + dropbearkey -t "$type" -f "$i" + done # Recreate machine-id: https://github.com/MichaIng/DietPi/issues/2015 [[ -f '/etc/machine-id' ]] && rm /etc/machine-id @@ -303,6 +301,13 @@ _EOF_ # shellcheck disable=SC2015 (( $wifi_enabled )) && ifup wlan$index_wlan || ifup eth$index_eth + # x86_64 BIOS: Set GRUB install device: https://github.com/MichaIng/DietPi/issues/4542 + if (( $G_HW_MODEL == 10 )) && dpkg-query -s grub-pc &> /dev/null + then + local root_drive=$(lsblk -npo PKNAME "$(findmnt -Ufnro SOURCE -M /)") + [[ $root_drive == '/dev/'* ]] && debconf-set-selections <<< "grub-pc grub-pc/install_devices multiselect $root_drive" + fi + } #/////////////////////////////////////////////////////////////////////////////////////