Last active
June 14, 2020 17:58
-
-
Save qub1750ul/49d36dd1fc705ecc9bff0af0e5979c44 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
if [ -z "$XDG_RUNTIME_DIR" ] ; then declare -r XDG_RUNTIME_DIR="/tmp" ; fi | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
declare -ar servicePortList=( 2001 2002 2010 2011 2012 2013 2014 ) | |
declare -ri sshPort=2000 | |
declare -r sshSocket="$XDG_RUNTIME_DIR/si-vps-warp.socket" | |
declare -r serverFQDN="si.ext.localhost" | |
declare username | |
echo "StudentIngegneria | Secure Wormhole Generator" | |
echo "Inizializzazione del warp su localhost" | |
echo "" | |
printf "Username: " ; read -r username | |
ssh -fNMS "$sshSocket" -p "$sshPort" -o ControlPersist=yes "${username}@${serverFQDN}" | |
trap 'ssh -S $sshSocket -qO exit server' TERM INT | |
for servicePort in ${servicePortList[*]} ; do | |
echo -e "\nConnessione all'universo ${servicePort}" | |
ssh -fNS "$sshSocket" server \ | |
-L "localhost:${servicePort}:${serverFQDN}:${servicePort}" | |
done | |
echo -e "\nWarp stabilizzato" | |
echo "In attesa del segnale di terminazione..." | |
cat > /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment