about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--README.md50
-rw-r--r--mrgrc.jpgbin0 -> 61830 bytes
-rwxr-xr-xmrgrctrnl64
3 files changed, 114 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..870922e --- /dev/null +++ b/README.md
@@ -0,0 +1,50 @@
1# MERGIRC TURNEL
2
3a configurable ssh tunneler that I use for IRC
4
5this is a small shell script that'll set up
6an IRC tunnel between hosts that you can configure
7using a file.
8
9When you run mrgrctrnl,
10it'll automagically tunnel the hosts
11and let you sign into IRC on your own computer.
12Yay!
13
14## Why
15
16I like running weechat from my computer but have it connected to others.
17For example, I like to stay connected to tilde.town's IRC from my laptop.
18According to instructions from
19[~nick](https://tilde.town/~nick/sshtunnel.html),
20you can just set up an SSH tunnel.
21But I have multiple servers!
22So I made this script.
23
24### Why the stupid name?
25
26![gersbermps meme edited so she's holding terminals](mrgrc.jpg "ermahgerd")
27
28## Config file
29
30The config file is located at `$XDG_CONFIG_HOME/mrgrctrnl/config`.
31Each row is an ssh tunnel to run,
32with whitespace-separeted fields.
33A `#` begins a comment that goes to the end of the line.
34
35```
36# machine user local remote
37example.com ted localhost:6989 localhost:6667
38```
39
40## Requirements
41
42- POSIX environment
43- ssh
44
45## Install
46
47````
48$ make clean
49# make install
50```
diff --git a/mrgrc.jpg b/mrgrc.jpg new file mode 100644 index 0000000..fc9e9d1 --- /dev/null +++ b/mrgrc.jpg
Binary files differ
diff --git a/mrgrctrnl b/mrgrctrnl new file mode 100755 index 0000000..8b6c10d --- /dev/null +++ b/mrgrctrnl
@@ -0,0 +1,64 @@
1#!/bin/sh
2# mrgrctrnl
3# configurable ssh tunneler
4# by Case Duckworth <acdw@acdw.net>
5# version 0.1
6# LICENSE: MIT
7
8usage()
9{
10 cat <<-END
11 mrgrctrnl: make magic ssh tunnels
12 usage: mrgrctrnl [-h] [-c CONF]
13
14 -h show this help
15 -c CONF use config file CONF.
16 . default: \$XDG_CONFIG_HOME/mrgrctrnl/config
17
18 END
19 exit "${1:-0}"
20}
21
22die()
23{
24 [ "$#" -eq 0 ] && exit 1
25 case "$1" in
26 0-9*) ec="$1"; shift ;;
27 *) ec=1 ;;
28 esac
29 printf '!!%s: %s\n' "mrgrctrnl" "$*"
30 exit "$ec"
31}
32
33config="${XDG_CONFIG_HOME:=$HOME/.config}/mrgrctrnl/config"
34pidf=/tmp/mrgrctrnl.pid
35
36while getopts hc: opt; do
37 case "$opt" in
38 h) usage ;;
39 c) config="$OPTARG" ;;
40 \?) usage 2 ;;
41 *) usage 2 ;;
42 esac
43done
44shift "$((OPTIND - 1))"
45
46[ -f "$config" ] || die "Need a config! Edit $config"
47[ -e "$pidf" ] && {
48 while read -r pid; do
49 kill "$pid"
50 done < "$pidf"
51 rm "$pidf"
52}
53
54while read -r machine user local remote
55do
56 while :
57 do
58 ssh -N "$user@$machine" -L "$local:$remote"
59 echo "$!" >> "$pidf"
60 sleep 3
61 done &
62done < "$config"
63
64wait