2016-04-19 18:01:55 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# PiVPN: list clients script
|
|
|
|
|
|
|
|
INDEX="/etc/openvpn/easy-rsa/keys/index.txt"
|
|
|
|
printf "\n"
|
2016-10-04 18:22:04 +00:00
|
|
|
if [ ! -f "$INDEX" ]; then
|
|
|
|
echo "The file: $INDEX was not found!"
|
2016-04-19 18:01:55 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-04-22 19:16:48 +00:00
|
|
|
printf ": NOTE : The first entry should always be your valid server!\n"
|
2016-04-19 18:01:55 +00:00
|
|
|
printf "\n"
|
|
|
|
printf "\e[1m::: Certificate Status List :::\e[0m\n"
|
|
|
|
printf " ::\e[4m Status \e[0m||\e[4m Name \e[0m:: \n"
|
|
|
|
|
2016-10-04 18:22:04 +00:00
|
|
|
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"
|
2016-04-24 15:29:29 +00:00
|
|
|
else
|
2016-10-04 18:22:04 +00:00
|
|
|
printf " Unknown :: %s\n" "$NAME"
|
2016-04-19 18:01:55 +00:00
|
|
|
fi
|
|
|
|
done <$INDEX
|
|
|
|
printf "\n"
|