[9552] | 1 | #!/bin/sh
|
---|
| 2 | #
|
---|
| 3 | # Quick and dirty hack to import all data
|
---|
| 4 |
|
---|
[9564] | 5 | DATAROOT=${1:-"`pwd $0`/scan-data"}
|
---|
| 6 | MAP_CACHE=${MAP_CACHE:-"/usr/local/var/httpd/cache/maps"}
|
---|
[9555] | 7 | MANAGE="`dirname $0`/manage.py"
|
---|
[9630] | 8 | SSH_USER=${SSH_USER:-$USER}
|
---|
[9555] | 9 | SSH_KEY="`dirname $0`/id_rsa"
|
---|
| 10 | export PYTHON_EGG_CACHE=/tmp/
|
---|
[9552] | 11 |
|
---|
[9630] | 12 | DATAROOT_CHOICES="`pwd $0`/scan-data /usr/local/scan-data"
|
---|
| 13 | if [ "$1" ]; then
|
---|
| 14 | DATAROOT=$1
|
---|
| 15 | else
|
---|
| 16 | for D in $DATAROOT_CHOICES; do
|
---|
| 17 | if [ -d $D ]; then
|
---|
| 18 | DATAROOT=$D
|
---|
| 19 | fi
|
---|
| 20 | done
|
---|
| 21 | fi
|
---|
| 22 | echo "# DATAROOT: $DATAROOT"
|
---|
| 23 | echo "# SSH_USER: $SSH_USER"
|
---|
| 24 |
|
---|
[9552] | 25 | echo "# rsync webfolder"
|
---|
[9630] | 26 | if [ -r "$SSH_KEY" ]; then
|
---|
| 27 | SSH_KEY_OPT='-i $SSH_KEY'
|
---|
| 28 | else
|
---|
| 29 | echo "# warning automatic ssh key $SSH_KEY not readable"
|
---|
| 30 | SSH_KEY_OPT=''
|
---|
| 31 | fi
|
---|
| 32 | rsync -az -e "ssh $SSH_KEY_OPT -l $SSH_USER -o StrictHostKeyChecking=no" tyan.wirelessleiden.nl:/usr/local/www/webfolder/scan-data/ $DATAROOT
|
---|
[9552] | 33 |
|
---|
[9555] | 34 |
|
---|
[9552] | 35 | echo "# unzip compressed .tar.gz files"
|
---|
[9566] | 36 | for FILE in `find $DATAROOT -name '*.tar.gz' | sort`; do
|
---|
[9552] | 37 | TARDIR=`dirname $FILE`
|
---|
[9564] | 38 | tar -C $TARDIR -xkzf $FILE
|
---|
[9552] | 39 | done
|
---|
| 40 |
|
---|
[9564] | 41 | #Kismet netxml Imports
|
---|
[9566] | 42 | FILES="`find $DATAROOT -name '*netxml*' | sort`"
|
---|
[9630] | 43 | [ -n "$FILES" ] && $MANAGE import_datafile $ARGS $FILES
|
---|
[9564] | 44 |
|
---|
| 45 | # Import all measure data
|
---|
[9566] | 46 | for USERDIR in `find $DATAROOT -mindepth 1 -maxdepth 1 -type d | sort`; do
|
---|
| 47 | for DEVICEDIR in `find $USERDIR -mindepth 1 -maxdepth 1 -type d | sort`; do
|
---|
[9552] | 48 | USERNAME=`basename $USERDIR`
|
---|
| 49 | DEVICE=`basename $DEVICEDIR`
|
---|
| 50 | ARGS="-g $USERNAME -e $USERNAME@wirelessleiden.nl -k $DEVICE"
|
---|
[9564] | 51 |
|
---|
[9566] | 52 | echo $ARGS
|
---|
[9564] | 53 | #Kismet gpsxml Imports
|
---|
[9566] | 54 | FILES="`find $DEVICEDIR -name '*gpsxml*'`"
|
---|
[9623] | 55 | [ -n "$FILES" ] && $MANAGE import_datafile $ARGS $FILES
|
---|
[9564] | 56 |
|
---|
[9552] | 57 | # DroidStumber imports
|
---|
[9564] | 58 | FILES=`find $DEVICEDIR -name 'ScanResult-*'`
|
---|
[9623] | 59 | [ -n "$FILES" ] && $MANAGE import_datafile $ARGS $FILES
|
---|
| 60 |
|
---|
| 61 | # Kismet imports
|
---|
| 62 | FILES=`find $DEVICEDIR -name '*.ns1'`
|
---|
| 63 | [ -n "$FILES" ] && $MANAGE import_datafile $ARGS $FILES
|
---|
[9552] | 64 | done
|
---|
| 65 | done
|
---|
| 66 |
|
---|
[9569] | 67 | if [ -r $MAP_CACHE ]; then
|
---|
[9555] | 68 | echo "# Clear cache $MAP_CACHE"
|
---|
[9569] | 69 | htcacheclean -v -l10K -p$MAP_CACHE
|
---|
[9555] | 70 | fi
|
---|
[9552] | 71 |
|
---|