Fix unbound variable errors

This commit is contained in:
2022-06-02 16:08:07 +02:00
parent a6eeccb417
commit 4f8c1b5388
15 changed files with 85 additions and 86 deletions

View File

@@ -54,21 +54,21 @@ step_3_info() {
local tar="<TARGET>" local tar="<TARGET>"
local exc="[EXCLUDES...]" local exc="[EXCLUDES...]"
shift shift
if [ "$1" == "-t" ] ; then if [ "${1:-}" == "-t" ] ; then
opt=" -t " opt=" -t "
tar= tar=
shift shift
fi fi
if [ ! -z "$1" ] ; then if [ -n "${1:-}" ] ; then
dir="$1" dir="$1"
shift shift
if [ ! -z $tar ] && [ ! -z "$1" ] ; then if [ -n $tar ] && [ -n "$1" ] ; then
tar="$1" tar="$1"
shift shift
else else
tar="$BACKUP_TARGET" tar="$BACKUP_TARGET"
fi fi
if [ ! -z "$1" ] ; then if [ -n "${1:-}" ] ; then
exc="$@" exc="$@"
else else
exc="[NO EXCLUDES]" exc="[NO EXCLUDES]"
@@ -83,7 +83,6 @@ step_3_info() {
} }
step_3_alias() { echo "budir"; } step_3_alias() { echo "budir"; }
step_3() { step_3() {
local arg
local configTarget=0 local configTarget=0
local noRemount=0 local noRemount=0
local buSource= local buSource=
@@ -93,7 +92,7 @@ step_3() {
# don't use step number # don't use step number
shift shift
for arg in "$@"; do for _ in "$@"; do
case "$1" in case "$1" in
-t) -t)
configTarget=1 configTarget=1

View File

@@ -39,7 +39,7 @@ step_1() {
SDDEV="$2" SDDEV="$2"
if [ -z "$1" ] && interactive ; then if [ -z "$1" ] && interactive ; then
read -p "Provide image download url from $toolDownSite: " toolDownUrl read -p "Provide image download url from $toolDownSite: " toolDownUrl
elif [ ! -z "$1" ] ; then elif [ -n "${1:-}" ] ; then
toolDownUrl="$1" toolDownUrl="$1"
else else
error -e "No image file provided for download" error -e "No image file provided for download"
@@ -246,7 +246,7 @@ HDBOOT_EOF
read_sd_dev() { read_sd_dev() {
local partExt="" local partExt=""
if [ ! -z "$1" ] ; then if [ -n "${1:-}" ] ; then
SDBOOT= SDBOOT=
SDROOT= SDROOT=
SDROOTDEV= SDROOTDEV=

View File

@@ -601,8 +601,9 @@ step_50() {
} }
checkVpn() { checkVpn() {
ip -br a | grep tun >>/dev/null 2>&1 if ip -br a | grep tun >>/dev/null 2>&1 ; then
[ $? -eq 0 ] && warning "A VPN connection is possibly active. Consider deactivating it befor any apt operation." [ $? -eq 0 ] && warning "A VPN connection is possibly active. Consider deactivating it befor any apt operation."
fi
} }
readonly sqr_minVersion=16 readonly sqr_minVersion=16

View File

@@ -59,9 +59,9 @@ step_1() {
return 1 return 1
fi fi
if [ ! -z "$1" ] && ( [ "$1" == "full" ] || [ "$1" == "incremental" ] ) ; then if [ -n "${1:-}" ] && ( [ "$1" == "full" ] || [ "$1" == "incremental" ] ) ; then
dupArgs+=("$1") dupArgs+=("$1")
elif [ ! -z "$1" ] ; then elif [ -n "${1:-}" ] ; then
echo " [W] $toolName command \"$1\" not recognized" echo " [W] $toolName command \"$1\" not recognized"
return 1 return 1
fi fi
@@ -155,7 +155,7 @@ step_7() {
shift shift
local ebuTarget="$EBU_TARGET" local ebuTarget="$EBU_TARGET"
local dupCommand= local dupCommand=
if [ ! -z "$1" ] ; then if [ -n "${1:-}" ] ; then
ebuTarget="$1" ebuTarget="$1"
fi fi
@@ -182,7 +182,7 @@ step_20_info() {
[ ! -z "${1:-}" ] && ebuTarget="$1" [ ! -z "${1:-}" ] && ebuTarget="$1"
if contextHelp; then if contextHelp; then
echo "Status of (profile) [TARGET]" echo "Status of (profile) [TARGET]"
elif [ ! -z "$1" ]; then elif [ -n "${1:-}" ]; then
echo "Status of target: $ebuTarget" echo "Status of target: $ebuTarget"
else else
echo "Status of profile \"$seq_profileName\" target: $ebuTarget" echo "Status of profile \"$seq_profileName\" target: $ebuTarget"
@@ -192,7 +192,7 @@ step_20_alias() { echo 'status'; }
step_20() { step_20() {
shift shift
local ebuTarget="$EBU_TARGET" local ebuTarget="$EBU_TARGET"
if [ ! -z "$1" ] ; then if [ -n "${1:-}" ] ; then
ebuTarget="$1" ebuTarget="$1"
fi fi
@@ -205,7 +205,7 @@ step_22_alias() { echo 'list'; }
step_22() { step_22() {
shift shift
local ebuTarget="$EBU_TARGET" local ebuTarget="$EBU_TARGET"
if [ ! -z "$1" ] ; then if [ -n "${1:-}" ] ; then
ebuTarget="$1" ebuTarget="$1"
fi fi

View File

@@ -60,7 +60,7 @@ step_20() {
if [ ! -z $ELEMENT_WEB_BACKUP ] ; then if [ ! -z $ELEMENT_WEB_BACKUP ] ; then
exe mkdir -p "$ELEMENT_WEB_BACKUP" exe mkdir -p "$ELEMENT_WEB_BACKUP"
fi fi
if [ ! -z $1 ] ; then if [ -n "${1:-}" ] ; then
tempRoot="$1" tempRoot="$1"
else else
tempRoot="$ELEMENT_WEB_LOC" tempRoot="$ELEMENT_WEB_LOC"

View File

@@ -35,10 +35,10 @@ step_20() {
error -e "No configuration file found" error -e "No configuration file found"
return 1 return 1
fi fi
if [ ! -z $FR_BACKUP ] ; then if [ -n "$FR_BACKUP" ] ; then
exe mkdir -p "$FR_BACKUP" exe mkdir -p "$FR_BACKUP"
fi fi
if [ ! -z "$1" ] ; then if [ -n "${1:-}" ] ; then
tempRoot="$1" tempRoot="$1"
else else
tempRoot="$FR_LOC" tempRoot="$FR_LOC"
@@ -61,7 +61,7 @@ step_20() {
step_22_info() { step_22_info() {
shift shift
if [ -z $1 ] ; then if [ -z "${1:-}" ] ; then
echo -n "Get latest version from github" echo -n "Get latest version from github"
if ! contextHelp ; then if ! contextHelp ; then
echo ": $(curl --silent "$latestUrl" | grep -Po '"tag_name": "\K.*?(?=")')" echo ": $(curl --silent "$latestUrl" | grep -Po '"tag_name": "\K.*?(?=")')"
@@ -76,7 +76,7 @@ step_22_alias() { echo "upgrade"; }
step_22() { step_22() {
shift # don't need step number shift # don't need step number
local latestVersion= local latestVersion=
if [ ! -z $1 ] ; then if [ -n "${1:-}" ] ; then
latestVersion="$1" latestVersion="$1"
else else
latestVersion=$(curl --silent "$latestUrl" | grep -Po '"tag_name": "\K.*?(?=")') latestVersion=$(curl --silent "$latestUrl" | grep -Po '"tag_name": "\K.*?(?=")')

View File

@@ -218,7 +218,7 @@ step_103_info() { echo "(re)Set passwort for <USER>"; }
step_103_alias() { echo "passwd"; } step_103_alias() { echo "passwd"; }
step_103() { step_103() {
shift shift
if [ ! -z $1 ] ; then if [ -n "${1:-}" ] ; then
echo " [I] Password operation for $1" echo " [I] Password operation for $1"
userId="$1" userId="$1"
elif [ ! -z $userId ] ; then elif [ ! -z $userId ] ; then
@@ -234,7 +234,7 @@ step_105_info() { echo "Adding <USER ID> to existing group <GROUP NAME>"; }
step_105_alias() { echo "user2group"; } step_105_alias() { echo "user2group"; }
step_105() { step_105() {
shift shift
if [ ! -z $1 ] ; then if [ -n "${1:-}" ] ; then
userId="$1" userId="$1"
echo " [I] User operation for $userId" echo " [I] User operation for $userId"
elif [ ! -z $userId ] ; then elif [ ! -z $userId ] ; then
@@ -269,7 +269,7 @@ step_107_info() { echo "Removing <USER ID> from existing group <GROUP NAME>"; }
step_107_alias() { echo "rmusergroup"; } step_107_alias() { echo "rmusergroup"; }
step_107() { step_107() {
shift shift
if [ ! -z $1 ] ; then if [ -n "${1:-}" ] ; then
userId="$1" userId="$1"
echo " [I] User operation for $userId" echo " [I] User operation for $userId"
elif [ ! -z $userId ] ; then elif [ ! -z $userId ] ; then

View File

@@ -31,7 +31,7 @@ seq_config() {
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
if [ $? -eq 0 ] ; then if [ $? -eq 0 ] ; then
CONFIG=1 CONFIG=1
info " Domain: $MAS_DOMAIN" info " Domain: ${MAS_DOMAIN:-}"
elif [ $? -eq 1 ] ; then elif [ $? -eq 1 ] ; then
# Config $CONFIG_FILE_NAME created. Needs modification first # Config $CONFIG_FILE_NAME created. Needs modification first
dry || return -1 dry || return -1
@@ -415,20 +415,19 @@ step_100_info() {
step_100_alias() { echo "test"; } step_100_alias() { echo "test"; }
step_100() { step_100() {
shift shift
local arg
local fromAdr local fromAdr
local toAdr="postmaster@$MAS_DOMAIN" local toAdr="postmaster@$MAS_DOMAIN"
local asUser= local asUser=
for arg in "$@" ; do for _ in "$@" ; do
case "$1" in case "$1" in
-f) -f)
shift shift
fromAdr="-f $1 " fromAdr="-f ${1:-} "
shift shift
;; ;;
-u) -u)
shift shift
asUser="sudo -u $1 " asUser="sudo -u ${1:-} "
shift shift
;; ;;
*) *)
@@ -436,7 +435,7 @@ step_100() {
;; ;;
esac esac
done done
if [ ! -z $1 ] ; then if [ -n "${1:-}" ] ; then
toAdr="$1" toAdr="$1"
fi fi
exe ${asUser}sh -c "echo \"Subject: Test from Postfix\nIt is \$(date)\n\nGreetings \$(whoami)\" | sendmail ${fromAdr}$toAdr" exe ${asUser}sh -c "echo \"Subject: Test from Postfix\nIt is \$(date)\n\nGreetings \$(whoami)\" | sendmail ${fromAdr}$toAdr"
@@ -456,7 +455,7 @@ step_104_alias() { echo "delqueue"; }
step_104() { step_104() {
shift shift
local msgId="ALL" local msgId="ALL"
if [ ! -z $1 ] ; then if [ -n "${1:-}" ] ; then
msgId="$1" msgId="$1"
fi fi
exe postsuper -d "$msgId" exe postsuper -d "$msgId"

View File

@@ -25,9 +25,9 @@ seq_config() {
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
if [ $? -eq 0 ] ; then if [ $? -eq 0 ] ; then
CONFIG=1 CONFIG=1
postgresDb="$MAYAN_DB" postgresDb="${MAYAN_DB:-}"
postgresUser="$MAYAN_DBUSER" postgresUser="${MAYAN_DBUSER:-}"
postgresPass="$MAYAN_DBPASS" postgresPass="${MAYAN_DBPASS:-}"
else else
# End if no configuration file exists # End if no configuration file exists
dry || return -1 dry || return -1
@@ -223,7 +223,7 @@ readDatabaseInfos() {
# Needs readDatabaseInfos() to execute some commands # Needs readDatabaseInfos() to execute some commands
toolScript() { toolScript() {
if [ ! -z "$1" ] ; then if [ -n "${1:-}" ] ; then
readDatabaseInfos readDatabaseInfos
fi fi

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
toolName=postfixadmin toolName=postfixadmin
toolPhpDeps='php${PFA_PHP_VERSION}-fpm php${PFA_PHP_VERSION}-imap php${PFA_PHP_VERSION}-mbstring php${PFA_PHP_VERSION}-mysql php${PFA_PHP_VERSION}-json php${PFA_PHP_VERSION}-curl php${PFA_PHP_VERSION}-zip php${PFA_PHP_VERSION}-xml php${PFA_PHP_VERSION}-bz2 php${PFA_PHP_VERSION}-intl php${PFA_PHP_VERSION}-gmp' toolPhpDeps='php${PFA_PHP_VERSION:-}-fpm php${PFA_PHP_VERSION:-}-imap php${PFA_PHP_VERSION:-}-mbstring php${PFA_PHP_VERSION:-}-mysql php${PFA_PHP_VERSION:-}-json php${PFA_PHP_VERSION:-}-curl php${PFA_PHP_VERSION:-}-zip php${PFA_PHP_VERSION:-}-xml php${PFA_PHP_VERSION:-}-bz2 php${PFA_PHP_VERSION:-}-intl php${PFA_PHP_VERSION:-}-gmp'
toolConfName="config.local.php" toolConfName="config.local.php"
toolTemplates="templates_c" toolTemplates="templates_c"
toolTemplatesLoc="$PFA_SRV_LOC/$toolTemplates" toolTemplatesLoc="$PFA_SRV_LOC/$toolTemplates"
@@ -18,12 +18,13 @@ CONFIG_FILE_NAME="${toolName}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example" CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
seq_config() { seq_config() {
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" if initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" ; then
if [ $? -eq 0 ] ; then info "${toolName} path: ${PFA_WEB_LOC:-}"
echo " ${toolName} path: ${PFA_WEB_LOC}" info -a "${toolName} backup: ${PFA_BACKUP:-}"
echo " ${toolName} backup: ${PFA_BACKUP}" info -a " php Version: ${PFA_PHP_VERSION:-}"
echo " php Version: ${PFA_PHP_VERSION}"
CONFIG=1 CONFIG=1
else
dry || return 1
fi fi
} }
@@ -45,7 +46,7 @@ step_1() {
exe apt install $localDeps $aptOpt exe apt install $localDeps $aptOpt
} }
step_2_info() { echo "Install $toolName to $PFA_SRV_LOC"; } step_2_info() { echo "Install $toolName to ${PFA_SRV_LOC:-}"; }
step_2() { step_2() {
step upgrade step upgrade
} }
@@ -149,7 +150,7 @@ step_18() {
shift shift
local isInstalled= local isInstalled=
local latestVersion= local latestVersion=
if [ ! -z $1 ] ; then if [ -n "${1:-}" ] ; then
latestVersion="$1" latestVersion="$1"
else else
latestVersion=$(curl --silent "$latestUrl" | grep -Po '"tag_name": "postfixadmin-\K.*?(?=")') latestVersion=$(curl --silent "$latestUrl" | grep -Po '"tag_name": "postfixadmin-\K.*?(?=")')
@@ -186,7 +187,7 @@ step_20() {
if [ ! -z $PFA_BACKUP ] ; then if [ ! -z $PFA_BACKUP ] ; then
exe mkdir -p "$PFA_BACKUP" exe mkdir -p "$PFA_BACKUP"
fi fi
if [ ! -z $1 ] ; then if [ -n "${1:-}" ] ; then
tempRoot="$1" tempRoot="$1"
else else
tempRoot="$PFA_SRV_LOC" tempRoot="$PFA_SRV_LOC"
@@ -219,7 +220,7 @@ step_22_alias() { echo "upgrade"; }
step_22() { step_22() {
shift # don't need step number shift # don't need step number
local latestVersion= local latestVersion=
if [ ! -z $1 ] ; then if [ -n "${1:-}" ] ; then
latestVersion="$1" latestVersion="$1"
else else
latestVersion=$(curl --silent "$latestUrl" | grep -Po '"tag_name": "postfixadmin-\K.*?(?=")') latestVersion=$(curl --silent "$latestUrl" | grep -Po '"tag_name": "postfixadmin-\K.*?(?=")')

View File

@@ -55,10 +55,10 @@ HDSWAPPUUID=
evalArgs() { evalArgs() {
local argCount=0 local argCount=0
for arg in "$@"; do for _ in "$@"; do
case "$1" in case "$1" in
-a|--arch) -a|--arch)
if [ ! -z "$2" ]; then if [ -n "${2:-}" ]; then
PIARCH="$2" PIARCH="$2"
((argCount+=2)) ((argCount+=2))
else else
@@ -115,7 +115,7 @@ step_2_info() {
echoinfoArgs "[OPTIONS] [SD CARD DEVICE]" echoinfoArgs "[OPTIONS] [SD CARD DEVICE]"
echo "Write Raspberry Pi OS image to SD card" echo "Write Raspberry Pi OS image to SD card"
echoinfo "This operation will delete all data previously on the SD card!" echoinfo "This operation will delete all data previously on the SD card!"
contextExe && [ ! -z $1 ] && echoinfo " [SD CARD DEVICE]: $1" contextExe && [ -n "${1:-}" ] && echoinfo " [SD CARD DEVICE]: $1"
} }
step_2_alias() { echo "writesd"; } step_2_alias() { echo "writesd"; }
step_2() { step_2() {
@@ -134,7 +134,7 @@ step_2() {
endReturn -o 1 "No root" endReturn -o 1 "No root"
fi fi
read_sd_dev "$1" read_sd_dev "${1:-}"
# check if device was confirmed # check if device was confirmed
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
endReturn -o 1 "SD card device not found" endReturn -o 1 "SD card device not found"
@@ -162,14 +162,14 @@ step_3_info() {
echoinfoArgs "[SD CARD DEVICE]" echoinfoArgs "[SD CARD DEVICE]"
echo "Prepare SD for first run" echo "Prepare SD for first run"
if contextExe; then if contextExe; then
[ ! -z $1 ] && echoinfo " [SD CARD DEVICE]: $1" [ -n "${1:-}" ] && echoinfo " [SD CARD DEVICE]: $1"
fi fi
} }
step_3() { step_3() {
# Shift away args # Shift away args
shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $? shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $?
if [ -z $1 ] && [ ! -z $SDDEV ] ; then if [ -z "${1:-}" ] && [ -n "${SDDEV:-}" ] ; then
if quiet ; then if quiet ; then
answer="n" answer="n"
else else
@@ -188,7 +188,7 @@ step_3() {
esac esac
fi fi
read_sd_dev "$1" read_sd_dev "${1:-}"
endReturn -o $? "SD card device not found" endReturn -o $? "SD card device not found"
if [ ! -w "$SDBOOT" ] ; then if [ ! -w "$SDBOOT" ] ; then
@@ -213,8 +213,8 @@ step_4_info() {
echoinfoArgs "[SD CARD DEVICE] [HD DEVICE]" echoinfoArgs "[SD CARD DEVICE] [HD DEVICE]"
echo "Prepare SD card to boot from hard disk" echo "Prepare SD card to boot from hard disk"
if contextExe; then if contextExe; then
[ ! -z $1 ] && echoinfo " [SD CARD DEVICE]: $1" [ -n "${1:-}" ] && echoinfo " [SD CARD DEVICE]: $1"
[ ! -z $2 ] && echoinfo " [HD DEVICE]: $2" [ -n "${2:-}" ] && echoinfo " [HD DEVICE]: $2"
fi fi
} }
step_4_alias() { echo "hdboot"; } step_4_alias() { echo "hdboot"; }
@@ -222,9 +222,9 @@ step_4() {
# Shift away args # Shift away args
shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $? shift; local lArgs=( "$@" ); evalArgs "${lArgs[@]}"; shift $?
read_sd_dev "$1" read_sd_dev "${1:-}"
endReturn -o $? "SD detection error $?" endReturn -o $? "SD detection error $?"
read_hd_dev "$2" read_hd_dev "${2:-}"
endReturn -o $? "HD detection error" endReturn -o $? "HD detection error"
echo " [I] SD: $SDDEV" echo " [I] SD: $SDDEV"
echo " $SDBOOT [$SDBOOTPUUID]" echo " $SDBOOT [$SDBOOTPUUID]"
@@ -285,8 +285,8 @@ step_5_info() {
echo "Prepare HD for boot (TODO)" echo "Prepare HD for boot (TODO)"
if contextExe; then if contextExe; then
[ ! -z $1 ] && echoinfo " [SD CARD DEVICE]: $1" [ -n "${1:-}" ] && echoinfo " [SD CARD DEVICE]: $1"
[ ! -z $2 ] && echoinfo " [HD DEVICE]: $2" [ -n "${2:-}" ] && echoinfo " [HD DEVICE]: $2"
fi fi
} }
step_5() { step_5() {
@@ -296,10 +296,10 @@ step_5() {
#TODO #TODO
error -e "Not ready yet...TODO" error -e "Not ready yet...TODO"
#return 1 #return 1
read_sd_dev "$1" read_sd_dev "${1:-}"
endReturn -o $? "SD detection error $?" endReturn -o $? "SD detection error $?"
read_hd_dev "$2" read_hd_dev "${2:-}"
endReturn -o $? "HD detection error" endReturn -o $? "HD detection error"
echo " [I] SD: $SDDEV" echo " [I] SD: $SDDEV"
echo " $SDBOOT [$SDBOOTPUUID]" echo " $SDBOOT [$SDBOOTPUUID]"
@@ -333,14 +333,14 @@ step_5() {
read_sd_dev() { read_sd_dev() {
local partExt="" local partExt=""
if [ ! -z "$1" ] ; then if [ -n "${1:-}" ] ; then
SDBOOT= SDBOOT=
SDROOT= SDROOT=
SDROOTDEV= SDROOTDEV=
SDROOTPUUID= SDROOTPUUID=
SDBOOTPUUID= SDBOOTPUUID=
SDDEV="$1" SDDEV="$1"
elif [ -z $SDDEV ] || [ ! -b "$SDDEV" ] ; then elif [ -z "${SDDEV:-}" ] || [ ! -b "$SDDEV" ] ; then
SDDEV= SDDEV=
SDBOOT= SDBOOT=
SDROOT= SDROOT=
@@ -385,7 +385,7 @@ SDBOOTPARTNO=1
SDROOTPARTNO=2 SDROOTPARTNO=2
read_hd_dev() { read_hd_dev() {
if [ ! -z "$1" ] ; then if [ -n "${1:-}" ] ; then
HDROOT= HDROOT=
HDROOTPUUID= HDROOTPUUID=
HDSWAPPUUID= HDSWAPPUUID=
@@ -447,7 +447,7 @@ step_22_info() { echoinfoArgs "[SD CARD DEVICE]"; echo "Resize second SD card pa
step_22_alias() { echo "resizesd"; } step_22_alias() { echo "resizesd"; }
step_22() { step_22() {
shift shift
read_sd_dev "$1" read_sd_dev "${1:-}"
if [ -z $SDDEV ] || [ "$SDDEV" = "" ] || [ "$SDROOT" == "/" ] ; then if [ -z $SDDEV ] || [ "$SDDEV" = "" ] || [ "$SDROOT" == "/" ] ; then
error -e "No SD found" error -e "No SD found"
return 1 return 1
@@ -570,7 +570,7 @@ tvserviceOffCmd="${tvserviceBin} -o'"
# checkBootConfig <CONFIGNAME> [VALUE] # checkBootConfig <CONFIGNAME> [VALUE]
checkBootConfig() { checkBootConfig() {
[ -z "$1" ] && return 1 [ -z "${1:-}" ] && return 1
local re_check="^[[:blank:]]*[^#]*${1}[[:blank:]]*=[[:blank:]]*$2" local re_check="^[[:blank:]]*[^#]*${1}[[:blank:]]*=[[:blank:]]*$2"
grep -rqE "$re_check" "$RPI_BOOT_CONFIG" grep -rqE "$re_check" "$RPI_BOOT_CONFIG"

View File

@@ -173,7 +173,7 @@ step_22() {
shift # don't need step number shift # don't need step number
local currentVersion= local currentVersion=
if [ ! -z $1 ] ; then if [ -n "${1:-}" ] ; then
latestVersion="$1" latestVersion="$1"
else else
fetchLatestVersion fetchLatestVersion

View File

@@ -73,7 +73,7 @@ step_2() {
addConf -a "$v3AuthEntry" "$v3AuthLoc" addConf -a "$v3AuthEntry" "$v3AuthLoc"
shift shift
if [ ! -z $1 ] && [ "$1" == "-s" ] ; then if [ -n "${1:-}" ] && [ "$1" == "-s" ] ; then
info "Stop after creating authentication config" info "Stop after creating authentication config"
exe service snmpd start exe service snmpd start
return 0 return 0
@@ -109,7 +109,7 @@ step_5_alias() { echo "ufw"; }
step_5() { step_5() {
shift shift
local lInterface="eth0" local lInterface="eth0"
[ ! -z "$1" ] && lInterface="$1" [ -n "${1:-}" ] && lInterface="$1"
# Check if interface exists # Check if interface exists
ip -br a | grep -E "^$lInterface" >>/dev/null 2>&1 ip -br a | grep -E "^$lInterface" >>/dev/null 2>&1
endReturn -o $? "Interface $lInterface does not exist" endReturn -o $? "Interface $lInterface does not exist"

View File

@@ -119,7 +119,7 @@ parseList() {
else else
error -e "Command list not found: $1" error -e "Command list not found: $1"
fi fi
if [ ! -z "$1" ] && dry || interactive ; then if [ -n "${1:-}" ] && dry || interactive ; then
read -p " Create template there y/[n]? " answer read -p " Create template there y/[n]? " answer
case "$answer" in case "$answer" in
y|Y) y|Y)

View File

@@ -19,36 +19,35 @@ CONFIG_FILE_NAME="${toolName}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example" CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
seq_config() { seq_config() {
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" if initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE" ; then
if [ $? -eq 0 ] ; then
CONFIG=1 CONFIG=1
else else
dry || return 1 dry || return 1
fi fi
toolConfigLoc=`eval echo "$TWXA_CONFIG_LOC"` toolConfigLoc=`eval echo "${TWXA_CONFIG_LOC:-}"`
toolConfig="$toolConfigLoc/config_cache/$toolConfigName" toolConfig="$toolConfigLoc/config_cache/$toolConfigName"
toolHtmlLoc=`eval echo "$TWXA_HTML_LOC"` toolHtmlLoc=`eval echo "${TWXA_HTML_LOC:-}"`
toolBackupLoc=`eval echo "$TWXA_BACKUP_LOC"` toolBackupLoc=`eval echo "${TWXA_BACKUP_LOC:-}"`
toolGitLoc=`eval echo "$TWXA_GIT_LOC"` toolGitLoc=`eval echo "${TWXA_GIT_LOC:-}"`
gitLibLoc=`eval echo "$TWXA_GIT_LOC/var/lib/torrentwatch-xa"` gitLibLoc=`eval echo "${TWXA_GIT_LOC:-}/var/lib/torrentwatch-xa"`
gitHtmlLoc=`eval echo "$TWXA_GIT_LOC/var/www/html/torrentwatch-xa"` gitHtmlLoc=`eval echo "${TWXA_GIT_LOC:-}/var/www/html/torrentwatch-xa"`
echo " git: $toolGitLoc" info " git: $toolGitLoc"
echo " config: $toolConfig" info -a "config: $toolConfig"
echo " html: $toolHtmlLoc" info -a " html: $toolHtmlLoc"
echo " backup: $toolBackupLoc" info -a "backup: $toolBackupLoc"
} }
step_1_info() { echo "Install $toolName [VERSION]"; } step_1_info() { echo "Install $toolName [VERSION]"; }
step_1_alias() { echo "install"; } step_1_alias() { echo "install"; }
step_1() { step_1() {
shift shift
if [ ! -z $1 ] ; then if [ -n "${1:-}" ] ; then
toolVersion="$1" toolVersion="$1"
fi fi
echo $toolConfig echo $toolConfig
} }
step_2_info() { echo "Setup git repository at $toolGitLoc [VERSION e.g. 1.4.1]"; } step_2_info() { echo "Setup git repository at ${toolGitLoc:-} [VERSION e.g. 1.4.1]"; }
step_2_alias() { echo "git"; } step_2_alias() { echo "git"; }
step_2() { step_2() {
shift shift
@@ -60,7 +59,7 @@ step_2() {
exe cd "$toolGitLoc" exe cd "$toolGitLoc"
exe git pull exe git pull
fi fi
if [ ! -z $1 ] ; then if [ -n "${1:-}" ] ; then
toolVersion="$1" toolVersion="$1"
fi fi
exe git checkout $toolVersion exe git checkout $toolVersion
@@ -76,7 +75,7 @@ step_20() {
fi fi
local buType="all" local buType="all"
if [ ! -z $1 ] ; then if [ -n "${1:-}" ] ; then
buType="$1" buType="$1"
fi fi
local buDate=`date +%Y%m%d-%H%M%S` local buDate=`date +%Y%m%d-%H%M%S`
@@ -118,7 +117,7 @@ step_30_info() { echo "Upgrade $toolName [VERSION]"; }
step_30_alias() { echo "upgrade"; } step_30_alias() { echo "upgrade"; }
step_30() { step_30() {
shift shift
if [ ! -z $1 ] ; then if [ -n "${1:-}" ] ; then
toolVersion="$1" toolVersion="$1"
fi fi