From 56d51a1e8cb6650b05333b513d0e0e337679d807 Mon Sep 17 00:00:00 2001 From: Slack Coder Date: Tue, 26 Mar 2024 06:07:55 -0500 Subject: Fix update notification Source notification information before the files containing it are moved. --- src/slack-autoupdate | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/slack-autoupdate b/src/slack-autoupdate index a76f1da..a246210 100644 --- a/src/slack-autoupdate +++ b/src/slack-autoupdate @@ -22,7 +22,8 @@ REBOOT_TIME="${REBOOT_TIME:-""}" # Packages are copied here on successful download. PACKAGE_DIR="${PACKAGE_DIR:-/var/spool/slack-autoupdate}" -# Packages are temperarily stored here until success. +# Packages are temporarily stored here until success. All contents of this +# directory are deleted. STAGING_DIR="/var/cache/slack-autoupdate/staging" # Information of interest to the admin on success. @@ -186,19 +187,7 @@ if ! OUTPUT="$( >>"$UPDATE_ERROR" echo -e "sbotools:\n\n$OUTPUT" fi -# Make updates atomic. -if [ -f "$UPDATE_ERROR" ]; then - mv "$UPDATE_ERROR" "$PACKAGE_DIR" - mv "$UPDATE_INFO" "$PACKAGE_DIR" - - exit 1 -fi - - -mv "$STAGING_DIR"/* "$PACKAGE_DIR/" -rm -fr "$STAGING_DIR" - -if [ -z "$(find "$PACKAGE_DIR" -name "*.t*z" -or -name "info.txt" -or -name "error.txt")" ]; then +if [ -z "$(find "$STAGING_DIR" -name "*.t*z" -or -name "info.txt" -or -name "error.txt")" ]; then # No updates exit 0 fi @@ -215,6 +204,17 @@ if [ "$NOTIFY" = "yes" ]; then fi fi +if [ -f "$UPDATE_ERROR" ]; then + mv "$UPDATE_ERROR" "$PACKAGE_DIR" + mv "$UPDATE_INFO" "$PACKAGE_DIR" + + exit 1 +fi + +# Now that everything is successful. +mv "$STAGING_DIR"/* "$PACKAGE_DIR/" +rm -fr "$STAGING_DIR" + if [ -n "$REBOOT_TIME" ]; then nohup shutdown -r "$REBOOT_TIME" >/dev/null 2>&1 & fi -- cgit v1.2.3