matterbridge - Fix unbound variable errors and performed shellcheck

This commit is contained in:
2022-06-29 10:17:30 +02:00
parent 638f3e53de
commit 43d57fa7db

View File

@@ -37,7 +37,7 @@ readonly goDir="/usr/local/go"
readonly goDownLoc="/tmp/go.tar.gz"
seq_config() {
if [ -z $toolVersion ] ; then
if [ -z "${toolVersion}" ] ; then
error -e "Couldn't determine latest version of $toolName"
fi
}
@@ -91,20 +91,20 @@ step_10_alias() { echo "backup"; }
step_10() {
if [ -f "$toolLoc" ] ; then
local toolBackup=
if [ ! -z ${versionNow} ] ; then
if [ -n "${versionNow}" ] ; then
toolBackup="${toolDir}/${toolName}_${versionNow}"
else
toolBackup="${toolDir}/${toolName}_bu"
fi
exe service ${toolName} stop >>/dev/null 2>&1
sqr::echo -n " [i] Backing up existing executable to ${toolBackup}..."
exe cp -ar "$toolLoc" "$toolBackup" && sqr::echo "ok"
exep service ${toolName} stop '>>/dev/null 2>&1'
info -n "Backing up existing executable to ${toolBackup}..."
exe cp -ar "$toolLoc" "$toolBackup" && info -d "ok"
fi
}
versionNow=$([ ! -z $(which ${toolName}) ] && ${toolName} --version | sed 's/.*version: \([0-9.]\+\).*/\1/')
versionNow=$([ -n "$(command -v ${toolName})" ] && ${toolName} --version | sed 's/.*version: \([0-9.]\+\).*/\1/')
step_12_info() {
if [ ! -z $versionNow ] ; then
if [ -n "${versionNow}" ] ; then
if [ "$toolVersion" == "$versionNow" ] ; then
echo "No upgrade available. Already on latest: $versionNow"
else
@@ -119,7 +119,7 @@ step_12_info() {
step_12_alias() { echo "upgrade"; }
step_12() {
step backup
exe wget -O "$toolLoc" $toolDownload
exe wget -O "$toolLoc" "${toolDownload}"
endReturn -o $? "Download failed"
exe chmod +x "$toolLoc"
exe service ${toolName} restart >>/dev/null 2>&1
@@ -137,13 +137,14 @@ step_30_info() {
step_30_alias() { echo "build"; }
step_30() {
shift
local goVer="$(curl --silent -L https://go.dev/dl | \
local goVer
goVer="$(curl --silent -L https://go.dev/dl | \
grep --max-count 1 -E "go[[:digit:]\.]{3,}.*\.tar\.gz" |\
sed 's/.*\/\(go.*\)\.linux.*/\1/g')"
local goArch="armhf" #arm64"
case "${1}" in
case "${1:-}" in
--arch|-a)
goArch="${2}"
goArch="${2:-"armhf"}"
shift 2 ;;
esac
[[ "${goArch}" == "armhf" ]] && goArch="armv6l"
@@ -152,7 +153,7 @@ step_30() {
# Download latest go
if [ ! -e "${goDir}" ] ; then
info "Download go${goVer}: ${goDownUrl}"
exe wget -O "${goDownLoc}" ${goDownUrl}
exe wget -O "${goDownLoc}" "${goDownUrl}"
endReturn -o $? "Download ${goVer} failed"
exe tar -C "$(dirname -- "${goDir}")" -xzf "${goDownLoc}"
endReturn -o $? "Extraction ${goVer} failed"
@@ -185,7 +186,7 @@ whatsappmulti"
exe "${goDir}/bin/go" install -tags ${mabrTags} github.com/42wim/matterbridge@master
step backup
exe cp -ar "${HOME}/go/bin/matterbridge" "${toolDir}"
exe service ${toolName} restart >>/dev/null 2>&1
exep service ${toolName} restart '>>/dev/null 2>&1'
}
step_32_info() { echo "Clean temporary files"; }