mirror of
https://github.com/EV21/uberspace-helper.git
synced 2026-10-07 20:33:18 +02:00
publish some update scripts
This commit is contained in:
5 files changed
+288
No files matched your search
+100
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
APP_NAME=Gitea
|
||||
GITEA_LOCATION=$HOME/gitea/gitea
|
||||
TMP_LOCATION=$HOME/tmp
|
||||
GPG_KEY_FINGERPRINT=7C9E68152594688862D62AF62D9AE806EC1592E2
|
||||
|
||||
ORG=go-gitea # Organisation or GitHub user
|
||||
REPO=gitea
|
||||
GITHUB_API_URL=https://api.github.com/repos/$ORG/$REPO/releases/latest
|
||||
|
||||
function do_update_procedure
|
||||
{
|
||||
$GITEA_LOCATION manager flush-queues
|
||||
supervisorctl stop gitea
|
||||
wget --quiet --progress=bar:force --output-document "$TMP_LOCATION"/gitea "$DOWNLOAD_URL"
|
||||
verify_file
|
||||
supervisorctl stop gitea
|
||||
mv --verbose "$TMP_LOCATION"/gitea "$GITEA_LOCATION"
|
||||
chmod u+x --verbose "$GITEA_LOCATION"
|
||||
supervisorctl start gitea
|
||||
supervisorctl status gitea
|
||||
}
|
||||
|
||||
function get_local_version
|
||||
{
|
||||
LOCAL_VERSION=$($GITEA_LOCATION --version |
|
||||
awk '{print $3}')
|
||||
}
|
||||
|
||||
function get_latest_version
|
||||
{
|
||||
curl --silent $GITHUB_API_URL > "$TMP_LOCATION"/github_api_response.json
|
||||
TAG_NAME=$(jq --raw-output '.tag_name' "$TMP_LOCATION"/github_api_response.json)
|
||||
LATEST_VERSION=${TAG_NAME:1}
|
||||
DOWNLOAD_URL=$(jq --raw-output '.assets[].browser_download_url' "$TMP_LOCATION"/github_api_response.json |
|
||||
grep --max-count=1 "linux-amd64")
|
||||
}
|
||||
|
||||
function get_signature_file
|
||||
{
|
||||
SIGNATURE_FILE_URL=$(jq --raw-output '.assets[].browser_download_url' "$TMP_LOCATION"/github_api_response.json |
|
||||
grep "linux-amd64.asc")
|
||||
rm "$TMP_LOCATION"/github_api_response.json
|
||||
wget --quiet --progress=bar:force --output-document "$TMP_LOCATION"/gitea.asc "$SIGNATURE_FILE_URL"
|
||||
}
|
||||
|
||||
function verify_file
|
||||
{
|
||||
get_signature_file
|
||||
|
||||
## downloading public key if it does not already exist
|
||||
if ! gpg --fingerprint $GPG_KEY_FINGERPRINT
|
||||
then
|
||||
## currently the key download via gpg does not work on Uberspace
|
||||
#gpg --keyserver keys.openpgp.org --recv $GPG_KEY_FINGERPRINT
|
||||
curl --silent https://keys.openpgp.org/vks/v1/by-fingerprint/$GPG_KEY_FINGERPRINT | gpg --import
|
||||
fi
|
||||
|
||||
if ! gpg --export-ownertrust | grep --quiet $GPG_KEY_FINGERPRINT:6:
|
||||
then echo "$GPG_KEY_FINGERPRINT:6:" | gpg --import-ownertrust
|
||||
fi
|
||||
|
||||
if gpg --verify "$TMP_LOCATION"/gitea.asc "$TMP_LOCATION"/gitea
|
||||
then rm "$TMP_LOCATION"/gitea.asc; return 0
|
||||
else echo "gpg verification results in a BAD signature"; exit 1
|
||||
echo "$GPG_KEY_FINGERPRINT:6:" | gpg --import-ownertrust
|
||||
fi
|
||||
}
|
||||
|
||||
## this is a helper function to compare two versions as a "lower than" operator
|
||||
function version_lt
|
||||
{
|
||||
test "$(echo "$@" |
|
||||
tr " " "n" |
|
||||
sort --version-sort --reverse |
|
||||
head --lines=1)" != "$1"
|
||||
}
|
||||
|
||||
function main
|
||||
{
|
||||
get_local_version
|
||||
get_latest_version
|
||||
|
||||
if [ "$LOCAL_VERSION" = "$LATEST_VERSION" ]
|
||||
then
|
||||
echo "Your $APP_NAME is already up to date."
|
||||
echo "You are running $APP_NAME $LOCAL_VERSION"
|
||||
else
|
||||
if version_lt "$LOCAL_VERSION" "$LATEST_VERSION"
|
||||
then
|
||||
echo "There is a new version available."
|
||||
echo "Doing update from $LOCAL_VERSION to $LATEST_VERSION"
|
||||
do_update_procedure
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
exit $?
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
APP=grocy
|
||||
ORG=grocy # Organisation or GitHub user
|
||||
REPO=grocy
|
||||
LOCAL_VERSION=$(jq --raw-output .Version /var/www/virtual/"$USER"/grocy/version.json)
|
||||
TAG_NAME=$(curl -s https://api.github.com/repos/$ORG/$REPO/releases/latest | jq --raw-output .tag_name)
|
||||
LATEST_VERSION=${TAG_NAME:1} # It is common to use the prefix v for the version tag.
|
||||
|
||||
## this is a helper function to compare two versions as a "lower than" operator
|
||||
function version_lt
|
||||
{
|
||||
test "$(echo "$@" |
|
||||
tr " " "n" |
|
||||
sort --version-sort --reverse |
|
||||
head --lines=1)" != "$1"
|
||||
}
|
||||
|
||||
if [ "$LOCAL_VERSION" = "$LATEST_VERSION" ]; then
|
||||
echo "Your $APP is running on $LOCAL_VERSION and it is already up to date."
|
||||
else
|
||||
if version_lt "$LOCAL_VERSION" "$LATEST_VERSION"
|
||||
then
|
||||
echo "There is a new Version available of $ORG"
|
||||
echo "The latest Version is $LATEST_VERSION"
|
||||
echo "Your local Version is $LOCAL_VERSION"
|
||||
bash /var/www/virtual/"$USER"/grocy/update.sh
|
||||
fi
|
||||
fi
|
||||
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/env bash
|
||||
APP_NAME=HedgeDoc
|
||||
ORG=hedgedoc # Organisation or GitHub user
|
||||
REPO=hedgedoc
|
||||
LOCAL_VERSION=$(jq --raw-output .version ~/hedgedoc/package.json)
|
||||
LATEST_VERSION=$(curl --silent https://api.github.com/repos/$ORG/$REPO/releases/latest |
|
||||
jq --raw-output .tag_name)
|
||||
|
||||
function do_upgrade() {
|
||||
supervisorctl stop $APP_NAME
|
||||
echo "waiting 1 minute until all processes are stopped"
|
||||
sleep 1m
|
||||
mv --verbose ~/hedgedoc ~/hedgedoc_"$LOCAL_VERSION"
|
||||
VERSION=$LATEST_VERSION
|
||||
cd || exit
|
||||
wget https://github.com/hedgedoc/hedgedoc/releases/download/"$VERSION"/hedgedoc-"$VERSION".tar.gz
|
||||
tar --extract --gzip --file=hedgedoc-"$VERSION".tar.gz
|
||||
rm --verbose hedgedoc-"$VERSION".tar.gz
|
||||
cp --verbose hedgedoc_"$LOCAL_VERSION"/config.json hedgedoc/config.json
|
||||
cd ~/hedgedoc || exit
|
||||
bin/setup
|
||||
echo "You may need to wait a minute until HedgeDoc is up and running."
|
||||
supervisorctl start $APP_NAME
|
||||
echo "If everything works fine you can delete ~/hedgedoc_$USED_VERSION"
|
||||
echo "Please consider that there might be uploaded files in ~/hedgedoc_$LOCAL_VERSION/public/uploads which were not migrated to the new version if you are using the default setting."
|
||||
rm --recursive ~/hedgedoc_"$LOCAL_VERSION"
|
||||
}
|
||||
|
||||
function yes-no_question
|
||||
{
|
||||
local question=$1
|
||||
while true
|
||||
do
|
||||
read -r -p "$question (Y/n) " ANSWER
|
||||
if [ "$ANSWER" = "" ]
|
||||
then ANSWER='Y'
|
||||
fi
|
||||
case $ANSWER in
|
||||
[Yy]* | [Jj]* )
|
||||
return 0 ;;
|
||||
[Nn]* )
|
||||
return 1 ;;
|
||||
* ) echo "Please answer yes or no." ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
## this is a helper function to compare two versions as a "lower than" operator
|
||||
function version_lt
|
||||
{
|
||||
test "$(echo "$@" |
|
||||
tr " " "n" |
|
||||
sort --version-sort --reverse |
|
||||
head --lines=1)" != "$1"
|
||||
}
|
||||
|
||||
function main
|
||||
{
|
||||
if [ "$LOCAL_VERSION" = "$LATEST_VERSION" ]
|
||||
then echo "Your HedgeDoc is already up to date."
|
||||
elif version_lt "$LOCAL_VERSION" "$LATEST_VERSION"
|
||||
then
|
||||
echo "There is a new Version available of $APP_NAME"
|
||||
echo "The latest Version is $LATEST_VERSION"
|
||||
echo "Your local Version is $LOCAL_VERSION"
|
||||
echo "Upgrades to next major releases are not tested."
|
||||
echo "Please read the release notes."
|
||||
echo "Also check if the upgrade instructions have changed."
|
||||
echo "Your instance might break."
|
||||
if yes-no_question "Do you wish to proceed with the upgrade?"
|
||||
then do_upgrade
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
||||
exit $?
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
APP_LOCATION=$HOME/html
|
||||
|
||||
## Updater automatically works in maintenance:mode.
|
||||
## Use the Uberspace backup system for files and database if you need to roll back.
|
||||
## The Nextcloud updater creates backups only to safe base and app code data and config files
|
||||
## so it takes ressources you might need for your productive data.
|
||||
## Deactivate NC-updater Backups with --no-backup
|
||||
php "$APP_LOCATION"/updater/updater.phar --no-backup --no-interaction
|
||||
|
||||
## database optimisations
|
||||
php "$APP_LOCATION"/occ db:add-missing-primary-keys --no-interaction
|
||||
php "$APP_LOCATION"/occ db:add-missing-columns --no-interaction
|
||||
php "$APP_LOCATION"/occ db:add-missing-indices --no-interaction
|
||||
php "$APP_LOCATION"/occ db:convert-filecache-bigint --no-interaction
|
||||
|
||||
php "$APP_LOCATION"/occ app:update --all
|
||||
/usr/sbin/restorecon -R "$APP_LOCATION"
|
||||
|
||||
if test -f ~/etc/services.d/notify_push.ini
|
||||
then supervisorctl restart notify_push
|
||||
fi
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
APP_NAME="Uptime Kuma"
|
||||
ORG=louislam # Organisation or GitHub user
|
||||
REPO=uptime-kuma
|
||||
GITHUB_API_URL=https://api.github.com/repos/$ORG/$REPO/releases/latest
|
||||
|
||||
function get_local_version
|
||||
{
|
||||
LOCAL_VERSION=$(git describe --tags)
|
||||
}
|
||||
|
||||
function get_latest_version
|
||||
{
|
||||
LATEST_VERSION=$(curl --silent $GITHUB_API_URL |
|
||||
jq --raw-output .tag_name)
|
||||
}
|
||||
|
||||
function do_update_procedure
|
||||
{
|
||||
git fetch --all
|
||||
git checkout "$LATEST_VERSION" --force
|
||||
npm ci --production
|
||||
npm run download-dist
|
||||
supervisorctl restart uptime-kuma
|
||||
sleep 3
|
||||
supervisorctl status
|
||||
}
|
||||
|
||||
## this is a helper function to compare two versions as a "lower than" operator
|
||||
function version_lt
|
||||
{
|
||||
test "$(echo "$@" |
|
||||
tr " " "n" |
|
||||
sort --version-sort --reverse |
|
||||
head --lines=1)" != "$1"
|
||||
}
|
||||
|
||||
function main
|
||||
{
|
||||
cd ~/uptime-kuma || exit 1
|
||||
get_local_version
|
||||
get_latest_version
|
||||
|
||||
if [ "$LOCAL_VERSION" = "$LATEST_VERSION" ]
|
||||
then
|
||||
echo "Your $APP_NAME is already up to date."
|
||||
echo "You are running $APP_NAME $LOCAL_VERSION"
|
||||
else
|
||||
if version_lt "$LOCAL_VERSION" "$LATEST_VERSION"
|
||||
then
|
||||
echo "There is a new version available."
|
||||
echo "Doing update from $LOCAL_VERSION to $LATEST_VERSION"
|
||||
do_update_procedure
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
exit $?
|
||||
Reference in new issue
Block a user