home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / UAGENT / root / usr / lib / uagent / uagent < prev    next >
Text File  |  1998-08-19  |  6KB  |  287 lines

  1. #!/bin/sh
  2. # Uagent Administration Menus
  3. # Cheyenne Software Inc.
  4. #
  5. # OS: UnixWare 2.x 
  6. #
  7. # Date: 01/12/94 (JH)
  8. #    1. Uagent v3.0 (supports ARCserve/Open)
  9. #
  10. # Date: 08/06/93 (JH)
  11. #    1. add a flag to specify Follow_Symbolic_Link or not, which is 
  12. #       determined by the existence of file $UAGBIN/uagent/follow.symlink.
  13. #
  14. # Usage: uagent [start [-p <tcp port#>] [follow] | stop | status | follow | notfollow]
  15. #
  16. # Date: 9/28/92 (JH)
  17. #    1. change 'arcagent' to 'uagentd'
  18. #    2. path for 'uagentd' ($UAGBIN) is determined at installation
  19. #
  20. # Date: 4/19/92 (PL)
  21. #
  22. #menu# uagent [start [-p <tcp port#>] | stop | status]
  23. #help# start will start UAGENT.
  24. #help# stop will stop UAGENT.
  25. #help# status will tell you if UAGENT is running.
  26.  
  27. UAGBIN="/usr/lib"
  28. FOLLOW="$UAGBIN/uagent/follow.symlink"
  29. IPCFILE="$UAGBIN/uagent/LOG/uag.ipc"
  30.  
  31. ARGS="$*"
  32. PSFLAG="-aef"
  33. PSCUT="-c9-14"
  34.  
  35. usage() 
  36. {
  37. echo "\nUsage:"
  38. echo "  uagent start [-b <bufsz>] [-m <maxbuf>] [-v] [-l] [-n]"
  39. echo "         [-s async|nonblocking] [-a <n>] [-s <bufsz>] [-t] [-S] [-e]"
  40. if [ "$1" = "" ]
  41. then
  42. echo "  uagent {status | stop}"
  43. fi
  44. echo "\n  -b <bufsz>: I/O buffer size in bytes (1024..8192)"
  45. echo "  -m <maxbuf>: # of buffers allocated for I/O (10..1024)"
  46. echo "  -s <bufsz>: specify socket buffer size in bytes (4096..65536)"
  47. echo "  -s <async|nonblocking>: set socket I/O to asynchronus/nonblocking mode"
  48. echo "  -v: verbose mode"
  49. echo "  -l: check all file locks [mandatory locks only]"
  50. echo "  -n: backup NFS mount directories"
  51. echo "  -t: will not reset file access time after backup"
  52. echo "  -a <n>: acknowledge for every n packets [0:no ack.]"
  53. echo "  -S: Single user mode"
  54. echo "  -e: backup will not traverse across file system"
  55. echo "\n[ ]: default values",
  56. exit 1
  57. }
  58.  
  59. getparm1() {
  60. if [ "$2" = "" ]
  61. then 
  62.   usage start
  63. fi
  64. parms="$parms $1 $2"
  65. }
  66.  
  67. getparm() {
  68. parms="$parms $1"
  69. }
  70.  
  71. check_uagent()
  72. {
  73.   pid=`ps $PSFLAG | grep uagentd | grep -v "grep uagentd" | cut $PSCUT` 
  74. }
  75.  
  76. kipc()
  77. {
  78. #set -x
  79. if [ -f $IPCFILE ]
  80. then
  81. cat $IPCFILE | while read A B
  82. do
  83. #echo A=$A B=$B
  84.   if [ "$A" != "0" ]
  85.   then
  86.   case $A in
  87.     s|m)
  88. #      echo  "ipcrm -$A $B > /dev/null 2>&1"
  89.       ipcrm -$A $B > /dev/null 2>&1;;
  90.     *)
  91.       ;;
  92.   esac
  93.   fi 
  94. done
  95.  
  96. #echo "rm $IPCFILE"
  97. rm $IPCFILE
  98. fi
  99. }
  100.  
  101. uid=`id | cut -d'=' -f2 | cut -d'(' -f1`
  102.  
  103. case "$1" in
  104.  
  105. notfollow)
  106.   check_uagent
  107.   if [ "$pid" = "" ]
  108.   then
  109.     echo "\nUAGENT is not started.  Please start uagent first.\n"
  110.     exit 0
  111.   fi
  112.   if [ $uid = 0 ]
  113.   then
  114.     if [ -f $FOLLOW ]
  115.     then
  116.       rm $FOLLOW 
  117.     fi
  118.     echo "\nUAGENT does NOT follow symbolic links...\n"
  119.   else
  120.     echo "\nOnly system administrator can change the state of following symbolic links.\n"
  121.     exit 0
  122.   fi
  123.   ;;
  124. follow)
  125.   check_uagent
  126.   if [ "$pid" = "" ]
  127.   then
  128.     echo "\nUAGENT is not started.  Please start uagent first.\n"
  129.     exit 0
  130.   fi
  131.   if [ $uid = 0 ]
  132.   then
  133.       touch $FOLLOW &&     chmod 700 $FOLLOW && echo "\nUAGENT follows symbolic links...\n"
  134.   else
  135.     echo "\nOnly system administrator can change the state of following symbolic links.\n"
  136.     exit 0
  137.   fi
  138.   ;;
  139. start)
  140.   if [ "$2" = "?" ]
  141.   then
  142.     usage start
  143.   fi
  144.  
  145.   if [ $uid = 0 ]
  146.   then
  147.  
  148.     check_uagent
  149.     if [ "$pid" != "" ]
  150.     then
  151.       echo "\nUAGENT already started.\n"
  152.       exit 0
  153.     fi
  154.  
  155. # Load the Portable Streams Environment for TLI drivers (AIX only)
  156. #   set -x
  157. #    PSE=`strload -q | grep no`
  158. #    if [ "$PSE" != "" ]
  159. #    then
  160. #      strload
  161. #    fi
  162. #
  163.     parms=""
  164. #
  165. # set arguments, put an extra argument 'uagent' to prevent flags from 
  166. # mingled with set.
  167. #
  168.     set uagent $ARGS  
  169.     while [ "$3" != "" ]
  170.     do
  171. #echo [$3]
  172.       case "$3" in
  173.       notfollow)        ;;
  174.       follow) parms="$parms -f"    ;;
  175.       -p)     getparm1 $3 $4
  176. #
  177. # on DEC, we need to re-set the arguments after return from a proceudre
  178. #
  179.           set uagent $ARGS
  180.           shift 
  181.           ARGS="$*"
  182.           ;;
  183.       -b)     getparm1 $3 $4
  184.           set uagent $ARGS
  185.           shift
  186.           ARGS="$*"
  187.           ;;
  188.       -m)     getparm1 $3 $4
  189.             set uagent $ARGS
  190.           shift
  191.           ARGS="$*"
  192.           ;;
  193.       -a)     getparm1 $3 $4
  194.             set uagent $ARGS
  195.           shift
  196.           ARGS="$*"
  197.           ;;
  198.       -s)     getparm1 $3 $4
  199.             set uagent $ARGS
  200.           shift
  201.           ARGS="$*"
  202.           ;;
  203.       -n)     getparm $3
  204.             set uagent $ARGS
  205.           ;;
  206.       -f)     getparm $3
  207.             set uagent $ARGS
  208.           ;;
  209.       -v)     getparm $3
  210.             set uagent $ARGS
  211.           ;;
  212.       -l)     getparm $3
  213.             set uagent $ARGS
  214.           ;;
  215.       -t)     getparm $3
  216.             set uagent $ARGS
  217.           ;;
  218.       -S)     getparm $3
  219.             set uagent $ARGS
  220.           ;;
  221.       -e)     getparm $3
  222.             set uagent $ARGS
  223.           ;;
  224.       *)      usage start    ;;
  225.       esac
  226.       shift 2
  227.       ARGS="$*"
  228.       set uagent $ARGS
  229.     done
  230.     $UAGBIN/uagent/uagentd $parms 
  231.     if [ "$?" = "0" ]
  232.     then
  233.       echo "\nUAGENT started...\n"
  234.     else
  235.       echo "\nFailed to start UAGENT.\n"
  236.     fi
  237.   else
  238.     echo "\nOnly system administrator can start UAGENT\n"
  239.     exit 0
  240.   fi
  241.   ;;
  242. stop)
  243.   if [ $uid = 0 ]
  244.   then
  245.     check_uagent
  246.     if [ "$pid" = "" ]
  247.     then
  248.       echo "\nUAGENT already stopped.\n"
  249.     else
  250.       echo "\nShutting down UAGENT process...\c"
  251.       kill -15 $pid >/dev/null 2>/dev/null 
  252.       echo "Down.\n"
  253.       kipc
  254.     fi
  255.   else
  256.     echo "\nOnly system administrator can stop UAGENT\n"
  257.     exit 0
  258.   fi
  259.   ;;
  260. status)
  261. #  msk=`grep umask /etc/profile | cut -f1 | cut -d' ' -f2`
  262. # if [ "$msk" = 077 -a $uid != 0 ]  # C2
  263. # then
  264. #   echo; echo "Only system administrator can check the status of UAGENT"; echo
  265. #   exit 0
  266. # fi
  267.   echo  "\nChecking the UAGENT process...It is \c"
  268.   check_uagent
  269.   if [ "$pid" = "" ]
  270.   then
  271.     echo "STOPPED.\n"
  272.   else
  273.     if [ -f $FOLLOW ] 
  274.     then
  275.     echo "RUNNING & FOLLOWING symbolic links.\n"
  276.     else
  277.     echo "RUNNING & NOT following symbolic links.\n"
  278.     fi
  279.   fi
  280.   ;;
  281. *)
  282.   usage
  283.   exit 1
  284.   ;;
  285. esac
  286. exit 0
  287.