From 6ca439e45ddb80361346540f818d57fa5e293d6b Mon Sep 17 00:00:00 2001 From: Alessandro Iezzi Date: Tue, 20 May 2025 15:34:03 +0200 Subject: Add the check config function --- vpn | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/vpn b/vpn index 94cece6..74751f9 100755 --- a/vpn +++ b/vpn @@ -28,6 +28,9 @@ #!/usr/bin/bash +SCRIPT_DIR=$(dirname $(realpath $0)) +CONFIG_FILE=$SCRIPT_DIR/config + # Configurations CONF_DIR=YOUR_CONFIG_DIR CONF_FILE=YOUR_CONFIG_FILE @@ -70,6 +73,33 @@ set_routes() echo "$devtun ready." } +add_config() +{ + local config_file= + local config_name= + + while [ -z "$config_file" ]; do + echo -n "Set OpenVPN config file: " + read config_file + done + + while [ -z "$config_name" ]; do + echo -n "Set a name for the config file: " + read config_name + done + config_file=$(eval realpath "$config_file") + + echo "CONF_${config_name^^}=$config_file" > "$CONFIG_FILE" +} + +check_config() +{ + [ -f "$CONFIG_FILE" ] && return + add_config +} + +check_config + ISROOT=`id -u` if [ $ISROOT != 0 ]; then -- cgit v1.2.3