--- update_sqlgrey_config.orig Thu Sep 15 12:11:24 2005 +++ update_sqlgrey_config Thu May 29 00:31:44 2014 @@ -1,10 +1,10 @@ -#!/bin/bash +#!/bin/sh # We need md5sum, diff and wget -MD5SUM=`which md5sum 2>/dev/null` +MD5SUM=`which md5 2>/dev/null` if [ $? -ne 0 ] then - echo "md5sum not found in PATH, can't continue" + echo "md5 not found in PATH, can't continue" exit -1 fi DIFF=`which diff 2>/dev/null` @@ -13,12 +13,7 @@ then echo "diff not found in PATH, can't continue" exit -1 fi -WGET=`which wget 2>/dev/null` -if [ $? -ne 0 ] -then - echo "wget not found in PATH, can't continue" - exit -1 -fi +FTP=/usr/bin/ftp # md5sum output parsing need a known locale LANG=C @@ -33,11 +28,6 @@ if [ -z "$whitelists_host" ] then whitelists_host="sqlgrey.bouton.name" fi -pidfile=`grep "^[[:space:]]*pidfile" $CONF | cut -d= -f2 | awk '{print $1}'` -if [ -z "$pidfile" ] -then - pidfile="/var/run/sqlgrey.pid" -fi # Go into a temp directory MYTMP=`mktemp -d ${TMPDIR:-/tmp}/sqlgrey.XXXXXX` @@ -48,18 +38,17 @@ MYTMP=`mktemp -d ${TMPDIR:-/tmp}/sqlgrey.XXXXXX` # Setup a clean exit clean_exit() { - cd ~sqlgrey [ -n "$MYTMP" -a -d "$MYTMP" ] && rm -rf $MYTMP exit $1 } trap clean_exit 2 3 15 # Fetch MD5 -$WGET -q http://$whitelists_host/MD5SUMS +$FTP -V http://$whitelists_host/MD5SUMS # Check installed files cd $MYDIR -TOUPDATE=`md5sum -c $MYTMP/MD5SUMS 2>/dev/null | grep FAILED | cut -d: -f1` +TOUPDATE=`md5 -c $MYTMP/MD5SUMS 2>/dev/null | grep FAILED | cut -d: -f1 | awk '{print $2;}'` if [ -z "$TOUPDATE" ] then @@ -77,7 +66,7 @@ for todownload in $TOUPDATE do echo "updating $MYDIR/$todownload:" rm $todownload 2>/dev/null - $WGET -N -q http://$whitelists_host/$todownload + $FTP -V http://$whitelists_host/$todownload if [ -f $MYDIR/$todownload ]; then $DIFF -u $MYDIR/$todownload $todownload else @@ -85,7 +74,7 @@ do fi done -md5sum -c MD5SUMS >/dev/null 2>/dev/null +md5 -c MD5SUMS >/dev/null 2>/dev/null if [ $? -ne 0 ] then # Can only happen if remote site is borked or file got corrupt in transit @@ -99,6 +88,6 @@ rm MD5SUMS mv * $MYDIR # Reload whitelists -kill -USR1 `cat $pidfile` +pkill -USR1 sqlgrey clean_exit 0