#!/bin/bash set -e RECIPIENTS="stvogel@eonerc.rwth-aachen.de,mstevic@eonerc.rwth-aachen.de" SERVER=s2ss.0l.de USER=acs PORT=$(shuf -i 60000-65535 -n 1) # wait for working network connection while ! curl http://canihazip.com/s &> /dev/null; do sleep 1 done IP=$(curl -s http://canihazip.com/s) HOSTNAME=$(dig +short -x $IP) if [ -z "$HOSTNAME" ]; then HOSTNAME=$(hostname) fi # check if system has net connectivity. otherwise die... ssh -q -o ConnectTimeout=2 $USER@$SERVER # setup SSH tunnel for mail notification ssh -f -N -L 25:localhost:25 $USER@$SERVER # setup SSH reverse tunnel for remote administration ssh -f -N -R $PORT:localhost:22 $USER@$SERVER # send mail with notification about new node sendmail "$RECIPIENTS" < To: $RECIPIENTS There's a new host with the S2SS LiveUSB Image running: Version: $(cat /etc/image-release) Reverse SSH tunnel port: $PORT Internet IP: $IP Hostname: $HOSTNAME Latency: $(ping -qc 5 $SERVER) Traceroute: $(traceroute $SERVER) Interfaces: $(ip addr) Hardware: $(lshw) EOF