home *** CD-ROM | disk | FTP | other *** search
/ ftp.jcu.edu.au / 2014.06.ftp.jcu.edu.au.tar / ftp.jcu.edu.au / v6.3.2b / SWBD63 / fabos-6.3.2b-10.ppc.rpm / fabos-6.3.2b.10.cpio.gz / fabos-6.3.2b.10.cpio / fabos / bin / timeout < prev    next >
Text File  |  2010-11-10  |  3KB  |  105 lines

  1. #!/bin/sh
  2. #
  3. #    Copyright (c) 2005-2006 Brocade Communications Systems, Inc.
  4. #    All rights reserved.
  5. #
  6. #    File name:   timeout.sh.in 
  7. #    Module name: fabos/src/utils/sys
  8. #     
  9. #    This program can be used to change the IDLE Timeout
  10. #    value for a login session
  11. #
  12. setswitch () 
  13.     eval `/fabos/cliexec/diagenv -b writed SWITCH_ENV 0 $1`
  14. }
  15.  
  16. setcontext () 
  17.     if [ "$1" != "chassis" ]
  18.     then
  19.         eval `/fabos/cliexec/lscfg_util --switch $1`
  20.     else
  21.         eval `/fabos/cliexec/lscfg_util --chassis`
  22.     fi
  23. }
  24.  
  25. export PATH=/fabos/sbin:/fabos/bin:/bin:/usr/bin:/sbin:/fabos/cliexec
  26.  
  27. #make sure the command only accessible on active CP
  28. #retCode=`hashow | /bin/grep Local | /bin/grep -c Standby`
  29.  
  30. #if [ $retCode -eq 1 ]; then
  31. #    echo WARNING: Illegal command on Standby!
  32. #    exit
  33. #fi
  34.  
  35. # let us set our switch to switch 0 -- timeout value always stored in sw0
  36. setswitch 0
  37. USERNAME=`/usr/bin/whoami`
  38.  
  39. if [ $# -eq 0 ]; then
  40.     # Check RBAC permission on command
  41.     /fabos/libexec/rbac_check `/bin/basename $0`
  42. else
  43.     # Check RBAC permission on identified options
  44.     /fabos/libexec/rbac_check `/bin/basename $0` $1
  45. fi
  46.  
  47. if [ $? -ne 0 ]; then
  48.     exit 127
  49. fi
  50.  
  51. if [ $# -eq 0 ] ; then
  52.     TIMESEC=`config get system.login.timeout 2`
  53.     # if the timeout value is not defined we will make it to 10 minutes
  54.     # as default value -- Defect 12101
  55.     [ -z $TIMESEC ] && TIMESEC=600
  56.     TIMEMIN=`expr $TIMESEC \/ 60`
  57.     echo Current IDLE Timeout is $TIMEMIN minutes
  58.     exit
  59. fi
  60.  
  61. # with RBAC , we dont need this check below anymore.
  62. # if we are here and role is other than root, admin, factory
  63. # exit with error
  64. #if [ "$USERNAME" != "root" -a "$USERNAME" != "admin" -a "$USERNAME" != "factory" -a "$USERNAME" !=  "switchadmin" ]
  65. #then
  66. #    echo Permission denied for this account
  67. #    exit
  68. #fi
  69.  
  70. if [ $# -ne 1 ]; then
  71.     echo Invalid Number of arguments
  72.     echo Please just specify the timeout in minutes
  73.     exit
  74. fi
  75.  
  76. choice=$1
  77. if [ -z "$choice" ]
  78. then
  79.     choice=invalid
  80. fi
  81. nchoice=`echo $choice | /usr/bin/tr -cd "[0-9]\n"`
  82. if [ "$nchoice" != "$choice" ]
  83. then
  84.     printf "Please specify a numeric timeout value in minutes\n"
  85.     exit
  86. fi
  87. if [ $nchoice -gt 99999 ]
  88. then
  89.     printf "Please specify a timeout value in [0-99999]minutes\n"
  90.     exit
  91. fi
  92. TIMESEC=`expr $nchoice \* 60`
  93. if [ $TIMESEC -lt 0 ]
  94. then
  95.     printf "Please specify a timeout value in [0-99999]minutes\n"
  96.     exit
  97. fi
  98. config set system.login.timeout 2 $TIMESEC
  99.  
  100. config update > /dev/null
  101. echo IDLE Timeout Changed to $nchoice minutes
  102. echo The modified IDLE Timeout will be in effect after NEXT login
  103.