Changeset 10817 for src/django_gheat/import_scan_data.sh
- Timestamp:
- May 13, 2012, 11:12:05 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/django_gheat/import_scan_data.sh
r9823 r10817 2 2 # 3 3 # Quick and dirty hack to import all data 4 # 5 # Rick van der Zwet <rick@wirelessleiden.nl> 4 6 5 7 BASEROOT=`cd $(dirname $0); pwd -P` 6 8 DATAROOT=${1:-"$BASEROOT/scan-data"} 9 SSH_USER=${2:-"backup"} 7 10 MAP_CACHE=${MAP_CACHE:-"/usr/local/var/httpd/cache/maps"} 8 11 MANAGE="`dirname $0`/manage.py" … … 10 13 export PYTHON_EGG_CACHE=/tmp/ 11 14 12 D ATAROOT_CHOICES="$DATAROOT /usr/local/scan-data"15 DEBUG=${DEBUG:-"false"} 13 16 14 DEBUG=${DEBUG:-false} 17 new_imports=false 15 18 16 19 debug() { … … 18 21 } 19 22 20 if [ "$1" ]; then21 DATAROOT=$122 else23 for D in $DATAROOT_CHOICES; do24 if [ -d $D ]; then25 DATAROOT=$D26 fi27 done28 fi29 23 debug "# DATAROOT: $DATAROOT" 30 24 debug "# SSH_USER: $SSH_USER" 31 25 32 26 echo "# rsync webfolder" 1>&2 33 if [ -r "$SSH_KEY" ]; then 34 SSH_KEY_OPT="-i $SSH_KEY" 35 SSH_USER=backup 36 else 37 echo "# warning automatic ssh key $SSH_KEY not readable" 38 SSH_KEY_OPT='' 39 SSH_USER=${SSH_USER:-${SUDO_USER:-$USER}} 27 if [ ! -r "$SSH_KEY" ]; then 28 echo "# ERROR: automatic ssh key $SSH_KEY not readable" 29 exit 1 40 30 fi 41 rsync -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 31 32 changes_files=`rsync -O --out-format="%n%L" -az -e "ssh -i $SSH_KEY -l $SSH_USER -o StrictHostKeyChecking=no" tyan.wirelessleiden.nl:/usr/local/www/webfolder/scan-data/ $DATAROOT` 33 34 if [ -z "$changes_files" ]; then 35 exit 0 36 fi 42 37 43 38 debug "# unzip compressed .tar.gz files" … … 59 54 done 60 55 56 do_import() { 57 $MANAGE import_datafile $* 1>/dev/null 2>/dev/null && new_imports=true 58 } 59 61 60 # Import all measure data 62 61 for USERDIR in `find $DATAROOT -mindepth 1 -maxdepth 1 -type d | sort`; do … … 64 63 USERNAME=`basename $USERDIR` 65 64 DEVICE=`basename $DEVICEDIR` 66 ARGS="- g $USERNAME -e $USERNAME@wirelessleiden.nl -k $DEVICE"65 ARGS="-b -g $USERNAME -e $USERNAME@wirelessleiden.nl -k $DEVICE" 67 66 68 67 echo "# INFO: Processing $USERNAME/$DEVICE" … … 70 69 FILES=`find $DEVICEDIR -name 'ScanResult-*'` 71 70 if [ -n "$FILES" ]; then 72 $MANAGE import_datafile$ARGS $FILES71 do_import $ARGS $FILES 73 72 fi 74 73 … … 77 76 for GPSXML in $FILES; do 78 77 NETXML=`echo $GPSXML | sed 's/gpsxml/netxml/g' ` 79 $MANAGE import_datafile$ARGS $NETXML $GPSXML78 do_import $ARGS $NETXML $GPSXML 80 79 done 81 80 … … 83 82 FILES=`find $DEVICEDIR -name '*.ns1'` 84 83 if [ -n "$FILES" ]; then 85 $MANAGE import_datafile$ARGS $FILES84 do_import $ARGS $FILES 86 85 fi 87 86 done 88 87 done 89 88 90 if [ -r $MAP_CACHE ]; then91 debug "# Clear cache$MAP_CACHE"89 if $new_imports && [ -r $MAP_CACHE ]; then 90 echo "# INFO: New imports, clearing cache of $MAP_CACHE" 92 91 htcacheclean -v -l10K -p$MAP_CACHE 93 92 fi
Note:
See TracChangeset
for help on using the changeset viewer.