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