1#!/bin/sh
2#
3# ufdbUpdate
4#
5# Update the URLfilterDB database by downloading it and sending
6# a HUP signal to ufdbguardd.
7#
8# It is suggested to execute this script from cron, on Monday-Friday
9# between 01:00 and 06:00 local time.
10#
11# Note that the user who runs this script must have sufficient privileges
12# to overwrite an existing URL filter database and to send a HUP signal
13# to ufdbguardd.
14#
15# $Id: ufdbUpdate.in,v 1.70 2020/05/18 12:24:03 root Exp root $
16
17if [ "${1:-notset}" = "-v" ]
18then
19   verbose=yes
20else
21   verbose=no
22fi
23
24# About the exit codes:
25# 0  all OK
26# 1  version mismatch warning; most likely there is a new version of ufdbguardd
27# 2  license expiration warning: less than 2 months to renew license
28# 3  license expired: a license renewal is required immediately
29# 11 configuration error
30# 12 temporary file error
31# 13 download OK but cannot signal ufdbguardd
32# 21-40 exit code of ufdbUpdate is exit code of wget + 20
33#       21 generic error
34#       22 parse error
35#       23 file I/O error
36#       24 network failure
37#       25 SSL verification failure
38#       26 authentication failure
39#       27 protocol error
40#       28 server replied with an error
41# 41-60 exit code of ufdbUpdate is exit code of gunzip + 40
42# 61-80 exit code of ufdbUpdate is exit code of tar + 60
43
44# begin of user settings
45
46# NOTE: historically, the DOWNLOAD_USER and DOWNLOAD_PASSWORD were set in this script
47# but since v1.31 they are set in a system configuration file which makes editing
48# this script no longer required.  So set DOWNLOAD_USER and DOWNLOAD_PASSWORD and
49# other variables in either /etc/sysconfig/ufdbguard, /etc/conf.d/ufdb,
50# /etc/default/ufdbguard, /usr/pkg/etc/ufdbguard, /etc/urlfilterdb/ufdbguard or
51# /usr/local/etc/ufdbguard.
52DOWNLOAD_USER=""                        # fill in the user and password
53DOWNLOAD_PASSWORD=""
54
55BLACKLIST_DIR="@ufdb_dbhome@"           # location of the URL database
56PROXY_USER=""                           # if the download must go via an authenticating proxy
57PROXY_PASSWORD=""
58RUNAS="@ufdb_user@"
59# http_proxy=""				# may need to set http_proxy is not already set
60CUSTOMER_ID="0000-0000-0000-0000"	# not yet required
61WGET_COMMAND="@WGET@"                     # or a full path name to wget
62NOTIFY_UFDBGUARDD="yes"                 # send HUP signal to ufdbguardd
63SYSLOG_FACILITY="local6"                # errors/warnings in system log have this facility name
64
65RATELIMIT="none"                        # may be set to 100k .. 100m
66
67# end of user settings.
68# DO NOT EDIT ANYTHING BELOW THIS LINE.  ########################################
69
70prefix=@prefix@
71exec_prefix=@exec_prefix@
72cfgdir=@ufdb_config@
73BINDIR="@ufdb_bindir@"
74UFDB_VERSION="@PACKAGE_VERSION@"
75UPDATE_HOST="updates.urlfilterdb.com"
76URL_DIR="$UPDATE_HOST/licensed/databases"
77GUARD_TYPE="ufdbguard/@ufdb_db_format@"
78DBFILE="blacklists-latest.tar.gz"
79WGET_OPTIONS="--tries 45 --waitretry=60 --timeout=60 --user-agent=ufdbUpdate-$UFDB_VERSION --no-check-certificate"
80# --limit-rate is removed since the implementation in wget has a severe bug
81# --no-check-certificate is used since on some older systems wget does not have a certificate database
82
83
84reporterror () {
85   MSG="ufdbUpdate failed: $*"
86   if [ "$ADMIN_MAIL" != "" ]
87   then
88      if [ -x /bin/mailx  -o  -x /usr/bin/mailx ]
89      then
90         echo "$MSG" | mailx -s "ufdbUpdate error  *****"  $ADMIN_MAIL
91      elif [ -x /usr/sbin/sendmail ]
92      then
93         ( echo "Subject: ufdbUpdate error  *****" ; echo ; echo "$MSG" ) | /usr/sbin/sendmail $ADMIN_MAIL
94      else
95         echo "could not send email to $ADMIN_MAIL to report about the following ufdbUpdate error  *****"
96	 echo "$MSG"
97      fi
98   fi
99}
100
101
102check_license_status () {
103   # See if there is a license warning for us
104   cd $BLACKLIST_DIR
105   $WGET_COMMAND -O ./license-status $WGET_OPTIONS \
106      "https://$DOWNLOAD_USER:$DOWNLOAD_PASSWORD@$UPDATE_HOST/status/license/$DOWNLOAD_USER"
107   exitcode=$?
108   if [ $exitcode -eq 0  -a  -s ./license-status ]
109   then
110      LICSTAT=`cat ./license-status`
111      case "$LICSTAT" in
112	 WARNING*|Warning*|warning*)
113	    if [ $exitval -lt 2 ]
114	    then
115	       exitval=2
116	    fi
117	    if [ $verbose = yes ]
118	    then
119	       echo "URL database license status: $LICSTAT"
120	    fi
121	    reporterror "ufdbGuard Licenses: $LICSTAT"
122	    logger -p $SYSLOG_FACILITY.warning -t ufdbUpdate "ufdbGuard licenses: $LICSTAT"
123	    ;;
124	 EXPIRED*|Expired*|expired*)
125	    if [ $exitval -lt 3 ]
126	    then
127	       exitval=3
128	    fi
129	    # if [ $verbose = yes ]
130	    # then
131	       echo "URL database license status: $LICSTAT    *****"
132	    # fi
133	    reporterror "ufdbGuard licenses: $LICSTAT"
134	    logger -p $SYSLOG_FACILITY.error -t ufdbUpdate "ufdbGuard licenses: $LICSTAT"
135	    ;;
136	 *)
137	    if [ $verbose = yes ]
138	    then
139	       echo "URL database license status: $LICSTAT"
140	    fi
141      esac
142   fi
143}
144
145
146reload_config () {
147   # A HUP signal is sent to the ufdbguardd to load the new URL database.
148   # 3rd party API implementators must replace the following code with their own.
149
150   if [ $verbose = yes ]
151   then
152      echo "Sending HUP signal to the ufdbguardd daemon to load new configuration..."
153   fi
154
155   # the 'ps' command on netbsd needs other flags than '-ef'
156   KERNEL=`uname -s`
157   case "$KERNEL" in
158       *NetBSD*)
159	   PSALL="-al" ;;
160       *FreeBSD*)
161	   PSALL="-axj" ;;
162       *OpenBSD*)
163	   PSALL="-axj" ;;
164       *)
165	   # Linux and others
166	   PSALL="-ef" ;;
167   esac
168   export PSALL
169
170
171   if [ -f @ufdb_piddir@/ufdbguardd.pid ]
172   then
173      DPIDS=`cat @ufdb_piddir@/ufdbguardd.pid`
174      # doublecheck
175      CHECK=`ps -p $DPIDS 2>/dev/null | grep ufdbguardd `
176      if [ "$CHECK" = "" ]
177      then
178	 PS=`ps $PSALL`
179	 DPIDS=`echo "$PS" | grep ufdbguardd | grep -v grep | awk '{ print $2 }' `
180      fi
181   else
182      if [ $verbose = yes ]
183      then
184	 echo "pid file @ufdb_piddir@/ufdbguardd.pid does not exist.  Using ps to find pid of ufdbguardd"
185      fi
186      PS=`ps $PSALL`
187      DPIDS=`echo "$PS" | grep ufdbguardd | grep -v grep | awk '{ print $2 }' `
188   fi
189
190
191   if [ "$DPIDS" != "" ]	# are there ufdbguardd processes ?
192   then
193      if [ -r @ufdb_piddir@/ufdbguardd.pid ]
194      then
195	 ufdbsignal -C "sighup ufdbguardd"
196	 exitval=$?
197      else
198	 echo "ufdbguardd is running but @ufdb_piddir@/ufdbguardd.pid does not exist.  Using kill -HUP $DPIDS ..."
199	 kill -HUP $DPIDS
200	 exitval=$?
201      fi
202      if [ $exitval != 0 ]
203      then
204	 reporterror "HUP signal could not be sent to the ufdbguardd daemon.  Restart the daemon manually."
205	 logger -p $SYSLOG_FACILITY.error -t ufdbUpdate \
206		"HUP signal could not be sent to the ufdbguardd daemon.  Restart the daemon manually."
207	 if [ $verbose = yes ]
208	 then
209	    echo "HUP signal could not be sent to the ufdbguardd daemon.  Restart the daemon manually."
210	 fi
211	 exitval=13
212      fi
213      if [ -f /var/run/urlfilterdb/icapd.pid ]
214      then
215	 ufdbsignal -q -C "sighup icapd"
216      fi
217   else			# no ufdbguardd processes...
218      reporterror "No ufdbguardd processes found.  Starting the daemon..."
219      logger -p $SYSLOG_FACILITY.error -t ufdbUpdate \
220	     "No ufdbguardd processes found.  Starting the daemon..."
221      if [ $verbose = yes ]
222      then
223	 echo "No ufdbguardd processes found.  Starting the daemon..."
224      fi
225      initscriptfound=no
226      for dir in   /usr/pkg/etc/rc.d  \
227		   /usr/local/etc/rc.d  \
228		   /etc/rc.d/init.d  \
229		   /etc/init.d  \
230		   /sbin/init.d  \
231		   $BINDIR
232      do
233	 if [ -f $dir/ufdb.sh -o -f $dir/ufdb ]
234	 then
235	    initscriptfound=yes
236
237	    # The most common reason why ufdbguardd does not start is because
238	    # the UNIX socket /tmp/ufdbguardd-03977 exists, so remove it!
239	    rm -f /tmp/ufdbguardd-03977
240
241	    if [ -x $dir/ufdb.sh ]
242	    then
243	       $dir/ufdb.sh start
244	    else
245	       $dir/ufdb start
246	    fi
247	    exitcode=$?
248	    if [ $exitcode -ne 0 ]
249	    then
250	       reporterror "The ufdbguardd daemon did not start (exit code is $exitval)."
251	       logger -p $SYSLOG_FACILITY.error -t ufdbUpdate \
252		      "The ufdbguardd daemon did not start (exit code is $exitval)."
253	       if [ $verbose = yes ]
254	       then
255		  echo "The ufdbguardd daemon did not start (exit code is $exitval)."
256	       fi
257	       exitval=13
258	    fi
259	    break
260	 fi
261      done
262
263      if [ $initscriptfound = no ]
264      then
265	 exitval=14
266	 reporterror "The ufdbguardd daemon could not be started (could not find the ufdb[.sh] start script)."
267	 logger -p $SYSLOG_FACILITY.error -t ufdbUpdate \
268		"The ufdbguardd daemon could not be started (could not find the ufdb[.sh] start script)."
269	 if [ $verbose = yes ]
270	 then
271	    echo "The ufdbguardd daemon could not be started (could not find the ufdb[.sh] start script)."
272	 fi
273      fi
274   fi
275}
276
277
278if [ $verbose = yes ]
279then
280   echo "ufdbUpdate $UFDB_VERSION"
281fi
282
283# Gentoo uses /etc/conf.d
284if [ -f /etc/conf.d/ufdb ]
285then
286   if [ $verbose = yes ]
287   then
288      echo "sourcing /etc/conf.d/ufdb ..."
289   fi
290   . /etc/conf.d/ufdb
291fi
292# Redhat, CentOS, Fedora use /etc/sysconfig
293if [ -f /etc/sysconfig/ufdbguard ]
294then
295   if [ $verbose = yes ]
296   then
297      echo "sourcing /etc/sysconfig/ufdbguard ..."
298   fi
299   . /etc/sysconfig/ufdbguard
300fi
301# Ubuntu and Debian uses /etc/default
302if [ -f /etc/default/ufdbguard ]
303then
304   if [ $verbose = yes ]
305   then
306      echo "sourcing /etc/default/ufdbguard ..."
307   fi
308   . /etc/default/ufdbguard
309fi
310# NetBSD
311if [ -f /usr/pkg/etc/ufdbguard ]
312then
313   if [ $verbose = yes ]
314   then
315      echo "sourcing /usr/pkg/etc/ufdbguard ..."
316   fi
317   . /usr/pkg/etc/ufdbguard
318fi
319# FreeBSD
320if [ -f /usr/local/etc/ufdbguard ]
321then
322   if [ $verbose = yes ]
323   then
324      echo "sourcing /usr/local/etc/ufdbguard ..."
325   fi
326   . /usr/local/etc/ufdbguard
327fi
328# all others
329if [ -f /etc/urlfilterdb/ufdbguard ]
330then
331   if [ $verbose = yes ]
332   then
333      echo "sourcing /etc/urlfilterdb/ufdbguard ..."
334   fi
335   . /etc/urlfilterdb/ufdbguard
336fi
337# the ufdbGuard API uses /usr/local/ufdb-api/etc
338case "@API_VERSION@" in
339   1.*|2.*|3.*)
340       if [ -f @prefix@/etc/ufdbguard ]
341       then
342          if [ $verbose = yes ]
343          then
344             echo "sourcing @prefix@/etc/ufdbguard ..."
345          fi
346          . @prefix@/etc/ufdbguard
347       fi ;;
348esac
349
350PATH="/usr/xpg4/bin:/bin:/usr/bin:$BINDIR:/usr/sbin:$PATH"
351export PATH
352
353if [ "$TMPDIR" = "" ]
354then
355   TMPDIR="/tmp"
356fi
357
358umask 022
359
360if [ "$RUNAS" != ""  -a  "$RUNAS" != "root" ]
361then
362   MYUSERID=`id -un`
363   if [ "$RUNAS" != "$MYUSERID" ]
364   then
365      echo "ERROR: mismatch in user id: RUNAS=$RUNAS but ufdbUpdate is executed as $MYUSERID."  >&2
366      echo "Download of the URL database is aborted.     *****  *****"  >&2
367      if [ "$MYUSERID" = "root" ]
368      then
369         echo "Do not run ufdbUpdate as root since it overwrites file permissions for $RUNAS." >&2
370      fi
371      exit 1
372   fi
373fi
374
375if [ "$DOWNLOAD_USER" = "" ]
376then
377   echo "The download user is not specified."
378   echo "On most systems DOWNLOAD_USER should be set in @ufdb_sysconfigfile@."
379   echo "Please contact support@urlfilterdb.com to get your (trial)"
380   echo "username and password to download updates of the URL database."
381   echo "For trial licenses:"
382   echo "During the evalution period you may use the demo username/password."
383   reporterror "download user name not set. "
384   logger -p $SYSLOG_FACILITY.error -t ufdbUpdate \
385          "download user name not set. contact support@urlfilterdb.com"
386   exit 11
387fi
388
389if [ ! -d "$TMPDIR"  -o  ! -w "$TMPDIR" ]
390then
391   echo "The temporary download directory \"$TMPDIR\" is invalid or not writable."
392   logger -p $SYSLOG_FACILITY.error -t ufdbUpdate \
393          "temporary directory \"$TMPDIR\" is invalid or not writable"
394   reporterror "temporary directory \"$TMPDIR\" is invalid or not writable"
395   exit 11
396fi
397
398if [ $verbose = yes ]
399then
400   echo "The URL database will be downloaded and unpacked to the directory \"$BLACKLIST_DIR\"."
401   echo "The username $DOWNLOAD_USER will be used for authentication."
402   echo "time and date in CET timezone:"
403   TZ=CET date
404fi
405
406if [ ! -d "$BLACKLIST_DIR"  -o  ! -w "$BLACKLIST_DIR" ]
407then
408   echo "$BLACKLIST_DIR is not an existing directory or not writable."
409   echo "Verify BLACKLIST_DIR in ufdbUpdate."
410   reporterror "Blacklist directory \"$BLACKLIST_DIR\" is invalid or not writable."
411   logger -p $SYSLOG_FACILITY.error -t ufdbUpdate \
412          "Blacklist directory \"$BLACKLIST_DIR\" is invalid or not writable."
413   exit 11
414fi
415
416
417if [ $verbose = no ]
418then
419   WGET_OPTIONS="-q $WGET_OPTIONS"
420else
421   WGET_OPTIONS="--progress=dot:mega $WGET_OPTIONS"
422fi
423
424if [ "$RATELIMIT" != "none" ]
425then
426   WGET_OPTIONS="--limit-rate $RATELIMIT  $WGET_OPTIONS"
427fi
428
429if [ ! -x $WGET_COMMAND ]
430then
431   echo "WGET_COMMAND is $WGET_COMMAND but is not an executable."
432   reporterror "WGET_COMMAND is $WGET_COMMAND but is not an executable."
433   logger -p $SYSLOG_FACILITY.error -t ufdbUpdate \
434        "WGET_COMMAND is $WGET_COMMAND but is not an executable."
435   if [ $verbose = yes ]
436   then
437      echo "Make sure that \"wget\" is installed and that PATH is set correctly."
438      echo "Rerun the configure command and \"make install\""
439   fi
440   exit 11
441fi
442
443if [ "$http_proxy" != ""  -a  "$https_proxy" = "" ]
444then
445   echo "ERROR: http_proxy is set but https_proxy is not."
446   exit 14
447fi
448
449if [ $verbose = yes ]
450then
451   if [ "$http_proxy" = "" ]
452   then
453      echo "http_proxy is not set: no proxy is used for downloads."
454   else
455      if [ "$PROXY_USER" != ""  -a  "$PROXY_PASSWORD" != "" ]
456      then
457	 echo "Warning: wget uses http_proxy=$http_proxy and PROXY_USER/PROXY_PASSWORD are unset."
458      else
459	 echo "wget uses http(s)_proxy=$http_proxy and PROXY_USER=$PROXY_USER."
460      fi
461   fi
462fi
463
464if [ "$PROXY_USER" != ""  -a  "$PROXY_PASSWORD" != "" ]
465then
466   WGET_OPTIONS="$WGET_OPTIONS  --proxy-user=$PROXY_USER  --proxy-passwd=$PROXY_PASSWORD "
467fi
468
469WGET_OPTIONS="$WGET_OPTIONS  --http-user=$DOWNLOAD_USER  --http-passwd=$DOWNLOAD_PASSWORD "
470
471TMP_FILE="$TMPDIR/urlfilterdb-latest.tar.gz"
472TMP_TARFILE="$TMPDIR/urlfilterdb-latest.tar"
473rm -f $TMP_FILE $TMP_TARFILE
474
475if [ -f $TMP_FILE ]
476then
477   echo "cannot remove file $TMP_FILE"
478   echo "URLfilterDB NOT downloaded."
479   reporterror "Cannot remove $TMP_FILE.  download aborted."
480   logger -p $SYSLOG_FACILITY.error -t ufdbUpdate \
481          "Cannot remove $TMP_FILE.  download aborted."
482   exit 12
483fi
484
485if [ $verbose = yes ]
486then
487   echo "Downloading the current database..."
488   echo "   $WGET_COMMAND -O $TMP_FILE https://$DOWNLOAD_USER:$DOWNLOAD_PASSWORD@$URL_DIR/$GUARD_TYPE/$DBFILE"
489fi
490
491# there are very old wget's which need the username/password in the URL :-(
492$WGET_COMMAND -O $TMP_FILE --header="X-username: $DOWNLOAD_USER" $WGET_OPTIONS --header="X-Hostname: `hostname 2>&1`"  \
493   "https://$DOWNLOAD_USER:$DOWNLOAD_PASSWORD@$URL_DIR/$GUARD_TYPE/$DBFILE"
494exitval=$?
495if [ $exitval -ne 0  -o  ! -s $TMP_FILE ]
496then
497   echo "wget failed to download the URL database -- wget exit code is $exitval"
498   case $exitval in
499   4) echo "wget reported a network failure.  Check access to $UPDATE_HOST" ;
500      break;;
501   5) echo "wget reported an SSL error.  Verify that the CA certificates on this system are up to date";
502      break;;
503   6) echo "wget reported an authentication failure.  Verify the download username/password."
504      echo "Your license may be expired.  Contact support@urlfilterdb.com if in doubt."
505      if [ "$DOWNLOAD_USER" != "" ]
506      then
507	 check_license_status
508      fi
509      break;;
510   8) echo "wget reported that the $UPDATE_HOST reported an error."
511      echo "Try again in 5 minutes and contact support@urlfilterdb.com if the failure persists."
512      break;;
513   esac
514
515   if [ -s $TMP_FILE ]
516   then
517      ls -l $TMP_FILE
518   else
519      echo "URL database download failed: $TMP_FILE does not exist or is empty."
520   fi
521   reporterror "URL database download failed.  wget exit code is $exitval."
522   logger -p $SYSLOG_FACILITY.error -t ufdbUpdate \
523          "URL database download failed.  wget exit code is $exitval.  run 'ufdbUpdate -v' for troubleshooting."
524   exitval=`expr $exitval + 20`
525   exit $exitval
526else
527   if [ $verbose = yes ]
528   then
529      echo "new database downloaded:"
530      ls -l $TMP_FILE
531   fi
532fi
533
534if [ $exitval -eq 0 ]
535then
536   if [ $verbose = yes ]
537   then
538      echo "Unpacking the database..."
539   fi
540
541   cd $BLACKLIST_DIR
542   cd ..
543
544   gunzip $TMP_FILE
545   exitval=$?
546   if [ $exitval -ne 0 ]
547   then
548      echo "Decompression with gunzip of the downloaded URL database ($TMP_FILE) failed."
549      echo "gunzip exit code is $exitval."
550      reporterror "Decompression of downloaded URL database failed.  gunzip exit code is $exitval."
551      logger -p $SYSLOG_FACILITY.error -t ufdbUpdate \
552	     "Decompression of downloaded URL database failed.  gunzip exit code is $exitval."
553      exitval=`expr $exitval + 40`
554      exit $exitval
555   fi
556
557   if [ $exitval -eq 0 ]
558   then
559      tar xf $TMP_TARFILE
560      exitval=$?
561      if [ $exitval -eq 0 ]
562      then
563         if [ $verbose = yes ]
564	 then
565	    echo "The downloaded database is installed in directory $BLACKLIST_DIR and its subdirectories"
566	 fi
567      else
568	 echo "unpacking with tar of downloaded URL database ($TMP_TARFILE) failed."
569	 echo "tar exit code is $exitval."
570	 reporterror "Unpacking of downloaded URL database failed.  tar exit code is $exitval."
571	 logger -p $SYSLOG_FACILITY.error -t ufdbUpdate \
572		"Unpacking of downloaded URL database failed.  tar exit code is $exitval."
573	 exitval=`expr $exitval + 60`
574	 exit $exitval
575      fi
576
577      # PhishTank was introduced in version 1.29
578      if [ -d "$cfgdir" -a -r $cfgdir/ufdbGuard.conf ]
579      then
580         if grep "do-not-download-phishtank" $cfgdir/ufdbGuard.conf
581	 then
582	    : do nothing
583	 else
584	    (
585	    cd $BLACKLIST_DIR
586	    if [ $exitval -eq 0  -a  -x ./phishtank/download_phishtank.sh ]
587	    then
588	       if [ $verbose = yes ]
589	       then
590		  echo "running download_phishtank.sh to download a new anti-phishing URL list from www.phishtank.com"
591	       fi
592	       ./phishtank/download_phishtank.sh
593	    fi
594	    )
595	 fi
596      fi
597   fi
598fi
599
600
601if [ $exitval -ne 0 ]
602then
603   if [ $verbose = yes ]
604   then
605      echo "exiting with exit status $exitval"
606   fi
607   exit $exitval
608fi
609
610rm -f $TMP_FILE $TMP_TARFILE
611
612
613if [ $exitval -ne 0 ]
614then
615   if [ $verbose = yes ]
616   then
617      echo "exiting with exit status $exitval"
618   fi
619   exit $exitval
620fi
621
622# Check the latest version.
623if [ "$API_VERSION" = "none"  -o  "$API_VERSION" = "" ]
624then
625   if [ -f $BLACKLIST_DIR/version ]
626   then
627      LATEST_VERSION=`cat $BLACKLIST_DIR/version`
628      if [ "$LATEST_VERSION" != "$UFDB_VERSION" ]
629      then
630         if [ $verbose = yes ]
631         then
632            echo "Notice: ufdbguard has version $UFDB_VERSION while the latest released version is $LATEST_VERSION"
633         fi
634         logger -p $SYSLOG_FACILITY.warning -t ufdbUpdate \
635            "ufdbguard has version $UFDB_VERSION while the latest released version is $LATEST_VERSION"
636         if [ $exitval -eq 0 ]
637         then
638            : exitval=1    # do NOT change the exit code of this script
639         fi
640      else
641         if [ $verbose = yes ]
642         then
643            echo "ufdbguard has the latest version: $LATEST_VERSION"
644         fi
645      fi
646   else
647      echo "warning: the downloaded database does not have a file called \"version\""
648      if [ $exitval -eq 0 ]
649      then
650         exitval=1
651      fi
652   fi
653fi
654
655# show the creation date
656if [ $verbose = yes ]
657then
658   if [ -f $BLACKLIST_DIR/creationdate ]
659   then
660      echo "URL database creation date: " `cat $BLACKLIST_DIR/creationdate`
661   else
662      echo "The URL database has no file with the creation date."
663   fi
664fi
665
666check_license_status
667
668if [ "$UFDB_UPDATE_SENDS_SIGNAL" = no ]
669then
670   # typically only "ufdbGuard for Squid" sends a signal to ufdbguardd
671   if [ $verbose = yes ]
672   then
673      echo "No signal is sent to a process to reload the URL database."
674   fi
675else
676   reload_config
677
678   if [ $verbose = yes ]
679   then
680      echo "Done."
681      if test -t 0
682      then
683	 schedule=`crontab -l 2>/dev/null | grep ufdbUpdate`
684	 if [ "$schedule" = "" ]
685	 then
686	    echo
687	    echo "NOTE: ufdbUpdate is not yet defined as a cron job.            *****"
688	    echo "daily downloads of the URL database are highly recommended."
689	 fi
690
691	 clients=`ps $PSALL | grep ufdbgclient | grep -v grep`
692	 if [ "$clients" = "" ]
693	 then
694	    echo
695	    echo "NOTE: there are currently no ufdbgclient processes running.   *****"
696	    echo "Check parameters url_rewrite_program and url_rewrite_children in squid.conf"
697	 fi
698      fi
699   fi
700fi
701
702if [ $verbose = yes ]
703then
704   echo "exit value of ufdbUpdate is $exitval"
705fi
706exit $exitval
707
708