first check-in of feisty meow codebase. many things broken still due to recent
[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=zooty.koeritz.com
9 username=fred
10 local_user=fred
11 tempdir=/tmp  # where we generate our files.
12
13 source $HOME/yeti/scripts/core/profile.sh
14
15 soundfile=$YETI_DIR/database/sounds/woouoo.wav
16 if [ ! -z "$1" ]; then
17   soundfile=$1
18 fi
19
20 ip_file="$(mktemp ${tempdir}/$(hostname | sed -e "s/\..*$//")_ip.XXXXXX)_${USER}"
21
22 # iterate forever, since we want to keep running this.
23 while true; do
24
25   # get live ip address
26   pushd $tempdir
27   wget http://automation.whatismyip.com/n09230945.asp -O "$ip_file" 
28
29   chmod 644 "$ip_file"
30   my_ip=$(head "$ip_file")
31
32   echo "my ip is [$my_ip]"
33
34   # send the file over to the server.
35   # note that the local_user here is expected to have a certificate that
36   # gets us access to the server.  this needs to be on the local machine
37   # for sftp to run without a login prompt.
38   sudo -u $local_user sftp $username@$server <<eof
39 mkdir gen
40 cd gen
41 put $ip_file $(hostname | sed -e "s/\..*$//")_ip.txt
42 eof
43
44   popd
45
46   sleep 600
47 done
48