mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-18 19:00:15 +00:00
Fixes #23, enhance 'pivpn add', minor bug fixes & other enhancements
This commit is contained in:
parent
6f9d151530
commit
dea112f50f
3 changed files with 33 additions and 2 deletions
|
@ -63,6 +63,8 @@ else
|
||||||
PLAT="raspbian"
|
PLAT="raspbian"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "${PLAT}" > /tmp/DET_PLATFORM
|
||||||
|
|
||||||
####### FUNCTIONS ##########
|
####### FUNCTIONS ##########
|
||||||
spinner()
|
spinner()
|
||||||
{
|
{
|
||||||
|
@ -733,6 +735,7 @@ confNetwork() {
|
||||||
confOVPN() {
|
confOVPN() {
|
||||||
IPv4pub=$(dig +short myip.opendns.com @resolver1.opendns.com)
|
IPv4pub=$(dig +short myip.opendns.com @resolver1.opendns.com)
|
||||||
$SUDO cp /tmp/pivpnUSR /etc/pivpn/INSTALL_USER
|
$SUDO cp /tmp/pivpnUSR /etc/pivpn/INSTALL_USER
|
||||||
|
$SUDO cp /tmp/DET_PLATFORM /etc/pivpn/DET_PLATFORM
|
||||||
|
|
||||||
# Set status that no certs have been revoked
|
# Set status that no certs have been revoked
|
||||||
echo 0 > /tmp/REVOKE_STATUS
|
echo 0 > /tmp/REVOKE_STATUS
|
||||||
|
|
|
@ -90,6 +90,11 @@ EOF
|
||||||
printf "Enter a Name for the Client: "
|
printf "Enter a Name for the Client: "
|
||||||
read NAME
|
read NAME
|
||||||
|
|
||||||
|
if [[ -z "$NAME" ]]; then
|
||||||
|
printf '%s\n' "::: You can not leave this blank!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
cd /etc/openvpn/easy-rsa
|
cd /etc/openvpn/easy-rsa
|
||||||
source /etc/openvpn/easy-rsa/vars
|
source /etc/openvpn/easy-rsa/vars
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER)
|
INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER)
|
||||||
REVOKE_STATUS=$(cat /etc/pivpn/REVOKE_STATUS)
|
REVOKE_STATUS=$(cat /etc/pivpn/REVOKE_STATUS)
|
||||||
|
PLAT=$(cat /etc/pivpn/DET_PLATFORM)
|
||||||
INDEX="/etc/openvpn/easy-rsa/keys/index.txt"
|
INDEX="/etc/openvpn/easy-rsa/keys/index.txt"
|
||||||
|
|
||||||
if [ ! -f $INDEX ]; then
|
if [ ! -f $INDEX ]; then
|
||||||
|
@ -14,12 +15,14 @@ fi
|
||||||
printf "\n"
|
printf "\n"
|
||||||
printf " ::\e[4m Certificate List \e[0m:: \n"
|
printf " ::\e[4m Certificate List \e[0m:: \n"
|
||||||
|
|
||||||
|
i=0
|
||||||
while read -r line || [[ -n "$line" ]]; do
|
while read -r line || [[ -n "$line" ]]; do
|
||||||
status=$(echo $line | awk '{print $1}')
|
status=$(echo $line | awk '{print $1}')
|
||||||
if [[ $status = "V" ]]; then
|
if [[ $status = "V" ]]; then
|
||||||
var=$(echo $line | awk '{print $5}' | cut -d'/' -f7)
|
var=$(echo $line | awk '{print $5}' | cut -d'/' -f7)
|
||||||
var=${var#CN=}
|
var=${var#CN=}
|
||||||
if [ "$var" != "server" ]; then
|
certs[$i]=$var
|
||||||
|
if [ "$i" != 0 ]; then
|
||||||
printf " $var\n"
|
printf " $var\n"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -29,6 +32,22 @@ printf "\n"
|
||||||
echo "::: Please enter the Name of the client to be revoked from the list above:"
|
echo "::: Please enter the Name of the client to be revoked from the list above:"
|
||||||
read NAME
|
read NAME
|
||||||
|
|
||||||
|
if [[ -z "$NAME" ]]; then
|
||||||
|
printf '%s\n' "::: You can not leave this blank!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
for((x=1;x<=$y;++x)) do
|
||||||
|
if [[ ${certs[$x]} = ${NAME} ]]; then
|
||||||
|
Valid=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ -z "$Valid" ]]; then
|
||||||
|
printf "::: You didn't enter a valid cert name!\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
cd /etc/openvpn/easy-rsa
|
cd /etc/openvpn/easy-rsa
|
||||||
source /etc/openvpn/easy-rsa/vars
|
source /etc/openvpn/easy-rsa/vars
|
||||||
|
|
||||||
|
@ -43,5 +62,9 @@ if [ $REVOKE_STATUS == 0 ]; then
|
||||||
printf "\nThis seems to be the first time you have revoked a cert.\n"
|
printf "\nThis seems to be the first time you have revoked a cert.\n"
|
||||||
printf "We are adding the CRL to the server.conf and restarting openvpn.\n"
|
printf "We are adding the CRL to the server.conf and restarting openvpn.\n"
|
||||||
sed -i '/#crl-verify/c\crl-verify /etc/openvpn/crl.pem' /etc/openvpn/server.conf
|
sed -i '/#crl-verify/c\crl-verify /etc/openvpn/crl.pem' /etc/openvpn/server.conf
|
||||||
systemctl restart openvpn.service
|
if [[ ${PLAT} == "ubuntu" ]]; then
|
||||||
|
service openvpn restart
|
||||||
|
else
|
||||||
|
systemctl restart openvpn.service
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue