An Attempt to deploy a project using a shell script
Posted: Wed Jun 13, 2007 11:27 am
I have made a vague attempt at creating a shell script to deploy a new project , along with its 'user-defined' environment variables and jobs. Is ther any better way of doing it? Apart from capturing status codes of commands and validating input arguments? This is a 'forecasted' requirement from my client.
The file containing environment variable definitions ${4} is supposed to be created from the output of command
The Code for the 'deployment script' follows
How can i work around the limitations of the dsadmin -listenv command? Is there some better way of doing a deployment script?
The file containing environment variable definitions ${4} is supposed to be created from the output of
Code: Select all
'dsadmin -listenv <projectName>' | grep "UD var prefix String"
The Code for the 'deployment script' follows
Code: Select all
#!/usr/bin/ksh
# DSDeployProject.sh ( Rudimentary Script to deploy a new project)
# Assumes an already exported DSX file placed in an unix folder
# Assumes a Environment variable file
# with records in NAME=VALUE pairs
# For simplicity all env variables are asusmed to be of string type
# Prompt Text is a default value , to be filled up by admin later
# For Simplicity , i assume user gives valid argument values!
#$1 is Name of new Project To be created
#$2 is the path of the Project Directory
#$3 is the dsx file to be imported( abosolute path)
#$4 is the ENV file for environment variable details
#(Can be filled with output of `dsadmin -listenv SourceProject > $4` command
# SYNTAX ./DSDeployProject.sh <ProjectName> <Project Directory Path> <DSX FilePath and Name> <ENV File name with "NAME=VALUE" records>
dsadmin -createproject $1 -location $2
dsjob -import $1 $3 -OVERWRITE
var_linecount=`cat $4 | wc -l`
echo $var_linecount
_i=1
echo
while true
do
echo $_i
var_Name=`awk 'NR=='${_i}'' $4 |awk -F= '{ print $1 }'`
var_Value=`awk 'NR=='${_i}'' $4 |awk -F= '{ print $2 }'`
echo "Creating ENV Variable" $var_Name "=" $var_Value
dsadmin -envadd $var_Name -type STRING -prompt "Enter Prompt Text" -value "$var_Value" $1
let _i='_i+1'
if test $_i -gt $var_linecount
then
echo "Loop Ended"
exit 0
fi
done