diff --git a/.update/pre-patches b/.update/pre-patches index b8c4b9d3c5..5d00232950 100644 --- a/.update/pre-patches +++ b/.update/pre-patches @@ -3,5 +3,26 @@ # DietPi-Update pre-patches that need to run before new scripts are downloaded and/or before APT upgrades # Created by MichaIng / micha@dietpi.com / https://dietpi.com/ # License: GPLv2 / https://github.com/MichaIng/DietPi#license + +# Load DietPi-Globals +. /boot/dietpi/func/dietpi-globals +readonly G_PROGRAM_NAME='DietPi-Pre-patches' +G_CHECK_ROOT_USER +G_CHECK_ROOTFS_RW +G_INIT + +# IMPORTANT: This script can be called with DietPi v6.17, hence assure compatibility! +# - Pre-v6.29: Create G_EXEC as G_RUN_CMD wrapper +declare -F G_EXEC > /dev/null || G_EXEC(){ G_RUN_CMD "$@"; } + +# Update Jellyfin APT repo key: https://dietpi.com/phpbb/viewtopic.php?t=8703 +if [[ -f '/etc/apt/trusted.gpg.d/dietpi-jellyfin.gpg' && $(date -u '+%Y%m%d' -r '/etc/apt/trusted.gpg.d/dietpi-jellyfin.gpg') -lt 20201216 ]] +then + G_DIETPI-NOTIFY 2 'Updating Jellyfin APT repo key: https://dietpi.com/phpbb/viewtopic.php?t=8703' + G_EXEC curl -sSfLO 'https://repo.jellyfin.org/jellyfin_team.gpg.key' + G_EXEC gpg --dearmor -o /etc/apt/trusted.gpg.d/dietpi-jellyfin.gpg --yes jellyfin_team.gpg.key + G_EXEC rm jellyfin_team.gpg.key +fi + exit 0 } diff --git a/.update/version b/.update/version index 0981a0672d..d62971817e 100644 --- a/.update/version +++ b/.update/version @@ -1,7 +1,7 @@ # Available DietPi version G_REMOTE_VERSION_CORE=7 G_REMOTE_VERSION_SUB=0 -G_REMOTE_VERSION_RC=0 +G_REMOTE_VERSION_RC=1 # Minimum DietPi version to allow update G_MIN_VERSION_CORE=6 G_MIN_VERSION_SUB=-1 diff --git a/CHANGELOG.txt b/CHANGELOG.txt index d5679489ef..758cac7a16 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -4,13 +4,16 @@ v7.0 Changes: - DietPi-Update | A new update check system has been implemented, which checks for a minimum required Debian and DietPi version and migrates systems with either too old Debian version or too old DietPi version to a different Git branch automatically. This especially smoothens the migration of our code base to newer Debian versions and the alternative branch can be used to inform and support Debian distribution upgrades and to upgrade the DietPi code to an intermediate version from where the system can be migrated back to the regular stable/master branch. Since this change required a new repository version file, we took the chance and incremented the DietPi core version to v7.0. This however has no further meaning, all previously supported DietPi and Debian versions remain supported and the change enables us to not require fresh image installs for major upgrades, like the upgrade from v159 to v6.0 did a few years ago. - Network | A change has been implemented on the order in which network-related systemd service targets are reached. "network.target" and "network-online.target" are now reach after all network interfaces have been configured, rather then already after only the loopback interface "lo" has been configured. This affects only systemd services which are not started by DietPi-Services, e.g. SSH/DNS/VPN/VNC servers, with the effect that they are assured to be able to bind to interfaces/IPs, where currently they would fail. The downside is, if one has an Ethernet adapter configured via dietpi-config or /etc/network/interfaces (as allow-hotplug device), but the cable not connected, affected services may be delayed until the interface bring-up timed out. +- DietPi-Backup | A new feature has been added which allows to automatically restore a dietpi-backup on first boot. For this set the new dietpi.txt option AUTO_SETUP_BACKUP_RESTORE=1, to get a list of found backups to select from (this does not work in combination with AUTO_SETUP_AUTOMATED=1). All attached drives are mounted temporarily and seached automatically. Set AUTO_SETUP_BACKUP_RESTORE=2 to have the first found backup restored non-interactively (this works in combination with AUTO_SETUP_AUTOMATED=1). The restore runs after the initial update, hence works with older images as well and can be done via SSH connection. Credits go to @ravenclaw900 for implementing this feature: https://github.com/MichaIng/DietPi/pull/4112 - DietPi-Backup | Support for XFS and ZFS target file system types has been added, which fully support the required symlink and POSIX permissions capabilities. +- DietPi-Config | RPi: An option has been added to toggle the SPI interface. Many thanks to @incanus for resurrecting this old feature request: https://github.com/MichaIng/DietPi/issues/98#issuecomment-783650204 - DietPi-Software | The mandatory reboot after installs has been removed. Installed services, which are not controlled by DietPi-Services, but would start automatically on reboot, are now started at the end of installs instead. A manual reboot is still a good idea, but strictly required only in rare cases. Many thanks to @Games-Crack for doing this suggesting: https://github.com/MichaIng/DietPi/issues/4032 - DietPi-Software | Installs do not imply all APT package upgrades anymore. While we recommend to keep all APT packages upgraded regularly, the new daily APT check and info within the DietPi-Banner, helps to keep you informed to do the best decision youself whether and when to apply which package upgrade. On first run installs the full upgrade is however kept, to assure each image starts in fully upgraded state, and packages which are required for the actual software choices you're installing, are upgraded as well, when installed already. - DietPi-Software | Uninstalls do not stop other services anymore. E.g. your webserver or media streaming server will stay active while you uninstall that other software that you don't require anymore. Since uninstalls do not require much RAM or CPU resources, this is perfectly fine. Many thanks to @mrgreaper giving the hint: https://github.com/MichaIng/DietPi/issues/4116 - DietPi-Software | Unbound: On install in combination with Pi-hole, no additional configuration file will be created anymore but the adjusted interface binding and port will be applied to "/etc/unbound/unbound.conf.d/dietpi.conf". Declaring "interface" in two configuration files do not override each other but lead to two concurrent bindings, which is not intended. The two files, if present, will be merged as well on DietPi update. It is hence intended that admins change "dietpi.conf" directly, if required, and this file won't be overwritten on reinstalls to preserve local changes. Additionally, on new installs, the configuration file will be better sorted and contain comments to explain their purpose. - DietPi-Software | Unbound: On new installs, by default access is now granted to all private IPv4 and IPv6 address ranges instead of to the 192.168.0.0/16 subnet only, which includes VPNs, containers and cases of multiple local networks the server is attached to. - DietPi-Software | Unbound: A monthly cron job is now created to keep the root hints file updated. Many thanks to @APraxx for doing this suggestion: https://github.com/MichaIng/DietPi/issues/4077 +- DietPi-Software | Python 3 pip: pip and pip-based installs on ARMv6 and ARMv7 boards will have the piwheels.org repository for pre-compiled wheels added automatically, which can reduce build dependencies and compile time dramatically. - DietPi-Software | Node-RED: New installs and reinstalls with setup Node-RED as local module for the "nodered" service user, rather than as global system module/command. This allows upgrading and removing all related Node modules through the web interface, instead of just the ones which were installed via web interface. Additionally a console alias for the "node-red-admin" CLI command has been added so that running this command with any user will call the local Node-RED instance as "nodered" service user. - DietPi-Software | Docker: The Docker APT repository is now installed manually instead of using the official Docker installer. This allows us to enable the Docker install option for Debian Bullseye systems, if only to allow widened testing of this upcoming Debian release with DietPi. @@ -39,6 +42,7 @@ Fixes: - DietPi-Software | Domoticz: Resolved an issue where saving custom scripts and starting with a template did not work. Many thanks to @tec13 for reporting this issue: https://dietpi.com/phpbb/viewtopic.php?t=8627 - DietPi-Software | Resolved an issue where for ruTorrent, Koel and Bitwarden_RS the automatic newest version detection failed and instead a possibly older fallback was used. Many thanks to @kelvmod for reporting this issue: https://github.com/MichaIng/DietPi/issues/4105 - DietPi-Software | LXQt: Resolved visual issues with our default configuration of Debian Buster, drastically simplified and cleaned up the files we ship. +- DietPi-Software | SABnzbd: Resolved an issue on Stretch where the install failed due to raised minimum Python version with SABnzbd v3.2.0. If Python 3.5 is installed, SABnzbd v3.1.1 will be installed now to allow keeping the install option enabled for now. Many thanks to @19eighties for reporting this issue: https://github.com/MichaIng/DietPi/issues/2762#issuecomment-787118995 As always, many smaller code performance and stability improvements, visual and spelling fixes have been done, too much to list all of them here. Check out all code changes of this release on GitHub: https://github.com/MichaIng/DietPi/pull/4126 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 84ce773ccf..0fe26142c3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,13 +9,15 @@ Are you able to: - Provide feedback and/or test areas of DietPi, to improve the user experience? - Report bugs? - Improve/add more features to the DietPi [website](https://github.com/MichaIng/DietPi-Website) or [documentation](https://github.com/MichaIng/DietPi-Docs)? -- Compile software for our supported SBCs? +- Compile software for our [supported platforms](https://dietpi.com/docs/hardware/)? - Contribute to DietPi with programming on GitHub? - Suggest new software that we can add to the `dietpi-software` install system? -If so, let us know! +If so, let us know! We are always looking for talented people who believe in the DietPi project, and, wish to contribute in any way you can. -- Send me an Email: micha@dietpi.com -- Join our forums: https://dietpi.com/phpbb/ -- GitHub: https://github.com/MichaIng/DietPi +- Send us an email: +- Join our forum: +- GitHub: + +Read more: diff --git a/README.md b/README.md index 5e206174d8..aba323a39a 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,17 @@ - -

