mirror of
https://github.com/hwdsl2/openvpn-install.git
synced 2026-01-11 19:06:18 +00:00
Add list clients option
- Add an option to list existing clients.
This commit is contained in:
@@ -623,11 +623,12 @@ else
|
|||||||
echo "Select an option:"
|
echo "Select an option:"
|
||||||
echo " 1) Add a new client"
|
echo " 1) Add a new client"
|
||||||
echo " 2) Export config for an existing client"
|
echo " 2) Export config for an existing client"
|
||||||
echo " 3) Revoke an existing client"
|
echo " 3) List existing clients"
|
||||||
echo " 4) Remove OpenVPN"
|
echo " 4) Revoke an existing client"
|
||||||
echo " 5) Exit"
|
echo " 5) Remove OpenVPN"
|
||||||
|
echo " 6) Exit"
|
||||||
read -rp "Option: " option
|
read -rp "Option: " option
|
||||||
until [[ "$option" =~ ^[1-5]$ ]]; do
|
until [[ "$option" =~ ^[1-6]$ ]]; do
|
||||||
echo "$option: invalid selection."
|
echo "$option: invalid selection."
|
||||||
read -rp "Option: " option
|
read -rp "Option: " option
|
||||||
done
|
done
|
||||||
@@ -679,8 +680,18 @@ else
|
|||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
# This option could be documented a bit better and maybe even be simplified
|
echo
|
||||||
# ...but what can I say, I want some sleep too
|
echo "Checking for existing client(s)..."
|
||||||
|
number_of_clients=$(tail -n +2 /etc/openvpn/server/easy-rsa/pki/index.txt | grep -c "^V")
|
||||||
|
if [[ "$number_of_clients" = 0 ]]; then
|
||||||
|
echo
|
||||||
|
echo "There are no existing clients!"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
tail -n +2 /etc/openvpn/server/easy-rsa/pki/index.txt | grep "^V" | cut -d '=' -f 2
|
||||||
|
;;
|
||||||
|
4)
|
||||||
number_of_clients=$(tail -n +2 /etc/openvpn/server/easy-rsa/pki/index.txt | grep -c "^V")
|
number_of_clients=$(tail -n +2 /etc/openvpn/server/easy-rsa/pki/index.txt | grep -c "^V")
|
||||||
if [[ "$number_of_clients" = 0 ]]; then
|
if [[ "$number_of_clients" = 0 ]]; then
|
||||||
echo
|
echo
|
||||||
@@ -731,7 +742,7 @@ else
|
|||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
4)
|
5)
|
||||||
echo
|
echo
|
||||||
read -rp "Confirm OpenVPN removal? [y/N]: " remove
|
read -rp "Confirm OpenVPN removal? [y/N]: " remove
|
||||||
until [[ "$remove" =~ ^[yYnN]*$ ]]; do
|
until [[ "$remove" =~ ^[yYnN]*$ ]]; do
|
||||||
@@ -796,7 +807,7 @@ else
|
|||||||
fi
|
fi
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
5)
|
6)
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user