permission script

hi guys

I am working on a menu...
and the menu has some options like check status for services (gmonitor group) or stop - start - restart those same services (gadmin group)

as you see there are 2 main groups gmonitor for monitoring and gadmin for restart - stop - start services

so checking command groups

#groups root
root : root bin daemon sys adm disk wheel ivmgr httpd gadmin

#groups cgonza
cgonza : cgonza testing gmonitor

basically I want to read the output from groups command and atfer that

if group gadmin is found allow the user to restart services and if gmonitor group is found deny access to restart services

the point is I don't know how to get that groupvar

if [ "$groupvar" == "gadmin" ]
        then
         restart services options
       else
         echo "... you are not allowed to ..."

thanks a lot

groups $LOGNAME|grep gadmin >/dev/null
if [ $? = 0 ]
then
  groupvar=gadmin
else
  groupvar=gmonitor
fi

Untested

tested and works as it should