source: src/django_gheat/import_scan_data.sh@ 9667

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

Suport .zip files...

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