#!/bin/sh
#
# mkspool	Read the active file and create the news directory
#		hierarchy from it.
#
# Usage:	mkspool [basedir]
#		the default basedir is /usr/spool/news
#
# NOTE:		Starting at wnews 4.44, this script is obsolete since
#		wnews creates the spool directories on-the-fly.
#
  SPOOLDIR=/usr/spool/news
  umask 022

  # Try to locate the active file.
  for i in /conf/news/active /usr/lib/news/active /usr/local/lib/news/active
  do
	if [ -f ${ROOTDIR}$i ]
	then
		active=${ROOTDIR}$i
		break
	fi
  done

  if [ "$active" = "" ]
  then
	echo "mkspool: cannot find your active file."
	exit 1
  fi

  # Check command line argument.
  if [ "$1" != "" ]
  then
	SPOOLDIR=$1
  fi

  # Now read line by line from the activee file.
  sed 's/ .*//
     s/\./ /g' < $active | (
	while read dirs
	do
		if [ "$dirs" != "" ]; then
			set $dirs
			dir=$SPOOLDIR
			while [ "$1" != "" ]
			do
				dir=$dir/$1
				[ ! -d $dir ] && {
					echo "Creating $dir.."
					mkdir $dir
					chown news $dir
				}
				shift
			done
		fi
	done
  )

  exit 0
