Start the socket file. Add file validation and cleanup

This commit is contained in:
2025-12-09 12:29:54 -05:00
parent 420798b783
commit 614f694fbd
2 changed files with 32 additions and 17 deletions

View File

@@ -5,17 +5,33 @@ opdir="${1?Output dir missing}"
: "${HOME?HOME is not set}"
check_file_exists() {
if [[ -f "$1" ]]; then
return 0
fi
echo "Warning: File does not exist- $1"
return 1
}
script_dir=$(dirname "$(realpath "$0")")
common_ssh_cfg_path="${DIYVPN_SSH_CFG:-$script_dir/common_sshconfig}"
diyvpn_cfg="${DIYVPN_CFG:-$HOME/.config/diyvpn/servers}"
check_file_exists "$common_ssh_cfg_path"
generate() {
local cfgpath name server_ssh_cfg idle_timeout listen_address
cfgpath="$1"
name=$(basename "$cfgpath" | tr -d '[:space:]')
server_ssh_cfg="$cfgpath"/ssh_config # TODO validate
source "$cfgpath/config.rc"
server_ssh_cfg="$cfgpath"/ssh_config
server_config_rc="$cfgpath"/config.rc
check_file_exists "$server_ssh_cfg" || return 0
check_file_exists "$server_config_rc" || return 0
# shellcheck disable=SC1091
source "server_config_rc"
idle_timeout="${IDLE_TIMEOUT:-10min}"
listen_address="${LISTEN_ADDRESS:?LISTEN_ADDRESS should be set}"