Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit b6f641c
Author: Uri Herrera <[email protected]>
Date:   Tue Nov 12 21:32:46 2024 -0600

    update pkg

commit 49467b0
Author: Uri Herrera <[email protected]>
Date:   Tue Nov 12 21:28:58 2024 -0600

    improve print_message func

commit de126d7
Author: Uri Herrera <[email protected]>
Date:   Tue Nov 12 21:13:15 2024 -0600

    fix error handling

commit 4cd9cf7
Author: Uri Herrera <[email protected]>
Date:   Tue Nov 12 21:04:00 2024 -0600

    revert changes

commit 7ed8e35
Author: Uri Herrera <[email protected]>
Date:   Tue Nov 12 20:57:06 2024 -0600

    improve error handling

commit b879915
Author: Uri Herrera <[email protected]>
Date:   Tue Nov 12 18:44:26 2024 -0600

    quit if root partition is not xfs

commit 4a5c5ae
Author: Uri Herrera <[email protected]>
Date:   Mon Nov 11 00:07:52 2024 -0600

    ...

commit db81e4b
Author: Uri Herrera <[email protected]>
Date:   Mon Nov 11 00:06:44 2024 -0600

    ...

commit eba789e
Author: Uri Herrera <[email protected]>
Date:   Sun Nov 10 23:58:07 2024 -0600

    use ping and wget to chk for gh domain connection

commit 046af63
Author: Uri Herrera <[email protected]>
Date:   Sun Nov 10 14:34:03 2024 -0600

    add chk for gh domain, improve messages

commit 9b6184d
Author: Uri Herrera <[email protected]>
Date:   Thu Nov 7 22:57:20 2024 -0600

    ....

commit cffacec
Author: Uri Herrera <[email protected]>
Date:   Thu Nov 7 20:02:41 2024 -0600

    chk for eonnectivity to raw.githubusercontent.com

    first, in the overlay and then in the chroot

commit fd3da32
Author: Uri Herrera <[email protected]>
Date:   Wed Nov 6 16:55:24 2024 -0600

    ...

commit cd2c56b
Author: Uri Herrera <[email protected]>
Date:   Wed Nov 6 16:49:59 2024 -0600

    check for the presence of overlay filesystems

commit 7015800
Author: Uri Herrera <[email protected]>
Date:   Wed Nov 6 16:25:55 2024 -0600

    dynamically calculate the version hash without hardcoding the path

commit 584c0f5
Author: Uri Herrera <[email protected]>
Date:   Wed Nov 6 16:20:00 2024 -0600

    ...

commit ff7d938
Author: Uri Herrera <[email protected]>
Date:   Wed Nov 6 16:14:30 2024 -0600

    update error msg

commit 0ba03bf
Author: Uri Herrera <[email protected]>
Date:   Wed Nov 6 16:10:58 2024 -0600

    improve unknown option msg

commit 2e41b57
Author: Uri Herrera <[email protected]>
Date:   Wed Nov 6 16:05:25 2024 -0600

    add error handling for unknown options

commit 0396669
Author: Uri Herrera <[email protected]>
Date:   Wed Nov 6 15:48:09 2024 -0600

    change msg when searching for overlayroot-chroot

    to make it clear that we're looking for the executable, not an indication of an overlay filesystem
  • Loading branch information
UriHerrera committed Nov 13, 2024
1 parent c5acab8 commit 006fc9e
Show file tree
Hide file tree
Showing 6 changed files with 575 additions and 391 deletions.
10 changes: 10 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
nuts (2.1.9) nitrux; urgency=medium

* Improve status messages for better readability.
* Add a new check to specifically verify the connection to raw.githubusercontent.com in the overlay and the chroot.
* Do not proceed with the update if the root partition filesystem is not XFS.
* Quit the rscue process if the root partition filesystem is not XFS.
* Fix error handling and improve some functions.

-- Uri Herrera <[email protected]> Tue, 12 Nov 2024 21:32:00 -0500

nuts (2.1.8) nitrux; urgency=medium

