Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.
This repository was archived by the owner on Dec 12, 2025. It is now read-only.

Update Script #11

@hongkongkiwi

Description

@hongkongkiwi

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions