aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/slack-autoupdate28
1 files changed, 14 insertions, 14 deletions
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