Go to:  Davar site entry | Site contents | Site index | Client/Server | MQSeries | Text bottom

SETMQAUT  Korn  Script

Note:  Several years after it's origination SETMQAUT script was completely outdated by new developments in MQSeries (most notably amqoamd command for displaying and saving of Object Authorities).  This script was left here just as an example of one possible way to code MQS utility function for UNIX shell.


SETMQAUT script sets and/or displays authorizations of the Queue Manager objects, names of which are coded into the script.  The script below presents patterns of several possible ways to list objects for standard +allmqi settings with the addition of specialized settings.  Different colors are used to highlight different object[/authority] listing patterns in the script text.

Real-life authorization setup script is Queue Manager specific, so it makes sense to name the actual script by the name of the Queue Manager, TESTQMGR in this example.

Note:  

Script shown below operates on user level (principal), reflecting the fact that this is the way authorizations are most often requested.  MQSeries, however, handles object authorizations on the group level.  If all users of the listed queues belong to the same group, for example, then external cycle by users won't be necessary and script could be simplified.

Demo of SETMQAUT script operation can be found below the script text.



# /var/mqm/aut/TESTQMGR  Set MQS Object Authorizations     08/16/200102/26/2002
# ------------------------------------------------------------------------------
# Copyright (C) 20012002 by Vladimir Veytsel                      www.davar.net

# 1. Script execution mode parameter (optional):

#    "S" or "s"      value causes authorizations to be SET only;
#    other non-empty value causes authorizations to be SET & displayed;
#              empty value causes authorizations to be only  displayed.

# Dbg=echo  # Uncomment for debugging

  MQM=TESTQMGR

  User=$(id | cut -f2 -d'(' | cut -f1 -d')')

  if [[ $User = root || $User = mqm ]]

     then Users="user1 user2"

#                 Keep queue names sorted to simplify maintenance
          Queues=
          Queues="$Queues TRANS.DATA"
          Queues="$Queues TRANS.REPLY"
          Queues="$Queues TRANS.TRACE"

          for N in 1 2
              do
                 Queues="$Queues TEST$N.DATA"
                 Queues="$Queues TEST$N.REPLY"
                 Queues="$Queues TEST$N.TRACE"
              done

          for T in DEMO REAL
              do for N in 1 2
                     do
                        Queues="$Queues $T$N.DATA"
                        Queues="$Queues $T$N.REPLY"
                        Queues="$Queues $T$N.TRACE"
                     done
              done

          cd /usr/bin

          if [[ $1. != . ]]
             then for User in $Users
                      do $Dbg setmqaut -m $MQM -p $User -t qmgr +allmqi
                         $Dbg setmqaut -m $MQM -p $User -t queue -n SYSTEM.DEAD.LETTER.QUEUE +browse
                         for Queue in $Queues
                             do $Dbg setmqaut -m $MQM -p $User -t queue -n $Queue +allmqi
                             done
                      done
                  $Dbg setmqaut -m $MQM -p user1 -t queue -n USER.DEAD.LETTER.QUEUE +get
                  $Dbg setmqaut -m $MQM -p user2 -t queue -n USER.DEAD.LETTER.QUEUE +browse
          fi

          if [[ $1. != [Ss]. ]]
             then for User in $Users
                      do $Dbg dspmqaut -m $MQM -p $User -t qmgr
                         $Dbg dspmqaut -m $MQM -p $User -t queue -n SYSTEM.DEAD.LETTER.QUEUE
                         for Queue in $Queues
                             do $Dbg dspmqaut -m $MQM -p $User -t queue -n $Queue
                             done
                      done
                  $Dbg dspmqaut -m $MQM -p user1 -t queue -n USER.DEAD.LETTER.QUEUE
                  $Dbg dspmqaut -m $MQM -p user2 -t queue -n USER.DEAD.LETTER.QUEUE
          fi

          unset User Users Queue Queues

     else echo Sorry, $MQM object authorization setup script requires
          echo root or mqm authority for execution, but you are $User.
          id
  fi
  


Below there is a log of debugging execution of the SETMQAUT script (renamed into TESTQMGR by the name of the Queue Manager for which it was developed).  For the debugging execution line Dbg=echo was temporarily uncommented, which caused each setmqaut command with all its parameters substituted to be echo-ed instead of being executed.



   # TESTQMGR s
   setmqaut -m TESTQMGR -p user1 -t qmgr +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n SYSTEM.DEAD.LETTER.QUEUE +browse
   setmqaut -m TESTQMGR -p user1 -t queue -n TRANS.DATA +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n TRANS.REPLY +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n TRANS.TRACE +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n TEST1.DATA +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n TEST1.REPLY +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n TEST1.TRACE +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n TEST2.DATA +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n TEST2.REPLY +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n TEST2.TRACE +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n DEMO1.DATA +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n DEMO1.REPLY +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n DEMO1.TRACE +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n DEMO2.DATA +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n DEMO2.REPLY +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n DEMO2.TRACE +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n REAL1.DATA +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n REAL1.REPLY +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n REAL1.TRACE +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n REAL2.DATA +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n REAL2.REPLY +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n REAL2.TRACE +allmqi
   setmqaut -m TESTQMGR -p user2 -t qmgr +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n SYSTEM.DEAD.LETTER.QUEUE +browse
   setmqaut -m TESTQMGR -p user2 -t queue -n TRANS.DATA +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n TRANS.REPLY +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n TRANS.TRACE +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n TEST1.DATA +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n TEST1.REPLY +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n TEST1.TRACE +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n TEST2.DATA +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n TEST2.REPLY +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n TEST2.TRACE +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n DEMO1.DATA +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n DEMO1.REPLY +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n DEMO1.TRACE +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n DEMO2.DATA +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n DEMO2.REPLY +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n DEMO2.TRACE +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n REAL1.DATA +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n REAL1.REPLY +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n REAL1.TRACE +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n REAL2.DATA +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n REAL2.REPLY +allmqi
   setmqaut -m TESTQMGR -p user2 -t queue -n REAL2.TRACE +allmqi
   setmqaut -m TESTQMGR -p user1 -t queue -n USER.DEAD.LETTER.QUEUE +get
   setmqaut -m TESTQMGR -p user2 -t queue -n USER.DEAD.LETTER.QUEUE +browse
          
        


View [and save] SETMQAUT text   (Use [Back] button or [Alt]+[CL] to return here)
Copyright © 20012002 by
Go to:  Davar site entry | Site contents | Site index | Client/Server | MQSeries | Text top