Refactor setMCVersion()
This commit is contained in:
35
installJRMC
35
installJRMC
@@ -18,7 +18,7 @@ shopt -s extglob
|
|||||||
|
|
||||||
declare -g SCRIPTVERSION="1.0-dev"
|
declare -g SCRIPTVERSION="1.0-dev"
|
||||||
declare -g BOARDURL="https://yabb.jriver.com/interact/index.php/board,83.0.html" # MC32
|
declare -g BOARDURL="https://yabb.jriver.com/interact/index.php/board,83.0.html" # MC32
|
||||||
declare -g MC_VERSION_HARDCODE="32.0.45" # Do find all replace
|
declare -g MC_VERSION="32.0.45" # Do find all replace
|
||||||
|
|
||||||
printHelp() {
|
printHelp() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
@@ -259,7 +259,7 @@ parseInput() {
|
|||||||
|
|
||||||
declare -g BUILD_SWITCH REPO_INSTALL_SWITCH COMPAT_SWITCH TEST_SWITCH
|
declare -g BUILD_SWITCH REPO_INSTALL_SWITCH COMPAT_SWITCH TEST_SWITCH
|
||||||
declare -g LOCAL_INSTALL_SWITCH CREATEREPO_SWITCH UNINSTALL_SWITCH
|
declare -g LOCAL_INSTALL_SWITCH CREATEREPO_SWITCH UNINSTALL_SWITCH
|
||||||
declare -g YES_SWITCH USER_VERSION_SWITCH USER_ARCH
|
declare -g YES_SWITCH USER_MC_VERSION USER_ARCH
|
||||||
declare -g RESTOREFILE BETAPASS SERVICE_TYPE
|
declare -g RESTOREFILE BETAPASS SERVICE_TYPE
|
||||||
declare -g VNCPASS USER_DISPLAY
|
declare -g VNCPASS USER_DISPLAY
|
||||||
declare -ga SERVICES CONTAINERS
|
declare -ga SERVICES CONTAINERS
|
||||||
@@ -320,8 +320,13 @@ parseInput() {
|
|||||||
;;
|
;;
|
||||||
--mcversion)
|
--mcversion)
|
||||||
shift
|
shift
|
||||||
MC_VERSION="$1"
|
if [[ $1 =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then
|
||||||
USER_VERSION_SWITCH=1
|
USER_MC_VERSION="$1"
|
||||||
|
else
|
||||||
|
err "Bad --mcversion"
|
||||||
|
printHelp
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
--arch)
|
--arch)
|
||||||
shift && USER_ARCH="$1"
|
shift && USER_ARCH="$1"
|
||||||
@@ -406,20 +411,16 @@ parseInput() {
|
|||||||
setMCVersion() {
|
setMCVersion() {
|
||||||
debug "Running: ${FUNCNAME[0]}"
|
debug "Running: ${FUNCNAME[0]}"
|
||||||
|
|
||||||
declare -g MC_VERSION_SOURCE MC_MVERSION MC_ROOT MC_REPO
|
declare -g MC_VERSION_SOURCE
|
||||||
declare -g MC_PKG MC_RPM MC_STUB MC_STUB_TARGET
|
|
||||||
declare cnt
|
declare cnt
|
||||||
|
|
||||||
# User input
|
# User input
|
||||||
if (( USER_VERSION_SWITCH )) &&
|
if [[ -n $USER_MC_VERSION ]]; then
|
||||||
[[ $MC_VERSION =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then
|
|
||||||
MC_VERSION_SOURCE="user input"
|
MC_VERSION_SOURCE="user input"
|
||||||
|
MC_VERSION="$USER_MC_VERSION"
|
||||||
# Containerized package manager
|
# Containerized package manager
|
||||||
else
|
elif installPackage --silent buildah &&
|
||||||
echo "Determining latest MC version"
|
cnt=$(buildah from --quiet debian:stable-slim) &>/dev/null &&
|
||||||
if installPackage --silent buildah &&
|
|
||||||
hash buildah &>/dev/null &&
|
|
||||||
cnt=$(buildah from debian:stable-slim) &&
|
|
||||||
buildah run "$cnt" -- bash -c \
|
buildah run "$cnt" -- bash -c \
|
||||||
"echo 'deb [trusted=no arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $MC_REPO main' > /etc/apt/sources.list 2>&1" &>/dev/null &&
|
"echo 'deb [trusted=no arch=amd64,i386,armhf,arm64] http://dist.jriver.com/latest/mediacenter/ $MC_REPO main' > /etc/apt/sources.list 2>&1" &>/dev/null &&
|
||||||
buildah run "$cnt" -- bash -c \
|
buildah run "$cnt" -- bash -c \
|
||||||
@@ -429,17 +430,17 @@ setMCVersion() {
|
|||||||
MC_VERSION_SOURCE="containerized package manager"
|
MC_VERSION_SOURCE="containerized package manager"
|
||||||
execute buildah rm "$cnt"
|
execute buildah rm "$cnt"
|
||||||
# Webscrape
|
# Webscrape
|
||||||
elif installPackage wget && MC_VERSION=$(wget -qO- "$BOARDURL" | grep -o "[0-9][0-9]\.[0-9]\.[0-9]\+" | head -n 1) &&
|
elif installPackage --silent wget &&
|
||||||
|
MC_VERSION=$(wget -qO- "$BOARDURL" | grep -o "[0-9][0-9]\.[0-9]\.[0-9]\+" | head -n 1) &&
|
||||||
[[ $MC_VERSION =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then
|
[[ $MC_VERSION =~ ([0-9]+.[0-9]+.[0-9]+) ]]; then
|
||||||
MC_VERSION_SOURCE="webscrape"
|
MC_VERSION_SOURCE="webscrape"
|
||||||
# Hardcoded
|
# Hardcoded
|
||||||
else
|
else
|
||||||
declare -g MC_VERSION="$MC_VERSION_HARDCODE"
|
MC_VERSION_SOURCE="hardcoded"
|
||||||
MC_VERSION_SOURCE="hardcoded or MC_VERSION env"
|
|
||||||
err "Warning! Using hardcoded version number"
|
err "Warning! Using hardcoded version number"
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
|
# Set major vresion var
|
||||||
MC_MVERSION="${MC_VERSION%%.*}"
|
MC_MVERSION="${MC_VERSION%%.*}"
|
||||||
|
|
||||||
# Set the appropriate MC repo to use based on the major version number
|
# Set the appropriate MC repo to use based on the major version number
|
||||||
|
|||||||
Reference in New Issue
Block a user