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
|
|
|
|
|
2019-12-09 16:05:34 +00:00
|
|
|
{
|
2019-10-14 10:27:28 +00:00
|
|
|
# Present the user with a summary of the clients, fetching info from dates.
|
2019-12-09 16:05:34 +00:00
|
|
|
printf ": \e[4mClient\e[0m \t \e[4mCreation date\e[0m :\n"
|
2019-10-14 10:27:28 +00:00
|
|
|
|
|
|
|
while read -r LINE; do
|
|
|
|
CLIENT_NAME="$(awk '{print $1}' <<< "$LINE")"
|
|
|
|
|
|
|
|
CREATION_DATE="$(awk '{print $2}' <<< "$LINE")"
|
|
|
|
|
|
|
|
# Dates are converted from UNIX time to human readable.
|
|
|
|
CD_FORMAT="$(date -d @"$CREATION_DATE" +'%d %b %Y, %H:%M, %Z')"
|
|
|
|
|
2019-12-09 16:05:34 +00:00
|
|
|
printf "• $CLIENT_NAME \t $CD_FORMAT\n"
|
2019-10-14 10:27:28 +00:00
|
|
|
done < clients.txt
|
|
|
|
|
2019-12-09 16:05:34 +00:00
|
|
|
printf "\n"
|
|
|
|
} | column -t -s $'\t'
|