source: src/django_gheat/import_scan_data.sh@ 9662

Last change on this file since 9662 was 9630, checked in by rick, 13 years ago

Make the import data script more robust.

  • Property svn:executable set to *
File size: 1.9 KB
Line 
1#!/bin/sh
2#
3# Quick and dirty hack to import all data
4
5DATAROOT=${1:-"`pwd $0`/scan-data"}
6MAP_CACHE=${MAP_CACHE:-"/usr/local/var/httpd/cache/maps"}
7MANAGE="`dirname $0`/manage.py"
8SSH_USER=${SSH_USER:-$USER}
9SSH_KEY="`dirname $0`/id_rsa"
10export PYTHON_EGG_CACHE=/tmp/
11
12DATAROOT_CHOICES="`pwd $0`/scan-data /usr/local/scan-data"
13if [ "$1" ]; then
14 DATAROOT=$1
15else
16 for D in $DATAROOT_CHOICES; do
17 if [ -d $D ]; then
18 DATAROOT=$D
19 fi
20 done
21fi
22echo "# DATAROOT: $DATAROOT"
23echo "# SSH_USER: $SSH_USER"
24
25echo "# rsync webfolder"
26if [ -r "$SSH_KEY" ]; then
27 SSH_KEY_OPT='-i $SSH_KEY'
28else
29 echo "# warning automatic ssh key $SSH_KEY not readable"
30 SSH_KEY_OPT=''
31fi
32rsync -az -e "ssh $SSH_KEY_OPT -l $SSH_USER -o StrictHostKeyChecking=no" tyan.wirelessleiden.nl:/usr/local/www/webfolder/scan-data/ $DATAROOT
33
34
35echo "# unzip compressed .tar.gz files"
36for FILE in `find $DATAROOT -name '*.tar.gz' | sort`; do
37 TARDIR=`dirname $FILE`
38 tar -C $TARDIR -xkzf $FILE
39done
40
41#Kismet netxml Imports
42FILES="`find $DATAROOT -name '*netxml*' | sort`"
43[ -n "$FILES" ] && $MANAGE import_datafile $ARGS $FILES
44
45# Import all measure data
46for 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
65done
66
67if [ -r $MAP_CACHE ]; then
68 echo "# Clear cache $MAP_CACHE"
69 htcacheclean -v -l10K -p$MAP_CACHE
70fi
71
Note: See TracBrowser for help on using the repository browser.