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