diff --git a/.meta/dietpi-survey_report b/.meta/dietpi-survey_report index c83d7a2002..d3c317617f 100644 --- a/.meta/dietpi-survey_report +++ b/.meta/dietpi-survey_report @@ -481,9 +481,16 @@ done aSOFTWARE_NAME6_35[62]='Box86' aSOFTWARE_NAME6_35[134]='Docker Compose' - # shellcheck disable=SC2034 aSOFTWARE_NAME6_35[137]='mjpg-streamer' + # v7.0 (identical to v6.35 transition version) + aSOFTWARE_NAME7_0=() + for i in "${!aSOFTWARE_NAME6_35[@]}" + do + # shellcheck disable=SC2034 + aSOFTWARE_NAME7_0[$i]=${aSOFTWARE_NAME6_35[$i]} + done + Main(){ # Copy files to RAM to speed up sourcing diff --git a/.update/patches b/.update/patches new file mode 100644 index 0000000000..63624b2127 --- /dev/null +++ b/.update/patches @@ -0,0 +1,7 @@ +#!/bin/bash +{ +# DietPi-Update incremental patches to apply system and software migrations and fixes +# Created by MichaIng / micha@dietpi.com / https://dietpi.com/ +# License: GPLv2 / https://github.com/MichaIng/DietPi#license +exit 0 +} diff --git a/.update/pre-patches b/.update/pre-patches new file mode 100644 index 0000000000..b8c4b9d3c5 --- /dev/null +++ b/.update/pre-patches @@ -0,0 +1,7 @@ +#!/bin/bash +{ +# 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 +exit 0 +} diff --git a/.update/version b/.update/version new file mode 100644 index 0000000000..e462abba26 --- /dev/null +++ b/.update/version @@ -0,0 +1,13 @@ +# Available DietPi version +G_REMOTE_VERSION_CORE=7 +G_REMOTE_VERSION_SUB=0 +G_REMOTE_VERSION_RC=-1 +# Minimum DietPi version to allow update +G_MIN_VERSION_CORE=6 +G_MIN_VERSION_SUB=-1 +# Alternative Git branch to automatically migrate to when version is too low +G_OLD_VERSION_BRANCH='master' +# Minimum Debian version to allow update +G_MIN_DEBIAN=4 +# Alternative Git branch to automatically migrate to when Debian version is too low +G_OLD_DEBIAN_BRANCH='jessie-support' diff --git a/dietpi/dietpi-update b/dietpi/dietpi-update index 78d86930b4..8e6ae1ef98 100644 --- a/dietpi/dietpi-update +++ b/dietpi/dietpi-update @@ -43,108 +43,100 @@ #///////////////////////////////////////////////////////////////////////////////////// readonly FP_LOG='/var/tmp/dietpi/logs/dietpi-update.log' - CHANGELOG_DOWNLOADED=0 # Prevent redownload of changelog if already done in this session - + # Git repo to update from GITOWNER_TARGET=$(sed -n '/^[[:blank:]]*DEV_GITOWNER=/{s/^[^=]*=//p;q}' /boot/dietpi.txt) GITOWNER_TARGET=${GITOWNER_TARGET:-MichaIng} GITBRANCH_TARGET=$(sed -n '/^[[:blank:]]*DEV_GITBRANCH=/{s/^[^=]*=//p;q}' /boot/dietpi.txt) GITBRANCH_TARGET=${GITBRANCH_TARGET:-master} - COREVERSION_SERVER=0 - SUBVERSION_SERVER=0 - RCVERSION_SERVER=0 - + # Remote version variables + # - Available DietPi version + G_REMOTE_VERSION_CORE= + G_REMOTE_VERSION_SUB= + G_REMOTE_VERSION_RC= + # - Minimum DietPi version to allow update + G_MIN_VERSION_CORE= + G_MIN_VERSION_SUB= + # - Alternative Git branch to automatically migrate to when version is too low + G_OLD_VERSION_BRANCH= + # - Minimum Debian version to allow update + G_MIN_DEBIAN= + # - Alternative Git branch to automatically migrate to when Debian version is too low + G_OLD_DEBIAN_BRANCH= + + # Version info to print to console INFO_CURRENT_VERSION= INFO_SERVER_VERSION= INFO_VERSIONS_UPDATE(){ INFO_CURRENT_VERSION="Current version : v$G_DIETPI_VERSION_CORE.$G_DIETPI_VERSION_SUB.$G_DIETPI_VERSION_RC" - INFO_SERVER_VERSION="Latest version : v$COREVERSION_SERVER.$SUBVERSION_SERVER.$RCVERSION_SERVER" + INFO_SERVER_VERSION="Latest version : v$G_REMOTE_VERSION_CORE.$G_REMOTE_VERSION_SUB.$G_REMOTE_VERSION_RC" - if [[ $G_GITBRANCH != "$GITBRANCH_TARGET" || $G_GITOWNER != "$GITOWNER_TARGET" ]]; then + # Show Git repo, when it changed + [[ $G_GITBRANCH != "$GITBRANCH_TARGET" || $G_GITOWNER != "$GITOWNER_TARGET" ]] || return - INFO_CURRENT_VERSION+=" (branch: $G_GITOWNER/$G_GITBRANCH)" - INFO_SERVER_VERSION+=" (branch: $GITOWNER_TARGET/$GITBRANCH_TARGET)" - - fi + INFO_CURRENT_VERSION+=" (branch: $G_GITOWNER/$G_GITBRANCH)" + INFO_SERVER_VERSION+=" (branch: $GITOWNER_TARGET/$GITBRANCH_TARGET)" } - URL_MIRROR_INDEX=0 - aURL_MIRROR_SERVERVERSION=( - - "https://raw.githubusercontent.com/$GITOWNER_TARGET/DietPi/$GITBRANCH_TARGET/dietpi/server_version-6" - "https://dietpi.com/downloads/dietpi-update_mirror/$GITBRANCH_TARGET/server_version-6" - - ) - - aURL_MIRROR_PREPATCH=( - - "https://raw.githubusercontent.com/$GITOWNER_TARGET/DietPi/$GITBRANCH_TARGET/dietpi/pre-patch_file" - "https://dietpi.com/downloads/dietpi-update_mirror/$GITBRANCH_TARGET/pre-patch_file" - - ) - - aURL_MIRROR_ARCHIVE=( - - "https://github.com/$GITOWNER_TARGET/DietPi/archive/$GITBRANCH_TARGET.tar.gz" - "https://dietpi.com/downloads/dietpi-update_mirror/$GITBRANCH_TARGET/DietPi-$GITBRANCH_TARGET.tar.gz" - - ) - - aURL_MIRROR_CHANGELOG=( - - "https://raw.githubusercontent.com/$GITOWNER_TARGET/DietPi/$GITBRANCH_TARGET/CHANGELOG.txt" - "https://dietpi.com/downloads/dietpi-update_mirror/$GITBRANCH_TARGET/CHANGELOG.txt" - - ) - Get_Server_Version(){ - local i - for i in "${!aURL_MIRROR_SERVERVERSION[@]}" - do - - G_DIETPI-NOTIFY 2 "Checking mirror: ${aURL_MIRROR_SERVERVERSION[$i]}" - if curl -sSfL "${aURL_MIRROR_SERVERVERSION[$i]}" > server_version; then + local url="https://raw.githubusercontent.com/$GITOWNER_TARGET/DietPi/$GITBRANCH_TARGET/.update/version" - # Get server version - COREVERSION_SERVER=$(mawk 'NR==1' server_version) - SUBVERSION_SERVER=$(mawk 'NR==2' server_version) - RCVERSION_SERVER=$(mawk 'NR==3' server_version) + G_DIETPI-NOTIFY 2 "Getting repository version: $url" + if curl -sSfL "$url" -o version; then - # Check if server version contains valid intergers - if disable_error=1 G_CHECK_VALIDINT "$COREVERSION_SERVER" && - disable_error=1 G_CHECK_VALIDINT "$SUBVERSION_SERVER" && - disable_error=1 G_CHECK_VALIDINT "$RCVERSION_SERVER"; then + # Source file + . version - G_DIETPI-NOTIFY 0 "Using update server: ${aURL_MIRROR_SERVERVERSION[$i]}" - URL_MIRROR_INDEX=$i - return 0 + # Check if remote version consists of valid integers + if disable_error=1 G_CHECK_VALIDINT "$G_REMOTE_VERSION_CORE" && + disable_error=1 G_CHECK_VALIDINT "$G_REMOTE_VERSION_SUB" && + disable_error=1 G_CHECK_VALIDINT "$G_REMOTE_VERSION_RC"; then - else - - G_DIETPI-NOTIFY 2 "Invalid server version string: ${COREVERSION_SERVER:-NULL}.${SUBVERSION_SERVER:-NULL}.${RCVERSION_SERVER:-NULL}" - - fi + G_DIETPI-NOTIFY 0 'Got valid repository version' + return 0 else - G_DIETPI-NOTIFY 2 "No valid response from: ${aURL_MIRROR_SERVERVERSION[$i]} ($( /boot/dietpi/.install_stage; } + Check_Git_Migration() + { + # Automatically migrate to alternative branch if Debian or DietPi version is too low. + if (( $G_DISTRO < $G_MIN_DEBIAN )) + then + G_DIETPI-NOTIFY 2 "Your Debian version is too low to update to the current branch: $G_DISTRO_NAME ($G_DISTRO)" + 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 + + 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 + G_DIETPI-NOTIFY 2 "Your DietPi version is too low to update to the current branch: v$G_DIETPI_VERSION_CORE.$G_DIETPI_VERSION_SUB" + 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 + fi + } + Check_DietPi_Update(){ # If requested, reduce current subversion by 1 to reapply last update @@ -160,14 +152,14 @@ If this error persists, please report at: https://github.com/MichaIng/DietPi/iss local result=1 # Update available - if (( $G_DIETPI_VERSION_CORE < $COREVERSION_SERVER || - ( $G_DIETPI_VERSION_CORE == $COREVERSION_SERVER && ( $G_DIETPI_VERSION_SUB < $SUBVERSION_SERVER || - ( $G_DIETPI_VERSION_SUB == $SUBVERSION_SERVER && $G_DIETPI_VERSION_RC < $RCVERSION_SERVER ) ) ) )); then + if (( $G_DIETPI_VERSION_CORE < $G_REMOTE_VERSION_CORE || + ( $G_DIETPI_VERSION_CORE == $G_REMOTE_VERSION_CORE && ( $G_DIETPI_VERSION_SUB < $G_REMOTE_VERSION_SUB || + ( $G_DIETPI_VERSION_SUB == $G_REMOTE_VERSION_SUB && $G_DIETPI_VERSION_RC < $G_REMOTE_VERSION_RC ) ) ) )); then result=0 # Write available update version to flag file - echo "$COREVERSION_SERVER.$SUBVERSION_SERVER.$RCVERSION_SERVER" > /run/dietpi/.update_available + echo "$G_REMOTE_VERSION_CORE.$G_REMOTE_VERSION_SUB.$G_REMOTE_VERSION_RC" > /run/dietpi/.update_available G_DIETPI-NOTIFY 0 'Update available:' @@ -198,7 +190,7 @@ If this error persists, please report at: https://github.com/MichaIng/DietPi/iss Run_DietPi_Update(){ # RC-only update: Reapply last subversion patches - if (( $G_DIETPI_VERSION_CORE == $COREVERSION_SERVER && $G_DIETPI_VERSION_SUB == $SUBVERSION_SERVER )); then + if (( $G_DIETPI_VERSION_CORE == $G_REMOTE_VERSION_CORE && $G_DIETPI_VERSION_SUB == $G_REMOTE_VERSION_SUB )); then ((G_DIETPI_VERSION_SUB--)) G_DIETPI_VERSION_RC=0 @@ -207,11 +199,26 @@ If this error persists, please report at: https://github.com/MichaIng/DietPi/iss fi G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Applying pre-patches' - G_EXEC_DESC='Downloading pre-patch file' G_EXEC curl -sSfL "${aURL_MIRROR_PREPATCH[$URL_MIRROR_INDEX]}" -o 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 - 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." + # 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" + G_EXEC_DESC='Applying execute permission' G_EXEC chmod +x pre-patch_file + 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 + + 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 @@ -222,21 +229,16 @@ If this error persists, please report at: https://github.com/MichaIng/DietPi/iss G_AGUG G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Installing new DietPi code' - G_EXEC_DESC='Downloading update archive' G_EXEC curl -sSfL "${aURL_MIRROR_ARCHIVE[$URL_MIRROR_INDEX]}" -o update.tar.gz - - G_EXEC_DESC='Unpacking update archive' G_EXEC tar xf update.tar.gz - rm update.tar.gz + G_EXEC_DESC='Downloading update archive' G_EXEC curl -sSfLO "https://github.com/$GITOWNER_TARGET/DietPi/archive/$GITBRANCH_TARGET.tar.gz" + G_EXEC_DESC='Unpacking update archive' G_EXEC tar xf "$GITBRANCH_TARGET.tar.gz" + rm "$GITBRANCH_TARGET.tar.gz" # Remove files from Git archive that are not to be installed on client - rm DietPi-"$GITBRANCH_TARGET"/dietpi/{pre-patch_file,server_version*} + rm "DietPi-$GITBRANCH_TARGET/dietpi/"{pre-patch_file,server_version-6} - # Remove old code before updating, so we dont need to patch for removals - # - https://github.com/MichaIng/DietPi/issues/905#issuecomment-298241622 - #rm -R /boot/dietpi/{func,misc,dietpi-*} - - G_EXEC_DESC='Installing new DietPi scripts' G_EXEC cp -Rf DietPi-"$GITBRANCH_TARGET"/dietpi /boot/ - G_EXEC_DESC='Installing new DietPi system files' G_EXEC cp -Rf DietPi-"$GITBRANCH_TARGET"/rootfs/. / - G_EXEC_DESC='Setting execute permissions for DietPi scripts' G_EXEC chmod -R +x /boot/dietpi /var/lib/dietpi/services /etc/cron.*/dietpi + G_EXEC_DESC='Installing new DietPi scripts' G_EXEC cp -Rf "DietPi-$GITBRANCH_TARGET/dietpi" /boot/ + G_EXEC_DESC='Installing new DietPi system files' G_EXEC cp -Rf "DietPi-$GITBRANCH_TARGET/rootfs/." / + G_EXEC_DESC='Setting execute permissions for DietPi scripts' G_EXEC chmod -R +x /boot/dietpi /var/lib/dietpi/services /etc/cron.*/dietpi "DietPi-$GITBRANCH_TARGET/.update/patches" # Save version + Git info now for sub scripts to pull from correct branch G_GITOWNER=$GITOWNER_TARGET @@ -251,8 +253,10 @@ If this error persists, please report at: https://github.com/MichaIng/DietPi/iss fi - # Failsafe: Sync changes to disk + # Failsafe: Force sync to disk sync + + # Reload systemd units systemctl daemon-reload G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Applying incremental patches' @@ -260,21 +264,32 @@ If this error persists, please report at: https://github.com/MichaIng/DietPi/iss G_DIETPI-NOTIFY 2 "$INFO_CURRENT_VERSION" G_DIETPI-NOTIFY 2 "$INFO_SERVER_VERSION" - if ! /boot/dietpi/patch_file; then + # DietPi v6 incremental patches + if (( $G_DIETPI_VERSION_CORE == 6 )) && ! /boot/dietpi/patch_file; then G_DIETPI-NOTIFY 1 "An error occured during incremental 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_VERSION_CORE=$COREVERSION_SERVER - G_DIETPI_VERSION_SUB=$SUBVERSION_SERVER - G_DIETPI_VERSION_RC=$RCVERSION_SERVER - G_VERSIONDB_SAVE + # - Remove patch_file + rm /boot/dietpi/patch_file - G_DIETPI-NOTIFY 0 "Incremental patching to v$COREVERSION_SERVER.$SUBVERSION_SERVER.$RCVERSION_SERVER completed" + if ! "DietPi-$G_GITBRANCH/.update/patches"; then - # Remove patch_file - rm /boot/dietpi/patch_file + G_DIETPI-NOTIFY 1 "An error occured during incremental patching. Please check the above log or $FP_LOG for errors, and rerun \"dietpi-update\" after the cause has been solved." + exit 1 + + fi + + # Autoremove possibly obsolete DEB packages and reload systemd units + G_AGA + systemctl daemon-reload + + G_DIETPI_VERSION_CORE=$G_REMOTE_VERSION_CORE + G_DIETPI_VERSION_SUB=$G_REMOTE_VERSION_SUB + G_DIETPI_VERSION_RC=$G_REMOTE_VERSION_RC + G_VERSIONDB_SAVE + G_DIETPI-NOTIFY 0 "Incremental patching to v$G_REMOTE_VERSION_CORE.$G_REMOTE_VERSION_SUB.$G_REMOTE_VERSION_RC completed" } @@ -283,34 +298,8 @@ If this error persists, please report at: https://github.com/MichaIng/DietPi/iss #///////////////////////////////////////////////////////////////////////////////////// Get_View_Changelog(){ - local i fp_changelog='CHANGELOG.txt' - - (( $CHANGELOG_DOWNLOADED )) || for i in "${!aURL_MIRROR_CHANGELOG[@]}" - do - - G_DIETPI-NOTIFY 2 "Checking mirror: ${aURL_MIRROR_CHANGELOG[$i]}" - if curl -sSfL "${aURL_MIRROR_CHANGELOG[$i]}" > $fp_changelog; then - - CHANGELOG_DOWNLOADED=1 - break - - else - - G_DIETPI-NOTIFY 2 "No response from: ${aURL_MIRROR_CHANGELOG[$i]}" - - fi - - done - - if (( $CHANGELOG_DOWNLOADED )); then - - G_WHIP_VIEWFILE $fp_changelog - - else - - G_WHIP_MSG 'Failed to download the changelog, please try again.' - - fi + [[ -f 'CHANGELOG.txt' ]] || G_EXEC_NOEXIT=1 G_EXEC curl -sSfLO "https://raw.githubusercontent.com/$GITOWNER_TARGET/DietPi/$GITBRANCH_TARGET/CHANGELOG.txt" || return 1 + G_WHIP_VIEWFILE CHANGELOG.txt } @@ -323,7 +312,7 @@ If this error persists, please report at: https://github.com/MichaIng/DietPi/iss G_WHIP_MENU_ARRAY=( '' '●─ Update DietPi ' - 'Update' ": Apply update to: v$COREVERSION_SERVER.$SUBVERSION_SERVER.$RCVERSION_SERVER" + 'Update' ": Apply update to: v$G_REMOTE_VERSION_CORE.$G_REMOTE_VERSION_SUB.$G_REMOTE_VERSION_RC" '' '●─ Additional Options ' 'Changelog' ': View recent changelog and patch notes.' 'Backup' ': Create a system backup before updating.' @@ -342,7 +331,7 @@ Please select 'Update' option to apply the update."; then - A potential downside is: We can't possibly accommodate or predict all modification to Linux configurations files by the end user, outside of DietPi programs, during updates.\n Although we test the updates thoroughly, if you have made any custom changes to Linux configuration files outside of the DietPi programs, an update may trigger a potential issue. >--------------------------------------------------------------------------<\n -Do you wish to continue and update DietPi to v$COREVERSION_SERVER.$SUBVERSION_SERVER.$RCVERSION_SERVER?" && return 0 +Do you wish to continue and update DietPi to v$G_REMOTE_VERSION_CORE.$G_REMOTE_VERSION_SUB.$G_REMOTE_VERSION_RC?" && return 0 elif [[ $G_WHIP_RETURNED_VALUE == 'Changelog' ]]; then @@ -371,7 +360,7 @@ Do you wish to continue and update DietPi to v$COREVERSION_SERVER.$SUBVERSION_SE G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Checking for available DietPi update' #---------------------------------------------------------------- # Check for DietPi update and in case store result to /run/dietpi/.update_available for use by DietPi-Banner - if Get_Server_Version && Check_DietPi_Update; then + if Get_Server_Version && Check_Git_Migration && Check_DietPi_Update; then # Exit if check-only input (( $INPUT == 2 )) && exit 0 @@ -421,7 +410,7 @@ Do you wish to continue and update DietPi to v$COREVERSION_SERVER.$SUBVERSION_SE fi #---------------------------------------------------------------- # Desktop run, exit key prompt - pgrep 'lxsession' > /dev/null && read -rp 'Press any key to exit DietPi-Update...' + [[ $DISPLAY ]] && read -rp 'Press any key to exit DietPi-Update...' # Else, check for and in case apply APT updates based on input mode and dietpi.txt choice else diff --git a/dietpi/func/dietpi-globals b/dietpi/func/dietpi-globals index f081fd5c33..0d0922b596 100644 --- a/dietpi/func/dietpi-globals +++ b/dietpi/func/dietpi-globals @@ -64,8 +64,8 @@ # DietPi version and Git branch [[ -f '/boot/dietpi/.version' ]] && . /boot/dietpi/.version # - Assign defaults/code version as fallback - [[ $G_DIETPI_VERSION_CORE ]] || G_DIETPI_VERSION_CORE=6 - [[ $G_DIETPI_VERSION_SUB ]] || G_DIETPI_VERSION_SUB=35 + [[ $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=-1 [[ $G_GITBRANCH ]] || G_GITBRANCH='master' [[ $G_GITOWNER ]] || G_GITOWNER='MichaIng' diff --git a/dietpi/patch_file b/dietpi/patch_file index 019f4a0bcb..c559c53db1 100644 --- a/dietpi/patch_file +++ b/dietpi/patch_file @@ -66,8 +66,7 @@ fi - # Whether to schedule a DietPi-Update restart, with or without system reboot - RESTART= + # Whether to schedue a reboot after DietPi-Update REBOOT= # Pre-v6.29: DietPi-RAMdisk removal needs to be done before loading DietPi-Globals, else /boot/dietpi still contains the old code @@ -88,9 +87,6 @@ # Failsafe sync - # DietPi-Update restart required since old version calls DietPi-RAMdisk forcefully and error-handled - RESTART=1 - fi # - Pre-create new DietPi runtime dir for later used scripts, created via /etc/tmpfiles.d/dietpi.conf from next boot on [[ -d '/run/dietpi' ]] || { mkdir -p /run/dietpi; chmod 777 /run/dietpi; } @@ -109,7 +105,6 @@ elif [[ ! -f '/boot/dietpi/.version' ]] || ! grep -q '^G_GITOWNER=' /boot/dietpi/.version; then rm /boot/dietpi/.version - RESTART=1 fi @@ -136,7 +131,7 @@ _EOF_ # Import DietPi-Globals -------------------------------------------------------------- /boot/dietpi/func/dietpi-obtain_hw_model # Always update . /boot/dietpi/func/dietpi-globals - G_PROGRAM_NAME='DietPi-Patch' + readonly G_PROGRAM_NAME='DietPi-Patch' G_INIT # Import DietPi-Globals -------------------------------------------------------------- @@ -144,8 +139,8 @@ _EOF_ # - DietPi-Update includes G_VERSIONDB_SAVE after every subversion patch from v6.27 on. (( $1 )) && G_DIETPI_VERSION_SUB=$1 - # Migrate newly supported SBCs from dev to master branch - if (( $G_DIETPI_VERSION_SUB < 29 )) && [[ -f '/etc/.dietpi_hw_model_identifier' ]]; then + # Pre-v6.29: Migrate newly supported SBCs from dev to master branch + if [[ $G_DIETPI_VERSION_SUB -lt 29 && -f '/etc/.dietpi_hw_model_identifier' ]]; then # NanoPi M4v2 (58) # Pine H64 (45) @@ -159,9 +154,6 @@ _EOF_ fi - # Pre-v6.29: Restart DietPi-Update in any case, to apply single-call patch_file change - (( $G_DIETPI_VERSION_SUB > 28 || $(pgrep -c patch_file) > 1 )) || RESTART=1 - # Pre-v6.20: New $G_DIETPI_INSTALL_STAGE system # - As loaded pre-v6.20 dietpi-update will recreate ".update_stage", we need to rerun dietpi-update. if [[ -f '/boot/dietpi/.update_stage' ]]; then @@ -180,12 +172,10 @@ _EOF_ fi - RESTART=1 - fi - # Restart DietPi-Update if scheduled - if [[ $RESTART == 1 ]]; then + # Restart DietPi-Update when not yet done, to migrate to v7 + if (( $(pgrep -c patch_file) < 2 )); then # Save current version to rerun patch on next launch G_VERSIONDB_SAVE @@ -1299,9 +1289,10 @@ Do you still want to keep "p7zip-full"?'; then fi #------------------------------------------------------------------------------- # Fix Pi-hole permissions to allow "pihole -up" - if [[ -d '/var/www/html/pihole' ]]; then + if [[ -d '/var/www/html/pihole' && -d '/var/www/html/admin' ]]; then - cd /var/www/html/admin && git reset --hard HEAD + G_EXEC cd /var/www/html/admin + git reset --hard HEAD G_EXEC cd /tmp/$G_PROGRAM_NAME fi @@ -2760,8 +2751,7 @@ _EOF_ # Remove obsolete directory [[ -d '/var/lib/dietpi/dietpi-software/services' ]] && G_EXEC rmdir --ignore-fail-on-non-empty /var/lib/dietpi/dietpi-software/services #------------------------------------------------------------------------------- - # Last subversion patch completed - # - Apply reinstalls + # Last subversion patch completed: Apply reinstalls if [[ -f '/var/tmp/dietpi/dietpi-update_reinstalls' ]] then # Coders NB: Assigning to array is not easily possible here since we need to split at newline AND space. @@ -2769,12 +2759,6 @@ _EOF_ (( $G_DIETPI_INSTALL_STAGE == 2 )) && { /boot/dietpi/dietpi-software reinstall $( 34 )) do G_DIETPI-NOTIFY 2 "Patching $G_DIETPI_VERSION_CORE.$G_DIETPI_VERSION_SUB to $G_DIETPI_VERSION_CORE.$(( $G_DIETPI_VERSION_SUB + 1 ))" Subversion_Patch || exit 1 diff --git a/dietpi/server_version b/dietpi/server_version deleted file mode 100644 index c76772f8fe..0000000000 --- a/dietpi/server_version +++ /dev/null @@ -1,2 +0,0 @@ -160 -6