Add all of my scripts.
This commit is contained in:
34
scripts/autoupdate.sh
Normal file
34
scripts/autoupdate.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env bash
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Version 2024/01/28 - Changelog: https://gist.github.com/AriRexouium/4a1277a9e8405a5b357778f6ff0764ba
|
||||
# This script checks for updates to a GitHub Gist and automatically updates if a new version is available.
|
||||
#
|
||||
# Usage: ./autoupdate.sh
|
||||
#
|
||||
# License:
|
||||
# This script is licensed under the GNU General Public License v3.0 or later.
|
||||
# For more information, see https://www.gnu.org/licenses/gpl-3.0.html
|
||||
# Copyright (C) 2023 Jarrett Aiken <jarret.aiken@achl.fr> (https://achl.fr)
|
||||
|
||||
GITHUB_USERNAME="AriRexouium"; GITHUB_GIST="4a1277a9e8405a5b357778f6ff0764ba"
|
||||
|
||||
UPDATE_TIME_FILE="${0}.update"
|
||||
if [ -f "${UPDATE_TIME_FILE}" ]; then
|
||||
UPDATE_TIME=$(cat "${UPDATE_TIME_FILE}")
|
||||
else
|
||||
UPDATE_TIME=0
|
||||
fi
|
||||
|
||||
CURRENT_TIME=$(date +%s); COOLDOWN_TIME=86400
|
||||
if [ $((CURRENT_TIME - UPDATE_TIME)) -ge ${COOLDOWN_TIME} ]; then
|
||||
CURRENT_VERSION=$(cat "${0}"); LATEST_VERSION=$(curl -s https://gist.githubusercontent.com/${GITHUB_USERNAME}/${GITHUB_GIST}/raw)
|
||||
if [ "${CURRENT_VERSION}" != "${LATEST_VERSION}" ]; then
|
||||
echo "${LATEST_VERSION}" > "${0}"
|
||||
chmod +x "${0}"
|
||||
echo "${CURRENT_TIME}" > "${UPDATE_TIME_FILE}"
|
||||
exec "./${0}" "${@}"
|
||||
fi
|
||||
fi
|
||||
Reference in New Issue
Block a user