updated to ignore svn entries file, plus sorted the list to make easier to add.
[feisty_meow.git] / scripts / security / start_tunnels.sh
index 242a6432aecc12834624f50bf013f03220889e87..6c78421c3794bd9b831699ac96bf1734649ef064 100644 (file)
@@ -7,21 +7,67 @@
 
 #hmmm:  none of the user info below will work for others: parameterize it.
 
-#source $HOME/yeti/scripts/profile.sh
+#hmmm: maybe we need a base function that takes all the disparate values,
+#      and this script could call it with known feisty meow settings.
 
-soundfile=$YETI_DIR/database/sounds/woouoo.wav
+##############
+
+# these variables are configurable from plug-ins.
+
+soundfile=$FEISTY_MEOW_DIR/database/sounds/woouoo.wav
 if [ ! -z "$1" ]; then
   soundfile=$1
 fi
 
-while true; do
-  echo Connecting sendmail and proxy servers via zooty.
-  ssh -i $HOME/.ssh/id_dsa_fred -2 -N -v -L 14008:localhost:25 fred@zooty.koeritz.com
-  bash $SHELLDIR/multimedia/sound_play.sh $soundfile
+##############
+
+# provides a list of properly formatted tunnels for ssh to create.  if this list
+# is empty, then we do nothing.
+# TUNNEL_LIST=()
+
+# set this to the hostname that will be providing the tunnel.  this is
+# usually a remote system.
+USER_PLUS_HOST=""
+
+# set this to your key file, plus the -i flag, such as: 
+#   SECURITY_KEY="-i $HOME/.ssh/id_rsa" 
+SECURITY_KEY=""
+
+##############
+
+#hmmm:move to fred configs!
+TUNNEL_LIST+=(-L 14008:localhost:25)
+USER_PLUS_HOST="fred@serene.feistymeow.org"
+SECURITY_KEY="-i $HOME/.ssh/id_dsa_fred" 
+
+##############
+
+# how often to play sounds when reconnecting.
+NOISE_PERIOD=180
+
+# when we last played a sound.
+LAST_SOUND_TIME=0
+
+play_sound_periodically()
+{
+  CURRENT_TIME=$(date +"%s")
+  if (( $CURRENT_TIME - $LAST_SOUND_TIME >= $NOISE_PERIOD )); then
+    echo playing sound now.
+    bash $FEISTY_MEOW_SCRIPTS/multimedia/sound_play.sh $soundfile &>/dev/null </dev/null &
 #hmmm: parameterize this for the sound to be played.  doofus.
+    LAST_SOUND_TIME=$CURRENT_TIME
+  fi
+}
+
+##############
+
+while true; do
+  echo Connecting sendmail to serenely zooty.
+  ssh  -2 -N -v ${TUNNEL_LIST[*]} "$USER_PLUS_HOST"
   echo "Got dumped from tunnels; re-establishing connection."
+  play_sound_periodically
   echo "Note: if you're being asked for a password, you haven't set up an RSA key yet."
-  sleep 14
+  sleep 1
 done
 
 #-L 8028:localhost:3128