Subject: Re: Request for import of SQLGrey
To: Geert Hendrickx <ghen@telenet.be>
From: Petr Janda <petr@punchyouremployer.com>
List: pkgsrc-users
Date: 09/18/2007 17:18:16
On Tue, 18 Sep 2007 04:30:13 pm Geert Hendrickx wrote:
> Can you try it with #!/bin/sh ?  Many linux scripts use #!/bin/bash while
> they work fine with POSIX sh.

It works. 
There are further modifications necessary.

The script is looking for command md5sum, on DragonFly/FreeBSD we have md5

The script is also looking for wget, so you should add that to dependency list 
too or do as I did Ive changed it to "ftp", that should be transparent 
accross all *nixes.

here is the diff. This dff is agains the original file that came with the 
source  package. I would double check the pidfile in the patch . "//" seems 
like a mistake to me.

Petr

--- update_sqlgrey_config.old   2007-09-18 17:12:07.000000000 +1000
+++ update_sqlgrey_config       2007-09-18 17:04:20.000000000 +1000
@@ -1,7 +1,7 @@
-#!/bin/bash
+#!/bin/sh

-# We need md5sum, diff and wget
-MD5SUM=`which md5sum 2>/dev/null`
+# We need md5sum, diff and ftp
+MD5SUM=`which md5 2>/dev/null`
 if [ $? -ne 0 ]
 then
     echo "md5sum not found in PATH, can't continue"
@@ -13,10 +13,10 @@ then
     echo "diff not found in PATH, can't continue"
     exit -1
 fi
-WGET=`which wget 2>/dev/null`
+FTP=`which ftp 2>/dev/null`
 if [ $? -ne 0 ]
 then
-    echo "wget not found in PATH, can't continue"
+    echo "ftp not found in PATH, can't continue"
     exit -1
 fi

@@ -24,7 +24,7 @@ fi
 LANG=C
 LC_ALL=C

-MYDIR=/etc/sqlgrey
+MYDIR=/usr/pkg/etc/sqlgrey
 CONF=$MYDIR/sqlgrey.conf

 # Get whitelists host and pidfile from conf
@@ -36,7 +36,7 @@ fi
 pidfile=`grep "^[[:space:]]*pidfile" $CONF | cut -d= -f2 | awk '{print $1}'`
 if [ -z "$pidfile" ]
 then
-    pidfile="/var/run/sqlgrey.pid"
+    pidfile="//var/run/sqlgrey.pid"
 fi

 # Go into a temp directory
@@ -48,18 +48,17 @@ MYTMP=`mktemp -d ${TMPDIR:-/tmp}/sqlgrey

 # 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 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`

 if [ -z "$TOUPDATE" ]
 then