grep -q ^nofiles: /etc/group ||
  groupadd -g 340 nofiles
grep -q ^alias: /etc/passwd ||
  useradd -r -g nofiles -d /var/qmail/alias -u 339 -s "" alias
grep -q ^qmaild: /etc/passwd ||
  useradd -r -g nofiles -d /var/qmail -u 340 -s "" qmaild
grep -q ^qmaill: /etc/passwd ||
  useradd -r -g nofiles -d /var/qmail -u 341 -s "" qmaill
grep -q ^qmailp: /etc/passwd ||
  useradd -r -g nofiles -d /var/qmail -u 342 -s "" qmailp
grep -q ^qmail: /etc/group ||
  groupadd -g 339 qmail
grep -q ^qmailq: /etc/passwd ||
  useradd -r -g qmail -d /var/qmail -u 343 -s "" qmailq
grep -q ^qmailr: /etc/passwd ||
  useradd -r -g qmail -d /var/qmail -u 344 -s "" qmailr
grep -q ^qmails: /etc/passwd ||
  useradd -r -g qmail -d /var/qmail -u 345 -s "" qmails
config() {
  NEW="$1"
  OLD="$(dirname $NEW)/$(basename $NEW .new)"
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
    rm $NEW
  fi
}
# LWQ 2.5.5
cd /usr/doc/netqmail-1.06/install_scripts
./config
cd /var/qmail/control
for i in me defaultdomain plusdomain locals rcpthosts
do
  config $i.new
done

#LWQ 2.8.2.3
grep -q '127.:allow,RELAYCLIENT=""' /etc/tcp.smtp 2>/dev/null ||
  echo '127.:allow,RELAYCLIENT=""' >>/etc/tcp.smtp
qmailctl cdb

# LWQ 2.8.3
for i in /usr/lib /usr/sbin
do
  if [ -e $i/sendmail ]
  then
    if [ $(readlink -f $i/sendmail) != /var/qmail/bin/sendmail ]
    then
      mv $i/sendmail $i/sendmail.old
      chmod 0 $i/sendmail.old
      ln -s /var/qmail/bin/sendmail $i
    fi
  else
    rm -f $i/sendmail  # Could be a dangling symlink
    ln -s /var/qmail/bin/sendmail $i
  fi
done
