upgrades; move SUDO and verbosity control to lib
This commit is contained in:
parent
bf6ece0f52
commit
8347d9e040
2 changed files with 13 additions and 19 deletions
|
@ -11,25 +11,21 @@
|
||||||
# Everything happens in /tmp/forgejo-upgrades
|
# Everything happens in /tmp/forgejo-upgrades
|
||||||
#
|
#
|
||||||
|
|
||||||
|
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
source $SELF_DIR/../../lib/lib.sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Forgejo releases for which a branch exists (7.0/forgejo etc.)
|
# Forgejo releases for which a branch exists (7.0/forgejo etc.)
|
||||||
#
|
#
|
||||||
RELEASE_NUMBERS="7.0"
|
RELEASE_NUMBERS="7.0"
|
||||||
|
|
||||||
PREFIX===============
|
PREFIX===============
|
||||||
HOST_PORT=$(hostname -I | cut -f1 -d' '):3000
|
HOST_PORT=$IP:3000
|
||||||
STORAGE_PATHS="attachments avatars lfs packages repo-archive repo-avatars"
|
STORAGE_PATHS="attachments avatars lfs packages repo-archive repo-avatars"
|
||||||
STORAGE_FUN="attachments avatars lfs packages repo_archive repo_avatars"
|
STORAGE_FUN="attachments avatars lfs packages repo_archive repo_avatars"
|
||||||
DIR=/tmp/forgejo-upgrades
|
DIR=/tmp/forgejo-upgrades
|
||||||
export DOT_FORGEJO_CURL=$DIR/forgejo-curl
|
export DOT_FORGEJO_CURL=$DIR/forgejo-curl
|
||||||
export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0
|
export DOT=$DOT_FORGEJO_CURL # for backward compatibility with forgejo-curl.sh 1.0.0
|
||||||
if ${VERBOSE:-false} ; then
|
|
||||||
set -ex
|
|
||||||
PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: '
|
|
||||||
else
|
|
||||||
set -e
|
|
||||||
fi
|
|
||||||
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
: ${FORGEJO_USER:=root}
|
: ${FORGEJO_USER:=root}
|
||||||
: ${FORGEJO_REPO:=fixture}
|
: ${FORGEJO_REPO:=fixture}
|
||||||
: ${FORGEJO_PASSWORD:=admin1234}
|
: ${FORGEJO_PASSWORD:=admin1234}
|
||||||
|
@ -37,18 +33,11 @@ RELEASE_NUMBERS_AND_DEV="$(for r in $RELEASE_NUMBERS ; do echo -n $r $r-dev ; do
|
||||||
|
|
||||||
source $SELF_DIR/fixtures.sh
|
source $SELF_DIR/fixtures.sh
|
||||||
|
|
||||||
function maybe_sudo() {
|
|
||||||
if test $(id -u) != 0 ; then
|
|
||||||
SUDO=sudo
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function log_info() {
|
function log_info() {
|
||||||
echo "$PREFIX $@"
|
echo "$PREFIX $@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function dependencies() {
|
function dependencies() {
|
||||||
maybe_sudo
|
|
||||||
|
|
||||||
if ! test -f /usr/local/bin/forgejo-curl.sh ; then
|
if ! test -f /usr/local/bin/forgejo-curl.sh ; then
|
||||||
$SUDO curl --fail -sS https://code.forgejo.org/forgejo/forgejo-curl/raw/branch/main/forgejo-curl.sh -o /usr/local/bin/forgejo-curl.sh
|
$SUDO curl --fail -sS https://code.forgejo.org/forgejo/forgejo-curl/raw/branch/main/forgejo-curl.sh -o /usr/local/bin/forgejo-curl.sh
|
||||||
|
@ -56,7 +45,6 @@ function dependencies() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! which curl daemon jq git-lfs > /dev/null ; then
|
if ! which curl daemon jq git-lfs > /dev/null ; then
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
|
||||||
$SUDO apt-get update -qq
|
$SUDO apt-get update -qq
|
||||||
$SUDO apt-get install -y -qq curl daemon git-lfs jq sqlite3 gettext-base
|
$SUDO apt-get install -y -qq curl daemon git-lfs jq sqlite3 gettext-base
|
||||||
fi
|
fi
|
||||||
|
@ -367,7 +355,7 @@ function run() {
|
||||||
mkdir -p $DIR
|
mkdir -p $DIR
|
||||||
> $DIR/$fun.out
|
> $DIR/$fun.out
|
||||||
tail --follow $DIR/$fun.out | sed --unbuffered -n -e "/^$PREFIX/s/^$PREFIX //p" &
|
tail --follow $DIR/$fun.out | sed --unbuffered -n -e "/^$PREFIX/s/^$PREFIX //p" &
|
||||||
pid=$!
|
local pid=$!
|
||||||
if ! VERBOSE=true ${BASH_SOURCE[0]} $fun "$@" >& $DIR/$fun.out ; then
|
if ! VERBOSE=true ${BASH_SOURCE[0]} $fun "$@" >& $DIR/$fun.out ; then
|
||||||
kill $pid
|
kill $pid
|
||||||
cat $DIR/$fun.out
|
cat $DIR/$fun.out
|
||||||
|
|
10
lib/lib.sh
10
lib/lib.sh
|
@ -2,7 +2,13 @@
|
||||||
# Copyright 2024 The Forgejo Authors
|
# Copyright 2024 The Forgejo Authors
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
set -e
|
if ${VERBOSE:-false} ; then
|
||||||
|
set -ex
|
||||||
|
PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: '
|
||||||
|
else
|
||||||
|
set -e
|
||||||
|
fi
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
@ -11,4 +17,4 @@ if test $(id -u) != 0 ; then
|
||||||
SUDO=sudo
|
SUDO=sudo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: '
|
IP=$(hostname -I | cut -f1 -d' ')
|
||||||
|
|
Loading…
Add table
Reference in a new issue