Fixes #23, enhance 'pivpn add', minor bug fixes & other enhancements

This commit is contained in:
Kaladin Light 2016-05-05 21:04:57 -04:00
parent 6f9d151530
commit dea112f50f
3 changed files with 33 additions and 2 deletions

View file

@ -63,6 +63,8 @@ else
PLAT="raspbian"
fi
echo "${PLAT}" > /tmp/DET_PLATFORM
####### FUNCTIONS ##########
spinner()
{
@ -733,6 +735,7 @@ confNetwork() {
confOVPN() {
IPv4pub=$(dig +short myip.opendns.com @resolver1.opendns.com)
$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
echo 0 > /tmp/REVOKE_STATUS

View file

@ -90,6 +90,11 @@ EOF
printf "Enter a Name for the Client: "
read NAME
if [[ -z "$NAME" ]]; then
printf '%s\n' "::: You can not leave this blank!"
exit 1
fi
cd /etc/openvpn/easy-rsa
source /etc/openvpn/easy-rsa/vars

View file

@ -3,6 +3,7 @@
INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER)
REVOKE_STATUS=$(cat /etc/pivpn/REVOKE_STATUS)
PLAT=$(cat /etc/pivpn/DET_PLATFORM)
INDEX="/etc/openvpn/easy-rsa/keys/index.txt"
if [ ! -f $INDEX ]; then
@ -14,12 +15,14 @@ fi
printf "\n"
printf " ::\e[4m Certificate List \e[0m:: \n"
i=0
while read -r line || [[ -n "$line" ]]; do
status=$(echo $line | awk '{print $1}')
if [[ $status = "V" ]]; then
var=$(echo $line | awk '{print $5}' | cut -d'/' -f7)
var=${var#CN=}
if [ "$var" != "server" ]; then
certs[$i]=$var
if [ "$i" != 0 ]; then
printf " $var\n"
fi
fi
@ -29,6 +32,22 @@ printf "\n"
echo "::: Please enter the Name of the client to be revoked from the list above:"
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
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 "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
if [[ ${PLAT} == "ubuntu" ]]; then
service openvpn restart
else
systemctl restart openvpn.service
fi
fi