* Ensure DKMS builds xone for the newer kernel.
Expand Down
8 changes: 4 additions & 4 deletions tmp/nuts-ccu
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ set -eu

TOOL_NAME="Nitrux Update Tool System"
COMP_NAME="(Cleanup Component)"
CCU_VERSION="$(md5sum /tmp/nuts-ccu | cut -c -32)"
CCU_VERSION="$(md5sum "$0" | cut -c -32)"


# -- Print informative messages to stderr.
Expand Down Expand Up @@ -85,17 +85,17 @@ dl_file() {
[ -f "$FILE_PATH" ] && rm "$FILE_PATH"

if ! command -v axel >/dev/null 2>&1; then
puts_error "axel command not found, unable to download file."
puts_error "axel command not found, unable to download file, quitting."
return 1
fi

if ! curl --output /dev/null --silent --head --fail "$FILE_URL"; then
puts_error "File URL is not accessible, unable to download file."
puts_error "File URL is not accessible, unable to download file, quitting."
return 1
fi

if ! axel -o "/tmp" -n 10 "$FILE_URL"; then
puts_error "Failed to download file."
puts_error "Failed to download file, quitting."
return 1
fi
}
Expand Down
33 changes: 22 additions & 11 deletions tmp/nuts-crr
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ set -eu

TOOL_NAME="Nitrux Update Tool System"
COMP_NAME="(Restore Component)"
CRR_VERSION="$(md5sum /usr/bin/nuts-crr | cut -c -32)"
CRR_VERSION="$(md5sum "$0" | cut -c -32)"


