#!/bin/sh -e
#
# @(#)domain.sh	1.1 99/03/06 Sun Microsystems, Inc.
#
# Create a new domain (configuration database).
#

PATH="/opt/SUNWicg/SunScreen/ssadm:/usr/bin:/usr/sbin/"
export PATH

CONFIGS=/etc/opt/SUNWicg/SunScreen/configs

usage()
{
    echo>&2 "Usage: $0: { -l | -a domain }"
    exit 2
}

add=false
list=false
while getopts la: c
do case $c in
   a) add=true domain=$OPTARG;;
   l) list=true;;
   ?) usage;;
   esac
done

if $add && $list
then usage
elif $add
then cd $CONFIGS
     mkdir -m 0770 "$domain"
     chgrp sys "$domain"
     cd "$domain"
     cp ../template.registry Registry
     cp ../template.policy Initial
     mkdir .ezdb
     mkdir .ezdb/auth_user.d .ezdb/logmacro.d .ezdb/proxy_user.d .ezdb/vars.d
elif $list
then cd $CONFIGS
     ls | grep -v '^template\.'
else usage
fi
