Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #########################################################################
- #In this script we get all variables and ask user for unidentified var"s#
- #########################################################################
- ##################
- #Global variables#
- ##################
- environmentName=""
- useAllForms=""
- action=""
- #######################
- #Functions declaration#
- #######################
- askEnviroName () {
- #in this function we ask about environment name and get all needed variables from sedb
- if [ "$environmentName" == "" ]
- then
- while true
- do
- print -n "Please input environment name in sedb:"
- read environmentName;
- environmentFormsDirtyList=`sedb forms $environmentName`
- if [ "$environmentFormsDirtyList" == "" ]
- then
- echo "\nCan't find environment in sedb. Please recheck environment name or add environment to sedb";
- else
- break
- fi
- done;
- fi
- if [ "$useAllForms" == "" ]
- then
- while true
- do
- print -n "Use all SIF\SYNC or disable already installed? (Y/N):"
- read useAllForms;
- if [ "$useAllForms" == "Y" ] || [ "$useAllForms" == "N" ]
- then
- break
- else
- echo "Please choose Y or N"
- fi
- done
- fi
- if [ "$action" == "" ]
- then
- print -n "Please select action():"
- read action;
- askEnviroName "$action"
- fi
- #here we can gen only needed variables
- case $1 in
- getTpcList)
- RiscTpcDirtyList=`sedb cputpc`
- echo "$RiscTpcDirtyList"
- ;;
- getEvnironmentVariables)
- environmentVariables=`sedb sca $environmentName`
- echo "$environmentVariables"
- ;;
- getEnvironmentForms)
- environmentFormsDirtyList=`sedb forms $environmentName`
- if [ "$useAllForms" == "Y" ]
- then
- echo "$environmentFormsDirtyList"
- elif [ "$useAllForms" == "N" ]
- then
- echo "$environmentFormsDirtyList" | grep -iv 'installed'
- fi
- ;;
- esac
- }
- getPackageList () {
- #in this function we get SIF\SYNC form, parce them and return needed packages to stdout.
- DirtyFormsList=`askEnviroName "getEnvironmentForms"`
- # if [ "$useAllForms" == "Y" ]
- # then
- # filtredFormsList=`echo "$DirtyFormsList" | grep -v "Installed"`
- # elif [ "$useAllForms" == "N" ]
- # then
- # filtredFormsList="$DirtyFormsList";
- # fi
- echo "$filtredFormsList"
- formsList=`echo "$DirtyFormsList" | awk '{print$1}'`
- for form in `echo "$formsList"`
- do
- formType=`echo $form | awk -F '#' '{print$1}'`
- formNumber=`echo $form | awk -F '#' '{print$2}'`
- if [ "$formType" == "SIF" ]
- then
- sif -a $formNumber 2>/dev/null
- elif [ "$formType" == "SYNC" ]
- then
- sif -a -y $formNumber 2>/dev/null
- fi
- done
- echo $allFromForms
- }
- getHasVariables () {
- #In this function we get list of HAS_ variables who must be set
- UDIR=`askEnviroName "getEvnironmentVariables" | grep UDIR | awk -F '=' '{print$2}'`
- . /etc/scc/Run! -H $UDIR/user/scc; . /se/lib/profile
- neededHas=`auxdeemmod | awk '{print$3}' | grep "HAS"`
- echo "$neededHas"
- }
- if [ "$1" == "" ]
- then
- askEnviroName
- else
- while getopts e:v:a: name
- do
- case $name in
- e)#environment name
- environmentName="$OPTARG"
- echo $OPTARG
- ;;
- v)#use all form? Y\N
- useAllForms="$OPTARG"
- echo $OPTARG
- ;;
- a)#action
- case $OPTARG in
- variables)#get all needed HAS variables
- action=$OPTARG
- getHasVariables;;
- packages)#get all needed packages
- action=$OPTARG
- askEnviroName
- getPackageList;;
- tpc)#get all needed TPC
- action=$OPTARG
- askEnviroName "getTpcList"
- ;;
- esac
- ;;
- ?) printf "Usage: %s: [-a] [-b value] args\n" $0
- #exit 2;;
- esac
- done
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement