Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Certificate List Function V2 #669

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions openvpn-install
Submodule openvpn-install added at 95be2f
42 changes: 37 additions & 5 deletions openvpn-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,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"
psgoundar marked this conversation as resolved.
Show resolved Hide resolved
while read -r line || [ -n "$line" ]; do
STATUS=$(echo "$line" | awk '{print $1}')
NAME=$(echo "$line" | awk '{print $5}' | awk -FCN= '{print $2}')
psgoundar marked this conversation as resolved.
Show resolved Hide resolved
EXPD=$(echo "$line" | awk '{if (length($2) == 15) print $2; else print "20"$2}' | cut -b 1-8 | date +"%b %d %Y" -f -)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expiration date is wrong for revoked clients, we should use the column provided instead of calculating it.

psgoundar marked this conversation as resolved.
Show resolved Hide resolved

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use \t instead of multiple spaces?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to Tabs

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"
Expand All @@ -1295,10 +1323,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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the same casing as the other options

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed Casing

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
Expand All @@ -1309,9 +1338,12 @@ function manageMenu() {
revokeClient
;;
3)
removeOpenVPN
listcerts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the same casing as the other functions and remove the added space

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed Casing

;;
4)
removeOpenVPN
;;
5)
exit 0
;;
esac
Expand Down