modernize multiple seqs and fix deprecated use of endCheckEmpty
This commit is contained in:
@@ -3,42 +3,27 @@
|
||||
#
|
||||
## Installation of self hosted git service Gitea
|
||||
|
||||
toolName="gitea"
|
||||
# Get script working directory
|
||||
# (when called from a different directory)
|
||||
WDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >>/dev/null 2>&1 && pwd)"
|
||||
APTOPT=
|
||||
CONFIG=0
|
||||
SCRIPT_FILE=$(basename -- $0)
|
||||
SCRIPT_NAME=${SCRIPT_FILE%%.*}
|
||||
CONFIG_FILE_NAME="${SCRIPT_NAME}.cfg"
|
||||
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
|
||||
readonly toolName="gitea"
|
||||
readonly giteaLatestUrl="https://api.github.com/repos/go-gitea/gitea/releases/latest"
|
||||
readonly giteaVersion=$(curl --silent "$giteaLatestUrl" | grep -Po '"tag_name": "v\K.*?(?=")')
|
||||
readonly giteaDir="/usr/local/bin"
|
||||
readonly giteaServiceLoc="/etc/systemd/system/gitea.service"
|
||||
readonly giteaLogDir="/var/log/gitea"
|
||||
readonly giteaDownFile="/tmp/giteaDown"
|
||||
readonly giteaUser="git"
|
||||
|
||||
giteaLatestUrl="https://api.github.com/repos/go-gitea/gitea/releases/latest"
|
||||
giteaVersion=$(curl --silent "$giteaLatestUrl" | grep -Po '"tag_name": "v\K.*?(?=")')
|
||||
giteaArch=
|
||||
giteaDownloadEval='https://dl.gitea.io/gitea/${giteaVersion}/gitea-${giteaVersion}-linux-${giteaArch}'
|
||||
giteaDownload=$(eval echo $giteaDownloadEval)
|
||||
giteaDir="/usr/local/bin"
|
||||
giteaServiceLoc="/etc/systemd/system/gitea.service"
|
||||
giteaLogDir="/var/log/gitea"
|
||||
giteaIniLoc=
|
||||
giteaDownFile="/tmp/giteaDown"
|
||||
giteaUser="git"
|
||||
versionNow=
|
||||
|
||||
seq_config() {
|
||||
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
|
||||
if [ $? -eq 0 ] ; then
|
||||
CONFIG=1
|
||||
else
|
||||
if ! initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
|
||||
# End if no configuration file exists
|
||||
dry || return -1
|
||||
dry || return 1
|
||||
fi
|
||||
|
||||
## Apt cmdline option to suppress user interaction
|
||||
quiet && APTOPT="-y"
|
||||
|
||||
if [ -z $giteaVersion ] ; then
|
||||
error -e "Couldn't determine latest version of $toolName"
|
||||
fi
|
||||
@@ -60,12 +45,13 @@ seq_config() {
|
||||
}
|
||||
|
||||
checkArchitecture() {
|
||||
[ -n "$giteaArch" ] && return 0
|
||||
[ ! -z "$(command -v dpkg)" ] && giteaArch=$(dpkg --print-architecture)
|
||||
case $giteaArch in
|
||||
armhf)
|
||||
giteaArch="arm-6";;
|
||||
esac
|
||||
giteaDownload=$(eval echo $giteaDownloadEval)
|
||||
giteaDownload="$(eval echo $giteaDownloadEval)"
|
||||
}
|
||||
|
||||
step_1_info() { echo "Updating apt"; }
|
||||
@@ -75,14 +61,12 @@ step_1() {
|
||||
}
|
||||
|
||||
step_2_info() {
|
||||
[ -z "$giteaArch" ] && checkArchitecture
|
||||
checkArchitecture
|
||||
echo "Downloading $toolName to user home from:"
|
||||
echoinfo "$giteaDownload"
|
||||
}
|
||||
step_2() {
|
||||
exe wget -O "$giteaDownFile" $giteaDownload
|
||||
saveReturn $?
|
||||
endReturn
|
||||
}
|
||||
|
||||
step_3_info() { echo "Adding user for $toolName ($giteaUser)"; }
|
||||
@@ -95,8 +79,6 @@ step_3() {
|
||||
--disabled-password \
|
||||
--home "$SEQ_GITEA_HOME_DIR" \
|
||||
"$SEQ_GITEA_USER"
|
||||
saveReturn $?
|
||||
endReturn
|
||||
}
|
||||
|
||||
step_4_info() { echo "Create required directory structure"; }
|
||||
@@ -108,9 +90,9 @@ step_4() {
|
||||
exe chmod 770 $SEQ_GITEA_CONF_DIR
|
||||
info "Creating $giteaLogDir"
|
||||
exe install -g $SEQ_GITEA_USER -m 770 -d "$giteaLogDir"
|
||||
sqr::echo -n "Copying gitea to global location and making it executable..."
|
||||
exe install -b -m 755 -T "$giteaDownFile" "$SEQ_GITEA_BIN_LOC" && sqr::echo "ok"
|
||||
endReturn "Failed to install $SEQ_GITEA_BIN_LOC"
|
||||
info -n "Copying gitea to global location and making it executable..."
|
||||
exe install -b -m 755 -T "$giteaDownFile" "$SEQ_GITEA_BIN_LOC" && info -d "ok"
|
||||
endReturn -o $? "Failed to install $SEQ_GITEA_BIN_LOC"
|
||||
}
|
||||
|
||||
step_5_info() { echo "Creating systemd service"; }
|
||||
@@ -158,7 +140,7 @@ NOTES_END
|
||||
|
||||
step_10_info() { echo "Create mysql database for $toolName"; }
|
||||
step_10() {
|
||||
exe "$WDIR/mysql.sh" -qq createdb --charset utf8mb4
|
||||
exe "${seq_origin}/mysql.sh" -qq createdb --charset utf8mb4
|
||||
}
|
||||
|
||||
step_12_info() {
|
||||
@@ -175,7 +157,7 @@ step_12_info() {
|
||||
}
|
||||
step_12_alias() { echo "upgrade"; }
|
||||
step_12() {
|
||||
endCheckEmpty versionNow "Please install $toolName first"
|
||||
endIfEmpty versionNow "Please install $toolName first"
|
||||
exe wget -O "$giteaDownFile" $giteaDownload
|
||||
endReturn -o $? "Download failed"
|
||||
|
||||
@@ -204,5 +186,7 @@ step_22() {
|
||||
exe vi "$giteaIniLoc"
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2034 # Appears unused
|
||||
readonly sqr_minVersion=16
|
||||
# shellcheck disable=SC1091 # Don't follow this source
|
||||
. /usr/local/bin/sequencer.sh
|
||||
|
Reference in New Issue
Block a user