Fixed shellcheck warning SC2164: "Use 'cd ... || exit' or 'cd ... || return' in case cd fails."

This commit is contained in:
Dundar Göc 2021-02-13 12:09:11 +01:00
parent 8d2a800851
commit fe636e3f43
7 changed files with 7 additions and 7 deletions

View file

@ -44,7 +44,7 @@ do
shift shift
done done
cd /etc/wireguard cd /etc/wireguard || exit
if [ ! -s configs/clients.txt ]; then if [ ! -s configs/clients.txt ]; then
echo "::: There are no clients to change" echo "::: There are no clients to change"
exit 1 exit 1

View file

@ -44,7 +44,7 @@ do
shift shift
done done
cd /etc/wireguard cd /etc/wireguard || exit
if [ ! -s configs/clients.txt ]; then if [ ! -s configs/clients.txt ]; then
echo "::: There are no clients to change" echo "::: There are no clients to change"
exit 1 exit 1

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
cd /etc/wireguard/configs cd /etc/wireguard/configs || exit
if [ ! -s clients.txt ]; then if [ ! -s clients.txt ]; then
echo "::: There are no clients to list" echo "::: There are no clients to list"
exit 1 exit 1

View file

@ -53,7 +53,7 @@ if [ ! -d "${install_home}/configs" ]; then
chmod 0750 "${install_home}/configs" chmod 0750 "${install_home}/configs"
fi fi
cd /etc/wireguard cd /etc/wireguard || exit
if [ -z "${CLIENT_NAME}" ]; then if [ -z "${CLIENT_NAME}" ]; then
read -r -p "Enter a Name for the Client: " CLIENT_NAME read -r -p "Enter a Name for the Client: " CLIENT_NAME

View file

@ -19,7 +19,7 @@ echo -e "::::\t \e[4mInstallation settings\e[0m \t ::::"
sed "s/$pivpnHOST/REDACTED/" < ${setupVars} sed "s/$pivpnHOST/REDACTED/" < ${setupVars}
printf "=============================================\n" printf "=============================================\n"
echo -e ":::: \e[4mServer configuration shown below\e[0m ::::" echo -e ":::: \e[4mServer configuration shown below\e[0m ::::"
cd /etc/wireguard/keys cd /etc/wireguard/keys || exit
cp ../wg0.conf ../wg0.tmp cp ../wg0.conf ../wg0.tmp
# Replace every key in the server configuration with just its file name # Replace every key in the server configuration with just its file name
for k in *; do for k in *; do

View file

@ -27,7 +27,7 @@ do
shift shift
done done
cd /etc/wireguard/configs cd /etc/wireguard/configs || exit
if [ ! -s clients.txt ]; then if [ ! -s clients.txt ]; then
echo "::: There are no clients to show" echo "::: There are no clients to show"
exit 1 exit 1

View file

@ -40,7 +40,7 @@ do
shift shift
done done
cd /etc/wireguard cd /etc/wireguard || exit
if [ ! -s configs/clients.txt ]; then if [ ! -s configs/clients.txt ]; then
echo "::: There are no clients to remove" echo "::: There are no clients to remove"
exit 1 exit 1