mirror of
https://github.com/Nyr/openvpn-install.git
synced 2024-11-23 21:46:08 +03:00
Small UX improvements
This commit is contained in:
parent
5b9f3b62b8
commit
6061a29028
@ -8,18 +8,18 @@
|
|||||||
# Detect Debian users running the script with "sh" instead of bash
|
# Detect Debian users running the script with "sh" instead of bash
|
||||||
if readlink /proc/$$/exe | grep -q "dash"; then
|
if readlink /proc/$$/exe | grep -q "dash"; then
|
||||||
echo "This script needs to be run with bash, not sh"
|
echo "This script needs to be run with bash, not sh"
|
||||||
exit 1
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$EUID" -ne 0 ]]; then
|
if [[ "$EUID" -ne 0 ]]; then
|
||||||
echo "Sorry, you need to run this as root"
|
echo "Sorry, you need to run this as root"
|
||||||
exit 2
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -e /dev/net/tun ]]; then
|
if [[ ! -e /dev/net/tun ]]; then
|
||||||
echo "The TUN device is not available
|
echo "The TUN device is not available
|
||||||
You need to enable TUN before running this script"
|
You need to enable TUN before running this script"
|
||||||
exit 3
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -e /etc/debian_version ]]; then
|
if [[ -e /etc/debian_version ]]; then
|
||||||
@ -32,7 +32,7 @@ elif [[ -e /etc/centos-release || -e /etc/redhat-release ]]; then
|
|||||||
RCLOCAL='/etc/rc.d/rc.local'
|
RCLOCAL='/etc/rc.d/rc.local'
|
||||||
else
|
else
|
||||||
echo "Looks like you aren't running this installer on Debian, Ubuntu or CentOS"
|
echo "Looks like you aren't running this installer on Debian, Ubuntu or CentOS"
|
||||||
exit 4
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
newclient () {
|
newclient () {
|
||||||
@ -69,7 +69,7 @@ if [[ -e /etc/openvpn/server.conf ]]; then
|
|||||||
echo
|
echo
|
||||||
echo "Tell me a name for the client certificate."
|
echo "Tell me a name for the client certificate."
|
||||||
echo "Please, use one word only, no special characters."
|
echo "Please, use one word only, no special characters."
|
||||||
read -p "Client name: " -e -i client CLIENT
|
read -p "Client name: " -e CLIENT
|
||||||
cd /etc/openvpn/easy-rsa/
|
cd /etc/openvpn/easy-rsa/
|
||||||
./easyrsa build-client-full $CLIENT nopass
|
./easyrsa build-client-full $CLIENT nopass
|
||||||
# Generates the custom client.ovpn
|
# Generates the custom client.ovpn
|
||||||
@ -85,7 +85,7 @@ if [[ -e /etc/openvpn/server.conf ]]; then
|
|||||||
if [[ "$NUMBEROFCLIENTS" = '0' ]]; then
|
if [[ "$NUMBEROFCLIENTS" = '0' ]]; then
|
||||||
echo
|
echo
|
||||||
echo "You have no existing clients!"
|
echo "You have no existing clients!"
|
||||||
exit 5
|
exit
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
echo "Select the existing client certificate you want to revoke:"
|
echo "Select the existing client certificate you want to revoke:"
|
||||||
@ -96,6 +96,9 @@ if [[ -e /etc/openvpn/server.conf ]]; then
|
|||||||
read -p "Select one client [1-$NUMBEROFCLIENTS]: " CLIENTNUMBER
|
read -p "Select one client [1-$NUMBEROFCLIENTS]: " CLIENTNUMBER
|
||||||
fi
|
fi
|
||||||
CLIENT=$(tail -n +2 /etc/openvpn/easy-rsa/pki/index.txt | grep "^V" | cut -d '=' -f 2 | sed -n "$CLIENTNUMBER"p)
|
CLIENT=$(tail -n +2 /etc/openvpn/easy-rsa/pki/index.txt | grep "^V" | cut -d '=' -f 2 | sed -n "$CLIENTNUMBER"p)
|
||||||
|
echo
|
||||||
|
read -p "Do you really want to revoke access for client $CLIENT? [y/N]: " -e REVOKE
|
||||||
|
if [[ "$REVOKE" = 'y' || "$REVOKE" = 'Y' ]]; then
|
||||||
cd /etc/openvpn/easy-rsa/
|
cd /etc/openvpn/easy-rsa/
|
||||||
./easyrsa --batch revoke $CLIENT
|
./easyrsa --batch revoke $CLIENT
|
||||||
EASYRSA_CRL_DAYS=3650 ./easyrsa gen-crl
|
EASYRSA_CRL_DAYS=3650 ./easyrsa gen-crl
|
||||||
@ -108,12 +111,16 @@ if [[ -e /etc/openvpn/server.conf ]]; then
|
|||||||
chown nobody:$GROUPNAME /etc/openvpn/crl.pem
|
chown nobody:$GROUPNAME /etc/openvpn/crl.pem
|
||||||
echo
|
echo
|
||||||
echo "Certificate for client $CLIENT revoked!"
|
echo "Certificate for client $CLIENT revoked!"
|
||||||
|
else
|
||||||
|
echo
|
||||||
|
echo "Certificate revocation for client $CLIENT aborted!"
|
||||||
|
fi
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
echo
|
echo
|
||||||
read -p "Do you really want to remove OpenVPN? [y/n]: " -e -i n REMOVE
|
read -p "Do you really want to remove OpenVPN? [y/N]: " -e REMOVE
|
||||||
if [[ "$REMOVE" = 'y' ]]; then
|
if [[ "$REMOVE" = 'y' || "$REMOVE" = 'Y' ]]; then
|
||||||
PORT=$(grep '^port ' /etc/openvpn/server.conf | cut -d " " -f 2)
|
PORT=$(grep '^port ' /etc/openvpn/server.conf | cut -d " " -f 2)
|
||||||
PROTOCOL=$(grep '^proto ' /etc/openvpn/server.conf | cut -d " " -f 2)
|
PROTOCOL=$(grep '^proto ' /etc/openvpn/server.conf | cut -d " " -f 2)
|
||||||
if pgrep firewalld; then
|
if pgrep firewalld; then
|
||||||
|
Loading…
Reference in New Issue
Block a user