#!/bin/sh
#
#   Shell Script to run on CVS server to do actual hosting-data
#   manipulation
#
#   By sandro@w3.org
#   $Id: hosting-control,v 1.1 2004/08/04 16:48:44 sandro Exp $
#


PATH=/bin:/usr/bin:/sbin:/usr/sbin

mydir=hosting-control-info

read cmd

case "$cmd" in

   newfile)
        read file
        dir=`dirname "$file"`
        base=`basename "$file"`
        cd "$dir" || exit 1
        echo $mydir
	if [ ! -d $mydir ]; then
          echo "directory '`/bin/pwd`' does not have a subdirectory '$mydir'"
          exit 1
        fi
        if [ -e "$base" ]; then
          echo "file already exists: $base"
          exit 1
        else
          date > $mydir/"$base"
	  cat > "$base"
          cvs add $mydir/"$base" "$base"
	  cvs commit -m'added by hosting_control script' __hosted__"$base" "$base"
        fi
	;;

    *)
        echo "unknown command: '$cmd'"
        exit 1
	;;
esac


          
     
