Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.71 KB | None | 0 0
  1. #!/bin/sh
  2. #########################################################################
  3. #In this script we get all variables and ask user for unidentified var"s#
  4. #########################################################################
  5.  
  6. ##################
  7. #Global variables#
  8. ##################
  9. environmentName=""
  10. useAllForms=""
  11. action=""
  12. #######################
  13. #Functions declaration#
  14. #######################
  15.  
  16. askEnviroName () {
  17.     #in this function we ask about environment name and get all needed variables from sedb
  18.     if [ "$environmentName" == "" ]
  19.         then
  20.             while true
  21.                 do
  22.                     print -n "Please input environment name in sedb:"
  23.                     read environmentName;
  24.                     environmentFormsDirtyList=`sedb forms $environmentName`
  25.                     if [ "$environmentFormsDirtyList" == "" ]
  26.                         then
  27.                             echo "\nCan't find environment in sedb. Please recheck environment name or add environment to sedb";
  28.                         else
  29.                             break
  30.                     fi
  31.                 done;
  32.     fi
  33.     if [ "$useAllForms" == "" ]
  34.         then
  35.             while true
  36.                 do
  37.                     print -n "Use all SIF\SYNC or disable already installed? (Y/N):"
  38.                     read useAllForms;
  39.                     if [ "$useAllForms" == "Y" ] || [  "$useAllForms" == "N" ]
  40.                         then
  41.                             break
  42.                         else
  43.                             echo "Please choose Y or N"
  44.                     fi
  45.                 done
  46.     fi
  47.     if [ "$action" == "" ]
  48.         then
  49.             print -n "Please select action():"
  50.             read action;
  51.             askEnviroName "$action"
  52.     fi
  53.     #here we can gen only needed variables
  54.     case $1 in
  55.         getTpcList)
  56.             RiscTpcDirtyList=`sedb cputpc`
  57.             echo "$RiscTpcDirtyList"
  58.         ;;
  59.         getEvnironmentVariables)
  60.             environmentVariables=`sedb sca $environmentName`
  61.             echo "$environmentVariables"
  62.         ;;
  63.         getEnvironmentForms)
  64.         environmentFormsDirtyList=`sedb forms $environmentName`
  65.             if [ "$useAllForms" == "Y" ]
  66.                 then
  67.                     echo "$environmentFormsDirtyList"
  68.             elif [ "$useAllForms" == "N" ]
  69.                 then
  70.                     echo "$environmentFormsDirtyList" | grep -iv 'installed'
  71.             fi
  72.         ;;
  73.     esac
  74. }
  75.  
  76.  
  77. getPackageList () {
  78.     #in this function we get SIF\SYNC form, parce them and return needed packages to stdout.
  79.     DirtyFormsList=`askEnviroName "getEnvironmentForms"`
  80. #   if [ "$useAllForms" == "Y" ]
  81. #       then
  82. #           filtredFormsList=`echo "$DirtyFormsList" | grep -v "Installed"`
  83. #   elif [ "$useAllForms" == "N" ]
  84. #       then
  85. #           filtredFormsList="$DirtyFormsList";
  86. #   fi
  87.     echo "$filtredFormsList"
  88.     formsList=`echo "$DirtyFormsList" | awk '{print$1}'`
  89.     for form in `echo "$formsList"`
  90.         do
  91.             formType=`echo $form | awk -F '#' '{print$1}'`
  92.             formNumber=`echo $form | awk -F '#' '{print$2}'`
  93.             if [ "$formType" == "SIF" ]
  94.                 then
  95.                     sif -a $formNumber 2>/dev/null
  96.             elif [ "$formType" == "SYNC" ]
  97.                 then
  98.                     sif -a -y $formNumber 2>/dev/null
  99.             fi
  100.         done
  101.     echo $allFromForms
  102. }
  103.  
  104. getHasVariables () {
  105.     #In this function we get list of HAS_ variables who must be set
  106.     UDIR=`askEnviroName "getEvnironmentVariables" | grep UDIR | awk -F '=' '{print$2}'`
  107.     . /etc/scc/Run! -H $UDIR/user/scc; . /se/lib/profile
  108.     neededHas=`auxdeemmod | awk '{print$3}' | grep "HAS"`
  109.     echo "$neededHas"
  110. }
  111. if [ "$1" == "" ]
  112.     then
  113.         askEnviroName
  114.     else
  115.         while getopts e:v:a: name
  116.             do
  117.                 case $name in
  118.                 e)#environment name
  119.                     environmentName="$OPTARG"
  120.                     echo $OPTARG
  121.                     ;;
  122.                 v)#use all form? Y\N
  123.                     useAllForms="$OPTARG"
  124.                     echo $OPTARG
  125.                     ;;
  126.                 a)#action
  127.                     case $OPTARG in
  128.                         variables)#get all needed HAS variables
  129.                             action=$OPTARG
  130.                             getHasVariables;;
  131.                         packages)#get all needed packages
  132.                             action=$OPTARG
  133.                             askEnviroName
  134.                             getPackageList;;
  135.                         tpc)#get all needed TPC
  136.                             action=$OPTARG
  137.                             askEnviroName "getTpcList"
  138.                         ;;
  139.                     esac
  140.                     ;;     
  141.                 ?)  printf "Usage: %s: [-a] [-b value] args\n" $0
  142.                     #exit 2;;
  143.                 esac
  144.             done
  145. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement