added systemd upgrade script which stops service, call upgrade script and restarts after binary upgrade

master
David Kebler 2020-12-13 14:03:08 -08:00
parent b4f1093b03
commit 9755e5d08e
4 changed files with 28 additions and 9 deletions

View File

@ -159,8 +159,6 @@ function download_bin () {
declare OPTION
declare OPTIND=0
echo passed stuff: $@
while getopts 'fg:itud:' OPTION; do
case "$OPTION" in
g) TokenFile=$OPTARG ;;
@ -212,18 +210,20 @@ function download_bin () {
if [[ $GITHUB_TOKEN ]]; then
echo "using access github token with script >>> $GITHUB_USER:$GITHUB_TOKEN"
fi
# URL=""
if [ $URL ]; then
echo "Downloading Gitea Binary at $URL"
wget --user=-u $GITHUB_USER --password=$GITHUB_TOKEN -q --show-progress -O $GITEA_BIN $URL
# wget --user=-u $GITHUB_USER --password=$GITHUB_TOKEN -q --show-progress -O $GITEA_BIN $URL
if ( [[ $? -eq 0 ]] && [[ "$NEW_VER" == *"$(version)"* ]] ); then
chmod +x $GITEA_BIN
echo upgrade succeeded, $GITEA_BIN version is $(version)
else
echo upgrade from $URL failed
return 1
fi
else
echo unabled to determine download url
return 2
fi
}

View File

@ -1,4 +1,23 @@
ServiceName=gitea
#!/bin/bash
declare OPTARG
declare OPTION
declare OPTIND=0
Saved=("$*")
while getopts 'fg:itud:' OPTION; do
case "$OPTION" in
*) ;;
esac
done
shift $(( $OPTIND - 1 ))
Instance=$1
[[ ! $1 ]] && echo warning no instance supplied using default && Instance=default
Service=$ServiceName@$Instance
DIR="$(dirname "$BASH_SOURCE")"
$DIR/stop $Instance
echo saved opts $Saved
$(dirname "$DIR")/upgrade $Saved
[[ $? -eq 0 ]] && $DIR/start $Instance || echo Upgrade failed not restarting gitea@$Instance service

View File

@ -1,5 +1,5 @@
#!/bin/bash
[[ ! $GITEA_DIR ]] && export GITEA_DIR="$(dirname "$(cd "$(readlink -f "$BASH_SOURCE")"; pwd -P)")"
[[ ! $GITEA_DIR ]] && export GITEA_DIR="$(dirname "$(cd "$(dirname "$BASH_SOURCE")"; pwd -P)")"
source $GITEA_DIR/scripts/library
download_bin "$@"

View File

@ -1,9 +1,9 @@
#!/bin/bash
DEBOUNCE=1.0
DIR="$(dirname "$(cd "$(dirname "$(readlink -f "$0")")";pwd -P)")" || exit
[[ ! $GITEA_DIR ]] && export GITEA_DIR="$(dirname "$(cd "$(readlink -f "$BASH_SOURCE")"; pwd -P)")"
# export WATCH_DIR="$DIR/frontend/"
# export WATCH_VERBOSE=1
COMMAND=$DIR/scripts/restart "$@"
COMMAND=$GITEA_DIR/scripts/restart "$@"
# LOGFILE="$DIR/watch.log"
echo "watching $DIR/frontend/ $DIR/config/$1.ini with $COMMAND"
inotifywait -mqr -e MODIFY $DIR/frontend/ $DIR/config/$1.ini |