mirror of
https://github.com/angristan/openvpn-install.git
synced 2024-12-04 14:35:31 +01:00
add CLIENT_FILEPATH environment variable support
This environment variable can be set to customize destination of .ovpn file to generate. If defined, it should contain the full path of the file to generate.
This commit is contained in:
parent
610d42e6b2
commit
1182e98aed
@ -1093,26 +1093,28 @@ function newClient() {
|
|||||||
echo "Client $CLIENT added."
|
echo "Client $CLIENT added."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Home directory of the user, where the client configuration will be written
|
if [[ -z "$CLIENT_FILEPATH" ]]; then
|
||||||
if [ -e "/home/${CLIENT}" ]; then
|
# Home directory of the user, where the client configuration will be written
|
||||||
# if $1 is a user name
|
if [ -e "/home/${CLIENT}" ]; then
|
||||||
homeDir="/home/${CLIENT}"
|
# if $1 is a user name
|
||||||
CLIENT_OWNER="$CLIENT"
|
homeDir="/home/${CLIENT}"
|
||||||
elif [ "${SUDO_USER}" ]; then
|
CLIENT_OWNER="$CLIENT"
|
||||||
# if not, use SUDO_USER
|
elif [ "${SUDO_USER}" ]; then
|
||||||
if [ "${SUDO_USER}" == "root" ]; then
|
# if not, use SUDO_USER
|
||||||
# If running sudo as root
|
if [ "${SUDO_USER}" == "root" ]; then
|
||||||
homeDir="/root"
|
# If running sudo as root
|
||||||
|
homeDir="/root"
|
||||||
|
else
|
||||||
|
homeDir="/home/${SUDO_USER}"
|
||||||
|
fi
|
||||||
|
CLIENT_OWNER="$SUDO_USER"
|
||||||
else
|
else
|
||||||
homeDir="/home/${SUDO_USER}"
|
# if not SUDO_USER, use /root
|
||||||
|
homeDir="/root"
|
||||||
fi
|
fi
|
||||||
CLIENT_OWNER="$SUDO_USER"
|
|
||||||
else
|
|
||||||
# if not SUDO_USER, use /root
|
|
||||||
homeDir="/root"
|
|
||||||
fi
|
|
||||||
|
|
||||||
CLIENT_FILEPATH="$homeDir/$CLIENT.ovpn"
|
CLIENT_FILEPATH="$homeDir/$CLIENT.ovpn"
|
||||||
|
fi
|
||||||
|
|
||||||
# Determine if we use tls-auth or tls-crypt
|
# Determine if we use tls-auth or tls-crypt
|
||||||
if grep -qs "^tls-crypt" /etc/openvpn/server.conf; then
|
if grep -qs "^tls-crypt" /etc/openvpn/server.conf; then
|
||||||
|
Loading…
Reference in New Issue
Block a user