Merge b90c15512a7a6a773da90edbe3adcac65830785d into e2d4990ae194e37fd5162168a8aac5e2d89e0e8d

This commit is contained in:
Swamy Goundar 2025-02-19 04:05:08 +01:00 committed by GitHub
commit 5c3f71768e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1336,6 +1336,35 @@ function removeOpenVPN() {
fi fi
} }
function listCerts () {
# Original Script from PiVPN: list clients script
# Modified Script to add Certificate expiration Date -- psgoundar
INDEX="/etc/openvpn/easy-rsa/pki/index.txt"
printf "\\n"
if [ ! -f "${INDEX}" ]; then
echo "The file: $INDEX was not found!"
exit 1
fi
printf "\\e[1m::: Certificate Status List :::\\e[0m\\n"
printf "\\n%6s\\t%14s\\t%22s\\n" "Status" "Name" "Expiration"
printf '=%.0s' {1..50}
printf '\n'
while read -r line || [ -n "$line" ]; do
STATUS=$(echo "$line" | awk '{print $1}')
NAME=$(echo "$line" | cut -d '=' -f2)
EXPD=$(echo "$line" | awk '{if (length($3) == 13) print "20"$3; else print "20"$2}' | cut -b 1-8 | date +"%b %d %Y" -f -)
if [ "${STATUS}" == "V" ]; then
printf "Valid \t %s \t %s\\n" "$NAME" "$EXPD"
elif [ "${STATUS}" == "R" ]; then
printf "Revoked \t %s \t %s\\n" "$NAME" "$EXPD"
else
printf "Unknown \t %s \t %s\\n" "$NAME" "$EXPD"
fi
done <${INDEX} | column -t
printf "\\n"
}
function manageMenu() { function manageMenu() {
echo "Welcome to OpenVPN-install!" echo "Welcome to OpenVPN-install!"
echo "The git repository is available at: https://github.com/angristan/openvpn-install" echo "The git repository is available at: https://github.com/angristan/openvpn-install"
@ -1345,10 +1374,11 @@ function manageMenu() {
echo "What do you want to do?" echo "What do you want to do?"
echo " 1) Add a new user" echo " 1) Add a new user"
echo " 2) Revoke existing user" echo " 2) Revoke existing user"
echo " 3) Remove OpenVPN" echo " 3) List current issued certificates"
echo " 4) Exit" echo " 4) Remove OpenVPN"
until [[ $MENU_OPTION =~ ^[1-4]$ ]]; do echo " 5) Exit"
read -rp "Select an option [1-4]: " MENU_OPTION until [[ $MENU_OPTION =~ ^[1-5]$ ]]; do
read -rp "Select an option [1-5]: " MENU_OPTION
done done
case $MENU_OPTION in case $MENU_OPTION in
@ -1359,9 +1389,12 @@ function manageMenu() {
revokeClient revokeClient
;; ;;
3) 3)
removeOpenVPN listCerts
;; ;;
4) 4)
removeOpenVPN
;;
5)
exit 0 exit 0
;; ;;
esac esac