Properly determine user's home directory

Code assumes that the specified user directory is under /home.  This code parses the /etc/passwd file in order to determine what that user's proper home directory is.
This commit is contained in:
Douglas Orend 2019-08-13 11:23:08 -05:00
parent 8e3a951524
commit 8b40035bf5
4 changed files with 13 additions and 9 deletions

View file

@ -17,6 +17,7 @@ else
fi
INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER)
INSTALL_HOME=$(cat /etc/passwd | grep "$INSTALL_USER" | cut -d: -f6)
PLAT=$(cat /etc/pivpn/DET_PLATFORM)
NO_UFW=$(cat /etc/pivpn/NO_UFW)
PORT=$(cat /etc/pivpn/INSTALL_PORT)
@ -83,7 +84,7 @@ echo ":::"
echo "::: Removing pivpn system files..."
$SUDO rm -rf /opt/pivpn &> /dev/null
$SUDO rm -rf /etc/.pivpn &> /dev/null
$SUDO rm -rf /home/$INSTALL_USER/ovpns &> /dev/null
$SUDO rm -rf $INSTALL_HOME/ovpns &> /dev/null
$SUDO rm -rf /var/log/*pivpn* &> /dev/null
$SUDO rm -rf /var/log/*openvpn* &> /dev/null