hysteria

ii wrapper script
git clone git://git.2f30.org/hysteria.git
Log | Files | Refs | README | LICENSE

commit db546d649c361af3197a5f3d9ca485acfd575ad7
parent 529e049f20d749afb699a10ae841133c385704d4
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sun May 18 12:50:34 +0200

add optional config argument for multi-session

- run hysteria "config" to use a custom config. ./config is still the default.
  This allows you to run multiple hysteria sessions at the same time in
  different tmux sessions.
- add $session variable to config.

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>

Diffstat:
autojoin | 12++++++++----
config | 1+
connectserver | 14+++++++++-----
hysteria | 13+++++++++----
monitor | 8++++++--
5 files changed, 33 insertions(+), 15 deletions(-)
diff --git a/autojoin b/autojoin @@ -1,16 +1,20 @@ #!/bin/sh -. ./config +if [ "$3" = "" ]; then + . ./config +else + . "$3" +fi if test $# -lt 2; then - echo "usage: $(basename $0) host channel..." 1>&2 + echo "usage: $(basename $0) host channel [config]..." 1>&2 exit 1 fi tmux list-sessions -F '#S' 2>/dev/null | \ - grep '^hysteria' >/dev/null 2>/dev/null + grep "^$session$" >/dev/null 2>/dev/null if [ $? -eq 1 ]; then - echo no hysteria session running 1>&2 + echo "no hysteria session \"$session\" running" 1>&2 exit 1 fi diff --git a/config b/config @@ -3,3 +3,4 @@ fullname="hysteria" hosts="irc.network.org:6667 irc.network-other.org:6667" channels="irc.network.org:#channel irc.network-other.org:#channel" ircdir="irc" +session="hysteria" diff --git a/connectserver b/connectserver @@ -1,19 +1,23 @@ #!/bin/sh +if [ "$2" = "" ]; then + . ./config +else + . "$2" +fi + if test -z $1; then - echo "usage: $(basename $0) host" 1>&2 + echo "usage: $(basename $0) host [config]" 1>&2 exit 1 fi tmux list-sessions -F '#S' 2>/dev/null | \ - grep '^hysteria' >/dev/null 2>/dev/null + grep "^$session$" >/dev/null 2>/dev/null if [ $? -eq 1 ]; then - echo no hysteria session running 1>&2 + echo "no hysteria session \"$session\" running" 1>&2 exit 1 fi -. ./config - host=$(printf '%s' "$1" | cut -d ':' -f 1) port=$(printf '%s' "$1" | cut -s -d ':' -f 2) [ "$port" = "" ] && port="6667" diff --git a/hysteria b/hysteria @@ -1,18 +1,23 @@ #!/bin/sh -x -. ./config +if [ "$1" = "" ]; then + config="./config" +else + config=$(readlink -f "$1") +fi +. "$config" rm -rf "$ircdir" mkdir -p "$ircdir" -tmux new-session -s hysteria -d ./monitor +tmux new-session -s "$session" -d "./monitor \"$config\"" tmux rename-window "monitor" for h in $hosts; do - ./connectserver "$h" + ./connectserver "$h" "$config" done for c in $channels; do host=$(printf '%s' "$c" | cut -d ':' -f 1) channel=$(printf '%s' "$c" | cut -s -d ':' -f 2) - ./autojoin "$host" "$channel" + ./autojoin "$host" "$channel" "$config" done diff --git a/monitor b/monitor @@ -3,10 +3,14 @@ # Monitor for private messages and/or new channels and # create a new split tmux window -. ./config +if [ "$1" = "" ]; then + . ./config +else + . "$1" +fi while :; do - for n in $(find $ircdir -type f -name "out" 2>/dev/null); do + for n in $(find "$ircdir" -type f -name "out" 2>/dev/null); do title=$(echo $n | awk -F/ '{ \ if (NF == 4) \ print $2":"$3; \