1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # Quick and dirty hack to import all data
|
---|
4 |
|
---|
5 | DATAROOT=${1:-"`pwd $0`/scan-data"}
|
---|
6 | MAP_CACHE=${MAP_CACHE:-"/usr/local/var/httpd/cache/maps"}
|
---|
7 | MANAGE="`dirname $0`/manage.py"
|
---|
8 | SSH_USER=${SSH_USER:-$USER}
|
---|
9 | SSH_KEY="`dirname $0`/id_rsa"
|
---|
10 | export PYTHON_EGG_CACHE=/tmp/
|
---|
11 |
|
---|
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 |
|
---|
25 | echo "# rsync webfolder"
|
---|
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
|
---|
33 |
|
---|
34 |
|
---|
35 | echo "# unzip compressed .tar.gz files"
|
---|
36 | for FILE in `find $DATAROOT -name '*.tar.gz' | sort`; do
|
---|
37 | TARDIR=`dirname $FILE`
|
---|
38 | tar -C $TARDIR -xkzf $FILE
|
---|
39 | done
|
---|
40 |
|
---|
41 | #Kismet netxml Imports
|
---|
42 | FILES="`find $DATAROOT -name '*netxml*' | sort`"
|
---|
43 | [ -n "$FILES" ] && $MANAGE import_datafile $ARGS $FILES
|
---|
44 |
|
---|
45 | # Import all measure data
|
---|
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
|
---|
48 | USERNAME=`basename $USERDIR`
|
---|
49 | DEVICE=`basename $DEVICEDIR`
|
---|
50 | ARGS="-g $USERNAME -e $USERNAME@wirelessleiden.nl -k $DEVICE"
|
---|
51 |
|
---|
52 | echo $ARGS
|
---|
53 | #Kismet gpsxml Imports
|
---|
54 | FILES="`find $DEVICEDIR -name '*gpsxml*'`"
|
---|
55 | [ -n "$FILES" ] && $MANAGE import_datafile $ARGS $FILES
|
---|
56 |
|
---|
57 | # DroidStumber imports
|
---|
58 | FILES=`find $DEVICEDIR -name 'ScanResult-*'`
|
---|
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
|
---|
64 | done
|
---|
65 | done
|
---|
66 |
|
---|
67 | if [ -r $MAP_CACHE ]; then
|
---|
68 | echo "# Clear cache $MAP_CACHE"
|
---|
69 | htcacheclean -v -l10K -p$MAP_CACHE
|
---|
70 | fi
|
---|
71 |
|
---|