mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-20 03:40:17 +00:00
Merge pull request #817 from MichaIng/patch-1
Failsafe home dir obtaining
This commit is contained in:
commit
567368c29c
4 changed files with 12 additions and 8 deletions
|
@ -1131,7 +1131,8 @@ confOVPN() {
|
||||||
# verify server name to strengthen security
|
# verify server name to strengthen security
|
||||||
$SUDO sed -i "s/SRVRNAME/${SERVER_NAME}/" /etc/openvpn/easy-rsa/pki/Default.txt
|
$SUDO sed -i "s/SRVRNAME/${SERVER_NAME}/" /etc/openvpn/easy-rsa/pki/Default.txt
|
||||||
|
|
||||||
INSTALL_HOME=$(cat /etc/passwd | grep "$INSTALL_USER" | cut -d: -f6)
|
INSTALL_HOME=$(grep -m1 "^${INSTALL_USER}:" /etc/passwd | cut -d: -f6)
|
||||||
|
INSTALL_HOME=${INSTALL_HOME%/} # remove possible trailing slash
|
||||||
if [ ! -d "$INSTALL_HOME/ovpns" ]; then
|
if [ ! -d "$INSTALL_HOME/ovpns" ]; then
|
||||||
$SUDO mkdir "$INSTALL_HOME/ovpns"
|
$SUDO mkdir "$INSTALL_HOME/ovpns"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -8,7 +8,7 @@ KEY=".key"
|
||||||
CA="ca.crt"
|
CA="ca.crt"
|
||||||
TA="ta.key"
|
TA="ta.key"
|
||||||
INDEX="/etc/openvpn/easy-rsa/pki/index.txt"
|
INDEX="/etc/openvpn/easy-rsa/pki/index.txt"
|
||||||
INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER)
|
INSTALL_USER=$(</etc/pivpn/INSTALL_USER)
|
||||||
|
|
||||||
helpFunc() {
|
helpFunc() {
|
||||||
echo "::: Create a client ovpn profile, optional nopass"
|
echo "::: Create a client ovpn profile, optional nopass"
|
||||||
|
@ -403,7 +403,8 @@ if [ $RESPONSE == "y" ] || [ $RESPONSE == "Y" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy the .ovpn profile to the home directory for convenient remote access
|
# Copy the .ovpn profile to the home directory for convenient remote access
|
||||||
INSTALL_HOME=$(cat /etc/passwd | grep "$INSTALL_USER" | cut -d: -f6)
|
INSTALL_HOME=$(grep -m1 "^${INSTALL_USER}:" /etc/passwd | cut -d: -f6)
|
||||||
|
INSTALL_HOME=${INSTALL_HOME%/} # remove possible trailing slash
|
||||||
cp "/etc/openvpn/easy-rsa/pki/$NAME$FILEEXT" "$INSTALL_HOME/ovpns/$NAME$FILEEXT"
|
cp "/etc/openvpn/easy-rsa/pki/$NAME$FILEEXT" "$INSTALL_HOME/ovpns/$NAME$FILEEXT"
|
||||||
chown "$INSTALL_USER" "$INSTALL_HOME/ovpns/$NAME$FILEEXT"
|
chown "$INSTALL_USER" "$INSTALL_HOME/ovpns/$NAME$FILEEXT"
|
||||||
chmod 640 "/etc/openvpn/easy-rsa/pki/$NAME$FILEEXT"
|
chmod 640 "/etc/openvpn/easy-rsa/pki/$NAME$FILEEXT"
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# PiVPN: revoke client script
|
# PiVPN: revoke client script
|
||||||
|
|
||||||
INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER)
|
INSTALL_USER=$(</etc/pivpn/INSTALL_USER)
|
||||||
PLAT=$(cat /etc/pivpn/DET_PLATFORM)
|
PLAT=$(</etc/pivpn/DET_PLATFORM)
|
||||||
INDEX="/etc/openvpn/easy-rsa/pki/index.txt"
|
INDEX="/etc/openvpn/easy-rsa/pki/index.txt"
|
||||||
|
|
||||||
helpFunc() {
|
helpFunc() {
|
||||||
|
@ -104,7 +104,8 @@ fi
|
||||||
|
|
||||||
cd /etc/openvpn/easy-rsa || exit
|
cd /etc/openvpn/easy-rsa || exit
|
||||||
|
|
||||||
INSTALL_HOME=$(cat /etc/passwd | grep "$INSTALL_USER" | cut -d: -f6)
|
INSTALL_HOME=$(grep -m1 "^${INSTALL_USER}:" /etc/passwd | cut -d: -f6)
|
||||||
|
INSTALL_HOME=${INSTALL_HOME%/} # remove possible trailing slash
|
||||||
for (( ii = 0; ii < ${#CERTS_TO_REVOKE[@]}; ii++)); do
|
for (( ii = 0; ii < ${#CERTS_TO_REVOKE[@]}; ii++)); do
|
||||||
printf "\n::: Revoking certificate '"%s"'.\n" "${CERTS_TO_REVOKE[ii]}"
|
printf "\n::: Revoking certificate '"%s"'.\n" "${CERTS_TO_REVOKE[ii]}"
|
||||||
./easyrsa --batch revoke "${CERTS_TO_REVOKE[ii]}"
|
./easyrsa --batch revoke "${CERTS_TO_REVOKE[ii]}"
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
# PiVPN: Uninstall Script
|
# PiVPN: Uninstall Script
|
||||||
|
|
||||||
INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER)
|
INSTALL_USER=$(cat /etc/pivpn/INSTALL_USER)
|
||||||
INSTALL_HOME=$(cat /etc/passwd | grep "$INSTALL_USER" | cut -d: -f6)
|
INSTALL_HOME=$(grep -m1 "^${INSTALL_USER}:" /etc/passwd | cut -d: -f6)
|
||||||
|
INSTALL_HOME=${INSTALL_HOME%/} # remove possible trailing slash
|
||||||
PLAT=$(cat /etc/pivpn/DET_PLATFORM)
|
PLAT=$(cat /etc/pivpn/DET_PLATFORM)
|
||||||
NO_UFW=$(cat /etc/pivpn/NO_UFW)
|
NO_UFW=$(cat /etc/pivpn/NO_UFW)
|
||||||
OLD_UFW=$(cat /etc/pivpn/NO_UFW)
|
OLD_UFW=$(cat /etc/pivpn/NO_UFW)
|
||||||
|
|
Loading…
Reference in a new issue