diff --git a/openvpn-install b/openvpn-install new file mode 160000 index 0000000..95be2fa --- /dev/null +++ b/openvpn-install @@ -0,0 +1 @@ +Subproject commit 95be2fa3f039c6d9667430c3b858e03da606199b diff --git a/openvpn-install.sh b/openvpn-install.sh index 5f49ada..3f7effd 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -1291,6 +1291,34 @@ function removeOpenVPN() { 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 "\\e[4mStatus\\e[0m :: \\e[4mName\\e[0m\\e[0m :: \\e[4mExpiration \\e[0m\\n" +while read -r line || [ -n "$line" ]; do + STATUS=$(echo "$line" | awk '{print $1}') + 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 + printf " Valid :: %s :: %s\\n" "$NAME" "$EXPD" + elif [ "${STATUS}" == "R" ]; then + #printf " Revoked :: %s :: %s\\n" "$NAME" "$EXPD" + continue + else + printf " Unknown :: %s :: %s\\n" "$NAME" "$EXPD" + fi +done <${INDEX} | column -t +printf "\\n" +} + function manageMenu() { echo "Welcome to OpenVPN-install!" echo "The git repository is available at: https://github.com/angristan/openvpn-install" @@ -1300,10 +1328,11 @@ function manageMenu() { echo "What do you want to do?" echo " 1) Add a new user" echo " 2) Revoke existing user" - echo " 3) Remove OpenVPN" - echo " 4) Exit" - until [[ $MENU_OPTION =~ ^[1-4]$ ]]; do - read -rp "Select an option [1-4]: " MENU_OPTION + echo " 3) List Current Issued Certificates" + echo " 4) Remove OpenVPN" + echo " 5) Exit" + until [[ $MENU_OPTION =~ ^[1-5]$ ]]; do + read -rp "Select an option [1-5]: " MENU_OPTION done case $MENU_OPTION in @@ -1314,9 +1343,12 @@ function manageMenu() { revokeClient ;; 3) - removeOpenVPN + listcerts ;; 4) + removeOpenVPN + ;; + 5) exit 0 ;; esac