aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSlack Coder <slackcoder@server.ky>2024-03-26 06:07:55 -0500
committerSlack Coder <slackcoder@server.ky>2024-03-26 06:13:54 -0500
commit56d51a1e8cb6650b05333b513d0e0e337679d807 (patch)
tree7a75c986781775e6627ee8b8abe9d9df2fc508d3 /src
parent892ee26a76e319a8bc972e481f83df0dfa10e97a (diff)
downloadslack-autoupdate-56d51a1e8cb6650b05333b513d0e0e337679d807.tar.xz
Fix update notification
Source notification information before the files containing it are moved.
Diffstat (limited to 'src')
-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