[9552] | 1 | #!/bin/sh
|
---|
| 2 | #
|
---|
| 3 | # Quick and dirty hack to import all data
|
---|
| 4 |
|
---|
[9555] | 5 | if [ `id -un` != "www" ]; then
|
---|
| 6 | echo "ERROR, run as www user: sudo -E -u www $0"
|
---|
| 7 | exit 1
|
---|
| 8 | fi
|
---|
[9552] | 9 |
|
---|
[9555] | 10 | DATAROOT="/usr/local/var/scan-data"
|
---|
| 11 | MAP_CACHE=/usr/local/var/httpd/cache/maps
|
---|
| 12 | MANAGE="`dirname $0`/manage.py"
|
---|
| 13 | SSH_USER=backup
|
---|
| 14 | SSH_KEY="`dirname $0`/id_rsa"
|
---|
| 15 | export PYTHON_EGG_CACHE=/tmp/
|
---|
[9552] | 16 |
|
---|
| 17 | echo "# rsync webfolder"
|
---|
[9555] | 18 | rsync -e "ssh -i $SSH_KEY -l $SSH_USER -o StrictHostKeyChecking=no" -az tyan.wirelessleiden.nl:/usr/local/www/webfolder/scan-data/ $DATAROOT || exit 1
|
---|
[9552] | 19 |
|
---|
[9555] | 20 |
|
---|
[9552] | 21 | echo "# unzip compressed .tar.gz files"
|
---|
| 22 | for 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
|
---|
| 27 | done
|
---|
| 28 |
|
---|
[9555] | 29 | ADDED=0
|
---|
[9552] | 30 | # Import all data
|
---|
| 31 | for 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
|
---|
[9555] | 44 | if [ $? -eq 0 ]; then
|
---|
| 45 | ADDED=1
|
---|
| 46 | fi
|
---|
[9552] | 47 | done
|
---|
| 48 | done
|
---|
| 49 | done
|
---|
| 50 |
|
---|
[9555] | 51 | if [ "$ADDED" -eq 1 ]; then
|
---|
| 52 | echo "# Clear cache $MAP_CACHE"
|
---|
| 53 | htcacheclean -l10K -p$MAP_CACHE
|
---|
| 54 | fi
|
---|
[9552] | 55 |
|
---|