This repository was archived by the owner on Dec 12, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 9
This repository was archived by the owner on Dec 12, 2025. It is now read-only.
Update Script #11
Copy link
Copy link
Open
Description
Perhaps in a future version we could have a self-update feature?
But in the meantime I wanted to share an update script, might be useful for others :)
#!/bin/bash -ue
EXISTING_FILE="/usr/local/bin/SARotate"
NEW_FILE="/tmp/SARotate"
SAROTATE_SERVICE="sarotate.service"
UPDATE_TYPE="SARotate-linux-x64"
RELEASE_JSON="$(curl -Ls "https://api.github.com/repos/saltydk/sarotate/releases/latest")"
RELEASE_VERSION="$(echo "$RELEASE_JSON" | jq -r '.name')"
if [ -f "$EXISTING_FILE" ]; then
SAR_VERSION="$("$EXISTING_FILE" --version 2>&1 | cut -f2 -d' ')"
fi
if [ "${SAR_VERSION-}" != "$RELEASE_VERSION" ]; then
echo "Found new update SARotate ${RELEASE_VERSION}, downloading now ..."
RELEASE_LINK="$(echo "$RELEASE_JSON" | jq --arg name "$UPDATE_TYPE" -r '.assets[] | select(.name == $name) | .browser_download_url')"
curl -Ls "$RELEASE_LINK" -o "$NEW_FILE"
echo "Stopping existing service"
systemctl stop "$SAROTATE_SERVICE"
echo "Installing update"
cp "$NEW_FILE" "$EXISTING_FILE"
chmod +x "$EXISTING_FILE"
rm -f "$NEW_FILE"
echo "Restarting system service to apply update"
systemctl start "$SAROTATE_SERVICE"
echo "All done"
fi
exit 0
Metadata
Metadata
Assignees
Labels
No labels