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
#!/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
How can i work around the limitations of the dsadmin -listenv command? Is there some better way of doing a deployment script?
Last edited by rameshrr3 on Thu Jun 14, 2007 6:23 am, edited 1 time in total.
The dsadmin -listenv command does not give me the environment variable prompt string and type
( Encrypted/String) . It gives me only a list of NAME=VALUE pairs
As far as testing goes:
I have been able to test so far much of the entire script( creating environment variables from and env file, importing a dsx file etc into an already created project) except for the project creation part, for which i do not have sufficient privileges.
Of course the dsenv is sourced in the admin user's profile file.So I dont have to source it again in the script.
The script will eventually be run by a user with admin privelege. I will be adding the exception handling and some basic argument validation clauses too.
All variables that will be of encrypted type will be passwords. All such variable names will have _PWD in their names, hence i probably will scan the output of the dsadmin -listenv for those user variables that end with _PWD. For Prompt string, will use the environment variable name itself for now.
I'm curious about this 'forecasted requirement' from your client. What exactly is this all for? How often does one need to 'deploy' a project? I know some folks have many projects, sometimes way too many in my opinion, but hey - different strokes. The need for new projects is pretty rare around here.
As noted, just mostly curious.
-craig
"You can never have too many knives" -- Logan Nine Fingers
When you have a client that is 'command line happy', where a script based solution, however rarely used, is considered the best, probably because it gives them a chance to show their geek ability with 'install' scripts. I Spent almost a day getting those single quotes right. .
On the flip side , and much to the disappointment of the 'client', there is not a straightforward & convinient way of exporting a project from unix command line.(At least in v 7.51A)