#! /bin/sh
#
# @(#)installdir	1.3	LPS_UNX_COM	02/19/95
#
# Copyright 1993   Digital Equipment Corporation, Maynard, MA
#
# installdir
#
# Script to create a directory (if it doesn't already exist) and set
# it to the specified mode, owner and group.
#
# Parameters are:
#
#     $1 - Directory path
#     $2 - Mode value
#     $3 - Owner
#     $4 - Group
#
# If any problems are encountered, the script exits with a value of 1;
# otherwise, the exit value is 0 for success.

if [ ! -d $1 ]
then
    if mkdir -p $1
    then
	:
    else
	echo "    Unable to create directory \"$1\""
	exit 1
    fi
fi

if chmod $2 $1
then
    if chown $3 $1
    then
	if chgrp $4 $1
	then
	    exit 0
	else
	    error="set group ownership"
	fi
    else
	error="set ownership"
    fi
else
    error="set mode (protection)"
fi

echo
echo "    Unable to $error for directory \"$1\""

exit 1
