67 lines
1.2 KiB
Bash
Executable File
67 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# lock to avoid concurrent updates
|
|
LOCK=/var/run/univnautes-update-map_in-progress.lock
|
|
if [ -r $LOCK ]
|
|
then
|
|
PID=`cat $LOCK`
|
|
ps waux | grep $PID | grep univnautes | grep -vq grep && exit
|
|
fi
|
|
unlock() {
|
|
rm -f $LOCK
|
|
exit
|
|
}
|
|
trap unlock INT TERM EXIT
|
|
echo $$ > $LOCK
|
|
|
|
# config
|
|
. /usr/local/univnautes/etc/univnautes.conf
|
|
|
|
log() {
|
|
logger -p local4.info -t update-map -- "$*"
|
|
}
|
|
|
|
GEOURLS=/var/lib/univnautes/geourls
|
|
GEOLOCAL=/var/lib/univnautes/geolocal
|
|
LOGINHTML=/var/lib/univnautes/templates/login.html
|
|
|
|
GEODIR=/var/lib/univnautes/geofiles
|
|
mkdir -p $GEODIR
|
|
GEOFILES=""
|
|
|
|
n=1
|
|
for url in `cat $GEOURLS | tr -d
|
|
`
|
|
do
|
|
GEOFILE=$GEODIR/$n
|
|
wget -q --no-check-certificate -O $GEOFILE $url
|
|
if [ $? -eq 0 ]
|
|
then
|
|
log "$url OK ($n)"
|
|
GEOFILES=$GEOFILES" "$GEOFILE
|
|
n=$(($n+1))
|
|
else
|
|
log "cannot download $url"
|
|
fi
|
|
done
|
|
|
|
if [ -r $GEOLOCAL ]
|
|
then
|
|
GEOFILES=$GEOFILES" "$GEOLOCAL
|
|
fi
|
|
|
|
# virtualenv activation
|
|
VIRTUAL_ENV="/usr/local/univnautes"
|
|
export VIRTUAL_ENV
|
|
PATH="$VIRTUAL_ENV/bin:$PATH"
|
|
export PATH
|
|
|
|
# create indexhtml
|
|
cd /usr/local/univnautes/pffedportal
|
|
if [ -r pffedportal.db ]
|
|
then
|
|
python ./create_loginhtml.py $GEOFILES 2>&1 > $LOGINHTML | logger -p local4.info -t update-map
|
|
log "geo-list of idp created"
|
|
fi
|
|
|
|
exit 0
|