Remove .ovpn config files after uninstalling OpenVPN

Also remove the if $1 = user. I prefer to put all the config files in the same directory
This commit is contained in:
Angristan 2017-09-28 12:25:54 +02:00 committed by GitHub
parent 9562799ec2
commit ebe2a22bb8

View File

@ -57,9 +57,7 @@ fi
newclient () {
# Where to write the custom client.ovpn?
if [ -e /home/$1 ]; then # if $1 is a user name
homeDir="/home/$1"
elif [ ${SUDO_USER} ]; then # if not, use SUDO_USER
if [ ${SUDO_USER} ]; then # if not, use SUDO_USER
homeDir="/home/${SUDO_USER}"
else # if not SUDO_USER, use /root
homeDir="/root"
@ -191,6 +189,13 @@ if [[ -e /etc/openvpn/server.conf ]]; then
fi
rm -rf /etc/openvpn
rm -rf /usr/share/doc/openvpn*
# Where are the client files?
if [ ${SUDO_USER} ]; then # if not, use SUDO_USER
homeDir="/home/${SUDO_USER}"
else # if not SUDO_USER, use /root
homeDir="/root"
fi
rm $homeDir*/.ovpn
echo ""
echo "OpenVPN removed!"
else