Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 642361dd

Přidáno uživatelem David Raška před asi 11 roky(ů)

Fixes:
- Fixes error in import script when running with --cron parameter

Zobrazit rozdíly:

import.sh
# get start tim
starttime=$(date '+%s')
# if no parameter given, try to get latest database date from web
if [ $# == 0 ];
then
print_info "No parameter given - Trying to get latest database date"
print_info "Trying to get latest database date"
# download web page
html=$(wget -O - http://nahlizenidokn.cuzk.cz/StahniAdresniMistaRUIAN.aspx 2>/dev/null)
# download web page
html=$(wget -O - http://nahlizenidokn.cuzk.cz/StahniAdresniMistaRUIAN.aspx 2>/dev/null)
if [ $? != 0 ];
then
print_warning "Cannot get latest database date"
rm -rf $directory
exit 1
fi
if [ $? != 0 ];
then
print_warning "Cannot get latest database date"
rm -rf $directory
exit 1
fi
# read date from html source
datestamp=$(echo $html | sed -nre "s/.*([0-9]{8})_OB_ADR_csv\.zip.*/\1/p")
# read date from html source
datestamp=$(echo $html | sed -nre "s/.*([0-9]{8})_OB_ADR_csv\.zip.*/\1/p")
if [ $? != 0 ];
then
print_warning "Cannot get latest database date"
rm -rf $directory
exit 1
fi
else
# get date from parameter
datestamp=$1
if [ $? != 0 ];
then
print_warning "Cannot get latest database date"
rm -rf $directory
exit 1
fi
db_datestamp=$(mysql $mysql_db -u $mysql_user -p$mysql_pass -h $mysql_server -P $mysql_port --silent -e "SELECT value FROM config WHERE name LIKE 'datestamp'")
if [ -n "$db_datestamp" ];
then
if [ $db_datestamp -ge $datestamp ];
if [ "$db_datestamp" -ge "$datestamp" ];
then
print_info "Database is up to date"
exit 0

Také k dispozici: Unified diff