2019-10-14 10:27:28 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# PiVPN: list clients script
|
2020-03-29 02:36:55 +00:00
|
|
|
# Updated Script to include Expiration Dates and Clean up Escape Seq -- psgoundar
|
2019-10-14 10:27:28 +00:00
|
|
|
|
|
|
|
INDEX="/etc/openvpn/easy-rsa/pki/index.txt"
|
|
|
|
if [ ! -f "${INDEX}" ]; then
|
|
|
|
echo "The file: $INDEX was not found!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
printf ": NOTE : The first entry should always be your valid server!\n"
|
2020-03-29 02:36:55 +00:00
|
|
|
printf "\\n"
|
|
|
|
printf "\\e[1m::: Certificate Status List :::\\e[0m\\n"
|
2020-04-02 02:44:37 +00:00
|
|
|
{
|
|
|
|
printf "\\e[4mStatus\\e[0m \t \\e[4mName\\e[0m\\e[0m \t \\e[4mExpiration\\e[0m\\n"
|
2019-10-14 10:27:28 +00:00
|
|
|
|
|
|
|
while read -r line || [ -n "$line" ]; do
|
|
|
|
STATUS=$(echo "$line" | awk '{print $1}')
|
2020-03-29 03:48:44 +00:00
|
|
|
NAME=$(echo "$line" | awk '{print $5}' | awk -FCN= '{print $2}')
|
2020-03-29 02:36:55 +00:00
|
|
|
EXPD=$(echo "$line" | awk '{if (length($2) == 15) print $2; else print "20"$2}' | cut -b 1-8 | date +"%b %d %Y" -f -)
|
|
|
|
|
2019-10-14 10:27:28 +00:00
|
|
|
if [ "${STATUS}" == "V" ]; then
|
2020-04-02 02:44:37 +00:00
|
|
|
printf "Valid \t %s \t %s\\n" "$NAME" "$EXPD"
|
2019-10-14 10:27:28 +00:00
|
|
|
elif [ "${STATUS}" == "R" ]; then
|
2020-04-05 21:34:53 +00:00
|
|
|
printf "Revoked \t %s \t %s\\n" "$NAME" "$EXPD"
|
2019-10-14 10:27:28 +00:00
|
|
|
else
|
2020-04-02 02:44:37 +00:00
|
|
|
printf "Unknown \t %s \t %s\\n" "$NAME" "$EXPD"
|
2019-10-14 10:27:28 +00:00
|
|
|
fi
|
2020-03-29 02:36:55 +00:00
|
|
|
|
2020-04-02 02:44:37 +00:00
|
|
|
done <${INDEX}
|
|
|
|
printf "\\n"
|
|
|
|
} | column -t -s $'\t'
|