- DietPi Logo -

-

- Lightweight justice for your single-board computer! -

- optimised • simplified • for everyone -

- WebsiteDocumentationView all supported platforms -

-
-

- Ready to run optimised software choices with dietpi-software -
Feature-rich configuration tool for your device with dietpi-config. -

-
- +

DietPi Logo

+

+ Lightweight justice for your single-board computer! +

+ optimised • simplified • for everyone +

+ WebsiteDocumentationView all supported platformsForum +

+
+

+ Ready to run optimised software choices with dietpi-software +
Feature-rich configuration tool for your device with dietpi-config. +

+
## Introduction @@ -151,7 +147,7 @@ If so, let us know! We are always looking for talented people who believe in the DietPi project, and, wish to contribute in any way you can. - Send me an Email: micha@dietpi.com -- Join our forums: https://dietpi.com/phpbb/ +- Join our forum: https://dietpi.com/phpbb/ - GitHub: https://github.com/MichaIng/DietPi ### FeatHub diff --git a/dietpi.txt b/dietpi.txt index e7fabbc82b..62bbdba433 100644 --- a/dietpi.txt +++ b/dietpi.txt @@ -67,6 +67,10 @@ AUTO_UNMASK_LOGIND=0 # - Executed script log: /var/tmp/dietpi/logs/dietpi-automation_custom_script.log AUTO_SETUP_CUSTOM_SCRIPT_EXEC=0 +# Restore a DietPi-Backup on first boot: 0 => disable | 1 => interactive restore (show list of found backups) | 2 => non-interactive restore (restore first found backup) +# - Simply attach the drive/disk/stick with contains the backup. All attached drives will be mounted temporarily and searched automatically. +AUTO_SETUP_BACKUP_RESTORE=0 + ##### Software Options ##### # SSH Server Selection: 0=none/custom | -1=Dropbear | -2=OpenSSH AUTO_SETUP_SSH_SERVER_INDEX=-1 diff --git a/dietpi/dietpi-autostart b/dietpi/dietpi-autostart index ae2ca4f37d..e919d6cb64 100644 --- a/dietpi/dietpi-autostart +++ b/dietpi/dietpi-autostart @@ -103,7 +103,7 @@ _EOF_ G_EXEC_NOHALT=1 G_AG_CHECK_INSTALL_PREREQ dbus G_EXEC_NOHALT=1 G_EXEC systemctl unmask systemd-logind - # Apply tweaks + # RPi tweaks if (( $G_HW_MODEL < 10 )); then G_CONFIG_INJECT 'boot_delay=' 'boot_delay=0' /boot/config.txt @@ -114,8 +114,9 @@ _EOF_ 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 )) && command -v startx > /dev/null; then + elif (( $ID_AUTOSTART == 16 )); then + command -v X > /dev/null || { G_WHIP_MSG '[FAILED] No X server has been found\n\nLightDM requires an X server. Please install a desktop or other X application first.'; return 1; } G_AG_CHECK_INSTALL_PREREQ lightdm # graphical.target Wants=display-manager.service G_EXEC ln -sf /lib/systemd/system/lightdm.service /etc/systemd/system/display-manager.service @@ -266,10 +267,9 @@ This mode allows for a < 2.5 second boot on an RPi3, into Amiberry.\n\nIf you ex #startx # Print Hello -#echo "Hello" +#echo 'Hello' #---Put your code below this line--- - _EOF_ G_WHIP_MSG 'A template script has been created:\n - /var/lib/dietpi/dietpi-autostart/custom.sh\n Please edit this file and enter the required commands you wish to launch. DietPi will then execute this script during boot.' diff --git a/dietpi/dietpi-backup b/dietpi/dietpi-backup index f5637f5290..0b713be8a6 100644 --- a/dietpi/dietpi-backup +++ b/dietpi/dietpi-backup @@ -30,14 +30,12 @@ G_INIT # Import DietPi-Globals -------------------------------------------------------------- - # Grab Input - disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1 || INPUT=0 + # Grab input + [[ $1 =~ ^-?1$ ]] && INPUT=$1 || INPUT=0 #///////////////////////////////////////////////////////////////////////////////////// # Backup System #///////////////////////////////////////////////////////////////////////////////////// - RSYNC_MODE_TEXT=0 - readonly FP_LOG='/var/log/dietpi-backup.log' # Backup Filepaths @@ -64,7 +62,7 @@ readonly aRSYNC_LOGGING_OPTIONS=('-v' "--log-file=$FP_LOG") # Date format for logs - Print_Date(){ date +"%Y-%m-%d_%T"; } + Print_Date(){ date '+%Y-%m-%d_%T'; } Create_Filter_Include_Exclude(){ @@ -97,168 +95,245 @@ _EOF_ } - Services_Stop(){ - - /boot/dietpi/dietpi-services stop - killall -w rsync &> /dev/null # https://github.com/MichaIng/DietPi/issues/1869#issuecomment-400036370 - - } - - Services_Start(){ /boot/dietpi/dietpi-services start; } - Run_Backup(){ - RSYNC_MODE_TEXT='Backup' - - G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" "$RSYNC_MODE_TEXT" + G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Backup' # Check valid FS Check_Supported_Directory_Location || return 1 - Services_Stop - # Generate target dir - mkdir -p "$FP_TARGET" + G_EXEC_NOHALT=1 G_EXEC mkdir -p "$FP_TARGET/data" # Error: Unable to create target folder. - if [[ ! -d $FP_TARGET ]]; then - - G_WHIP_MSG "$RSYNC_MODE_TEXT failed:\n\nUnable to create $FP_TARGET" + if [[ ! -d $FP_TARGET/data ]]; then - # Error: Rsync is already running - elif pgrep 'rsync' &> /dev/null; then - - Error_Rsync_Already_Running + G_WHIP_MSG "Backup failed:\n\nUnable to create $FP_TARGET/data" else - # Start Backup - echo -e "DietPi-Backup Log File. $(Print_Date)\n\n" > $FP_LOG + /boot/dietpi/dietpi-services stop + + # Check if rsync is already running, while the daemon should have been stopped above + pgrep 'rsync' &> /dev/null && { Error_Rsync_Already_Running 'Backup'; return 1; } # Generate Exclude/Include lists Create_Filter_Include_Exclude - while : - do - - # System - G_EXEC mkdir -p "$FP_TARGET"/data - - # Check for sufficient free space - # - NB: working in KiB until end MiB conversion, as, don't like using long long int, and, KiB should offer a good end result. - local old_backup_size=$(du -ks "$FP_TARGET"/data | mawk '{print $1}') # Actual disk space usage - - rsync --dry-run --stats "${aRSYNC_RUN_OPTIONS_BACKUP[@]}" "$FP_SOURCE" "$FP_TARGET"/data/ > /tmp/dietpi-backup_result - local new_backup_size=$(( $(grep -m1 '^Total file size:' /tmp/dietpi-backup_result | sed 's/[^0-9]*//g') / 1024 +1 )) # Theoretical, data size only - local total_file_count=$(mawk '/^Number of files:/{print $6;exit}' /tmp/dietpi-backup_result | sed 's/[^0-9]*//g') - local total_folder_count=$(mawk '/^Number of files:/{print $8;exit}' /tmp/dietpi-backup_result | sed 's/[^0-9]*//g') - local target_fs_blocksize=$(stat -fc %s "$FP_TARGET"/data) - new_backup_size=$(( $new_backup_size + ( $total_file_count + $total_folder_count ) * $target_fs_blocksize / 1024 + 1 )) # Add one block size to each file + dir as worst case result - local end_result=$(( ( $new_backup_size - $old_backup_size ) / 1024 + 1 )) - rm /tmp/dietpi-backup_result - - if ! G_CHECK_FREESPACE "$FP_TARGET"/data $end_result; then - - G_WHIP_BUTTON_OK_TEXT='Ignore' - G_WHIP_BUTTON_CANCEL_TEXT='Exit' - if ! G_WHIP_YESNO 'The backup target location appears to have insufficient free space to successfully finish the backup.\nHowever, this check is a rough estimation in reasonable time, thus it could be marginally incorrect. + # Check for sufficient free space + local old_backup_size=$(du -sB1 "$FP_TARGET/data" | mawk '{print $1}') # Actual disk usage in bytes + # - Dry run to obtain transferred data size + rsync --dry-run --stats "${aRSYNC_RUN_OPTIONS_BACKUP[@]}" "$FP_SOURCE" "$FP_TARGET/data/" > .dietpi-backup_result + local new_backup_size=$(grep -m1 '^Total file size:' .dietpi-backup_result | sed 's/[^0-9]*//g') # Apparent data size without block size related overhead + local total_file_count=$(mawk '/^Number of files:/{print $6;exit}' .dietpi-backup_result | sed 's/[^0-9]*//g') + local total_folder_count=$(mawk '/^Number of files:/{print $8;exit}' .dietpi-backup_result | sed 's/[^0-9]*//g') + rm .dietpi-backup_result + local target_fs_blocksize=$(stat -fc '%s' "$FP_TARGET/data") + new_backup_size=$(( $new_backup_size + ( $total_file_count + $total_folder_count ) * $target_fs_blocksize )) # Add one block size for each file + dir as worst case result + local end_result=$(( ( $new_backup_size - $old_backup_size ) / 1024**2 + 1 )) # bytes => MiB rounded up + # - Perform check + if ! G_CHECK_FREESPACE "$FP_TARGET/data" $end_result; then + + G_WHIP_BUTTON_OK_TEXT='Ignore' + G_WHIP_BUTTON_CANCEL_TEXT='Exit' + if ! G_WHIP_YESNO 'The backup target location appears to have insufficient free space to successfully finish the backup. +However, this check is a rough estimation in reasonable time, thus it could be marginally incorrect. \nWould you like to override this warning and continue with the backup?'; then - echo -e "$RSYNC_MODE_TEXT cancelled due to insufficient free space : $(Print_Date)" >> "$FP_TARGET/$BACKUP_STATS_FILENAME" - break - - fi + echo -e "Backup cancelled due to insufficient free space : $(Print_Date)" >> "$FP_TARGET/$BACKUP_STATS_FILENAME" + /boot/dietpi/dietpi-services start + return 1 fi - G_DIETPI-NOTIFY 2 "$RSYNC_MODE_TEXT to $FP_TARGET in progress, please wait..." + fi - rsync "${aRSYNC_RUN_OPTIONS_BACKUP[@]}" "${aRSYNC_LOGGING_OPTIONS[@]}" "$FP_SOURCE" "$FP_TARGET"/data/ - EXIT_CODE=$? - G_DIETPI-NOTIFY -1 $EXIT_CODE "$G_PROGRAM_NAME: $RSYNC_MODE_TEXT" - if (( $EXIT_CODE == 0 )); then + G_DIETPI-NOTIFY 2 "Backup to $FP_TARGET in progress, please wait..." - echo -e "$RSYNC_MODE_TEXT completed : $(Print_Date)" >> "$FP_TARGET/$BACKUP_STATS_FILENAME" - G_WHIP_MSG "$RSYNC_MODE_TEXT completed:\n - $FP_TARGET" + # Init log file + echo -e "Backup log from $(Print_Date)\n" > $FP_LOG - else + rsync "${aRSYNC_RUN_OPTIONS_BACKUP[@]}" "${aRSYNC_LOGGING_OPTIONS[@]}" "$FP_SOURCE" "$FP_TARGET/data/" + EXIT_CODE=$? - G_WHIP_MSG "$RSYNC_MODE_TEXT failed:\n - $FP_TARGET\n\nYou will see the log file on the next screen. Please check it for information and/or errors." + /boot/dietpi/dietpi-services start - fi + G_DIETPI-NOTIFY -1 $EXIT_CODE "$G_PROGRAM_NAME: Backup" + if (( $EXIT_CODE == 0 )); then - # Done - break + echo -e "Backup completed : $(Print_Date)" >> "$FP_TARGET/$BACKUP_STATS_FILENAME" + G_WHIP_MSG "Backup completed:\n - $FP_TARGET" - done + else + + G_WHIP_MSG "Backup failed:\n - $FP_TARGET\n\nYou will see the log file on the next screen. Please check it for information and/or errors." + + fi log=1 G_WHIP_VIEWFILE $FP_LOG - # Return to main menu - TARGETMENUID=0 + fi + + } + # When restoring a backup, assure that either the UUIDs stored in the backup fstab/boot config matches the current system drive, or that we know all relevant files to adjust afterwards. + Check_UUIDs() + { + UPDATE_UUIDs=0 UPDATE_GRUB=0 UPDATE_RPI=0 UPDATE_ARMBIAN=0 UPDATE_ODROID=0 UPDATE_UBOOT=0 + UUID_ROOT=$(findmnt -no UUID /) + PARTUUID_ROOT=$(findmnt -no PARTUUID /) + + # If the current rootfs' UUID or PARTUUID can be found in the the backups fstab, it can be assumed that it was created from the same drives. + grep -q "^UUID=${UUID_ROOT}[[:blank:]]" "$FP_TARGET/data/etc/fstab" || grep -q "^PARTUUID=${PARTUUID_ROOT}[[:blank:]]" "$FP_TARGET/data/etc/fstab" && return 0 + + UPDATE_UUIDs=1 + + # Else check if we know how to adjust the boot config after the backup has been restored. + # - x86_64 + if (( $G_HW_ARCH == 10 )) && command -v update-grub > /dev/null + then + UPDATE_GRUB=1 + + # - RPi + elif (( $G_HW_MODEL < 10 )) && [[ -f $FP_TARGET/data/boot/cmdline.txt ]] + then + UPDATE_RPI=1 + + # - Armbian + elif [[ -f $FP_TARGET/data/boot/armbianEnv.txt ]] + then + UPDATE_ARMBIAN=1 + + # - Odroids / classic U-Boot + elif [[ -f $FP_TARGET/data/boot/boot.ini ]] + then + UPDATE_ODROID=1 + + # - Modern U-Boot + elif [[ -f $FP_TARGET/data/boot/boot.cmd ]] && command -v mkimage > /dev/null + then + UPDATE_UBOOT=1 + + # - Else we cannot assure that the restored image will boot. + else + # Let user decide, but default to "no" + G_WHIP_YESNO '[WARNING] UUIDs of the backup and the current system differ +\nThe file systems unique identifiers, usually used to mount the drives at boot, seem to differ between the backup and the current system. +\nThis usually indicates that you try to restore an old backup onto a newly flashed DietPi system. +\nMoreover are we not able to find the boot configuration, where those UUIDs would need to be adjusted, to assure that the system will boot. +\nWe hence do not recommend to restore this backup on this system. If you continue, you will need to assure yourself that fstab and boot configurations match the UUIDs, else the system may not boot. +\nDo you want to restore this backup?' && return 0 || return 1 fi - Services_Start + G_WHIP_DEFAULT_ITEM='ok' G_WHIP_YESNO '[WARNING] UUIDs of the backup and the current system differ +\nThe file systems unique identifiers, usually used to mount the drives at boot, seem to differ between the backup and the current system. +\nThis usually indicates that you try to restore an old backup onto a newly flashed DietPi system. +\nBut we were able to find the boot configuration, where those UUIDs would need to be adjusted, to assure that the system will boot. +\nIt should be hence safe to restore this backup, but if the UUIDs were used elsewhere, you might need to adjust it manually. +\nDo you want to restore this backup?' && return 0 || return 1 + } + Update_UUIDs() + { + # fstab + while read -r mountpoint + do + [[ $mountpoint ]] || continue + local uuid=$(findmnt -no UUID "$mountpoint") + [[ $uuid ]] && G_EXEC sed -i "\|[[:blank:]]${mountpoint}[[:blank:]]|s|^[[:blank:]]*UUID=[^[:blank:]]*|UUID=$uuid|" /etc/fstab + local partuuid=$(findmnt -no PARTUUID "$mountpoint") + [[ $partuuid ]] && G_EXEC sed -i "\|[[:blank:]]${mountpoint}[[:blank:]]|s|^[[:blank:]]*PARTUUID=[^[:blank:]]*|PARTUUID=$partuuid|" /etc/fstab + + done < <(lsblk -no MOUNTPOINT "/dev/$(lsblk -no PKNAME "$G_ROOTFS_DEV")") + + # boot configs + # - x86_64 + if (( UPDATE_GRUB == 1 )) + then + G_EXEC update-grub + command -v update-tirfs > /dev/null && G_EXEC update-tirfs && return + command -v update-initramfs > /dev/null && G_EXEC update-initramfs -u + + # - RPi + elif (( UPDATE_RPI == 1 )) + then + G_EXEC sed -Ei "s/(^|[[:blank:]])root=[^[:blank:]]*/\1root=PARTUUID=$PARTUUID_ROOT/" /boot/cmdline.txt + + # - Armbian + elif (( UPDATE_ARMBIAN == 1 )) + then + grep -q '^[[:blank:]]*rootdev=UUID=' /boot/armbianEnv.txt && G_CONFIG_INJECT 'rootdev=UUID=' "rootdev=UUID=$UUID_ROOT" /boot/armbianEnv.txt && return + grep -q '^[[:blank:]]*rootdev=PARTUUID=' /boot/armbianEnv.txt && G_CONFIG_INJECT 'rootdev=PARTUUID=' "rootdev=PARTUUID=$PARTUUID_ROOT" /boot/armbianEnv.txt + + # - Odroids / classic U-Boot + elif (( UPDATE_ODROID == 1 )) + then + G_EXEC sed -Ei "s/(\"|root=)UUID=[^[:blank:]\"]*/\1UUID=$UUID_ROOT/" /boot/boot.ini + G_EXEC sed -Ei "s/(\"|root=)PARTUUID=[^[:blank:]\"]*/\1PARTUUID=$PARTUUID_ROOT/" /boot/boot.ini + + # - Modern U-Boot + elif (( UPDATE_UBOOT == 1 )) + then + G_EXEC sed -Ei "s/(\"|root=)UUID=[^[:blank:]\"]*/\1UUID=$UUID_ROOT/" /boot/boot.cmd + G_EXEC sed -Ei "s/(\"|root=)PARTUUID=[^[:blank:]\"]*/\1PARTUUID=$PARTUUID_ROOT/" /boot/boot.cmd + G_EXEC mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr + fi } Run_Restore(){ - RSYNC_MODE_TEXT='Restore' - - G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" "$RSYNC_MODE_TEXT" + G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Restore' # Check valid FS Check_Supported_Directory_Location || return 1 - Services_Stop - # Error: Backup not found if [[ ! -f $FP_TARGET/$BACKUP_STATS_FILENAME ]]; then - G_DIETPI-NOTIFY 2 "No Backup was found in $FP_TARGET" - G_DIETPI-NOTIFY 1 "$RSYNC_MODE_TEXT failed.\n" + G_WHIP_MSG "Restore failed:\n\n$FP_TARGET/$BACKUP_STATS_FILENAME does not exist\n\nHave you created a backup?" - G_WHIP_MSG "$RSYNC_MODE_TEXT failed:\n\n$FP_TARGET/$BACKUP_STATS_FILENAME does not exist\n\nHave you created a backup?" + # Restore + else - # Error: Rsync is already running - elif pgrep 'rsync' &> /dev/null; then + Check_UUIDs || return 1 - Error_Rsync_Already_Running + /boot/dietpi/dietpi-services stop - # Restore - else + # Check if rsync is already running, while the daemon should have been stopped above + pgrep 'rsync' &> /dev/null && { Error_Rsync_Already_Running 'Restore'; return 1; } # Generate Exclude/Include lists Create_Filter_Include_Exclude - G_DIETPI-NOTIFY 2 "$RSYNC_MODE_TEXT from $FP_TARGET in progress, please wait..." + G_DIETPI-NOTIFY 2 "Restore from $FP_TARGET in progress, please wait..." + + # Init log file + echo -e "Restore log from $(Print_Date)\n" > $FP_LOG - rsync "${aRSYNC_RUN_OPTIONS_RESTORE[@]}" "${aRSYNC_LOGGING_OPTIONS[@]}" "$FP_TARGET"/data/ "$FP_SOURCE" + rsync "${aRSYNC_RUN_OPTIONS_RESTORE[@]}" "${aRSYNC_LOGGING_OPTIONS[@]}" "$FP_TARGET/data/" "$FP_SOURCE" EXIT_CODE=$? + hash -d # Clear PATH cache - G_DIETPI-NOTIFY -1 $EXIT_CODE "$G_PROGRAM_NAME: $RSYNC_MODE_TEXT" + (( $UPDATE_UUIDs )) && Update_UUIDs + + /boot/dietpi/dietpi-services start + + G_DIETPI-NOTIFY -1 $EXIT_CODE "$G_PROGRAM_NAME: Restore" if (( $EXIT_CODE == 0 )); then - echo -e "$RSYNC_MODE_TEXT completed : $(Print_Date)" >> "$FP_TARGET/$BACKUP_STATS_FILENAME" - G_WHIP_MSG "$RSYNC_MODE_TEXT completed:\n - $FP_TARGET\n\nNB: A Reboot is highly recommended." + echo -e "Restore completed : $(Print_Date)" >> "$FP_TARGET/$BACKUP_STATS_FILENAME" + G_WHIP_MSG "Restore completed:\n - $FP_TARGET\n\nNB: A Reboot is highly recommended." else - G_WHIP_MSG "$RSYNC_MODE_TEXT failed:\n - $FP_TARGET\n\nYou will see the log file on the next screen. Please check it for information and/or errors." + G_WHIP_MSG "Restore failed:\n - $FP_TARGET\n\nYou will see the log file on the next screen. Please check it for information and/or errors." fi log=1 G_WHIP_VIEWFILE $FP_LOG - # Done - TARGETMENUID=0 - fi - Services_Start - } Check_Supported_Directory_Location(){ @@ -275,10 +350,10 @@ _EOF_ if [[ ! -d $FP_TARGET ]] then G_EXEC mkdir -p "$FP_TARGET" - TARGET_FILESYSTEM_TYPE=$(df -T $FP_TARGET | mawk 'NR==2 {print $2}') + TARGET_FILESYSTEM_TYPE=$(df -T "$FP_TARGET" | mawk 'NR==2 {print $2}') G_EXEC rmdir "$FP_TARGET" else - TARGET_FILESYSTEM_TYPE=$(df -T $FP_TARGET | mawk 'NR==2 {print $2}') + TARGET_FILESYSTEM_TYPE=$(df -T "$FP_TARGET" | mawk 'NR==2 {print $2}') fi for i in "${aSUPPORTED_FILESYSTEMS[@]}" @@ -355,7 +430,7 @@ _EOF_ \nSimply choose a location where you want to save and restore your backups from, then, select Backup or Restore. \nMore information: https://dietpi.com/docs/dietpi_tools/#dietpi-backup-backuprestore";; - 'Delete') G_WHIP_YESNO "Do you wish to DELETE the following backup?\n - $FP_TARGET" && rm -R "$FP_TARGET";; + 'Delete') G_WHIP_YESNO "Do you wish to DELETE the following backup?\n - $FP_TARGET" && G_EXEC_NOEXIT=1 G_EXEC rm -R "$FP_TARGET";; 'Backup') G_WHIP_YESNO "The system will be backed up to:\n - $FP_TARGET\n\nDo you wish to continue and start the backup?" && Run_Backup;; @@ -448,8 +523,7 @@ _EOF_ else - # Return to main menu - TARGETMENUID=0 + TARGETMENUID=0 # Return to main menu fi @@ -479,11 +553,13 @@ _EOF_ } + # $1=Backup/Restore Error_Rsync_Already_Running(){ - G_DIETPI-NOTIFY 1 'Another Rsync process is already running.' - echo -e "$RSYNC_MODE_TEXT failed: $(Print_Date). Rsync is already running." >> "$FP_TARGET/$BACKUP_STATS_FILENAME" - G_WHIP_MSG "$RSYNC_MODE_TEXT Error:\n\nA $RSYNC_MODE_TEXT could not be started as rsync is already running." + G_DIETPI-NOTIFY 1 'Another rsync process is already running.' + echo -e "$1 failed: $(Print_Date). rsync is already running." >> "$FP_TARGET/$BACKUP_STATS_FILENAME" + G_WHIP_MSG "$1 Error:\n\nA $1 could not be started as rsync is already running." + /boot/dietpi/dietpi-services start } @@ -512,7 +588,6 @@ _EOF_ # NB: To exclude from a custom located dietpi_userdata, you need to add its symlinked path: /mnt/dietpi_userdata/excludeThis #- /path/to/my/file #- /path/to/my/directory/ - _EOF_ #----------------------------------------------------------------------------- diff --git a/dietpi/dietpi-config b/dietpi/dietpi-config index 8cd602b7df..d279b91fdd 100644 --- a/dietpi/dietpi-config +++ b/dietpi/dietpi-config @@ -1263,7 +1263,7 @@ NB: You now need to run "apt update" or "G_AGUP" once after each reboot, before local swap_location=$(sed -n '/^[[:blank:]]*AUTO_SETUP_SWAPFILE_LOCATION=/{s/^[^=]*=//p;q}' /boot/dietpi.txt) local swap_size_text="$swap_size MB" (( $swap_size )) || swap_size_text='Off' - G_WHIP_MENU_ARRAY=('Swapfile' ": [$swap_size_text | $swap_location]") + G_WHIP_MENU_ARRAY=('Swap file' ": [$swap_size_text | $swap_location]") # APT cache G_WHIP_MENU_ARRAY+=('APT cache' ': Manage APT cache/info storage') @@ -1346,6 +1346,12 @@ NB: You now need to run "apt update" or "G_AGUP" once after each reboot, before rpi_i2c_baudrate=$(( ${rpi_i2c_baudrate:-100000} / 1000 )) G_WHIP_MENU_ARRAY+=('I2C frequency' ": [$rpi_i2c_baudrate kHz]") + # SPI state + local rpi_spi_enabled=$(grep -cm1 '^[[:blank:]]*dtparam=spi=on' /boot/config.txt) + local rpi_spi_text='Off' + (( $rpi_spi_enabled )) && rpi_spi_text='On' + G_WHIP_MENU_ARRAY+=('SPI state' ": [$rpi_spi_text]") + # USB boot option: RPi3 only and not required for RPi3+: https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/msd.md if [[ $G_HW_MODEL == 3 && $G_HW_MODEL_NAME != *'+'* ]]; then @@ -1362,7 +1368,7 @@ NB: You now need to run "apt update" or "G_AGUP" once after each reboot, before TARGETMENUID=3 # Return to this menu - if [[ $G_WHIP_RETURNED_VALUE == 'Swapfile' ]]; then + if [[ $G_WHIP_RETURNED_VALUE == 'Swap file' ]]; then G_WHIP_YESNO 'Swapfile control has been moved to DietPi-Drive_Manager, would you like to run the application now? \nOnce finished, exit to resume DietPi-Config' && /boot/dietpi/dietpi-drive_manager @@ -1480,6 +1486,11 @@ Further information: https://www.raspberrypi.org/documentation/hardware/raspberr fi + elif [[ $G_WHIP_RETURNED_VALUE == 'SPI state' ]]; then + + /boot/dietpi/func/dietpi-set_hardware spi $(( ! $rpi_spi_enabled )) + REBOOT_REQUIRED=1 + elif [[ $G_WHIP_RETURNED_VALUE == 'Serial/UART' ]]; then TARGETMENUID=18 @@ -4190,7 +4201,7 @@ Additional benchmarks: # No-IP Client local noip_installed=0 local noip_menutext='[Not Installed] Install No-IP now' - if grep -q '^aSOFTWARE_INSTALL_STATE\[67\]=2' /boot/dietpi/.installed; then + if command -v noip2 > /dev/null && [[ -f '/etc/systemd/system/noip2.service' ]]; then noip_installed=1 noip_menutext='[Offline] Enter/Setup No-IP details' @@ -4418,7 +4429,7 @@ NB: If you need to use *.pool.ntp.org servers, enter the base domain only. The s G_TERM_CLEAR G_EXEC systemctl stop noip2 # Failsafe: Directory required for "noip2 -C" to create the config file there - mkdir -p /usr/local/etc + G_EXEC mkdir -p /usr/local/etc noip2 -C read -rp 'Press any key to continue...' G_EXEC systemctl restart noip2 diff --git a/dietpi/dietpi-drive_manager b/dietpi/dietpi-drive_manager index 39ca513f5c..b58b751ec4 100644 --- a/dietpi/dietpi-drive_manager +++ b/dietpi/dietpi-drive_manager @@ -30,8 +30,8 @@ SERVICES_STOPPED=0 G_EXIT_CUSTOM(){ (( $SERVICES_STOPPED )) && /boot/dietpi/dietpi-services start; } - # Grab input (valid interger) - disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1 || INPUT=0 + # Grab input + [[ $1 == [134] ]] && INPUT=$1 || INPUT=0 EXIT_CODE=0 @@ -65,7 +65,6 @@ aDRIVE_SIZE_TOTAL[$index]= aDRIVE_SIZE_USED[$index]= aDRIVE_SIZE_PERCENTUSED[$index]= - aDRIVE_ISFILESYSTEM[$index]=0 aDRIVE_ISMOUNTED[$index]=0 aDRIVE_ISREADONLY_CURRENTLY[$index]=0 @@ -1725,7 +1724,7 @@ NTFS:\nRecommended if you plan to use this drive on a Windows system. High CPU u G_AG_CHECK_INSTALL_PREREQ smbclient cifs-utils # Mount now - mkdir -p "$samba_fp_mount_target" + G_EXEC mkdir -p "$samba_fp_mount_target" > $fp_tmp # - Mount attempts from highest CIFS version to lowest, until one succeeds @@ -1740,7 +1739,7 @@ NTFS:\nRecommended if you plan to use this drive on a Windows system. High CPU u # Apply to fstab sed -i "\#[[:space:]]${samba_fp_mount_target}[[:space:]]#d" /etc/fstab # - NB: Convert spaces to '\040': https://github.com/MichaIng/DietPi/issues/1201#issuecomment-339720271 - echo "//$samba_clientname/${samba_clientshare//[[:space:]]/\\040} $samba_fp_mount_target cifs username=$samba_clientuser,password=$samba_clientpassword,iocharset=utf8,uid=dietpi,gid=dietpi,file_mode=0770,dir_mode=0770,vers=$i,_netdev,nofail,noauto,x-systemd.automount" >> /etc/fstab + echo "//$samba_clientname/${samba_clientshare//[[:space:]]/\\040} $samba_fp_mount_target cifs username=$samba_clientuser,password=$samba_clientpassword,iocharset=utf8,uid=dietpi,gid=dietpi,file_mode=0770,dir_mode=0770,vers=$i,nofail,noauto,x-systemd.automount" >> /etc/fstab MENU_DRIVE_TARGET=$samba_fp_mount_target Init_Drives_and_Refresh @@ -1795,14 +1794,14 @@ NTFS:\nRecommended if you plan to use this drive on a Windows system. High CPU u G_AG_CHECK_INSTALL_PREREQ nfs-common netbase # Mount now - mkdir -p "$nfs_fp_mount_target" + G_EXEC mkdir -p "$nfs_fp_mount_target" > $fp_tmp if mount -vt nfs -o port=2049 "$nfs_server_ip":/ "$nfs_fp_mount_target" &>> $fp_tmp; then # Apply to fstab sed -i "\#[[:space:]]${nfs_fp_mount_target}[[:space:]]#d" /etc/fstab - echo "$nfs_server_ip:/ $nfs_fp_mount_target nfs _netdev,nofail,noauto,x-systemd.automount" >> /etc/fstab + echo "$nfs_server_ip:/ $nfs_fp_mount_target nfs nofail,noauto,x-systemd.automount" >> /etc/fstab MENU_DRIVE_TARGET=$nfs_fp_mount_target Init_Drives_and_Refresh @@ -1825,7 +1824,7 @@ NTFS:\nRecommended if you plan to use this drive on a Windows system. High CPU u # Apply to fstab sed -i "\#[[:space:]]${nfs_fp_mount_target}[[:space:]]#d" /etc/fstab - echo "$nfs_server_ip:$nfs_fp_server_share $nfs_fp_mount_target nfs _netdev,nofail,noauto,x-systemd.automount" >> /etc/fstab + echo "$nfs_server_ip:$nfs_fp_server_share $nfs_fp_mount_target nfs nofail,noauto,x-systemd.automount" >> /etc/fstab MENU_DRIVE_TARGET=$nfs_fp_mount_target Init_Drives_and_Refresh @@ -1870,24 +1869,18 @@ NTFS:\nRecommended if you plan to use this drive on a Windows system. High CPU u # Generate menu G_WHIP_MENU_ARRAY=() - df -Ph | tail -n +2 | sed -E '/(^udev|tmpfs)/d' > .df_out_tmp - 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_out_tmp - rm .df_out_tmp + done < <(df -Ph | tail -n +2 | sed -E '/(^udev|tmpfs)/d') - if G_WHIP_MENU 'Please select a mount location to use:'; then + G_WHIP_MENU 'Please select a mount location to use:' || exit 1 - G_DIETPI-NOTIFY 0 "Drive mount selected: $G_WHIP_RETURNED_VALUE" - echo "$G_WHIP_RETURNED_VALUE" > $fp_mount_selection - exit 0 - - fi - exit 1 + G_DIETPI-NOTIFY 0 "Drive mount selected: $G_WHIP_RETURNED_VALUE" + echo "$G_WHIP_RETURNED_VALUE" > $fp_mount_selection + exit 0 } diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 5c9d810f77..5efcd6b64c 100644 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -35,43 +35,33 @@ Available commands: # Filepath #///////////////////////////////////////////////////////////////////////////////////// readonly FP_INSTALLED_FILE='/boot/dietpi/.installed' - readonly FP_INSTALLED_FILE_TMP='.installed' # Used to set user/personal data directories (e.g.: usbdrive) FP_DIETPI_DEDICATED_USBDRIVE= Write_InstallFileList(){ - local fp_target=$FP_INSTALLED_FILE - local write_software_in_pending_state=0 - if [[ $1 == 'temp' ]]; then - - fp_target=$FP_INSTALLED_FILE_TMP - write_software_in_pending_state=1 - - fi - - > $fp_target + > $FP_INSTALLED_FILE # Save installed states for i in "${!aSOFTWARE_NAME[@]}" do - # Never save pending state for software (=1). Excluding temp saves. - if (( ${aSOFTWARE_INSTALL_STATE[$i]} == 1 && ! $write_software_in_pending_state )); then + # Never save pending state for software (=1). + if (( ${aSOFTWARE_INSTALL_STATE[$i]} == 1 )); then - echo "aSOFTWARE_INSTALL_STATE[$i]=0" >> $fp_target + echo "aSOFTWARE_INSTALL_STATE[$i]=0" >> $FP_INSTALLED_FILE else - echo "aSOFTWARE_INSTALL_STATE[$i]=${aSOFTWARE_INSTALL_STATE[$i]}" >> $fp_target + echo "aSOFTWARE_INSTALL_STATE[$i]=${aSOFTWARE_INSTALL_STATE[$i]}" >> $FP_INSTALLED_FILE fi done # Misc - cat << _EOF_ >> $fp_target + cat << _EOF_ >> $FP_INSTALLED_FILE # DietPi Choice System: SSH Server INDEX_SSHSERVER_CURRENT=$INDEX_SSHSERVER_CURRENT @@ -97,11 +87,8 @@ _EOF_ # Load Software states G_DIETPI-NOTIFY -2 'Reading database' - local fp_target=$FP_INSTALLED_FILE - [[ $1 == 'temp' ]] && fp_target=$FP_INSTALLED_FILE_TMP - # Load - [[ -f $fp_target ]] && . $fp_target + [[ -f $FP_INSTALLED_FILE ]] && . $FP_INSTALLED_FILE # Always reset choice system during first run to defaults: https://github.com/MichaIng/DietPi/issues/1122 if (( $G_DIETPI_INSTALL_STAGE == 1 )); then @@ -3011,6 +2998,7 @@ _EOF_ # shellcheck disable=SC2154 (( $no_check_url )) || G_CHECK_URL "$url" + unset -v fallback_url dps_index no_check_url G_EXEC cd /tmp/$G_PROGRAM_NAME # Failsafe @@ -3047,20 +3035,21 @@ _EOF_ G_EXEC 7zr x -y "$file" ${target:+"-o$target"} - elif [[ $target != "$file" ]]; then + elif [[ $target && $target != "$file" ]]; then # Pre-create target dir, if given - local fp_dir - [[ $target == *'/'* ]] && fp_dir=${target%/*} - [[ $fp_dir && ! -d $fp_dir ]] && G_EXEC mkdir -p "$fp_dir" + [[ $target == *'/'* && ! -d ${target%/*} ]] && G_EXEC mkdir -p "${target%/*}" [[ -f $target ]] && G_DIETPI-NOTIFY 2 "Updating file: $target" G_EXEC mv "$file" "$target" + else + + return + fi - [[ $target != "$file" && -f $file ]] && G_EXEC rm "$file" - unset -v fallback_url dps_index no_check_url + [[ -f $file ]] && G_EXEC rm "$file" } @@ -3575,7 +3564,7 @@ Package: openssl libssl*\nPin: origin packages.sury.org\nPin-Priority: -1' > /et else - Download_Install 'https://download.phpbb.com/pub/release/3.3/3.3.2/phpBB-3.3.2.tar.bz2' + Download_Install 'https://download.phpbb.com/pub/release/3.3/3.3.3/phpBB-3.3.3.tar.bz2' G_EXEC mv phpBB3 /var/www/phpbb # Files are shipped with strange UID:GID 1000:1000 while for security reasons it should be root:root. G_EXEC chown -R root:root /var/www/phpbb @@ -4688,18 +4677,15 @@ _EOF_ software_id=35 # Logitech Media Server if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then - Banner_Installing # http://wiki.slimdevices.com/index.php/DebianPackage#installing_7.9.2 + Banner_Installing # https://wiki.slimdevices.com/index.php/DebianPackage#installing_7.9.2 # Grab architecture local arch='arm' (( $G_HW_ARCH == 10 )) && arch='amd64' - # Grab URL for the latest package - INSTALL_URL_ADDRESS="https://www.mysqueezebox.com/update/?version=7.9&geturl=1&os=deb$arch" - G_CHECK_URL "$INSTALL_URL_ADDRESS" - - # Install, failsafe checking this URL again - Download_Install "$(curl -sf "$INSTALL_URL_ADDRESS")" + # Grab latest package URL: Force HTTPS! + local fallback_url="https://downloads.slimdevices.com/LogitechMediaServer_v8.1.1/logitechmediaserver_8.1.1_$arch.deb" + Download_Install "$(curl -sSfL "https://www.mysqueezebox.com/update/?version=8.1&geturl=1&os=deb$arch" | sed 's|^http://|https://|')" fi @@ -4820,7 +4806,7 @@ _EOF_ # ARMv6: Install package manually since repo is not compatible: https://grafana.com/grafana/download?platform=arm if (( $G_HW_ARCH == 1 )); then - Download_Install 'https://dl.grafana.com/oss/release/grafana-rpi_7.3.5_armhf.deb' + Download_Install 'https://dl.grafana.com/oss/release/grafana-rpi_7.4.3_armhf.deb' # Else use official APT repo: https://grafana.com/docs/grafana/latest/installation/debian/#install-from-apt-repository else @@ -4994,7 +4980,7 @@ Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=bullseye\nPin- # RPi elif (( $G_HW_MODEL < 10 )); then - # Install bootloader package as well to assure we have a corretly booting system with intended kernel + # Install bootloader package as well to assure we have a correctly booting system with intended kernel apackages=('raspberrypi-kernel' 'raspberrypi-kernel-headers' 'raspberrypi-bootloader') # Odroid XU4 @@ -5035,10 +5021,8 @@ Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=bullseye\nPin- # - Known as issue currently on Odroid C2/N1/N2, check for new build system if linux-/ holds current headers instead of linux-source-/: https://dietpi.com/meveric/pool/c2/l/ for i in /lib/modules/* do - [[ -d $i/build ]] && continue [[ -d /usr/src/linux-headers-${i##*/} ]] && ln -sfv "/usr/src/linux-headers-${i##*/}" "$i/build" - done # If existing install, reconfigure to rebuild WireGuard kernel module against current kernel + headers @@ -5684,23 +5668,28 @@ Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=bullseye\nPin- # APT deps DEPS_LIST='par2 p7zip-full' # - Pre-compiling required on ARM - (( $G_HW_ARCH < 10 )) && DEPS_LIST+=' libffi-dev libssl-dev' + (( $G_HW_ARCH > 9 )) || DEPS_LIST+=' libffi-dev libssl-dev' - Download_Install 'https://github.com/sabnzbd/sabnzbd/archive/master.tar.gz' + # Stretch: SABnzbd v3.2.0 raised the Python dependency to v3.6: https://github.com/sabnzbd/sabnzbd/tree/3.2.0 + local version='master' + (( $(python3 -V | tr -cd '0-9') < 360 )) && version='3.1.1' + + # Download + Download_Install "https://github.com/sabnzbd/sabnzbd/archive/$version.tar.gz" # Reinstall: Remove old install dir if [[ -d '/etc/sabnzbd' ]]; then # Preserve old config file - [[ -f '/etc/sabnzbd/sabnzbd.ini' ]] && G_EXEC mv /etc/sabnzbd/sabnzbd.ini sabnzbd-master/sabnzbd.ini + [[ -f '/etc/sabnzbd/sabnzbd.ini' ]] && G_EXEC mv /etc/sabnzbd/sabnzbd.ini sabnzbd-$version/sabnzbd.ini G_EXEC rm -R /etc/sabnzbd fi - # Install new files - G_EXEC mv sabnzbd-master /etc/sabnzbd + # Install + G_EXEC mv sabnzbd-$version /etc/sabnzbd - # Required Python modules + # Python deps G_EXEC cd /etc/sabnzbd G_EXEC_OUTPUT=1 G_EXEC pip3 install -Ur requirements.txt G_EXEC cd /tmp/$G_PROGRAM_NAME @@ -6660,7 +6649,7 @@ If you want to update ${aSOFTWARE_NAME[$software_id]}, please use its internal u local ha_user='homeassistant' local ha_home="/home/$ha_user" local ha_pyenv_activation=". $ha_home/pyenv-activate.sh" - local ha_python_version='3.8.7' + local ha_python_version='3.8.8' G_DIETPI-NOTIFY 2 "Home Assistant user: $ha_user" G_DIETPI-NOTIFY 2 "Home Assistent home: $ha_home" @@ -6947,7 +6936,7 @@ exec sudo -u $ha_user dash -c '$ha_pyenv_activation; exec pip3 install -U homeas fi - software_id=4 + software_id=4 # Vifm if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing @@ -6995,7 +6984,7 @@ exec sudo -u $ha_user dash -c '$ha_pyenv_activation; exec pip3 install -U homeas fi - software_id=3 + software_id=3 # MC if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then Banner_Installing @@ -9688,7 +9677,7 @@ _EOF_ [[ -f '/etc/default/logitechmediaserver' ]] && rm /etc/default/logitechmediaserver # Grant user access to DietPi media files - usermod -aG dietpi squeezeboxserver + G_EXEC usermod -aG dietpi squeezeboxserver # systemd service cat << _EOF_ > /etc/systemd/system/logitechmediaserver.service @@ -11911,25 +11900,14 @@ _EOF_ G_EXEC mkdir -p /var/log/sabnzbd G_EXEC chown -R sabnzbd:root /{etc,var/log}/sabnzbd - # Create config + # Config # - Touch only if it does not yet exist, assume reinstall otherwise and preserve custom changes # - API keys and initial config are only generated during 1st run # - We need to launch program, then apply our config tweaks, else, wizard setup in web interface simply loops without API keys. if [[ ! -f '/etc/sabnzbd/sabnzbd.ini' ]]; then - G_DIETPI-NOTIFY 2 'Generating initial config, please wait...' - G_EXEC systemctl daemon-reload - G_EXEC systemctl start sabnzbd - until [[ -f '/etc/sabnzbd/sabnzbd.ini' ]] - do - - sleep 0.5 - - done - sleep 2 - - G_EXEC_NOHALT=1 G_EXEC systemctl stop sabnzbd - sleep 2 # Additional wait, config being overwritten after below changes: https://dietpi.com/phpbb/viewtopic.php?p=7082#p7082 + Create_Config /etc/sabnzbd/sabnzbd.ini sabnzbd + sleep 1 # Additional wait, config being overwritten after below changes: https://dietpi.com/phpbb/viewtopic.php?p=7082#p7082 G_CONFIG_INJECT 'download_dir =' 'download_dir = /mnt/dietpi_userdata/downloads/incomplete' /etc/sabnzbd/sabnzbd.ini G_CONFIG_INJECT 'complete_dir =' 'complete_dir = /mnt/dietpi_userdata/downloads/complete' /etc/sabnzbd/sabnzbd.ini @@ -16132,6 +16110,31 @@ _EOF_ # Apply GPU Memory Splits Install_Apply_GPU_Settings + # No-IP configuration + (( ${aSOFTWARE_INSTALL_STATE[67]} == 1 )) && G_WHIP_YESNO 'No-IP can be setup and configured by using DietPi-Config. Would you like to complete this now? +\n - Once finished, exit DietPi-Config to finish this install. +\n - More information:\nhttps://dietpi.com/phpbb/viewtopic.php?p=58#p58' && /boot/dietpi/dietpi-config 16 1 + + # DietPi-AutoStart choice + if (( $G_DIETPI_INSTALL_STAGE == 2 )) && (( + ${aSOFTWARE_INSTALL_STATE[23]} == 1 || + ${aSOFTWARE_INSTALL_STATE[24]} == 1 || + ${aSOFTWARE_INSTALL_STATE[25]} == 1 || + ${aSOFTWARE_INSTALL_STATE[26]} == 1 || + ${aSOFTWARE_INSTALL_STATE[31]} == 1 || + ${aSOFTWARE_INSTALL_STATE[51]} == 1 || + ${aSOFTWARE_INSTALL_STATE[108]} == 1 || + ${aSOFTWARE_INSTALL_STATE[112]} == 1 || + ${aSOFTWARE_INSTALL_STATE[119]} == 1 || + ${aSOFTWARE_INSTALL_STATE[155]} == 1 || + ${aSOFTWARE_INSTALL_STATE[173]} == 1 )); then + + G_WHIP_YESNO 'Would you like to configure the DietPi-AutoStart option? +\nThis will allow you to choose which program loads automatically, after the system has booted up, e.g.: + - Console\n - Desktop\n - Kodi' && /boot/dietpi/dietpi-autostart + + fi + # Install finished, set all installed software to state 2 (installed) # - Apply same states to Allo and Allo_update (( ${aSOFTWARE_INSTALL_STATE[159]} == 1 || ${aSOFTWARE_INSTALL_STATE[160]} == 1 )) && { aSOFTWARE_INSTALL_STATE[159]=2; aSOFTWARE_INSTALL_STATE[160]=2; } @@ -16224,6 +16227,7 @@ _EOF_ AUTOINSTALL_WEBSERVERINDEX=$(sed -n '/^[[:blank:]]*AUTO_SETUP_WEB_SERVER_INDEX=/{s/^[^=]*=//p;q}' /boot/dietpi.txt) AUTOINSTALL_CUSTOMSCRIPTURL=$(sed -n '/^[[:blank:]]*AUTO_SETUP_CUSTOM_SCRIPT_EXEC=/{s/^[^=]*=//p;q}' /boot/dietpi.txt) AUTOINSTALL_TIMESYNCMODE=$(sed -n '/^[[:blank:]]*CONFIG_NTP_MODE=/{s/^[^=]*=//p;q}' /boot/dietpi.txt) + AUTOINSTALL_RESTORE=$(sed -n '/^[[:blank:]]*AUTO_SETUP_BACKUP_RESTORE=/{s/^[^=]*=//p;q}' /boot/dietpi.txt) # Else set defaults [[ $AUTOINSTALL_ENABLED ]] || AUTOINSTALL_ENABLED=0 [[ $AUTOINSTALL_AUTOSTARTTARGET ]] || AUTOINSTALL_AUTOSTARTTARGET=0 @@ -16233,6 +16237,7 @@ _EOF_ [[ $AUTOINSTALL_WEBSERVERINDEX ]] || AUTOINSTALL_WEBSERVERINDEX=0 [[ $AUTOINSTALL_CUSTOMSCRIPTURL ]] || AUTOINSTALL_CUSTOMSCRIPTURL=0 [[ $AUTOINSTALL_TIMESYNCMODE ]] || AUTOINSTALL_TIMESYNCMODE=2 + [[ $AUTOINSTALL_RESTORE ]] || AUTOINSTALL_RESTORE=0 } @@ -16836,26 +16841,6 @@ We allow it to take up to 30 minutes, it's process can be followed, please be pa fi - # Boot Choices - if (( ${aSOFTWARE_INSTALL_STATE[23]} == 1 || - ${aSOFTWARE_INSTALL_STATE[24]} == 1 || - ${aSOFTWARE_INSTALL_STATE[25]} == 1 || - ${aSOFTWARE_INSTALL_STATE[26]} == 1 || - ${aSOFTWARE_INSTALL_STATE[31]} == 1 || - ${aSOFTWARE_INSTALL_STATE[51]} == 1 || - ${aSOFTWARE_INSTALL_STATE[108]} == 1 || - ${aSOFTWARE_INSTALL_STATE[112]} == 1 || - ${aSOFTWARE_INSTALL_STATE[119]} == 1 || - ${aSOFTWARE_INSTALL_STATE[155]} == 1 || - ${aSOFTWARE_INSTALL_STATE[173]} == 1 )); then - - # Set Boot Order - G_WHIP_YESNO 'Would you like to configure the auto boot options for DietPi? -\nThis will allow you to choose which program loads automatically, after the system has booted up, e.g.: - - Console\n - Desktop\n - Kodi' && /boot/dietpi/dietpi-autostart - - fi - fi } @@ -17555,6 +17540,88 @@ List of installed software and their online documentation URLs: # Load all automation vars FirstRun_Automation_Init + # Restore DietPi-Backup + if (( $AUTOINSTALL_RESTORE )); then + + # Reboot only when backup restore succeeded + restore_succeeded=0 + + G_DIETPI-NOTIFY 2 'DietPi-Backup restore selected, scanning and mounting attached drives...' + i=0 + while read -r line + do + # Mount drives to temporary mount points + mkdir -p "/mnt/dietpi-backup$i" && mount "$line" "/mnt/dietpi-backup$i" + ((i++)) + + done < <(lsblk -rnpo NAME,UUID,MOUNTPOINT | mawk '$2 && ! $3 {print $1}') + + G_DIETPI-NOTIFY 2 'Searching all drives for DietPi-Backup instances...' + mapfile -t alist < <(find /mnt -type f -name '.dietpi-backup_stats') + + # Interactive restore + if [[ $AUTOINSTALL_RESTORE == 1 ]]; then + + # Do we have any results? + if [[ ${alist[0]} ]]; then + + # Create List for Whiptail + G_WHIP_MENU_ARRAY=() + for i in "${alist[@]}" + do + last_backup_date=$(sed -n '/ompleted/s/^.*: //p' "$i" | tail -1) # Date of last backup for this backup + backup_directory=${i%/.dietpi-backup_stats} # Backup directory (minus the backup file), that we can use for target backup directory. + G_WHIP_MENU_ARRAY+=("$backup_directory" ": $last_backup_date") + done + + export G_DIETPI_SERVICES_DISABLE=1 + G_WHIP_MENU 'Please select a previous backup to restore:' && /boot/dietpi/dietpi-backup -1 "$G_WHIP_RETURNED_VALUE" && restore_succeeded=1 + unset -v G_DIETPI_SERVICES_DISABLE + + else + + G_WHIP_MSG 'No previous backups were found in /mnt/*. Install will continue like normal.' + + fi + + # Non-interactive restore + elif [[ $AUTOINSTALL_RESTORE == 2 ]]; then + + # Do we have any results? + if [[ ${alist[0]} ]]; then + + # Restore first found backup + export G_DIETPI_SERVICES_DISABLE=1 + /boot/dietpi/dietpi-backup -1 "${alist[0]%/.dietpi-backup_stats}" && restore_succeeded=1 + unset -v G_DIETPI_SERVICES_DISABLE + + else + + G_DIETPI-NOTIFY 1 'DietPi-Backup auto-restore was selected but no backup has been found in /mnt/*. Install will continue like normal.' + + fi + + # Downgrade dietpi.txt option + G_CONFIG_INJECT 'AUTO_SETUP_BACKUP_RESTORE=' 'AUTO_SETUP_BACKUP_RESTORE=1' /boot/dietpi.txt + + fi + + # Remove mounted drives and mount points + findmnt /mnt/dietpi-backup[0-9]* > /dev/null && umount /mnt/dietpi-backup[0-9]* + [[ -d '/mnt/dietpi-backup0' ]] && rmdir /mnt/dietpi-backup[0-9]* + + # Reboot on successful restore + if (( $restore_succeeded )); then + + G_DIETPI-NOTIFY 2 'The system will now reboot into the restored system' + sync # Failsafe + sleep 3 + reboot + + fi + + fi + # Global PW # - Automation, apply as per dietpi.txt if (( $AUTOINSTALL_ENABLED )); then diff --git a/dietpi/dietpi-update b/dietpi/dietpi-update index 8e6ae1ef98..5724c59fe8 100644 --- a/dietpi/dietpi-update +++ b/dietpi/dietpi-update @@ -127,6 +127,7 @@ G_DIETPI-NOTIFY 2 "We're switching to an alternative branch: $G_OLD_DEBIAN_BRANCH" GITBRANCH_TARGET=$G_OLD_DEBIAN_BRANCH Get_Server_Version || return 1 + G_CONFIG_INJECT 'DEV_GITBRANCH=' "DEV_GITBRANCH=$GITBRANCH_TARGET" /boot/dietpi.txt elif (( $G_DIETPI_VERSION_CORE < $G_MIN_VERSION_CORE || ( $G_DIETPI_VERSION_CORE == $G_MIN_VERSION_CORE && $G_DIETPI_VERSION_SUB < $G_MIN_VERSION_SUB ) )) then @@ -134,6 +135,7 @@ G_DIETPI-NOTIFY 2 "We're switching to an alternative branch: $G_OLD_VERSION_BRANCH" GITBRANCH_TARGET=$G_OLD_VERSION_BRANCH Get_Server_Version || return 1 + G_CONFIG_INJECT 'DEV_GITBRANCH=' "DEV_GITBRANCH=$GITBRANCH_TARGET" /boot/dietpi.txt fi } @@ -201,27 +203,27 @@ G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Applying pre-patches' # DietPi v6 pre-patches, required for DietPi pre-v6.17 systems, which have DietPi-Update restarted before having these pre-patches applied. - if (( $G_DIETPI_VERSION_CORE == 6 )); then - - G_EXEC_DESC='Downloading DietPi v6 pre-patches' G_EXEC curl -sSfLO "https://raw.githubusercontent.com/$GITOWNER_TARGET/DietPi/$GITBRANCH_TARGET/dietpi/pre-patch_file" + if (( $G_DIETPI_VERSION_CORE == 6 )) + then + G_EXEC_DESC='Downloading pre-patches' G_EXEC curl -sSfLO "https://raw.githubusercontent.com/$GITOWNER_TARGET/DietPi/$GITBRANCH_TARGET/dietpi/pre-patch_file" G_EXEC_DESC='Applying execute permission' G_EXEC chmod +x pre-patch_file - if ! ./pre-patch_file $G_DIETPI_VERSION_SUB; then - + if ! ./pre-patch_file $G_DIETPI_VERSION_SUB + then G_DIETPI-NOTIFY 1 "An error occured during pre-patch $?. Please check the above log or $FP_LOG for errors, and rerun \"dietpi-update\" after the cause has been solved." exit 1 - fi + # DietPi v6 pre-patches internally apply DietPi v7 pre-patches, hence do not apply then separately. + else + G_EXEC_DESC='Downloading pre-patches' G_EXEC curl -sSfLO "https://raw.githubusercontent.com/$GITOWNER_TARGET/DietPi/$GITBRANCH_TARGET/.update/pre-patches" + G_EXEC_DESC='Applying execute permission' G_EXEC chmod +x pre-patches + if ! ./pre-patches + then + G_DIETPI-NOTIFY 1 "An error occured during pre-patching. Please check the above log or $FP_LOG for errors, and rerun \"dietpi-update\" after the cause has been solved." + exit 1 + fi fi - G_EXEC_DESC='Downloading pre-patches' G_EXEC curl -sSfLO "https://raw.githubusercontent.com/$GITOWNER_TARGET/DietPi/$GITBRANCH_TARGET/.update/pre-patches" - G_EXEC_DESC='Applying execute permission' G_EXEC chmod +x pre-patches - if ! ./pre-patches; then - - G_DIETPI-NOTIFY 1 "An error occured during pre-patching. Please check the above log or $FP_LOG for errors, and rerun \"dietpi-update\" after the cause has been solved." - exit 1 - - fi G_DIETPI-NOTIFY 0 'Successfully applied pre-patches' G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Upgrading APT packages' diff --git a/dietpi/func/dietpi-globals b/dietpi/func/dietpi-globals index b7137e62b1..a5cb3b1cb6 100644 --- a/dietpi/func/dietpi-globals +++ b/dietpi/func/dietpi-globals @@ -66,7 +66,7 @@ # - Assign defaults/code version as fallback [[ $G_DIETPI_VERSION_CORE ]] || G_DIETPI_VERSION_CORE=7 [[ $G_DIETPI_VERSION_SUB ]] || G_DIETPI_VERSION_SUB=0 - [[ $G_DIETPI_VERSION_RC ]] || G_DIETPI_VERSION_RC=0 + [[ $G_DIETPI_VERSION_RC ]] || G_DIETPI_VERSION_RC=1 [[ $G_GITBRANCH ]] || G_GITBRANCH='master' [[ $G_GITOWNER ]] || G_GITOWNER='MichaIng' # - Save current version and Git branch @@ -722,6 +722,7 @@ $grey───────────────────────── G_WHIP_YESNO(){ local result=1 + [[ ${G_WHIP_DEFAULT_ITEM,,} == 'yes' || ${G_WHIP_DEFAULT_ITEM,,} == 'ok' ]] && result=0 if (( $G_INTERACTIVE )); then diff --git a/dietpi/func/dietpi-set_hardware b/dietpi/func/dietpi-set_hardware index f3331197c3..2dc68055d0 100644 --- a/dietpi/func/dietpi-set_hardware +++ b/dietpi/func/dietpi-set_hardware @@ -21,6 +21,7 @@ $FP_SCRIPT wificountrycode GB/US/DE/... $FP_SCRIPT bluetooth enable/disable $FP_SCRIPT serialconsole enable/disable [tty(S|AMA|SAC)[0-9]] (optional Serial/UART device) $FP_SCRIPT i2c enable/disable/khz +$FP_SCRIPT spi enable/disable $FP_SCRIPT soundcard target_card (non-matching name for reset to default). Add '-eq' to target_card string to enable ALSA equalizer on card. HW:x,x (specify target card and device index eg: HW:9,1) $FP_SCRIPT remoteir odroid_remote/justboom_ir_remote # Odroid/RPi only $FP_SCRIPT lcdpanel target_panel (none to remove all) @@ -830,7 +831,7 @@ _EOF_ G_EXEC sed -i '/^[[:blank:]]*dtoverlay=ads7846,cs=1,penirq=17/d' /boot/config.txt G_EXEC sed -i '/^[[:blank:]]*dtoverlay=w1-gpio-pullup,gpiopin=4,extpullup=1/d' /boot/config.txt - # - Leave these enabled, just in case the user has other hardware that may use them. + # Leave these enabled, just in case the user has other hardware that may use them. #G_EXEC sed -i '/^[[:blank:]]*dtparam=i2c_arm=/c\dtparam=i2c_arm=on' /boot/config.txt #G_EXEC sed -i '/^[[:blank:]]*dtparam=spi=/c\dtparam=spi=on' /boot/config.txt @@ -1044,6 +1045,38 @@ _EOF_ } + #///////////////////////////////////////////////////////////////////////////////////// + # SPI: https://github.com/raspberrypi/documentation/tree/master/hardware/raspberrypi/spi + #///////////////////////////////////////////////////////////////////////////////////// + SPI_Main(){ + + (( $G_HW_MODEL > 9 )) && { Unsupported_Input_Name; return 1; } # Exit path for non-RPi + + if [[ $INPUT_DEVICE_VALUE == 'enable' ]]; then + + # config.txt + G_CONFIG_INJECT 'dtparam=spi=' 'dtparam=spi=on' /boot/config.txt + + # Enable in runtime seems to be possible? + #dtparam spi=on + + elif [[ $INPUT_DEVICE_VALUE == 'disable' ]]; then + + # config.txt + G_CONFIG_INJECT 'dtparam=spi=' 'dtparam=spi=off' /boot/config.txt + G_EXEC sed -i '/^[[:blank:]]*dtoverlay=spi[0-9]-[0-9]cs/d' /boot/config.txt # Alternative SPI interfaces and chip select lines + + # Disable in runtime seems to be possible? + #dtparam spi=off + + else + + Unknown_Input_Mode + + fi + + } + #///////////////////////////////////////////////////////////////////////////////////// # Bluetooth #///////////////////////////////////////////////////////////////////////////////////// @@ -2252,6 +2285,10 @@ _EOF_ I2c_Main + elif [[ $INPUT_DEVICE_NAME == 'spi' ]]; then + + SPI_Main + elif [[ $INPUT_DEVICE_NAME == 'lcdpanel' ]]; then Lcd_Panel_Main diff --git a/dietpi/pre-patch_file b/dietpi/pre-patch_file index 17aceb02fe..ae3cc600c0 100644 --- a/dietpi/pre-patch_file +++ b/dietpi/pre-patch_file @@ -76,18 +76,9 @@ fi #------------------------------------------------------------------------------- - # Pre-patch 4: https://github.com/MichaIng/DietPi/issues/2656 # Pre-patch 5: Add new G_CHECK_URL dietpi.txt settings if (( $G_DIETPI_VERSION_SUB < 23 )); then - if [[ -f '/etc/apt/preferences.d/dietpi-wireguard' ]]; then - - echo -e '\e[90m[\e[0m INFO \e[90m]\e[0m Pre-patch 4 | Hardening Debian Sid repo usage to prevent accidental distro upgrades but allow auto-upgrades for WireGuard packages' - echo -e 'Package: *\nPin: release n=sid\nPin-Priority: -1\n -Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=sid\nPin-Priority: 100' > /etc/apt/preferences.d/dietpi-wireguard || exit 4 - - fi - grep -q 'CONFIG_G_CHECK_URL_TIMEOUT' /DietPi/dietpi.txt || echo 'CONFIG_G_CHECK_URL_TIMEOUT=10' >> /DietPi/dietpi.txt || exit 5 grep -q 'CONFIG_G_CHECK_URL_ATTEMPTS' /DietPi/dietpi.txt || echo 'CONFIG_G_CHECK_URL_ATTEMPTS=2' >> /DietPi/dietpi.txt || exit 5 @@ -276,6 +267,23 @@ Package: wireguard wireguard-dkms wireguard-tools\nPin: release n=bullseye\nPin- curl -sSfL https://apt.radxa.com/buster-stable/public.key | gpg --dearmor -o /etc/apt/trusted.gpg.d/dietpi-radxa.gpg --yes || exit 24 fi #------------------------------------------------------------------------------- + # Pre-patch 25: Run DietPi v7 pre-patches as part of DietPi v6 pre-patches, to assure they run before APT. + echo -e '\e[90m[\e[0m INFO \e[90m]\e[0m Pre-patch 25 | Running DietPi v7 pre-patches' + # - Obtain target Git repo + if [[ -f '/DietPi/dietpi.txt' ]] + then + GIT_OWNER=$(sed -n '/^[[:blank:]]*DEV_GITOWNER=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) + GIT_BRANCH=$(sed -n '/^[[:blank:]]*DEV_GITBRANCH=/{s/^[^=]*=//p;q}' /DietPi/dietpi.txt) + else + GIT_OWNER=$(sed -n '/^[[:blank:]]*DEV_GITOWNER=/{s/^[^=]*=//p;q}' /boot/dietpi.txt) + GIT_BRANCH=$(sed -n '/^[[:blank:]]*DEV_GITBRANCH=/{s/^[^=]*=//p;q}' /boot/dietpi.txt) + fi + [[ $GIT_OWNER ]] || GIT_OWNER='MichaIng' + [[ $GIT_BRANCH ]] || GIT_BRANCH='master' + curl -sSfLO "https://raw.githubusercontent.com/$GIT_OWNER/DietPi/$GIT_BRANCH/.update/pre-patches" || exit 26 + chmod +x pre-patches || exit 26 + ./pre-patches || exit 26 + #------------------------------------------------------------------------------- # Finished exit 0 #-------------------------------------------------------------------------------