Find the answer to your Linux question:
Results 1 to 4 of 4
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 ...
  1. #1
    Just Joined!
    Join Date
    Dec 2006
    Posts
    21

    allow or not 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

    Code:
    #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

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

  2. #2
    Linux Enthusiast Mudgen's Avatar
    Join Date
    Feb 2007
    Location
    Virginia
    Posts
    623
    uservar=`whoami`
    groupvar=`groups $uservar|sed s/.*://`
    if [[ $groupvar == "gadmin* ]]
    then
    echo ...you are allowed to..."
    else
    echo "... you are not allowed to ..."
    fi

    Should do what you want.

  3. #3
    Just Joined!
    Join Date
    Dec 2006
    Posts
    21
    thanks a lot

  4. #4
    Linux Enthusiast Mudgen's Avatar
    Join Date
    Feb 2007
    Location
    Virginia
    Posts
    623
    I have a typo in there, I think: The quote before gadmin should be a * like the one following it. Sorry.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...