# -- Print informative messages to stderr.
Expand Down Expand Up @@ -65,9 +65,20 @@ puts_error() {
# -- Print messages or text using multiple lines to stderr.

print_message() {
if [ -n "$1" ]; then
printf "%s\n" "$@" >&2
fi
if [ $# -eq 0 ]; then
printf "\n" >&2
else
printf "%s\n" "$@" >&2
fi
}


# -- Print warning messages to stderr.

puts_warning() {
if [ -n "$1" ]; then
printf "%s: \e[33mWarning:\e[0m %s\n" "$TOOL_NAME" "$*" >&2
fi
}


Expand Down Expand Up @@ -105,17 +116,17 @@ dl_file() {
[ -f "$FILE_PATH" ] && rm "$FILE_PATH"

if ! command -v axel >/dev/null 2>&1; then
puts_error "axel command not found, unable to download file."
puts_error "axel command not found, unable to download file, quitting."
return 1
fi

if ! curl --output /dev/null --silent --head --fail "$FILE_URL"; then
puts_error "File URL is not accessible, unable to download file."
puts_error "File URL is not accessible, unable to download file, quitting."
return 1
fi

if ! axel -o "/tmp" -n 10 "$FILE_URL"; then
puts_error "Failed to download file."
puts_error "Failed to download file, quitting."
return 1
fi
}
Expand All @@ -132,8 +143,8 @@ unmount_directory() {
}

unmount_on_failure() {
unmount_directory "/home" || { puts_error "Failed to unmount /home."; }
unmount_directory "/dev" || { puts_error "Failed to unmount /dev."; }
unmount_directory "/home" || { puts_error "Failed to unmount /home, quitting."; }
unmount_directory "/dev" || { puts_error "Failed to unmount /dev, quitting."; }
exit 1
}

Expand Down Expand Up @@ -199,7 +210,7 @@ DIRECTORIES=("$NUTS_DIR_BAK" "$NUTS_DIR_XFS" "$NUTS_DIR_DLS" "$NUTS_DIR_SQS")

for DIR in "${DIRECTORIES[@]}"; do
if [[ ! -d "$DIR" ]]; then
puts_error "Directory '$DIR' does not exist. Creating the directory..."
puts_warning "Directory '$DIR' does not exist. Creating the directory..."
if ! mkdir -p "$DIR"; then
puts_error "Failed to create directory '$DIR', quitting."
unmount_on_failure
Expand All @@ -208,7 +219,7 @@ for DIR in "${DIRECTORIES[@]}"; do
fi
done

puts_info "All required directories exist, continuing..."
puts_success "Success! All required directories exist, continuing..."


# -- Verify the checksum of the backup file with the generated checksum file.
Expand Down
47 changes: 29 additions & 18 deletions tmp/nuts-cru
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ set -eu

TOOL_NAME="Nitrux Update Tool System"
COMP_NAME="(Update Component)"
CRU_VERSION="$(md5sum /usr/bin/nuts-cru | cut -c -32)"
CRU_VERSION="$(md5sum "$0" | cut -c -32)"


# -- Print informative messages to stderr.
Expand Down Expand Up @@ -65,9 +65,20 @@ puts_error() {
# -- Print messages or text using multiple lines to stderr.

print_message() {
if [ -n "$1" ]; then
printf "%s\n" "$@" >&2
fi
if [ $# -eq 0 ]; then
printf "\n" >&2
else
printf "%s\n" "$@" >&2
fi
}


# -- Print warning messages to stderr.

puts_warning() {
if [ -n "$1" ]; then
printf "%s: \e[33mWarning:\e[0m %s\n" "$TOOL_NAME" "$*" >&2
fi
}


Expand Down Expand Up @@ -105,17 +116,17 @@ dl_file() {
[ -f "$FILE_PATH" ] && rm "$FILE_PATH"

if ! command -v axel >/dev/null 2>&1; then
puts_error "axel command not found, unable to download file."
puts_error "axel command not found, unable to download file, quitting."
return 1
fi

if ! curl --output /dev/null --silent --head --fail "$FILE_URL"; then
puts_error "File URL is not accessible, unable to download file."
puts_error "File URL is not accessible, unable to download file, quitting."
return 1
fi

if ! axel -o "/tmp" -n 10 "$FILE_URL"; then
puts_error "Failed to download file."
puts_error "Failed to download file, quitting."
return 1
fi
}
Expand Down Expand Up @@ -151,8 +162,8 @@ unmount_directory() {
}

unmount_on_failure() {
unmount_directory "/home" || { puts_error "Failed to unmount /home."; }
unmount_directory "/dev" || { puts_error "Failed to unmount /dev."; }
unmount_directory "/home" || { puts_error "Failed to unmount /home, quitting."; }
unmount_directory "/dev" || { puts_error "Failed to unmount /dev, quitting."; }
exit 1
}

Expand Down Expand Up @@ -231,7 +242,7 @@ DIRECTORIES=("$NUTS_DIR_BAK" "$NUTS_DIR_XFS" "$NUTS_DIR_DLS" "$NUTS_DIR_SQS")

for DIR in "${DIRECTORIES[@]}"; do
if [[ ! -d "$DIR" ]]; then
puts_error "Directory '$DIR' does not exist. Creating the directory..."
puts_warning "Directory '$DIR' does not exist. Creating the directory..."
if ! mkdir -p "$DIR"; then
puts_error "Failed to create directory '$DIR', quitting."
unmount_on_failure
Expand All @@ -240,7 +251,7 @@ for DIR in "${DIRECTORIES[@]}"; do
fi
done

puts_info "All required directories exist, continuing..."
puts_success "Success! All required directories exist, continuing..."


# -- Run the backup cleaner.
Expand Down Expand Up @@ -291,7 +302,7 @@ OTA_FILE="$NUTS_DIR_DLS/nuts-ota.squashfs"
if [[ -f "$OTA_FILE" ]]; then
puts_info "OTA file found, skipping..."
else
puts_info "OTA file not found! Downloading OTA file, continuing..."
puts_warning "OTA file not found! Downloading OTA file, continuing..."
MIRROR_LIST=$(grep 'MIRRORLIST=' /tmp/nuts-query.info | sed -e 's/[^=]*=//' -e 's/,/ /g')
DOWNLOAD_SUCCESS=false
for MIRROR_URL in $MIRROR_LIST; do
Expand All @@ -301,7 +312,7 @@ else
wait $!

if ! wait $!; then
puts_error "Download from $MIRROR_URL failed. Trying the next mirror..."
puts_warning "Download from $MIRROR_URL failed. Trying the next mirror..."
else
puts_success "Success! OTA update download completed, continuing..."
DOWNLOAD_SUCCESS=true
Expand All @@ -325,9 +336,9 @@ NQ_OTA_SUM=$(grep -oP '(?<=OTASUM=)[a-f0-9]{32}' /tmp/nuts-query.info)
if [[ "$LOCAL_OTA_SUM" == "$NQ_OTA_SUM" ]]; then
puts_info "OTA file checksum matches, continuing..."
else
puts_error "OTA file checksum does not match, deleting file..."
puts_warning "OTA file checksum does not match, deleting file..."
rm "$NUTS_DIR_DLS"/nuts-ota.squashfs
puts_error "Mismatched OTA file deleted; reboot and try to update again. Quitting."
puts_error "Mismatched OTA file deleted; reboot and try to update again, quitting."
unmount_on_failure
fi

Expand All @@ -352,12 +363,12 @@ VAR_DATA_URL="https://raw.githubusercontent.com/Nitrux/storage/master/Other/var-
TARFILE_DL_PATH="/tmp/var-lib-dpkg-$VAR_DATA_TARGET.tar.xz"

if [[ -f "$AIPKG_MANAGER" ]]; then
puts_info "AppImage already exists, skipping download."
puts_info "AppImage already exists, skipping download, continuing..."
else
if dl_file "$APPIMAGE_URL" > "$AIFILE_DL_PATH" && \
[[ $(file --mime-type -b "$AIFILE_DL_PATH") == "application/x-executable" ]] && \
mv "$AIFILE_DL_PATH" "$AIPKG_MANAGER" && chmod +x "$AIPKG_MANAGER"; then
puts_info "AppImage downloaded and processed successfully, continuing..."
puts_success "Success! AppImage downloaded and processed successfully, continuing..."
else
puts_error "Failed to download or process the AppImage, quitting."
[[ -f "$AIPKG_MANAGER" ]] && rm "$AIPKG_MANAGER"
Expand Down Expand Up @@ -409,7 +420,7 @@ dl_file "$CLEANUP_SCRIPT_URL" >/tmp/nuts-ccu || { puts_error "Failed to download
if chmod +x /tmp/nuts-ccu && bash /tmp/nuts-ccu ; then
puts_success "Success! Cleanup script executed without problems, continuing..."
else
puts_error "Something failed in the cleanup script, quitting."
puts_error "Something failed in the cleanup script; reboot and try to update again, quitting."
unmount_on_failure
fi

Expand Down
13 changes: 9 additions & 4 deletions tmp/nuts-sup
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ set -eu

TOOL_NAME="Nitrux Update Tool System"
COMP_NAME="(Self-Update Component)"
SUP_VERSION="$(md5sum /usr/bin/nuts-sup | cut -c -32)"
SUP_VERSION="$(md5sum "$0" | cut -c -32)"


# -- Print informative messages to stderr.
Expand Down Expand Up @@ -89,6 +89,12 @@ unmount_directory() {
fi
}

unmount_on_failure() {
unmount_directory "/home" || { puts_error "Failed to unmount /home, quitting."; }
unmount_directory "/dev" || { puts_error "Failed to unmount /dev, quitting."; }
exit 1
}


# -- Variables.

Expand Down Expand Up @@ -134,8 +140,8 @@ fi
if [[ -n $CURRENT_NUTS_BRANCH ]]; then
sed -i "s/^NUTS_BRANCH=.*$/NUTS_BRANCH=$CURRENT_NUTS_BRANCH/" "$CONFIG_FILE"
else
puts_error "Failed to restore $TOOL_NAME branch."
exit 1
puts_error "Failed to restore $TOOL_NAME branch, quitting."
unmount_on_failure
fi


Expand Down Expand Up @@ -164,5 +170,4 @@ sleep $REBOOT_SECONDS

reboot


# ====== END ======
Loading

0 comments on commit 006fc9e

Please sign in to comment.