Skip to content

Commit

Permalink
update pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
UriHerrera committed Aug 18, 2023
1 parent c243818 commit 0775506
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
7 changes: 7 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
nuts (1.1.0) nitrux; urgency=medium

* Update nuts, nuts-cru and nuts-crr to use the Git branch specified in nuts.conf.
* Check if backup checksum exists.

-- Uri Herrera <uri_herrera@nxos.org> Fri, 18 Aug 2023 13:00:00 -0500

nuts (1.0.10) nitrux; urgency=medium

* Actually, unmount everything because it is an early exit lol.
Expand Down
2 changes: 1 addition & 1 deletion etc/nuts.conf
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ NUTS_LOG=/var/log/nuts.log
KEXEC_VMLINUZ=/vmlinuz
KEXEC_INITRD=/initrd.img

# Define which branch in Git use to download the components and files.
# Define which branch on Github is used to download the components and other files.
# Default is main
#
NUTS_BRANCH=main
12 changes: 6 additions & 6 deletions usr/bin/nuts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ done
# -- Overwrite the file if it already exists.

INFO_FILE="/tmp/nuts-query.info"
REMOTE_URL="https://raw.githubusercontent.com/Nitrux/nuts/main/tmp/nuts-query.info"
REMOTE_URL="https://raw.githubusercontent.com/Nitrux/nuts/$NUTS_BRANCH/tmp/nuts-query.info"

if [ ! -f "$INFO_FILE" ]; then
puts_info "Can't find nuts-query.info, downloading..."
Expand Down Expand Up @@ -339,9 +339,9 @@ done
# -- Always download the latest component.

overlay_ch rm -f /usr/bin/nuts-cru >"$OUTPUT_FILE" 2>&1
overlay_ch axel -o /usr/bin -c -n 10 https://raw.githubusercontent.com/Nitrux/nuts/main/usr/bin/nuts-cru >"$OUTPUT_FILE"
overlay_ch axel -o /etc -c -n 10 https://raw.githubusercontent.com/Nitrux/nuts/main/etc/nuts.conf >"$OUTPUT_FILE"
overlay_ch axel -o /tmp -c -n 10 https://raw.githubusercontent.com/Nitrux/nuts/main/tmp/nuts-query.info >"$OUTPUT_FILE"
overlay_ch axel -o /usr/bin -c -n 10 "https://raw.githubusercontent.com/Nitrux/nuts/$NUTS_BRANCH/usr/bin/nuts-cru" >"$OUTPUT_FILE"
overlay_ch axel -o /etc -c -n 10 "https://raw.githubusercontent.com/Nitrux/nuts/$NUTS_BRANCH/etc/nuts.conf" >"$OUTPUT_FILE"
overlay_ch axel -o /tmp -c -n 10 "https://raw.githubusercontent.com/Nitrux/nuts/$NUTS_BRANCH/tmp/nuts-query.info" >"$OUTPUT_FILE"
overlay_ch chmod +x /usr/bin/nuts-cru >"$OUTPUT_FILE"
overlay_ch nuts-cru

Expand All @@ -367,8 +367,8 @@ done
# -- Always download the latest component.

overlay_ch rm -r /usr/bin/nuts-crr >"$OUTPUT_FILE" 2>&1
overlay_ch axel -o /usr/bin -c -n 10 https://raw.githubusercontent.com/Nitrux/nuts/main/usr/bin/nuts-crr >"$OUTPUT_FILE"
overlay_ch axel -o /etc -c -n 10 https://raw.githubusercontent.com/Nitrux/nuts/main/etc/nuts.conf >"$OUTPUT_FILE"
overlay_ch axel -o /usr/bin -c -n 10 "https://raw.githubusercontent.com/Nitrux/nuts/$NUTS_BRANCH/usr/bin/nuts-crr" >"$OUTPUT_FILE"
overlay_ch axel -o /etc -c -n 10 "https://raw.githubusercontent.com/Nitrux/nuts/$NUTS_BRANCH/etc/nuts.conf" >"$OUTPUT_FILE"
overlay_ch chmod +x /usr/bin/nuts-crr >"$OUTPUT_FILE"
overlay_ch nuts-crr

Expand Down
20 changes: 13 additions & 7 deletions usr/bin/nuts-crr
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,18 @@ puts_info "All required directories exist. Continuing."
# -- Exit if checksum doesn't match.

BACKUP_SUM=$(md5sum "$(echo "$NUTS_DIR_BAK"/nuts-backup-*.squashfs | tr ' ' '\n' | tail -n 1)" | cut -c -32)
GEN_BAK_SUM=$(tail "$NUTS_DIR_BAK"/nuts-backup.md5sum | cut -c -32)

if [[ "$BACKUP_SUM" == "$GEN_BAK_SUM" ]]; then
puts_info "Backup checksum matches, continuing..."
if [[ -f "$NUTS_DIR_BAK/nuts-backup.md5sum" ]]; then
GEN_BAK_SUM=$(tail "$NUTS_DIR_BAK/nuts-backup.md5sum" | cut -c -32)

if [[ "$BACKUP_SUM" == "$GEN_BAK_SUM" ]]; then
puts_info "Backup checksum matches, continuing..."
else
puts_error "Backup checksum does not match, quitting."
exit 1
fi
else
puts_error "Backup checksum does not match, quitting."
puts_error "Backup checksum does not exist, quitting."
exit 1
fi

Expand Down Expand Up @@ -248,7 +254,7 @@ fi

puts_info "Restoring backup of ${CURRENT_DIST^}, continuing..."

dl_file https://raw.githubusercontent.com/Nitrux/nuts/main/tmp/rsync-exclude.list >"$OUTPUT_FILE"
dl_file "https://raw.githubusercontent.com/Nitrux/nuts/$NUTS_BRANCH/tmp/rsync-exclude.list" >"$OUTPUT_FILE"

SOURCE_DIR="$NUTS_DIR_SQS"
DESTINATION_DIR="/"
Expand All @@ -271,8 +277,8 @@ puts_success "Success! Backup has been restored."

puts_info "Calling the $TOOL_NAME Cleanup Crew, continuing..."

CLEANUP_SCRIPT_URL="https://raw.githubusercontent.com/Nitrux/nuts/main/tmp/nuts-ccr"
FILE_LIST_URL="https://raw.githubusercontent.com/Nitrux/nuts/main/tmp/nuts-cc-file.list"
CLEANUP_SCRIPT_URL="https://raw.githubusercontent.com/Nitrux/nuts/$NUTS_BRANCH/tmp/nuts-ccr"
FILE_LIST_URL="https://raw.githubusercontent.com/Nitrux/nuts/$NUTS_BRANCH/tmp/nuts-cc-file.list"

dl_file "$CLEANUP_SCRIPT_URL" >"$OUTPUT_FILE" || { puts_error "Failed to download the cleanup script, quitting."; exit 1; }
dl_file "$FILE_LIST_URL" >"$OUTPUT_FILE" || { puts_error "Failed to download the file list, quitting."; exit 1; }
Expand Down

0 comments on commit 0775506

Please sign in to comment.