Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions user/local/share/towel/bin/towel-update
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,16 @@ if [ "$assume_yes" != "true" ]; then
fi

tmpdir="$(/usr/bin/mktemp -d)"
trap '/usr/bin/rm -rf "$tmpdir"' EXIT
restore_backup=""

function _towel_update_cleanup() {
if [ -n "$restore_backup" ]; then
rm -rf "$TOWEL_DATA"
mv "$backup_current" "$TOWEL_DATA" 2>/dev/null
fi
/usr/bin/rm -rf "$tmpdir"
}
trap _towel_update_cleanup EXIT

base_url="https://github.com/${TOWEL_GITHUB_REPO}/releases/download/v${latest_version}"
tarball="towel-${latest_version}.tar.gz"
Expand Down Expand Up @@ -214,15 +223,15 @@ source "$src/user/local/share/towel/bin/towel-common"

backup_current="${TOWEL_DATA}.backup.$(date +%s)"
mv "$TOWEL_DATA" "$backup_current" 2>/dev/null || true
trap 'rm -rf "$TOWEL_DATA"; mv "$backup_current" "$TOWEL_DATA" 2>/dev/null' EXIT
restore_backup="1"

towel_install_from_dir "$src" || {
echo 1>&2 "towel update --apply failed: installation error"
exit 1
}

rm -rf "$backup_current"
trap - EXIT
restore_backup=""
echo "towel updated to $latest_version."
echo "Note: distrobox/containers configs were not refreshed."
echo " Re-run ./install from the tarball to update those."