Fixed shellcheck warning SC2004, SC2006, SC2129, SC2219. Issue #1233.

SC2004: "$/${} is unnecessary on arithmetic variables."
SC2006: "Use $(...) notation instead of legacy backticked `...`."
SC2129: "Consider using { cmd1; cmd2; } >> file instead of individual redirects."
SC2219: "Instead of 'let expr', prefer (( expr ))."
This commit is contained in:
Dundar Göc 2021-02-07 21:20:48 +01:00
parent d67095f3ef
commit 513c2afc2e
7 changed files with 35 additions and 25 deletions

View file

@ -764,9 +764,11 @@ getStaticIPv4Settings() {
echo "::: Skipping setting static IP address" echo "::: Skipping setting static IP address"
fi fi
echo "dhcpReserv=${dhcpReserv}" >> ${tempsetupVarsFile} {
echo "IPv4addr=${IPv4addr}" >> ${tempsetupVarsFile} echo "dhcpReserv=${dhcpReserv}"
echo "IPv4gw=${IPv4gw}" >> ${tempsetupVarsFile} echo "IPv4addr=${IPv4addr}"
echo "IPv4gw=${IPv4gw}"
} >> ${tempsetupVarsFile}
return return
fi fi
@ -1099,10 +1101,12 @@ installPiVPN(){
fi fi
echo "pivpnDEV=${pivpnDEV}" >> ${tempsetupVarsFile} {
echo "pivpnNET=${pivpnNET}" >> ${tempsetupVarsFile} echo "pivpnDEV=${pivpnDEV}"
echo "subnetClass=${subnetClass}" >> ${tempsetupVarsFile} echo "pivpnNET=${pivpnNET}"
echo "ALLOWED_IPS=\"${ALLOWED_IPS}\"" >> ${tempsetupVarsFile} echo "subnetClass=${subnetClass}"
echo "ALLOWED_IPS=\"${ALLOWED_IPS}\""
} >> ${tempsetupVarsFile}
} }
askWhichVPN(){ askWhichVPN(){
@ -1737,9 +1741,11 @@ askEncryption(){
fi fi
fi fi
echo "TWO_POINT_FOUR=${TWO_POINT_FOUR}" >> ${tempsetupVarsFile} {
echo "pivpnENCRYPT=${pivpnENCRYPT}" >> ${tempsetupVarsFile} echo "TWO_POINT_FOUR=${TWO_POINT_FOUR}"
echo "USE_PREDEFINED_DH_PARAM=${USE_PREDEFINED_DH_PARAM}" >> ${tempsetupVarsFile} echo "pivpnENCRYPT=${pivpnENCRYPT}"
echo "USE_PREDEFINED_DH_PARAM=${USE_PREDEFINED_DH_PARAM}"
} >> ${tempsetupVarsFile}
return return
fi fi
@ -1747,9 +1753,11 @@ askEncryption(){
if [ "$VPN" = "openvpn" ]; then if [ "$VPN" = "openvpn" ]; then
TWO_POINT_FOUR=1 TWO_POINT_FOUR=1
pivpnENCRYPT=256 pivpnENCRYPT=256
echo "TWO_POINT_FOUR=${TWO_POINT_FOUR}" >> ${tempsetupVarsFile} {
echo "pivpnENCRYPT=${pivpnENCRYPT}" >> ${tempsetupVarsFile} echo "TWO_POINT_FOUR=${TWO_POINT_FOUR}"
echo "USE_PREDEFINED_DH_PARAM=${USE_PREDEFINED_DH_PARAM}" >> ${tempsetupVarsFile} echo "pivpnENCRYPT=${pivpnENCRYPT}"
echo "USE_PREDEFINED_DH_PARAM=${USE_PREDEFINED_DH_PARAM}"
} >> ${tempsetupVarsFile}
return return
fi fi
fi fi
@ -1782,9 +1790,11 @@ askEncryption(){
USE_PREDEFINED_DH_PARAM=0 USE_PREDEFINED_DH_PARAM=0
fi fi
echo "TWO_POINT_FOUR=${TWO_POINT_FOUR}" >> ${tempsetupVarsFile} {
echo "pivpnENCRYPT=${pivpnENCRYPT}" >> ${tempsetupVarsFile} echo "TWO_POINT_FOUR=${TWO_POINT_FOUR}"
echo "USE_PREDEFINED_DH_PARAM=${USE_PREDEFINED_DH_PARAM}" >> ${tempsetupVarsFile} echo "pivpnENCRYPT=${pivpnENCRYPT}"
echo "USE_PREDEFINED_DH_PARAM=${USE_PREDEFINED_DH_PARAM}"
} >> ${tempsetupVarsFile}
} }
cidrToMask(){ cidrToMask(){

View file

@ -133,7 +133,7 @@ function useBitwarden() {
# login and unlock vault # login and unlock vault
printf "****Bitwarden Login****" printf "****Bitwarden Login****"
printf "\n" printf "\n"
SESSION_KEY=`bw login --raw` SESSION_KEY=$(bw login --raw)
export BW_SESSION=$SESSION_KEY export BW_SESSION=$SESSION_KEY
printf "Successfully Logged in!" printf "Successfully Logged in!"
printf "\n" printf "\n"
@ -168,7 +168,7 @@ function useBitwarden() {
printf "Creating a PiVPN item for your vault..." printf "Creating a PiVPN item for your vault..."
printf "\n" printf "\n"
# create a new item for your PiVPN Password # create a new item for your PiVPN Password
PASSWD=`bw generate -usln --length $LENGTH` PASSWD=$(bw generate -usln --length $LENGTH)
bw get template item | jq '.login.type = "1"'| jq '.name = "PiVPN"' | jq -r --arg NAME "$NAME" '.login.username = $NAME' | jq -r --arg PASSWD "$PASSWD" '.login.password = $PASSWD' | bw encode | bw create item bw get template item | jq '.login.type = "1"'| jq '.name = "PiVPN"' | jq -r --arg NAME "$NAME" '.login.username = $NAME' | jq -r --arg PASSWD "$PASSWD" '.login.password = $PASSWD' | bw encode | bw create item
bw logout bw logout

View file

@ -60,7 +60,7 @@ if [[ -z "${CERTS_TO_REVOKE}" ]]; then
# Prevent printing "server" certificate # Prevent printing "server" certificate
CERTS[$i]=$(echo -e "${NAME}") CERTS[$i]=$(echo -e "${NAME}")
fi fi
let i=i+1 ((i++))
fi fi
done <${INDEX} done <${INDEX}
@ -82,7 +82,7 @@ if [[ -z "${CERTS_TO_REVOKE}" ]]; then
re='^[0-9]+$' re='^[0-9]+$'
if [[ ${NAME} =~ $re ]] ; then if [[ ${NAME} =~ $re ]] ; then
NAME=${CERTS[$(($NAME))]} NAME=${CERTS[$((NAME))]}
fi fi
for((x=1;x<=i;++x)); do for((x=1;x<=i;++x)); do
@ -104,7 +104,7 @@ else
if [[ "${STATUS}" = "V" ]]; then if [[ "${STATUS}" = "V" ]]; then
NAME=$(echo -e "$line" | sed -e 's:.*/CN=::') NAME=$(echo -e "$line" | sed -e 's:.*/CN=::')
CERTS[$i]=${NAME} CERTS[$i]=${NAME}
let i=i+1 ((i++))
fi fi
done <${INDEX} done <${INDEX}

View file

@ -81,7 +81,7 @@ for CLIENT_NAME in "${CLIENTS_TO_CHANGE[@]}"; do
re='^[0-9]+$' re='^[0-9]+$'
if [[ ${CLIENT_NAME} =~ $re ]] ; then if [[ ${CLIENT_NAME} =~ $re ]] ; then
CLIENT_NAME=${LIST[$(($CLIENT_NAME -1))]} CLIENT_NAME=${LIST[$((CLIENT_NAME -1))]}
fi fi
if ! grep -q "^${CLIENT_NAME} " configs/clients.txt; then if ! grep -q "^${CLIENT_NAME} " configs/clients.txt; then

View file

@ -79,7 +79,7 @@ for CLIENT_NAME in "${CLIENTS_TO_CHANGE[@]}"; do
re='^[0-9]+$' re='^[0-9]+$'
if [[ ${CLIENT_NAME} =~ $re ]] ; then if [[ ${CLIENT_NAME} =~ $re ]] ; then
CLIENT_NAME=${LIST[$(($CLIENT_NAME -1))]} CLIENT_NAME=${LIST[$((CLIENT_NAME -1))]}
fi fi
if ! grep -q "^${CLIENT_NAME} " configs/clients.txt; then if ! grep -q "^${CLIENT_NAME} " configs/clients.txt; then

View file

@ -55,7 +55,7 @@ fi
for CLIENT_NAME in "${CLIENTS_TO_SHOW[@]}"; do for CLIENT_NAME in "${CLIENTS_TO_SHOW[@]}"; do
re='^[0-9]+$' re='^[0-9]+$'
if [[ ${CLIENT_NAME} =~ $re ]] ; then if [[ ${CLIENT_NAME} =~ $re ]] ; then
CLIENT_NAME=${LIST[$(($CLIENT_NAME -1))]} CLIENT_NAME=${LIST[$((CLIENT_NAME -1))]}
fi fi
if grep -qw "${CLIENT_NAME}" clients.txt; then if grep -qw "${CLIENT_NAME}" clients.txt; then
echo -e "::: Showing client \e[1m${CLIENT_NAME}\e[0m below" echo -e "::: Showing client \e[1m${CLIENT_NAME}\e[0m below"

View file

@ -70,7 +70,7 @@ for CLIENT_NAME in "${CLIENTS_TO_REMOVE[@]}"; do
re='^[0-9]+$' re='^[0-9]+$'
if [[ ${CLIENT_NAME} =~ $re ]] ; then if [[ ${CLIENT_NAME} =~ $re ]] ; then
CLIENT_NAME=${LIST[$(($CLIENT_NAME -1))]} CLIENT_NAME=${LIST[$((CLIENT_NAME -1))]}
fi fi
if ! grep -q "^${CLIENT_NAME} " configs/clients.txt; then if ! grep -q "^${CLIENT_NAME} " configs/clients.txt; then