1
0
Fork 0
mirror of https://github.com/pivpn/pivpn.git synced 2024-12-25 22:30:15 +00:00
pivpn/scripts/wireguard/listCONF.sh

28 lines
743 B
Bash
Raw Normal View History

2019-10-14 10:27:28 +00:00
#!/bin/bash
cd /etc/wireguard/configs
if [ ! -s clients.txt ]; then
echo "::: There are no clients to list"
exit 1
fi
printf "\e[1m::: Clients Summary :::\e[0m\n"
2019-10-14 10:27:28 +00:00
# Present the user with a summary of the clients, fetching info from dates.
{
echo -e "\e[4mClient\e[0m \t \e[4mPublic key\e[0m \t \e[4mCreation date\e[0m"
2019-10-14 10:27:28 +00:00
while read -r LINE; do
CLIENT_NAME="$(awk '{print $1}' <<< "$LINE")"
PUBLIC_KEY="$(awk '{print $2}' <<< "$LINE")"
CREATION_DATE="$(awk '{print $3}' <<< "$LINE")"
2019-10-14 10:27:28 +00:00
# Dates are converted from UNIX time to human readable.
CD_FORMAT="$(date -d @"$CREATION_DATE" +'%d %b %Y, %H:%M, %Z')"
echo -e "$CLIENT_NAME \t $PUBLIC_KEY \t $CD_FORMAT"
2019-10-14 10:27:28 +00:00
done < clients.txt
} | column -t -s $'\t'