add ctl script

This commit is contained in:
2025-12-03 00:23:44 -05:00
parent a0b0ccfaa1
commit 30cff1fdf9
2 changed files with 71 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ common_ssh_cfg_path="${DIYVPN_SSH_CFG:-$script_dir/common_sshconfig}"
diyvpn_cfg="${DIYVPN_CFG:-$HOME/.config/diyvpn/servers}"
generate() {
local cfgpath name server_ssh_cfg idle_timeout listen_port
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
@@ -18,7 +18,7 @@ generate() {
source "$cfgpath/config.rc"
idle_timeout="${IDLE_TIMEOUT:-10min}"
listen_port="${LISTEN_PORT:?LISTEN_PORT should be set}"
listen_address="${LISTEN_ADDRESS:?LISTEN_ADDRESS should be set}"
cat >"$opdir/diyvpnssh-$name.service" <<-EOF
[Unit]
@@ -52,7 +52,7 @@ generate() {
Description=Socket for diyvpn to server $name
[Socket]
ListenStream=$listen_port
ListenStream=$listen_address
[Install]
WantedBy=sockets.target