2016-04-19 14:01:55 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# PiVPN: list clients script
|
|
|
|
|
2016-12-06 10:56:51 -05:00
|
|
|
INDEX="/etc/openvpn/easy-rsa/pki/index.txt"
|
2016-04-19 14:01:55 -04:00
|
|
|
printf "\n"
|
2016-12-06 10:56:51 -05:00
|
|
|
if [ ! -f "${INDEX}" ]; then
|
2016-10-04 20:22:04 +02:00
|
|
|
echo "The file: $INDEX was not found!"
|
2016-04-19 14:01:55 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-04-22 15:16:48 -04:00
|
|
|
printf ": NOTE : The first entry should always be your valid server!\n"
|
2016-04-19 14:01:55 -04: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 20:22:04 +02:00
|
|
|
while read -r line || [ -n "$line" ]; do
|
|
|
|
STATUS=$(echo "$line" | awk '{print $1}')
|
2016-12-06 10:56:51 -05:00
|
|
|
NAME=$(echo "$line" | sed -e 's:.*/CN=::')
|
|
|
|
if [ "${STATUS}" == "V" ]; then
|
2016-10-04 20:22:04 +02:00
|
|
|
printf " Valid :: %s\n" "$NAME"
|
2016-12-06 10:56:51 -05:00
|
|
|
elif [ "${STATUS}" == "R" ]; then
|
2016-10-04 20:22:04 +02:00
|
|
|
printf " Revoked :: %s\n" "$NAME"
|
2016-04-24 11:29:29 -04:00
|
|
|
else
|
2016-10-04 20:22:04 +02:00
|
|
|
printf " Unknown :: %s\n" "$NAME"
|
2016-04-19 14:01:55 -04:00
|
|
|
fi
|
2016-12-06 10:56:51 -05:00
|
|
|
done <${INDEX}
|
2016-04-19 14:01:55 -04:00
|
|
|
printf "\n"
|