Skip to content

Commit

Permalink
wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
ariary committed Sep 19, 2022
1 parent 7189100 commit 955cbca
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
1 change: 1 addition & 0 deletions light-pty4all/socat-listener-behind-tunneling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ fi
#launch gitar
echo "[+] launch gitar server"
SECRET=$RANDOM
echo "gitar -a https://${TUNNEL_ENDPOINT} -f ${LPORT} --secret ${SECRET}"
tmux split-window -h "gitar -a https://${TUNNEL_ENDPOINT} -f ${LPORT} --secret ${SECRET}" # https??
URL="http:https://${TUNNEL_ENDPOINT}/${SECRET}"

Expand Down
22 changes: 22 additions & 0 deletions wrapper/prerequisite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

echo "[+] Installing tacos in ${HOME}/.local/bin"
mkdir -p $HOME/.local/bin/
git clone https://github.com/ariary/tacos.git && cd tacos
go mod tidy
make before.build
make build.tacos && mv tacos $HOME/.local/bin/

echo "[+] Installing listener scripts in ${HOME}/.tacos"
mkdir -p $HOME/.tacos
mv light-pty4all $HOME/.tacos/
cd .. && rm -rf tacos

echo "[+] Installing gitar in ${HOME}/.local/bin"
go install github.com/ariary/gitar@latest

echo "[+] Installing tmux"
sudo apt install tmux

echo "[+] Installing socat"
sudo apt-get update && sudo apt-get install socat
72 changes: 72 additions & 0 deletions wrapper/wrapper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env bash

## Use this script to ease tacos/socat listener deployment
for i in "$@"; do
case $i in
--ngrok|-n)
NGROK=true
shift;shift;
;;
--bore|-b)
BORE=true
shift;shift;
;;
--help|-h)
HELP=true
;;
*)
;;
esac
done


## Help part
if [[ "$HELP" ]];
then
echo "Usage w/ tunneling: $0 [flag]";
echo -e "\t--bore to perform tunneling using bore"
echo -e "\t--ngrok to perform tunneling using ngrok"
echo
echo "Usage w/o tunneling: $0 [lhost] [lport]";
exit 92
fi



#### Cleaning part
# this function is called when Ctrl-C is sent
function trap_ctrlc ()
{
# perform cleanup here
echo "\n[+] perform clean up before exit"
rm server.* 2>/dev/null
rm sh 2>/dev/null
rm tacos 2>/dev/null
rm socat-* 2>/dev/null
rm $0
exit 92
}

# initialise trap to call trap_ctrlc function when signal 2 (SIGINT) is received
trap "trap_ctrlc" 2

#### Set environment
if [[ "$NGROK" ]] || [[ -z "$BORE" ]];
then
cp $HOME/.tacos/light-pty4all/socat-listener-behind-tunneling.sh .

else
cp $HOME/.tacos/light-pty4all/socat-listener.sh .
fi
cp $HOME/.tacos/light-pty4all/*.tpl .
cp $HOME/.local/bin/tacos .

if [[ "$NGROK" ]];
then
./socat-listener-behind-tunneling.sh
elif [[ "$BORE" ]];
then
./socat-listener-behind-tunneling.sh --bore
else
./socat-listener.sh --lhost $1 --lport $2 --gitar
fi

0 comments on commit 955cbca

Please sign in to comment.