LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   allow or not script (https://www.linuxquestions.org/questions/linux-newbie-8/allow-or-not-script-801120/)

kopper27 04-09-2010 04:14 PM

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

unSpawn 04-09-2010 07:14 PM

You don't need the string, using the exit value like:
Code:

groups 2>/dev/null|grep -q gmonitor; case "$?" in
0) restart services options;;
*) echo "... you are not allowed to ...";;
# et cetera

should do, or if you still want to "if then" try:
Code:

if [ "${groupvar}" = "${groupvar//gadmin/}" ]; then
 echo "... you are not allowed to ..."
else
 restart services options
# et cetera



All times are GMT -5. The time now is 04:23 PM.