mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-18 19:00:15 +00:00
Merge pull request #1000 from psgoundar/pivpn
Updated listOVPN to Include Expiration Dates
This commit is contained in:
commit
4e8d4dfd8e
1 changed files with 14 additions and 9 deletions
|
@ -1,27 +1,32 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# PiVPN: list clients script
|
# PiVPN: list clients script
|
||||||
|
# Updated Script to include Expiration Dates and Clean up Escape Seq -- psgoundar
|
||||||
|
|
||||||
INDEX="/etc/openvpn/easy-rsa/pki/index.txt"
|
INDEX="/etc/openvpn/easy-rsa/pki/index.txt"
|
||||||
printf "\n"
|
|
||||||
if [ ! -f "${INDEX}" ]; then
|
if [ ! -f "${INDEX}" ]; then
|
||||||
echo "The file: $INDEX was not found!"
|
echo "The file: $INDEX was not found!"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf ": NOTE : The first entry should always be your valid server!\n"
|
printf ": NOTE : The first entry should always be your valid server!\n"
|
||||||
printf "\n"
|
printf "\\n"
|
||||||
printf "\e[1m::: Certificate Status List :::\e[0m\n"
|
printf "\\e[1m::: Certificate Status List :::\\e[0m\\n"
|
||||||
printf " ::\e[4m Status \e[0m||\e[4m Name \e[0m:: \n"
|
{
|
||||||
|
printf "\\e[4mStatus\\e[0m \t \\e[4mName\\e[0m\\e[0m \t \\e[4mExpiration\\e[0m\\n"
|
||||||
|
|
||||||
while read -r line || [ -n "$line" ]; do
|
while read -r line || [ -n "$line" ]; do
|
||||||
STATUS=$(echo "$line" | awk '{print $1}')
|
STATUS=$(echo "$line" | awk '{print $1}')
|
||||||
NAME=$(echo "$line" | sed -e 's:.*/CN=::')
|
NAME=$(echo "$line" | awk '{print $5}' | awk -FCN= '{print $2}')
|
||||||
|
EXPD=$(echo "$line" | awk '{if (length($2) == 15) print $2; else print "20"$2}' | cut -b 1-8 | date +"%b %d %Y" -f -)
|
||||||
|
|
||||||
if [ "${STATUS}" == "V" ]; then
|
if [ "${STATUS}" == "V" ]; then
|
||||||
printf " Valid :: %s\n" "$NAME"
|
printf "Valid \t %s \t %s\\n" "$NAME" "$EXPD"
|
||||||
elif [ "${STATUS}" == "R" ]; then
|
elif [ "${STATUS}" == "R" ]; then
|
||||||
printf " Revoked :: %s\n" "$NAME"
|
printf "Revoked \t %s \t %s\\n" "$NAME" "$EXPD"
|
||||||
else
|
else
|
||||||
printf " Unknown :: %s\n" "$NAME"
|
printf "Unknown \t %s \t %s\\n" "$NAME" "$EXPD"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done <${INDEX}
|
done <${INDEX}
|
||||||
printf "\n"
|
printf "\\n"
|
||||||
|
} | column -t -s $'\t'
|
||||||
|
|
Loading…
Reference in a new issue