diff --git a/scripts/library b/scripts/library index 1cfac6d..4cb594c 100644 --- a/scripts/library +++ b/scripts/library @@ -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 } diff --git a/scripts/systemd/upgrade b/scripts/systemd/upgrade index 6bc5fe3..37380f7 100755 --- a/scripts/systemd/upgrade +++ b/scripts/systemd/upgrade @@ -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 diff --git a/scripts/upgrade b/scripts/upgrade index b78e187..45818d8 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -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 "$@" diff --git a/scripts/watch b/scripts/watch index 875bd7d..c06e596 100755 --- a/scripts/watch +++ b/scripts/watch @@ -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 |