source: src/django_gheat/import_scan_data.sh@ 9561

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

Quick and dirty full_import

  • Property svn:executable set to *
File size: 1.4 KB
Line 
1#!/bin/sh
2#
3# Quick and dirty hack to import all data
4
5if [ `id -un` != "www" ]; then
6 echo "ERROR, run as www user: sudo -E -u www $0"
7 exit 1
8fi
9
10DATAROOT="/usr/local/var/scan-data"
11MAP_CACHE=/usr/local/var/httpd/cache/maps
12MANAGE="`dirname $0`/manage.py"
13SSH_USER=backup
14SSH_KEY="`dirname $0`/id_rsa"
15export PYTHON_EGG_CACHE=/tmp/
16
17echo "# rsync webfolder"
18rsync -e "ssh -i $SSH_KEY -l $SSH_USER -o StrictHostKeyChecking=no" -az tyan.wirelessleiden.nl:/usr/local/www/webfolder/scan-data/ $DATAROOT || exit 1
19
20
21echo "# unzip compressed .tar.gz files"
22for FILE in `find $DATAROOT -name '*.tar.gz'`; do
23 TARDIR=`dirname $FILE`
24 if [ \! -r "$TARDIR/`tar -tf $FILE | head -1`" ]; then
25 tar -C $TARDIR -xzf $file
26 fi
27done
28
29ADDED=0
30# Import all data
31for USERDIR in `find $DATAROOT -depth 1 -type d`; do
32 for DEVICEDIR in `find $USERDIR -depth 1 -type d`; do
33 USERNAME=`basename $USERDIR`
34 DEVICE=`basename $DEVICEDIR`
35 ARGS="-g $USERNAME -e $USERNAME@wirelessleiden.nl -k $DEVICE"
36 # Kismet Imports
37 for FILE in `find $DEVICEDIR -name 'Kismet*gpsxml*'`; do
38 $MANAGE import_kismet $ARGS -m `basename $FILE` $FILE
39 done
40
41 # DroidStumber imports
42 for FILE in `find $DEVICEDIR -name 'ScanResult-*'`; do
43 $MANAGE import_droidstumbler $ARGS -m `basename $FILE` $FILE
44 if [ $? -eq 0 ]; then
45 ADDED=1
46 fi
47 done
48 done
49done
50
51if [ "$ADDED" -eq 1 ]; then
52 echo "# Clear cache $MAP_CACHE"
53 htcacheclean -l10K -p$MAP_CACHE
54fi
55
Note: See TracBrowser for help on using the repository browser.