diff --git a/auto_install/install.sh b/auto_install/install.sh index fd96ff0..bedbb8e 100755 --- a/auto_install/install.sh +++ b/auto_install/install.sh @@ -1131,10 +1131,11 @@ confOVPN() { # verify server name to strengthen security $SUDO sed -i "s/SRVRNAME/${SERVER_NAME}/" /etc/openvpn/easy-rsa/pki/Default.txt - if [ ! -d "/home/$pivpnUser/ovpns" ]; then - $SUDO mkdir "/home/$pivpnUser/ovpns" + INSTALL_HOME=$(cat /etc/passwd | grep "$INSTALL_USER" | cut -d: -f6) + if [ ! -d "$INSTALL_HOME/ovpns" ]; then + $SUDO mkdir "$INSTALL_HOME/ovpns" fi - $SUDO chmod 0777 -R "/home/$pivpnUser/ovpns" + $SUDO chmod 0777 -R "$INSTALL_HOME/ovpns" } confLogging() { diff --git a/scripts/makeOVPN.sh b/scripts/makeOVPN.sh index 150f954..29605eb 100755 --- a/scripts/makeOVPN.sh +++ b/scripts/makeOVPN.sh @@ -403,15 +403,16 @@ if [ $RESPONSE == "y" ] || [ $RESPONSE == "Y" ]; then fi # Copy the .ovpn profile to the home directory for convenient remote access -cp "/etc/openvpn/easy-rsa/pki/$NAME$FILEEXT" "/home/$INSTALL_USER/ovpns/$NAME$FILEEXT" -chown "$INSTALL_USER" "/home/$INSTALL_USER/ovpns/$NAME$FILEEXT" -chmod o-r "/etc/openvpn/easy-rsa/pki/$NAME$FILEEXT" -chmod o-r "/home/$INSTALL_USER/ovpns/$NAME$FILEEXT" +INSTALL_HOME=$(cat /etc/passwd | grep "$INSTALL_USER" | cut -d: -f6) +cp "/etc/openvpn/easy-rsa/pki/$NAME$FILEEXT" "$INSTALL_HOME/ovpns/$NAME$FILEEXT" +chown "$INSTALL_USER" "$INSTALL_HOME/ovpns/$NAME$FILEEXT" +chmod 640 "/etc/openvpn/easy-rsa/pki/$NAME$FILEEXT" +chmod 640 "$INSTALL_HOME/ovpns/$NAME$FILEEXT" printf "\n\n" printf "========================================================\n" printf "\e[1mDone! %s successfully created!\e[0m \n" "$NAME$FILEEXT" printf "%s was copied to:\n" "$NAME$FILEEXT" -printf " /home/%s/ovpns\n" "$INSTALL_USER" +printf " %s/ovpns\n" "$INSTALL_HOME" printf "for easy transfer. Please use this profile only on one\n" printf "device and create additional profiles for other devices.\n" printf "========================================================\n\n" diff --git a/scripts/removeOVPN.sh b/scripts/removeOVPN.sh index 4503358..462b25c 100755 --- a/scripts/removeOVPN.sh +++ b/scripts/removeOVPN.sh @@ -104,6 +104,7 @@ fi cd /etc/openvpn/easy-rsa || exit +INSTALL_HOME=$(cat /etc/passwd | grep "$INSTALL_USER" | cut -d: -f6) for (( ii = 0; ii < ${#CERTS_TO_REVOKE[@]}; ii++)); do printf "\n::: Revoking certificate '"%s"'.\n" "${CERTS_TO_REVOKE[ii]}" ./easyrsa --batch revoke "${CERTS_TO_REVOKE[ii]}" @@ -113,7 +114,8 @@ for (( ii = 0; ii < ${#CERTS_TO_REVOKE[@]}; ii++)); do rm -rf "pki/reqs/${CERTS_TO_REVOKE[ii]}.req" rm -rf "pki/private/${CERTS_TO_REVOKE[ii]}.key" rm -rf "pki/issued/${CERTS_TO_REVOKE[ii]}.crt" - rm -rf "/home/${INSTALL_USER}/ovpns/${CERTS_TO_REVOKE[ii]}.ovpn*" + + rm -rf "${INSTALL_HOME}/ovpns/${CERTS_TO_REVOKE[ii]}.ovpn" rm -rf "/etc/openvpn/easy-rsa/pki/${CERTS_TO_REVOKE[ii]}.ovpn" cp /etc/openvpn/easy-rsa/pki/crl.pem /etc/openvpn/crl.pem done diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh index 9ca8cbc..ecd2765 100755 --- a/scripts/uninstall.sh +++ b/scripts/uninstall.sh @@ -2,6 +2,7 @@ # PiVPN: Uninstall Script 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) OLD_UFW=$(cat /etc/pivpn/NO_UFW) @@ -69,9 +70,10 @@ echo ":::" echo ":::" # Removing pivpn files echo "::: Removing pivpn system files..." - rm -rf /opt/pivpn &> /dev/null - rm -rf /etc/.pivpn &> /dev/null - rm -rf /home/$INSTALL_USER/ovpns &> /dev/null + + $SUDO rm -rf /opt/pivpn &> /dev/null + $SUDO rm -rf /etc/.pivpn &> /dev/null + $SUDO rm -rf $INSTALL_HOME/ovpns &> /dev/null rm -rf /var/log/*pivpn* &> /dev/null rm -rf /var/log/*openvpn* &> /dev/null