#! /bin/sh

# A script to check gup consistency

# the username that gup runs as
gup_uid="newsgup"

cd /var/mailserv/newsgup

# global header
if [ ! -f headers/global ]; then
  echo 'missing global header!'
fi

cd hosts
default=../default
for h in *
do
  echo $h

  # header
  if [ ! -f $h/header ]; then
    echo "linking default/header -> $h/header"
    ln $default/header $h/header
  fi

  # body
  if [ ! -f $h/groups ]; then
    echo "copying basic groups entry -> $h/groups"
    cp $default/groups $h/groups
  fi

  # trailer
  if [ ! -f $h/trailer ]; then
    echo "linking default/trailer -> $h/trailer"
    ln $default/trailer $h/trailer
  fi

  # exclusions
  if [ ! -f $h/exclude ]; then
    echo "linking default/exclude -> $h/exclude"
    ln $default/exclude $h/exclude
  fi
done

chown $gup_uid */groups
cd ..

# global trailer
if [ ! -f trailers/global ]; then
  echo 'missing global trailer!'
fi
