Created
January 30, 2014 19:22
-
-
Save pfaffman/8716725 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Get data from connected server identified by the current WIFI SSID | |
if [ -f /sbin/iwconfig ] | |
then | |
# it's ubuntu (or, maybe debian) | |
HOST=`iwconfig wlan0 | grep ESSID | sed 's/.*ESSID:\"\(.*\)\"/\1/'` | |
else | |
# oops. | |
echo Mac solution is not implemented | |
# networksetup -getairportnetwork en1 | awk -F": " '{print $2}' | |
# This would probably work on a mac if ssh keys are configured | |
fi | |
# ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no 10.10.10.1 | |
echo Host: $HOST | |
TARGET=~/data/$HOST | |
mkdir -p $TARGET | |
DIR=`date +"%Y-%m-%d"` | |
cat <<EOF> /tmp/sshconfig | |
UserKnownHostsFile=/dev/null | |
StrictHostKeyChecking=no | |
Host bogus | |
Port 22 | |
User pfaffman | |
HostName 10.10.10.1 | |
EOF | |
cat <<EOF>/tmp/dumpdata | |
#!/bin/bash | |
# Put script here that puts the files you need into $DIR | |
EOF | |
chmod a+rx /tmp/dumpdata | |
echo sending dumpdata | |
rsync --rsh='ssh -F /tmp/sshconfig' -a /tmp/dumpdata bogus:/tmp | |
echo running dumpdata via doing ssh | |
ssh -F /tmp/sshconfig bogus /tmp/dumpdata | |
echo rsyncing data to $TARGET -- rsync -rav --rsh='ssh -F /tmp/sshconfig' bogus:/tmp/$DIR $TARGET | |
rsync -rav --rsh='ssh -F /tmp/sshconfig' bogus:/tmp/$DIR $TARGET |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment