#!/bin/sh
#writen by Zane C. Bowers <vvelox@vvelox.net>
. `which sh-include`
include random
include lugtools
usage(){
echo "lgrm: remove POSIX group from LDAP for use with NSS LDAP"
echo "version 0.1.2"
echo ""
echo "required:"
echo "-g <group> the primary group of the user"
echo ""
echo "-h display this"
}
#default config file
config=~/.lugtools
#get the options
while getopts hg:G:u:h OPTION ; do
case "$OPTION" in
g) groupname="$OPTARG" ;;
h) usage=true ;;
\?) usage=true ;;
esac
done
#if usage is defined, print the usage info and exit
if [ ! -z $usage ]; then
usage;
exit 1;
fi
#includes the config file
if [ -e $config ]; then
. $config
else
echo $config does not exist
exit 1
fi
#exit if no groupname is specified
if [ -z $groupname ]; then
echo "-g not used to define a groupname"
exit 1
fi
#exits if the group already exists
if [ `groupExists $groupname` = "false" ]; then
echo "$groupname does not exist"
exit 1
fi
groupDN=`LDAPgroupDN "$groupname" "$GROUPBASE" "$BIND" "$PASSWDFILE"`
ldapdelete -D "$BIND" -y $PASSWDFILE $groupDN
if [ $? = 0 ]; then
echo "$groupname removed"
else
echo "failed to remove $groupname"
exit 1
fi
syntax highlighted by Code2HTML, v. 0.9.1