Operating System - HP-UX
1753765 Members
5830 Online
108799 Solutions
New Discussion

Re: automation installation of package

 
tempsample
Frequent Advisor

automation installation of package

Hi

 

we have to upgrade raid manager in nearly 600 servers.

 

There is no centralized or NFS server.

 

but from NIM server ,I can log in to all 600 servers.

 

manuall installation for all 600 hosts requires more time.

 

in for loop i can add for i in hostname

 

and make a script.

 

but i have to automate the full process.

 

 

such thing like

 

taking a copy of HORCM file.

 

 

stop HORCM service.

uninstalling raid manager

 

then installing raid manager.

then start HORCM service.

 

 

i would need a help  and idea , how to write a script for all steps.

 

18 REPLIES 18
tempsample
Frequent Advisor

Re: automation installation of package

i would like to add my thoughts ,

 

for i in hostname1 hostname 2

 

do

 

stop horcm services

 

then

check if horcm servcies are stopped 

 

if not exit

 

cp -ip backup of horcm configuration

 

then

 

uninstall raidmanager

 

then run raidqry -v

 

then check if raid manager is uninstalled successfully.

 

thenn

 

 

iinstall new version of raid manager

 

then run raidqry to confirm if raid manager is updated

Dennis Handly
Acclaimed Contributor

Re: automation installation of package

You may just want to develop a script that works on a machine and then sends mail on the status.

Once you have that script, copy it to all the machines and start the script with nohup and in the background and you wouldn't need to stay connected.

tempsample
Frequent Advisor

Re: automation installation of package

hi Dennis,

 

thanks for the info.

 

Can you help me in sharing the sample.

 

so that i can develop the remaining the part and test.

 

 

 

Dennis Handly
Acclaimed Contributor

Re: automation installation of package

>Can you help me in sharing the sample?

 

Sorry, I don't have one.

You should start with your outline of the steps above.

Take what you do manually and put in a script with checking at each step.

tempsample
Frequent Advisor

Re: automation installation of package

Hi Dnnis,

 

Thanks for the respose.

 

i have to started to create the script,but i have doubt in the below script.

 

as first step, I am taking backup of /etc/horcm0.conf and /etc/horcm1.conf firl.

 

#!/usr/bin/sh -x

 

WORKDAY=`date +%Y%m%d`

echo "#ls -ltr /etc/horcm?.conf  | grep -c ${WORKDAY}"
ls -ltr /etc/horcm?.conf  | grep -c ${WORKDAY}


RTNSTR=`ls -ltr /etc/horcm?.conf  | grep -c ${WORKDAY}`

if [ ${RTNSTR} = 1 ]; then
  echo "/etc/horcm0.conf  and /etc/horcm1.conf today's backup already created."
  echo "return 0"
  RTNCODE=0
else
  echo "#cp -p /etc/horcm1.conf  /etc/horcm0.conf_${WORKDAY}"


  cp -p /etc/horcm?.conf /home/tmp/raidmgr/log/horcm?.conf_${WORKDAY}   

 

  if [ $? -ne 0 ]; then
    echo "\nERROR. found."
    echo "Cannot backup /etc/horcm0.conf ."
    echo "return 1"
    RTNCODE=1
  else
    echo "\n Copy OK."
    echo "return 0"
    RTNCODE=0
  fi
fi

echo "\n End  : `date +\"%Y/%m/%d %H:%M:%S\"`"
echo "------------------------------------------------------------"

 

echo "#cp -p /etc/horcm1.conf  /etc/horcm0.conf_${WORKDAY}"


  cp -p /etc/horcm?.conf /home/tmp/raidmgr/log/horcm?.conf_${WORKDAY}  

 

1.how i can take backup of two horcm files --> horcm0.conf and horcm1.conf.

 

 

tempsample
Frequent Advisor

Re: automation installation of package

Hi,

 

Actually there are four files,

 

ls horcm*
horcm.conf   horcm0.conf  horcm1.conf  horcmgr

 

but i have to take backup only for /etc/horcm0.conf and /etc/horcm1.conf

 

how can i edit in the script ??

Dennis Handly
Acclaimed Contributor

Re: automation installation of package

>RTNSTR=`ls -ltr /etc/horcm?.conf | grep -c ${WORKDAY}`

 

I would recommend using the more modern $() syntax:

RTNSTR=$(ls -ltr /etc/horcm?.conf | grep -c ${WORKDAY})

 

>if [ ${RTNSTR} = 1 ]; then

 

Since this is a number, you should use the -eq operator:

if [ ${RTNSTR} -eq 1 ]; then

 

>1. how I can take backup of two horcm files --> horcm0.conf and horcm1.conf.

> cp -p /etc/horcm?.conf /home/tmp/raidmgr/log/horcm?.conf_${WORKDAY}

 

This won't replace the value of the "?" on the left to the "?" on the right.  You need a loop:

(( failed = 0 ))

for file in /etc/horcm?.conf; do

   base=${file##*/}  # basename

   cp -p $file /home/tmp/raidmgr/log/${base}_${WORKDAY}

   if [ $? -ne 0 ]; then

      # you can either count the failures or copy your existing error check

      (( failed += 1 ))

   fi

done

tempsample
Frequent Advisor

Re: automation installation of package

Hi Deenis,

 

Thanks for the response.

 

I will try to test as per your suggestion.

 

I have more doubt,

 

I am trying to view the output ,while running the script and ouptput has to appened to log file.

 

echo "/etc/horcm0.conf today's backup already created." >> ${BKP2LOG}

 

but when i run sh -x, i am able to view the output,but when i run with sh ,i am not able to view.

 

so currently ,I am using as below..

 

echo "/etc/horcm0.conf today's backup already created." >> ${BKP2LOG}   ----> this will be in log file

echo "/etc/horcm0.conf today's backup already created."  ---> I can screen in terminal

 

is this is the correct way ??

Dennis Handly
Acclaimed Contributor

Re: automation installation of package

>is this is the correct way?

 

Yes, you can do that with two echoes.  Or you can simply put the script in the background and tail -f the logfile.