Newer
Older
tperimeter / rebuild-hosts.allow.sh
#!/bin/sh
# rebuild-hosts.allow.sh
# Rebuild /etc/hosts.allow From Standard And User-Requested Entries
# Part Of The 'tperimeter' Package
#
# Copyright (c) 2006 TundraWare Inc., Des Plaines, IL USA
# All Rights Reserved
# $Id: rebuild-hosts.allow.sh,v 1.101 2006/04/29 07:54:51 tundra Exp $

BASE="/usr/local/etc/tperimeter"
EPILOGUE=${BASE}/epilogue
PROLOGUE=${BASE}/prologue
STANDARD=${BASE}/allow
USERREQUESTS="/www/cgi-bin/tperimeter/requests"

#####
# Function To Scan A Directory Structure To Build
# "Allow" Entries In Proper /etc/hosts.allow Format
#####

BuildAllowEntries()
{
  if [ -d $1 ]          # Only attempt this if the target directory exists
  then
    cd $1
    for x in *
      do
        echo -n $x": "
        cd $x
        for y in *
        do
          echo -n $y" "
        done
        echo " :ALLOW"
        cd ..
      done
  fi
}
# End Of 'BuildAllowEntries()'

#####
# Rebuild /etc/hosts-allow
#####

# Timestamp it

echo "# Built On:  `date`"
echo ""

# First, the standard prologue

cat ${PROLOGUE}


# Add any user-requested temporary additions

echo "# Access Requested Via The 'tperimeter' Interface"
echo ""

BuildAllowEntries ${USERREQUESTS}


# Delete the user requests

rm -rf ${USERREQUESTS}


# Now include the standard set of access definitions

echo ""
echo "# Standard 'Allow' Entries"
echo ""

BuildAllowEntries ${STANDARD}

# Finally, add the epilogue

cat ${EPILOGUE}