Cleaned up listOVPN.sh

This commit is contained in:
redfast00 2016-10-04 20:22:04 +02:00
parent caee0858cf
commit 4e0f9ac0ff
No known key found for this signature in database
GPG key ID: B7DD106EAC545F95

View file

@ -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"