another new script for tunneling. starting to achieve critical mass for
[feisty_meow.git] / scripts / security / tell_zooty_our_ip.sh
index 9c5b02a1fe1daddb5fac60d059a079a09a101f41..5e8aa2e63ccc0eedcff7b0d3df7074c1f47c97ab 100644 (file)
@@ -17,7 +17,7 @@ if [ ! -z "$1" ]; then
   soundfile=$1
 fi
 
-ip_file="$(mktemp ${tempdir}/$(hostname | sed -e "s/\..*$//")_ip.XXXXXX)_${USER}"
+ip_file="$(mktemp ${tempdir}/ip_${USER}_$(hostname | sed -e "s/\..*$//").XXXXXX)"
 
 # get live ip address
 pushd $tempdir
@@ -33,10 +33,14 @@ echo "my ip is [$my_ip]"
 # gets us access to the server.  this needs to be on the local machine
 # for sftp to run without a login prompt.
 sudo -u $local_user sftp $username@$server <<eof
-mkdir gen
+if [ ! -d gen ]; then
+  mkdir gen
+fi
 cd gen
 put $ip_file $(hostname | sed -e "s/\..*$//")_ip.txt
 eof
 
+\rm -f "$ip_file"
+
 popd