Liste de liens :
Liste de liens :
Remplacer les aaa, bbc, etc. par les paramètres du portail
NO_ARGS=0 E_OPTERROR=85 # txmweb.sh upgrade -p yyy # parameters TOMCAT="/var/lib/tomcat6/webapps" SRCFILES="/var/lib/tomcat6/txm/data/projets/" APPNAME="bbb" TXMWEBHOME="/usr/share/tomcat6/txm/.TXMWEB" WARPATH="/var/lib/tomcat6/txm/data/projets/bbb.war" USER="txm" PASSWORD="yyy" URL="zzz" read -p "Enter Tomcat Password: " PASSWORD if [ $# -eq "$NO_ARGS" ] # Script invoked with no command-line args? then echo "Usage: sh txmweb.sh install|upgrade [-user xxx] -password yyy [-url zzz] [-war aaa] -app bbb -repo ccc -tomcat ddd -txmhome eee" echo "Or sh txmweb.sh install|upgrade -u xxx -p yyy -l zzz -w aaa -a bbb -e ccc -t ddd -x eee" exit $E_OPTERROR fi WHAT=$1 shift echo "do $WHAT" if ! options=$(getopt -o uplwaetx -l user,password,url,war,appname,repo,tomcat,txmhome -- "$@") then # something went wrong, getopt will put out an error message for us exit 1 fi while [ $# -gt 0 ] do case "$1" in -u|--user ) USER="$2";; -p|--password ) PASSWORD="$2";; -l|--url ) URL="$2";; -w|--war ) WARPATH="$2";; -a|--appname ) APPNAME="$2";; -e|--repo ) SRCFILES="$2";; -t|--tomcat ) TOMCAT="$2";; -x|--txmhome ) TXMWEBHOME="$2";; (--) shift; break;; (-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;; (*) break;; esac shift shift done echo "user: $USER" echo "url: $URL" echo "manager url: $URL" echo "tomcat: $TOMCAT" echo "srcfiles: $SRCFILES" echo "txmweb home: $TXMWEBHOME" echo "war: $WARPATH" echo "appname: $APPNAME" if [ $WHAT = "upgrade" ] then sh upgrade.sh "$USER" "$PASSWORD" "$URL" "$TOMCAT" "$SRCFILES" "$TXMWEBHOME" "$WARPATH" "$APPNAME" else sh install.sh $USER "$USER" "$PASSWORD" "$URL" "$TOMCAT" "$SRCFILES" "$TXMWEBHOME" "$WARPATH" "$APPNAME" fi;
#!/bin/bash echo "** TXMWEB upgrade: start." code=ERFIH3EZ2R5943U50A435JZ5R0ZEITERT # auth params USER="$1" PASSWORD="$2" URL="$3" # parameters TOMCAT="$4" SRCFILES="$5" TXMWEBHOME="$6" # application WARPATH="$7" APPNAME="$8" MANAGERURL="http://$USER:$PASSWORD@$URL/manager/html" echo "** TXMWEB upgrade: checking directories..." # check params # Test if $TOMCAT exists if [ ! -d "$TOMCAT" ]; then echo "** TXMWEB upgrade: $TOMCAT is missing. Can't continue the installation." exit 1; fi # Test if $WARPATH exists if [ ! -f "$WARPATH" ]; then echo "** TXMWEB upgrade: war zip is missing: $WARPATH. Can't continue the installation." exit 1; fi # Test $SRCFILES content if [ ! -d "$SRCFILES/$APPNAME/biblio" ]; then echo "** TXMWEB upgrade: $SRCFILES/$APPNAME/biblio is missing. This folder contains the bibliographic records of texts" exit 1; fi if [ ! -d "$SRCFILES/$APPNAME/css" ]; then echo "** TXMWEB upgrade: $SRCFILES/$APPNAME/css is missing. This folder contains the css files" exit 1; fi if [ ! -d "$SRCFILES/$APPNAME/html" ]; then echo "** TXMWEB upgrade: $SRCFILES/$APPNAME/html is missing. This folder contains the HTML files" exit 1; fi if [ ! -d "$SRCFILES/$APPNAME/images" ]; then echo "** TXMWEB upgrade: $SRCFILES/$APPNAME/images is missing. This folder contains the png, jpg, ... files" exit 1; fi if [ ! -d "$SRCFILES/$APPNAME/jsp" ]; then echo "** TXMWEB upgrade: $SRCFILES/$APPNAME/jsp is missing. This folder contains the jsp files. Such as 404.jsp" exit 1; fi if [ ! -d "$SRCFILES/$APPNAME/data/mails" ]; then echo "** TXMWEB upgrade: $SRCFILES/$APPNAME/data/mails is missing. This folder contains the mails templates." exit 1; fi # set maintenance state echo "** TXMWEB upgrade: set maintenance state..." wget "$URL/$APPNAME/maintenance/?code=$code&state=true&message=The server is going to shutdown in 1 minute" -O _ -q var=$(cat _) echo $var if [ "$var" = "false" ]; then echo "** TXMWEB upgrade: the server is not in maintenance state. Aborting" exit 1; fi echo "** TXMWEB upgrade: waiting 60s to let users see the message..." #sleep 60 # undeploy and deploy $APPNAME echo "$MANAGERURL/undeploy?path=/$APPNAME" wget "$MANAGERURL/undeploy?path=/$APPNAME" -O – -q if [ $? != 0 ]; then echo "** TXMWEB upgrade: Failed to undeploy $APPNAME with cmd '$MANAGERURL/undeploy?path=/$APPNAME'. Continuing." fi echo "$MANAGERURL/deploy?deployPath=/$APPNAME&deployConfig=&deployWar=file:$WARPATH" wget "$MANAGERURL/deploy?deployPath=/$APPNAME&deployConfig=&deployWar=file:$WARPATH" -O – -q if [ $? != 0 ]; then echo "** TXMWEB upgrade: Failed to deploy $APPNAME with cmd '$MANAGERURL/deploy?deployPath=/$APPNAME&deployConfig=&deployWar=file:$WARPATH'. Aborting." exit 1; fi # test if ant list contains $APPNAME echo "** TXMWEB upgrade: check if the webapp is deployed..." wget "$MANAGERURL/list" -O testwar -q grep -q \/$APPNAME testwar if [ $? != 0 ]; then echo "** TXMWEB upgrade: $APPNAME is not ready." exit 1; fi rm -rf testwar sudo chmod -R g+w "$TOMCAT/$APPNAME" mkdir "$SRCFILES/$APPNAME/biblio" mkdir "$SRCFILES/$APPNAME/html" mkdir "$SRCFILES/$APPNAME/images" mkdir "$SRCFILES/$APPNAME/css" mkdir "$SRCFILES/$APPNAME/jsp" mkdir "$SRCFILES/$APPNAME/pdf" mkdir "$SRCFILES/$APPNAME/catalog" mkdir "$SRCFILES/$APPNAME/files" mkdir "$SRCFILES/$APPNAME/js" # copy biblio, html, images, css and jsp dir in dev webapps echo "** TXMWEB upgrade: copying biblio, html, images, css and jsp directories in webapps dir..." cp -rf "$SRCFILES/$APPNAME/biblio" "$TOMCAT/$APPNAME" && cp -rf "$SRCFILES/$APPNAME/html" "$TOMCAT/$APPNAME" && cp -f "$SRCFILES/$APPNAME/TXMWEB.jsp" "$TOMCAT/$APPNAME" && cp -f "$SRCFILES/$APPNAME/favicon.ico" "$TOMCAT/$APPNAME" && cp -f "$SRCFILES/$APPNAME/*.css" "$TOMCAT/$APPNAME" && cp -rf "$SRCFILES/$APPNAME/images" "$TOMCAT/$APPNAME" && cp -rf "$SRCFILES/$APPNAME/css" "$TOMCAT/$APPNAME" && cp -rf "$SRCFILES/$APPNAME/jsp" "$TOMCAT/$APPNAME" && cp -rf "$SRCFILES/$APPNAME/pdf" "$TOMCAT/$APPNAME" && cp -rf "$SRCFILES/$APPNAME/catalog" "$TOMCAT/$APPNAME" && cp -rf "$SRCFILES/$APPNAME/files" "$TOMCAT/$APPNAME" && cp -rf "$SRCFILES/$APPNAME/js" "$TOMCAT/$APPNAME" if [ $? != 0 ]; then echo "** TXMWEB upgrade: Failed to copy biblio, html, images, css and jsp dir in webapp $WEBAPPS/$APPNAME." exit 1; fi # be sute that files are usable by tomcat6 sudo chown -R tomcat6:tomcat6 "$TOMCAT/$APPNAME" # the end echo "** TXMWEB dev deploy: done."