added more tunnels.
[feisty_meow.git] / scripts / security / tell_zooty_our_ip.sh
1 #!/bin/bash
2 # this script acquires our local IP address and connects over to zooty
3 # to write a status file there.  this enables us to later connect backwards
4 # to our home system without being hosed by the floating IP address.
5
6 #hmmm:  none of the user info below will work for others: parameterize it.
7
8 server=serene.feistymeow.org
9 username=fred
10 local_user=fred
11 tempdir=/tmp  # where we generate our files.
12
13 source $HOME/feisty_meow/scripts/core/launch_feisty_meow.sh
14
15 soundfile=$FEISTY_MEOW_DIR/database/sounds/woouoo.wav
16 if [ ! -z "$1" ]; then
17   soundfile=$1
18 fi
19
20 ip_file="$(mktemp ${tempdir}/ip_${USER}_$(hostname | sed -e "s/\..*$//").XXXXXX)"
21
22 # get live ip address
23 pushd $tempdir
24 wget http://automation.whatismyip.com/n09230945.asp -O "$ip_file" 
25
26 chmod 644 "$ip_file"
27 my_ip=$(head "$ip_file")
28
29 echo "my ip is [$my_ip]"
30
31 # send the file over to the server.
32 # note that the local_user here is expected to have a certificate that
33 # gets us access to the server.  this needs to be on the local machine
34 # for sftp to run without a login prompt.
35 sudo -u $local_user sftp $username@$server <<eof
36 mkdir gen
37 cd gen
38 put $ip_file $(hostname | sed -e "s/\..*$//")_ip.txt
39 eof
40
41 \rm -f "$ip_file"
42
43 popd
44