- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Script help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2012 08:59 AM
09-10-2012 08:59 AM
I have a script that I did not write and the developers would like it modified to tell them which tomcat node their application is deployed on. Something like appdeploy <ENVIRONMENT> <APPNAME> and it would tell them which tomcat node their application is on. Any help would be greatly appreciated.
#!/bin/bash
# 23Mar2010 - Not written by me :{
# Used to deploy applications to tomcat6 nodes.
# Function Declarations
########################################################################################
function get_node {
case $ENVIRONMENT in
beta|prod)
case $1 in
app1) NODE="${ENVIRONMENT}-tc5";;
app2) NODE="${ENVIRONMENT}-tc5";;
app3) NODE="${ENVIRONMENT}-tc1";;
app4) NODE="${ENVIRONMENT}-tc2";;
app5) NODE="${ENVIRONMENT}-tc7";;
app6) NODE="${ENVIRONMENT}-tc11";;
app7) NODE="${ENVIRONMENT}-tc3";;
app8) NODE="${ENVIRONMENT}-tc7";;
app9) NODE="${ENVIRONMENT}-tc8";;
app10) NODE="${ENVIRONMENT}-tc9";;
app11) NODE="${ENVIRONMENT}-tc2";;
app12) NODE="${ENVIRONMENT}-tc3";;
app13) NODE="${ENVIRONMENT}-tc10";;
app14) NODE="${ENVIRONMENT}-tc6";;
app15) NODE="${ENVIRONMENT}-tc8";;
app16) NODE="${ENVIRONMENT}-tc9";;
app17) NODE="${ENVIRONMENT}-tc10";;
app18) NODE="${ENVIRONMENT}-tc4";;
app19) NODE="${ENVIRONMENT}-tc4";;
app20) NODE="${ENVIRONMENT}-tc10";;
app21) NODE="${ENVIRONMENT}-tc3";;
app22) NODE="${ENVIRONMENT}-tc5";;
app23) NODE="${ENVIRONMENT}-tc4";;
app22) NODE="${ENVIRONMENT}-tc5";;
app23) NODE="${ENVIRONMENT}-tc5";;
app24) NODE="${ENVIRONMENT}-tc7";;
app25) NODE="${ENVIRONMENT}-tc8";;
app26) NODE="${ENVIRONMENT}-tc4";;
*)
echo "The application ${APPNAME} is not configured. Please contact the systems team."
exit;;
esac;;
*)
echo "${ENVIRONMENT} is not a valid environment."
exit 1;;
esac
}
function usage {
echo -e "Usage: appdeploy <ENVIRONMENT> <WARFILE> <APPNAME>\n"
echo "Example:"
echo "appdeploy beta /mnt/dist/tomcat/application/beta/application-3.0.4.war application"
exit
}
function check_filename {
FILE=`echo $1 | tr [:upper:] [:lower:]`
EXT=${FILE##*.}
if [ ${EXT} != "war" ]; then
usage
fi
}
function confirm {
read -p "Confirm deploy of ${WARFILE} to ${NODE} as ${APPNAME}? [y/N]" yn
RESPONSE=`echo $yn | tr [:upper:] [:lower:]`
case $RESPONSE in
y|yes)
DEPLOY="yes";;
*)
DEPLOY="no";;
esac
}
########################################################################################
# Check for arguments passed and display usage if they don't make sense.
if [ $# -ne 3 ]; then
usage
exit 1
fi
# Set variables from command-line arguments
ENVIRONMENT=`echo $1 | tr [:upper:] [:lower:]`
WARFILE=$2
APPNAME=$3
# Check that the first variable is a war file
check_filename $WARFILE
# Determine which node to deploy to
get_node $APPNAME
# Confirm deploy
confirm
if [ ${DEPLOY} = "yes" ]; then
#create "current" symlink on /mnt/dist
WAR=`basename $WARFILE`
PTH=`dirname $WARFILE`
echo "Changing current pointer..."
ln -s -f ${WARFILE} ${PTH}/current
echo "Deploying application..."
scp ${WARFILE} ${NODE}:/usr/local/tomcat/webapps/${APPNAME}.war
echo "Application Deployed."
exit
else
echo "Deploy Aborted."
fi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2012 08:28 PM - edited 09-10-2012 08:30 PM
09-10-2012 08:28 PM - edited 09-10-2012 08:30 PM
Solution>would like it modified to tell them which tomcat node their application is deployed on.
It appears that your function get_node has the info you need.
You could change the UI from: appdeploy <ENVIRONMENT> <WARFILE> <APPNAME>
To also include: appdeploy <ENVIRONMENT> <APPNAME>
(I would add a "-" option instead of basing it on the number of parms.)
By checking the number of parms:
if [ $# -eq 2 ]; then
# Set variables from command-line arguments
ENVIRONMENT=`echo $1 | tr [:upper:] [:lower:]`
APPNAME=$2
# Determine which node to deploy to
get_node $APPNAME
echo "Deployed on $NODE"
exit 0
fi
And then the existing:
# Check for arguments passed and display usage if they don't make sense.
if [ $# -ne 3 ]; then
And of course update the usage:
function usage {
echo -e "Usage: appdeploy <ENVIRONMENT> <WARFILE> <APPNAME>"
echo -e "Usage: appdeploy <ENVIRONMENT> <APPNAME>\n"
echo "If <WARFILE> is missing, the NODE is displayed."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2012 07:24 AM
09-11-2012 07:24 AM
Re: Script help
Thanks alot Dennis that did the trick