Last active
September 12, 2021 09:55
-
-
Save trchopan/ae82246e27b0455117d5b06ce7512b04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PUBLIC_IP=<PUBLIC_IP> | |
PUBLIC_PORT=<PUBLIC_PORT> | |
AUTH="<USER_NAME>:<PASSWORD>" | |
PORTS=( 2222 3333 ) | |
LOCAL_PORTS=( 22 3000 ) | |
logdir="/home/ubuntu/chisel/log" | |
mkdir -p $logdir | |
while true; do | |
timestamp=$(date "+%Y%m%d-%H%M%S") | |
echo "=== Checking chisel clients ===" | |
for (( n=0; n<${#PORTS[@]}; n++ )); do | |
if [[ -z $(ps aux |grep chisel | grep ${PORTS[n]}) ]]; then | |
echo Starting chisel client ${PORTS[n]} | |
/home/ubuntu/go/bin/chisel client --auth "$AUTH" $PUBLIC_IP:$PUBLIC_PORT R:${PORTS[n]}:localhost:${LOCAL_PORTS[n]} > "$logdir/${PORTS[n]}-$timestamp" 2>&1 & | |
else | |
echo "chisel client found on ${PORTS[n]}" | |
fi | |
done | |
sleep 30 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment