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=backup
|
---|
9 | SSH_KEY="`dirname $0`/id_rsa"
|
---|
10 | export PYTHON_EGG_CACHE=/tmp/
|
---|
11 |
|
---|
12 | echo "# rsync webfolder"
|
---|
13 | rsync -e "ssh -i $SSH_KEY -l $SSH_USER -o StrictHostKeyChecking=no" -az tyan.wirelessleiden.nl:/usr/local/www/webfolder/scan-data/ $DATAROOT
|
---|
14 |
|
---|
15 |
|
---|
16 | echo "# unzip compressed .tar.gz files"
|
---|
17 | for FILE in `find $DATAROOT -name '*.tar.gz'`; do
|
---|
18 | TARDIR=`dirname $FILE`
|
---|
19 | tar -C $TARDIR -xkzf $FILE
|
---|
20 | done
|
---|
21 |
|
---|
22 | ADDED=0
|
---|
23 |
|
---|
24 | #Kismet netxml Imports
|
---|
25 | FILES="`find $DATAROOT -name '*netxml*'`"
|
---|
26 | [ -n "$FILES" ] && $MANAGE import_kismet $ARGS $FILES
|
---|
27 |
|
---|
28 | # Import all measure data
|
---|
29 | for USERDIR in `find $DATAROOT -maxdepth 1 -type d`; do
|
---|
30 | for DEVICEDIR in `find $USERDIR -maxdepth 1 -type d`; do
|
---|
31 | USERNAME=`basename $USERDIR`
|
---|
32 | DEVICE=`basename $DEVICEDIR`
|
---|
33 | ARGS="-g $USERNAME -e $USERNAME@wirelessleiden.nl -k $DEVICE"
|
---|
34 |
|
---|
35 | #Kismet gpsxml Imports
|
---|
36 | FILES="`find $DEVICEDIR -name '*netxml*'` `find $DEVICEDIR -name '*gpsxml*'`"
|
---|
37 | [ -n "$FILES" ] && $MANAGE import_kismet $ARGS $FILES
|
---|
38 |
|
---|
39 | # DroidStumber imports
|
---|
40 | FILES=`find $DEVICEDIR -name 'ScanResult-*'`
|
---|
41 | [ -n "$FILES" ] && $MANAGE import_droidstumbler $ARGS $FILES
|
---|
42 | done
|
---|
43 | done
|
---|
44 |
|
---|
45 | if [ "$ADDED" -eq 1 -a -r $MAP_CACHE ]; then
|
---|
46 | echo "# Clear cache $MAP_CACHE"
|
---|
47 | htcacheclean -l10K -p$MAP_CACHE
|
---|
48 | fi
|
---|
49 |
|
---|