From: COUNTERMAN, DANIEL (CONTRACTOR) (DANIEL.COUNTERMAN@DFAS.MIL)
Date: Fri May 14 2004 - 10:22:21 EDT
Here is the line I am referring to:
echo "/$filevolume/prod/wang/oix/$imagestore
-anon=65535,root=fcohpd:fcosun06,access=fcohpd:fcosun06" >> /etc/exports
I want to change this line in the script to something like this:
echo "$EXPORTFILE" >> /etc/exports
I want to put the "/$filevolume/prod/wang/oix/$imagestore -anon=65535,root=fcohpd:fcosun06,access=fcohpd:fcosun06" within the config file, so that if any servers are added or changed, all I need to do is change the config file, rather than the script, and pass the filevolume and imagestore variables within the script to the config file. Do you have an answer for that?
Thanks,
Dan
-----Original Message-----
From: Paveza, Gary [mailto:gary.paveza@AIG.COM]
Sent: Friday, May 14, 2004 10:08 AM
To: COUNTERMAN, DANIEL (CONTRACTOR)
Subject: RE: Script Question
Your colors don't come through, but here is what I would do.
For any variable that you want to control in a configuration file, write it
to that configuration file - and remove setting it from your script.
As one of the first things your script does, it should source that
configuration script (using the .<space><filename> syntax. That way your
main script is the same across all servers, you just need to modify the
configuration file.
-----Original Message-----
From: COUNTERMAN, DANIEL (CONTRACTOR) [mailto:DANIEL.COUNTERMAN@DFAS.MIL]
Sent: Friday, May 14, 2004 10:06 AM
To: Paveza, Gary
Cc: 'Hpux-Admin (E-mail); KENNEBECK, JEFFREY (CONTRACTOR)
Subject: Script Question
Thank you for replying to my question.
The script works, I am just trying to make this easy to implement across
multiple servers, so by changing the configuration file, this will
accomplish this, so please take a look and let me know how I can pass the
lines in RED, which are server specific to a configuration file.
Note the question below - looking for something to replace the lines in RED
within a config file if possible.
Here is the script:
#!/bin/sh
############################################################################
####
#
# SCRIPT: create_imgobj
#
# PURPOSE: Create new Image and Object Stores
#
#
# COMMENTS:
#
# DATE SE Description of Change
#
############################################################################
####
# check if correct user id
############################################################################
####
umask 0
clear
if [ $LOGNAME != "root" ]
then echo "script processing must be executed by root not $LOGNAME."
exit 0
fi
############################################################################
####
# read variables
############################################################################
####
if [ -f /dfas/cfg/check.cfg ]; then
. /dfas/cfg/check.cfg
else
echo "ERROR: check.cfg MISSING.\n"
fi
if [ -f /home/dcount/imgobj_scripts/imagestore.cfg ]; then
. /home/dcount/imgobj_scripts/imagestore.cfg
else
echo "ERROR: imagestore.cfg MISSING.\n"
exit 1
fi
############################################################################
####
############################################################################
####
# main section
############################################################################
####
# subroutines come first than main for script execution
# to work properly
#
#################################################################
## Create New Image Stores ##
## 1) Shutdown Tier1 ##
## 2) Create the new Image Store directory structure ##
## 3) Set Ownership and Access Rights ##
## 4) Touch the .NFS file within new structure ##
## 5) Add to /prod/tier1/config/hpfilesys.cfg ##
## 6) Add to /etc/exports file and export the new volume ##
## 7) Create linkpoint within /prod/wang/oix ##
## 8) Modify and run sql script to add image store to Oracle ##
## t_file_volume table ##
## 9) Restart Tier1 ##
#################################################################
new_imagestore()
{
clear
echo "Image Stores Maintenance - New Image Store"
echo
echo "Shutting down Tier1"
T1 stop
echo
clear
echo "Creating /$filevolume/prod/wang/oix/is$imagestore"
mkdir -p /$filevolume/prod/wang/oix/$imagestore
echo
echo "Setting ownership using chown -R prod:prod /$filevolume"
chown -R prod:prod /$filevolume
echo
echo "Setting access using chmod -R ug+rwx /$filevolume/prod"
chmod -R ug+rwx /$filevolume/prod
echo
echo "Setting access using chmod -R o+rx /$filevolume/prod"
chmod -R o+rx /$filevolume/prod
echo
echo "Setting access using chmod -R ugo+rwx
/$filevolume/prod/wang/oix/$imagestore"
chmod -R ugo+rwx /$filevolume/prod/wang/oix/$imagestore
echo
echo "Touching .NFS within Image Store"
touch /$filevolume/prod/wang/oix/$imagestore/.NFS
chown prod:prod /$filevolume/prod/wang/oix/$imagestore/.NFS
chmod 664 /$filevolume/prod/wang/oix/$imagestore/.NFS
echo
echo "Press enter to continue"
read x
clear
echo
echo "Updating /prod/tier1/config/hpfilesys.cfg"
echo
server=`hostname`
if [ $server = "fcohpc" ]
then
cp -p /prod/tier1/config/hpfilesys.cfg /prod/tier1/config/hpfilesys.`date
+%m%d%Y`
cp -p /etc/exports /etc/exports.`date +%m%d%Y`
echo "Adding the following line:"
echo "/prod/wang/oix/$imagestore `hostname` $imagestore 0 DIV=JN" >>
/prod/tier1/config/hpfilesys.cfg
echo
echo "/$filevolume/prod/wang/oix/$imagestore
-anon=65535,root=fcohpd:fcosun06,access=fcohpd:fcosun06" >> /etc/exports
echo
$ORACLE_HOME/bin/sqlplus ${USERLOGIN} @${OMDBA_HOME}/max_dow_entry.sql
integer y=`cat /tmp/maxdow.doc`
let z=$y+1
$ORACLE_HOME/bin/sqlplus ${USERLOGIN} @${OMDBA_HOME}/add_image_uat.sql
$imagestore $z
echo
echo "Displaying entries added to t_file_volume: "
cat /tmp/addimage_uat.doc
echo
echo
echo "Displaying line added for hpfilesys.cfg and exports files"
tail -1 /prod/tier1/config/hpfilesys.cfg
tail -1 /etc/exports
exportfs -a
echo
fi
echo "Press enter to continue"
read x
clear
echo
echo "Creating linkpoint within /prod/wang/oix"
echo
echo "ln -s /$filevolume/prod/wang/oix/$imagestore $imagestore"
ln -s /$filevolume/prod/wang/oix/$imagestore $imagestore
echo
echo
echo "Press enter to continue"
read x
clear
echo
echo "Image Store Review"
echo
echo "Review volume for correct structure, ownership, and access"
echo
echo "/$filevolume/prod/wang/oix/$imagestore"
ls -lad /$filevolume
ls -lad /$filevolume/prod/wang
ls -lag /$filevolume/prod/wang/oix/$imagestore
echo
echo "Press enter to continue"
read x
clear
echo
echo "Restarting Tier1"
T1 start
} # End of subroutine_1
update_imagestore()
{
# Enter script commands to execute
echo "Start of subroutine_2, called by mainroutine_2"
echo
clear
echo "Updating Image Store (Replace)"
echo
echo "Shutting down Tier1"
T1 stop
echo
clear
server=`hostname`
if [ $server = "fcohpc" ]
then
cp -p /prod/tier1/config/hpfilesys.cfg /prod/tier1/config/hpfilesys.`date
+%m%d%Y`
echo
echo "Displaying imagestore being turned on in hpfilesys.cfg: "
/home/dcount/imgobj_scripts/turnon $newimage
echo
cat /home/dcount/imgobj_scripts/turnedon
mv /home/dcount/imgobj_scripts/turnedon /prod/tier1/config/hpfilesys.cfg
echo
echo
echo "Press enter to continue"
read x
echo "Displaying imagestore being turned off in hpfilesys.cfg: "
/home/dcount/imgobj_scripts/turnoff $oldimage
echo
cat /home/dcount/imgobj_scripts/turnedoff
mv /home/dcount/imgobj_scripts/turnedoff /prod/tier1/config/hpfilesys.cfg
echo
echo
echo "Press enter to continue"
read x
echo
$ORACLE_HOME/bin/sqlplus ${USERLOGIN} @${OMDBA_HOME}/update_image_uat.sql
$newimage $oldimage
echo
echo "Displaying entries updated to t_file_volume: "
cat /tmp/updateimage_uat.doc
echo
echo
echo "Press enter to continue"
read x
echo
fi
clear
echo
echo "Restarting Tier1"
T1 start
} # End of subroutine_2
delete_imagestore()
{
# Enter script commands to execute
clear
echo "Delete Image Store"
echo
sleep 2
echo "Shutting down Tier1"
T1 stop
echo
clear
echo
server=`hostname`
if [ $server = "fcohpc" ]
then
cp -p /prod/tier1/config/hpfilesys.cfg /prod/tier1/config/hpfilesys.`date
+%m%d%Y`
echo "Displaying imagestore being turned off in hpfilesys.cfg: "
/home/dcount/imgobj_scripts/turnoff $oldimage
echo
cat /home/dcount/imgobj_scripts/turnedoff
mv /home/dcount/imgobj_scripts/turnedoff /prod/tier1/config/hpfilesys.cfg
echo
echo "Press enter to continue"
read x
echo
$ORACLE_HOME/bin/sqlplus ${USERLOGIN} @${OMDBA_HOME}/delete_image_uat.sql
$oldimage
echo
echo "Displaying entries deleted from t_file_volume: "
cat /tmp/deleteimage_uat.doc
echo
echo
echo "Press enter to continue"
read x
echo
fi
clear
echo
echo "Restarting Tier1"
T1 start
} # End of subroutine_3
########################################################
## Image Store Processing ##
########################################################
mainroutine_1()
{
# Enter script commands to execute
clear
echo "Image Store Creation Process \n"
echo
echo "Enter Filevolume to use (fco######)\n"
read filevolume
echo "Enter Image Store to use (is######)\n"
read imagestore
echo
echo "Image Store will be created as: \n"
echo "/$filevolume/prod/wang/oix/$imagestore"
echo
echo "Do you want to proceed? \n"
echo "Enter 'Y' to proceed, anything else to abort.\n"
read a
if [ "$a" != "Y" ] && [ "$a" != "y" ]
then
echo
echo "Aborted."
exit 99
else
echo "Calling new_imagestore routine"
echo
new_imagestore
fi
echo
echo "Image Store Processing complete."
echo
echo "Do you need to add another Image Store?"
echo "Enter 'Y' to proceed, anything else to abort.\n"
read check_prompt
check_prompt=$check_prompt
if [ "$check_prompt" != "Y" ] && [ "$a" != "y" ]
then
echo
echo "Aborted."
exit 0
else
mainroutine_1
fi
} # End of mainroutine_1
#
mainroutine_2()
{
# Enter script commands to execute
clear
echo "Image Store Creation Process \n"
echo
echo "Enter Image Store to replace (oldimage) (is######)\n"
read oldimage
echo "Enter Image Store to update (newimage) (is######)\n"
read newimage
echo
echo "Image Store $oldimage will be updated with $newimage: \n"
echo
echo "Do you want to proceed? \n"
echo "Enter 'Y' to proceed, anything else to abort.\n"
read a
if [ "$a" != "Y" ] && [ "$a" != "y" ]
then
echo
echo "Aborted."
exit 99
else
echo "Calling update_imagestore routine"
echo
update_imagestore
fi
echo
echo "Image Store Processing complete."
echo
echo "Do you need to add another Image Store?"
echo "Enter 'Y' to proceed, anything else to abort.\n"
read check_prompt
check_prompt=$check_prompt
if [ "$check_prompt" != "Y" ] && [ "$a" != "y" ]
then
echo
echo "Aborted."
exit 0
else
mainroutine_2
fi
} # End of mainroutine_2
mainroutine_3()
{
# Enter script commands to execute
clear
echo "Image Store Deletion Process \n"
echo
echo "Enter Image Store to delete (is######)\n"
read oldimage
echo
echo "Image Store $oldimage will be deleted: \n"
echo
echo "Do you want to proceed? \n"
echo "Enter 'Y' to proceed, anything else to abort.\n"
read a
if [ "$a" != "Y" ] && [ "$a" != "y" ]
then
echo
echo "Aborted."
exit 99
else
echo "Calling delete_imagestore routine"
echo
delete_imagestore
fi
echo
echo "Image Store Deletion complete."
echo
echo "Do you need to delete another Image Store?"
echo "Enter 'Y' to proceed, anything else to abort.\n"
read check_prompt
check_prompt=$check_prompt
if [ "$check_prompt" != "Y" ] && [ "$a" != "y" ]
then
echo
echo "Aborted."
exit 0
else
mainroutine_3
fi
} # End of mainroutine_3
# start of main script occurs here
datadir="/prod/wang/oix/"
HOST=`hostname`
clear
echo
echo "Image/Object Store Maintenance"
echo
echo "Select:"
echo " 1) Add New Image Store"
echo " 2) Update Image Store (Replace)"
echo " 3) Delete Image Store"
echo " 4) Exit ?\c"
read select_one
case $select_one in
"1")
mainroutine_1
exit 0
;;
"2")
mainroutine_2
exit 0
;;
"3")
mainroutine_3
exit 0
;;
"4")
exit 0
;;
"-*")
exit 1
;;
esac
-----Original Message-----
From: Paveza, Gary [mailto:gary.paveza@AIG.COM]
Sent: Friday, May 14, 2004 9:44 AM
To: COUNTERMAN, DANIEL (CONTRACTOR)
Subject: RE: [HPADM] Script Question
Source the configuration file within your script.
. <config file>
Note the space between . and config file.
That will make all variables in the config file available to your script.
-----Original Message-----
From: COUNTERMAN, DANIEL (CONTRACTOR) [mailto:DANIEL.COUNTERMAN@DFAS.MIL]
Sent: Friday, May 14, 2004 9:35 AM
To: 'Hpux-Admin (E-mail)
Cc: UNIX-WIZ (E-mail)
Subject: [HPADM] Script Question
All,
I am trying to see if it is possible to use a configuration file
within a script and pass a parameter to the configuration file.
Here is an example of what I am trying to do:
In /dfas/cfg/imagestore.cfg:
export ENVIRONMENT=/prod/oracle/scofvp1p
export OMDBA_HOME=/shared/home/dcounter/scripts/imgobj_scripts
export ORACLE_HOME=/u01/app/oracle/product/9.2.0.4
EXPORTFILE="/$1/prod/wang/oix/$2
-anon=65535,root=fcohp16:fcohp16f:fcosun01:fcosun01e:fcosun04e"
In the script I want to be able to pass the variable filevolume to $1 and
imagestore to $2 in the configuration file and use EXPORTFILE as the
variable throughout the script. This will be used on multiple servers, so I
want to be able to just change the configuration file and not the script
which would contain the hardcoded servers going to the /etc/exports file.
Is this possible? Or does anyone have an idea of how I can do something
like this?
Thanks,
Dan
-- ---> Please post QUESTIONS and SUMMARIES only!! <--- To subscribe/unsubscribe to this list, contact majordomo@dutchworks.nl Name: hpux-admin@dutchworks.nl Owner: owner-hpux-admin@dutchworks.nl Archives: ftp.dutchworks.nl:/pub/digests/hpux-admin (FTP, browse only) http://www.dutchworks.nl/htbin/hpsysadmin (Web, browse & search)
This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 11:02:41 EDT