#!/bin/bash

# This script is designed to run under CentOS-2 or Red Hat Enterprise Linux 2.1

SYSLOGD=/sbin/syslogd
BASEDIR=/var/log/virtual

if [ "$2" ] ; then
   mkdir -p $BASEDIR/$1
   cd $BASEDIR/$1
   if [ `pwd` != $BASEDIR/$1 ] ; then
      exit 1
   fi

   mkdir -p dev etc lib sbin var/log var/run
   cp $SYSLOGD sbin
   for f in `ldd $SYSLOGD | awk '{print $3}'` ; do
      cp $f lib
   done
   cp /lib/libnss_dns.so.2 /lib/libnss_files.so.2 /lib/libresolv.so.2 lib
   cp /etc/syslog.conf etc
   cp /etc/localtime etc
   cp /etc/host.conf /etc/nsswitch.conf /etc/resolv.conf etc
   #grep syslog /etc/services > etc/services
   echo "syslog $2/udp" > etc/services

   echo "Start syslogd with this command"
   echo "chroot $BASEDIR/$1 $SYSLOGD -r"
else
   echo "Usage: $0 name port_number"
   echo "eg: $0 staff 1514"
fi

