source: src/django_gheat/import_scan_data.sh@ 9777

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

By making directories the data should be more easy to parse..

  • Property svn:executable set to *
File size: 2.4 KB
RevLine 
[9552]1#!/bin/sh
2#
3# Quick and dirty hack to import all data
4
[9670]5BASEROOT=`cd $(dirname $0); pwd -P`
[9665]6DATAROOT=${1:-"$BASEROOT/scan-data"}
[9564]7MAP_CACHE=${MAP_CACHE:-"/usr/local/var/httpd/cache/maps"}
[9555]8MANAGE="`dirname $0`/manage.py"
9SSH_KEY="`dirname $0`/id_rsa"
10export PYTHON_EGG_CACHE=/tmp/
[9552]11
[9665]12DATAROOT_CHOICES="$DATAROOT /usr/local/scan-data"
[9690]13
14DEBUG=${DEBUG:-false}
15
16debug() {
17 $DEBUG && echo $*
18}
19
[9630]20if [ "$1" ]; then
21 DATAROOT=$1
22else
23 for D in $DATAROOT_CHOICES; do
24 if [ -d $D ]; then
25 DATAROOT=$D
26 fi
27 done
28fi
[9690]29debug "# DATAROOT: $DATAROOT"
30debug "# SSH_USER: $SSH_USER"
[9630]31
[9690]32echo "# rsync webfolder" 1>&2
[9630]33if [ -r "$SSH_KEY" ]; then
[9672]34 SSH_KEY_OPT="-i $SSH_KEY"
35 SSH_USER=backup
[9630]36else
37 echo "# warning automatic ssh key $SSH_KEY not readable"
38 SSH_KEY_OPT=''
[9777]39 SSH_USER=${SSH_USER:-${SUDO_USER:-$USER}}
[9630]40fi
[9690]41rsync -O --out-format="%n%L" -az -e "ssh $SSH_KEY_OPT -l $SSH_USER -o StrictHostKeyChecking=no" tyan.wirelessleiden.nl:/usr/local/www/webfolder/scan-data/ $DATAROOT
[9552]42
[9690]43debug "# unzip compressed .tar.gz files"
[9566]44for FILE in `find $DATAROOT -name '*.tar.gz' | sort`; do
[9777]45 TARDIR=`dirname $FILE`/`basename $FILE .tar.gz`
46 if [ ! -d $TARDIR ]; then
47 mkdir $TARDIR
48 tar -C $TARDIR -xvzf $FILE
49 fi
[9552]50done
51
[9690]52debug "# unzip compressed .zip files"
[9667]53for FILE in `find $DATAROOT -name '*.zip' | sort`; do
[9777]54 ARCHIVEDIR=`dirname $FILE`/`basename $FILE .zip`
55 if [ ! -d $ARCHIVEDIR ]; then
56 mkdir $ARCHIVEDIR
57 (cd $ARCHIVEDIR; unzip -qn $FILE )
58 fi
[9667]59done
60
[9564]61#Kismet netxml Imports
[9566]62FILES="`find $DATAROOT -name '*netxml*' | sort`"
[9630]63[ -n "$FILES" ] && $MANAGE import_datafile $ARGS $FILES
[9564]64
65# Import all measure data
[9566]66for USERDIR in `find $DATAROOT -mindepth 1 -maxdepth 1 -type d | sort`; do
67 for DEVICEDIR in `find $USERDIR -mindepth 1 -maxdepth 1 -type d | sort`; do
[9552]68 USERNAME=`basename $USERDIR`
69 DEVICE=`basename $DEVICEDIR`
70 ARGS="-g $USERNAME -e $USERNAME@wirelessleiden.nl -k $DEVICE"
[9564]71
[9777]72 # DroidStumber imports
73 FILES=`find $DEVICEDIR -name 'ScanResult-*'`
74 [ -n "$FILES" ] && $MANAGE import_datafile $ARGS $FILES
75
[9564]76 #Kismet gpsxml Imports
[9566]77 FILES="`find $DEVICEDIR -name '*gpsxml*'`"
[9623]78 [ -n "$FILES" ] && $MANAGE import_datafile $ARGS $FILES
[9564]79
[9623]80 # Kismet imports
81 FILES=`find $DEVICEDIR -name '*.ns1'`
82 [ -n "$FILES" ] && $MANAGE import_datafile $ARGS $FILES
[9552]83 done
84done
85
[9569]86if [ -r $MAP_CACHE ]; then
[9690]87 debug "# Clear cache $MAP_CACHE"
[9569]88 htcacheclean -v -l10K -p$MAP_CACHE
[9555]89fi
[9552]90
Note: See TracBrowser for help on using the repository browser.