Skip to content

Instantly share code, notes, and snippets.

@tagroup
Created July 6, 2012 07:39
Show Gist options
  • Save tagroup/3058718 to your computer and use it in GitHub Desktop.
Save tagroup/3058718 to your computer and use it in GitHub Desktop.
Script to open a reverse ssh tunnel if a specific file exists on a server with 'yes' in it
#!/bin/bash
WGET="/usr/bin/wget"
$WGET -q --tries=10 --timeout=5 http://youralwaysonserver/openpi.php -O /tmp/openpi &> /dev/null
if grep -Fxq "yes" /tmp/openpi
then
ssh -gNnT -R *:55555:raspberrypi.local:80 piremoteuser@youralwaysonserver &
PID=$!
echo "Opened"
sleep 360s;
kill $PID
echo "Closed"
else
echo "no"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment