#!/bin/sh -e

##########################################################################
#   Title:
#       Optional, defaults to the name of the script sans extention
#
#   Section:
#       8
#
#   Synopsis:
#       
#   Description:
#       Create a new group
#       
#   Arguments:
#       [-g gid]
#       groupname
#       
#   Returns:
#
#   Examples:
#
#   Files:
#
#   Environment:
#
#   See also:
#       
#   History:
#   Date        Name        Modification
#   2018-11-09  J Bacon     Begin
#   2024-11-11  Jason Bacon Add man page template and usage
##########################################################################

usage()
{
    printf "Usage: $0 [-g gid] groupname\n"
    exit 1
}


##########################################################################
#   Main
##########################################################################

if [ 0$1 = 0-g ]; then
    gid_flags="-g $2"
    shift
    shift
fi

if [ $# != 1 ]; then
    usage
fi

group_name=$1

case $(auto-ostype) in
DragonFly|FreeBSD)
    pw groupadd $group_name $gid_flags
    ;;

OpenBSD|NetBSD|RHEL)
    groupadd $gid_flags $group_name
    ;;

*)
    auto-unsupported-os $0
    exit 1
    ;;

esac
