1#!/bin/sh 2# 3# ufdbDLstatus 4# 5# Retrieve the status of previous downloads (today and yestesday) 6# 7# $Id: ufdbDLstatus.in,v 1.1 2018/12/30 20:06:28 root Exp root $ 8 9if [ "${1:-notset}" = "-v" ] 10then 11 verbose=yes 12else 13 verbose=no 14fi 15 16# begin of user settings 17 18# This script requires DOWNLOAD_USER and DOWNLOAD_PASSWORD in the same manner as ufdbUpdate 19# Set DOWNLOAD_USER and DOWNLOAD_PASSWORD and 20# other variables in either /etc/sysconfig/ufdbguard, /etc/conf.d/ufdb, 21# /etc/default/ufdbguard, /usr/pkg/etc/ufdbguard, /etc/urlfilterdb/ufdbguard or 22# /usr/local/etc/ufdbguard. 23DOWNLOAD_USER="" # fill in the user and password 24DOWNLOAD_PASSWORD="" 25 26PROXY_USER="" # if the download must go via an authenticating proxy 27PROXY_PASSWORD="" 28 29CUSTOMER_ID="0000-0000-0000-0000" # not yet required 30WGET_COMMAND="/usr/bin/wget" # or a full path name to wget 31 32# end of user settings. 33# DO NOT EDIT ANYTHING BELOW THIS LINE. ######################################## 34 35prefix=/local/ufdbguard 36exec_prefix=${prefix} 37cfgdir=/local/ufdbguard/etc 38BINDIR="/local/ufdbguard/bin" 39UFDB_VERSION="1.35.3" 40UPDATE_HOST="updates.urlfilterdb.com" 41 42WGET_OPTIONS="--tries 4 --waitretry=8 --timeout=60 --user-agent=ufdbDLstatus-$UFDB_VERSION --no-check-certificate" 43# --limit-rate is removed since the implementation in wget has a severe bug 44# --no-check-certificate is used since on some older systems wget does not have a certificate database 45 46 47reporterror () { 48 MSG="ufdbDLstatus failed: $*" 49 if [ "$ADMIN_MAIL" != "" ] 50 then 51 if [ -x /bin/mailx -o -x /usr/bin/mailx ] 52 then 53 echo "$MSG" | mailx -s "ufdbDLstatus error *****" $ADMIN_MAIL 54 elif [ -x /usr/sbin/sendmail ] 55 then 56 ( echo "Subject: ufdbDLstatus error *****" ; echo ; echo "$MSG" ) | /usr/sbin/sendmail $ADMIN_MAIL 57 else 58 echo "could not send email to $ADMIN_MAIL to report about the following ufdbDLstatus error *****" 59 echo "$MSG" 60 fi 61 fi 62} 63 64 65if [ $verbose = yes ] 66then 67 echo "ufdbDLstatus $UFDB_VERSION" 68fi 69 70# Gentoo uses /etc/conf.d 71if [ -f /etc/conf.d/ufdb ] 72then 73 if [ $verbose = yes ] 74 then 75 echo "sourcing /etc/conf.d/ufdb ..." 76 fi 77 . /etc/conf.d/ufdb 78fi 79# Redhat, CentOS, Fedora use /etc/sysconfig 80if [ -f /etc/sysconfig/ufdbguard ] 81then 82 if [ $verbose = yes ] 83 then 84 echo "sourcing /etc/sysconfig/ufdbguard ..." 85 fi 86 . /etc/sysconfig/ufdbguard 87fi 88# Ubuntu and Debian uses /etc/default 89if [ -f /etc/default/ufdbguard ] 90then 91 if [ $verbose = yes ] 92 then 93 echo "sourcing /etc/default/ufdbguard ..." 94 fi 95 . /etc/default/ufdbguard 96fi 97# NetBSD 98if [ -f /usr/pkg/etc/ufdbguard ] 99then 100 if [ $verbose = yes ] 101 then 102 echo "sourcing /usr/pkg/etc/ufdbguard ..." 103 fi 104 . /usr/pkg/etc/ufdbguard 105fi 106# FreeBSD 107if [ -f /usr/local/etc/ufdbguard ] 108then 109 if [ $verbose = yes ] 110 then 111 echo "sourcing /usr/local/etc/ufdbguard ..." 112 fi 113 . /usr/local/etc/ufdbguard 114fi 115# all others 116if [ -f /etc/urlfilterdb/ufdbguard ] 117then 118 if [ $verbose = yes ] 119 then 120 echo "sourcing /etc/urlfilterdb/ufdbguard ..." 121 fi 122 . /etc/urlfilterdb/ufdbguard 123fi 124 125PATH="/usr/xpg4/bin:/bin:/usr/bin:$BINDIR:/usr/sbin:$PATH" 126export PATH 127 128if [ "$TMPDIR" = "" ] 129then 130 TMPDIR="/tmp" 131fi 132 133umask 022 134 135if [ "$DOWNLOAD_USER" = "" ] 136then 137 echo "The download user is not specified." 138 echo "On most systems DOWNLOAD_USER should be set in /etc/sysconfig/ufdbguard." 139 echo "Please contact support@urlfilterdb.com to get your (trial)" 140 echo "username and password to download updates of URLfilterDB." 141 echo "For trial licenses:" 142 echo "During the evalution period you may use the demo username/password." 143 reporterror "download user name not set. " 144 logger -p $SYSLOG_FACILITY.error -t ufdbDLstatus \ 145 "download user name not set. contact support@urlfilterdb.com" 146 exit 11 147fi 148 149 150if [ $verbose = no ] 151then 152 WGET_OPTIONS="-q $WGET_OPTIONS" 153else 154 WGET_OPTIONS="--progress=dot:mega $WGET_OPTIONS" 155fi 156 157if [ ! -x $WGET_COMMAND ] 158then 159 echo "WGET_COMMAND is $WGET_COMMAND but is not an executable." 160 reporterror "WGET_COMMAND is $WGET_COMMAND but is not an executable." 161 logger -p $SYSLOG_FACILITY.error -t ufdbDLstatus \ 162 "WGET_COMMAND is $WGET_COMMAND but is not an executable." 163 if [ $verbose = yes ] 164 then 165 echo "Make sure that \"wget\" is installed and that PATH is set correctly." 166 echo "Rerun the configure command and \"make install\"" 167 fi 168 exit 11 169fi 170 171if [ "$http_proxy" != "" -a "$https_proxy" = "" ] 172then 173 echo "ERROR: http_proxy is set but https_proxy is not." 174 exit 14 175fi 176 177if [ $verbose = yes ] 178then 179 if [ "$https_proxy" = "" ] 180 then 181 echo "https_proxy is not set: no proxy is used for downloads." 182 else 183 if [ "$PROXY_USER" != "" -a "$PROXY_PASSWORD" != "" ] 184 then 185 echo "Warning: wget uses https_proxy=$https_proxy and PROXY_USER/PROXY_PASSWORD are unset." 186 else 187 echo "wget uses https_proxy=$https_proxy and PROXY_USER=$PROXY_USER." 188 fi 189 fi 190fi 191 192if [ "$PROXY_USER" != "" -a "$PROXY_PASSWORD" != "" ] 193then 194 WGET_OPTIONS="$WGET_OPTIONS --proxy-user=$PROXY_USER --proxy-passwd=$PROXY_PASSWORD " 195fi 196 197WGET_OPTIONS="$WGET_OPTIONS --http-user=$DOWNLOAD_USER --http-passwd=$DOWNLOAD_PASSWORD " 198 199 200if [ $verbose = yes ] 201then 202 echo "The URL database download status will be requested from \"$UPDATE_HOST\"." 203 echo "The username $DOWNLOAD_USER will be used for authentication." 204 echo " $WGET_COMMAND -O - https://$DOWNLOAD_USER:$DOWNLOAD_PASSWORD@$URL_DIR/$GUARD_TYPE/$DBFILE" 205fi 206 207# there are very old wget's which need the username/password in the URL :-( 208$WGET_COMMAND -O - $WGET_OPTIONS --header="X-Hostname: `hostname 2>&1`" \ 209 "https://$DOWNLOAD_USER:$DOWNLOAD_PASSWORD@$UPDATE_HOST/scgi-bin/dlhist.pl" 210exitval=$? 211if [ $exitval -ne 0 ] 212then 213 echo "Download of the URL download status failed (wget exit code is $exitval)." 214 echo "You might need a new username/password from support@urlfilterdb.com" 215 reporterror "URL database download status report failed. You might need a new username/password. wget exit code is $exitval." 216 logger -p $SYSLOG_FACILITY.error -t ufdbDLstatus \ 217 "URL database download status report failed. You might need a new username/password. wget exit code is $exitval." 218 exitval=`expr $exitval + 20` 219else 220 if [ $verbose = yes ] 221 then 222 echo "retrieval of URL database download status report was successful" 223 fi 224fi 225 226 227if [ $exitval -ne 0 ] 228then 229 if [ $verbose = yes ] 230 then 231 echo "exiting with exit status $exitval" 232 fi 233 exit $exitval 234fi 235 236 237if [ $verbose = yes ] 238then 239 echo "Done." 240fi 241 242if [ $verbose = yes ] 243then 244 echo "exit value of ufdbDLstatus is $exitval" 245fi 246exit $exitval 247 248