about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2020-04-26 08:20:30 -0500
committerCase Duckworth2020-04-26 08:20:30 -0500
commit7b5d702e202e3e3b6d00670ecd670505071a4f54 (patch)
treeb7122deaa26fdfb1fb0a7db07beccf0b4079cc8d
parentAdd Uninstall info (diff)
downloadmrgrctrnl-7b5d702e202e3e3b6d00670ecd670505071a4f54.tar.gz
mrgrctrnl-7b5d702e202e3e3b6d00670ecd670505071a4f54.zip
Add key and rest fields and improve ssh calls
-rw-r--r--README.md10
-rwxr-xr-xmrgrctrnl11
2 files changed, 16 insertions, 5 deletions
diff --git a/README.md b/README.md index 7d92514..b1f724a 100644 --- a/README.md +++ b/README.md
@@ -33,10 +33,16 @@ with whitespace-separeted fields.
33A `#` begins a comment that goes to the end of the line. 33A `#` begins a comment that goes to the end of the line.
34 34
35``` 35```
36# machine user local remote 36# machine user local remote key rest
37example.com ted localhost:6989 localhost:6667 37example.com ted localhost:6989 localhost:6667 /path/to/key.pub [..]
38``` 38```
39 39
40**machine**, **user**, **local**, and **remote** are required.
41**key** and **rest** are optional.
42
43**rest** is more command-line options, if there's anything else you'd like to
44include in the command.
45
40## Requirements 46## Requirements
41 47
42- POSIX environment 48- POSIX environment
diff --git a/mrgrctrnl b/mrgrctrnl index 1229993..ca17f55 100755 --- a/mrgrctrnl +++ b/mrgrctrnl
@@ -70,19 +70,24 @@ then demolish_tunnels
70fi 70fi
71 71
72awk '{sub(/#.*$/,"");print}' "$config" | 72awk '{sub(/#.*$/,"");print}' "$config" |
73while read -r machine user local remote 73while read -r machine user local remote key rest
74do 74do
75 if [ -z "$machine" ] || [ -z "$user" ] || 75 if [ -z "$machine" ] || [ -z "$user" ] ||
76 [ -z "$local" ] || [ -z "$remote" ] 76 [ -z "$local" ] || [ -z "$remote" ]
77 then continue 77 then continue
78 fi 78 fi
79 79
80 echo ssh -N "$user@$machine" -L "$local:$remote" 80 set -- -N "$user@$machine" -L "$local:$remote"
81 [ -n "$key" ] && set -- "$@" -i "$key"
82 #shellcheck disable=2086
83 [ -n "$rest" ] && set -- "$@" $rest
84
85 echo ssh "$@"
81 86
82 "$dry_run" || { 87 "$dry_run" || {
83 while : 88 while :
84 do 89 do
85 ssh -N "$user@$machine" -L "$local:$remote" 90 ssh "$@"
86 echo "$!" >> "$pidf" 91 echo "$!" >> "$pidf"
87 sleep 5 92 sleep 5
88 done & 93 done &