From 4e0f9ac0ff100a6bf7b4a73ccfb577f83559cff7 Mon Sep 17 00:00:00 2001 From: redfast00 Date: Tue, 4 Oct 2016 20:22:04 +0200 Subject: [PATCH] Cleaned up listOVPN.sh --- scripts/listOVPN.sh | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/scripts/listOVPN.sh b/scripts/listOVPN.sh index 4ff34de..90b870d 100644 --- a/scripts/listOVPN.sh +++ b/scripts/listOVPN.sh @@ -3,9 +3,8 @@ INDEX="/etc/openvpn/easy-rsa/keys/index.txt" printf "\n" -if [ ! -f $INDEX ]; then - printf "The file: $INDEX \n" - printf "Was not Found!\n" +if [ ! -f "$INDEX" ]; then + echo "The file: $INDEX was not found!" exit 1 fi @@ -14,18 +13,15 @@ printf "\n" printf "\e[1m::: Certificate Status List :::\e[0m\n" printf " ::\e[4m Status \e[0m||\e[4m Name \e[0m:: \n" -while read -r line || [[ -n "$line" ]]; do - status=$(echo $line | awk '{print $1}') - var=$(echo $line | sed -e 's/^.*CN=\([^/]*\)\/.*/\1/') - if [[ $status = "V" ]]; then - printf " Valid :: " - printf " $var\n" - elif [[ $status = "R" ]]; then - printf " Revoked :: " - printf " $var\n" +while read -r line || [ -n "$line" ]; do + STATUS=$(echo "$line" | awk '{print $1}') + NAME=$(echo "$line" | sed -e 's/^.*CN=\([^/]*\)\/.*/\1/') + if [ "$STATUS" = "V" ]; then + printf " Valid :: %s\n" "$NAME" + elif [ "$STATUS" = "R" ]; then + printf " Revoked :: %s\n" "$NAME" else - printf " Unknown :: \n" - printf " $var\n" + printf " Unknown :: %s\n" "$NAME" fi done <$INDEX printf "\n"