Author: tchemit Date: 2014-07-13 17:57:18 +0200 (Sun, 13 Jul 2014) New Revision: 96 Url: http://forge.codelutin.com/projects/adminsys/repository/revisions/96 Log: refs #5428 (on goh) Added: scripts/redmine-tools/update-tomcat.sh Removed: scripts/redmine-tools/update-tomcat-7.sh Deleted: scripts/redmine-tools/update-tomcat-7.sh =================================================================== --- scripts/redmine-tools/update-tomcat-7.sh 2014-07-13 15:56:45 UTC (rev 95) +++ scripts/redmine-tools/update-tomcat-7.sh 2014-07-13 15:57:18 UTC (rev 96) @@ -1,91 +0,0 @@ -#!/bin/sh - -# -# USAGE: check-get-tomcat.sh [debug] -# -# verifie s'il y a ou non une nouvelle version tomcat par rapport a celle installee -# si c'est le cas: -# - telecharge le fichier -# - le decompresse -# - le met en place pour les diffentes instances souhaite -# - affiche le chemin des nouvelles instances mise en place si besoin -# -# l'administrateur devra alors redemarrer les tomcat des forges -# - service tomcat-7 restart -# - -DEBUG=false -#MIRROR=http://mirrors.linsrv.net/apache/tomcat -MIRROR=http://www.carfab.com/apachesoftware/tomcat -TARGET_DIR=/opt/repository -LINK_DIR=/opt - -if [ "$1" = "debug" ]; then - export DEBUG=true -fi - -debug () { - if [ "$DEBUG" = "true" ]; then - echo "$1" - fi -} - -getFileURL () { - local RELEASE=$2 - local VERSION=${2%%.*} - local result="$MIRROR/tomcat-$VERSION/v$RELEASE/bin/apache-tomcat-$RELEASE.tar.gz" - debug "getFileURL: $result" - eval $1=\$result -} - -# get the last release for specified tomcat version -# @param $1 returned value -# @param $2 tomcat version 6, 7 or 8 -getLastRelease () { - local VERSION=$2 - local result=$(curl -s $MIRROR/tomcat-$VERSION/ |grep "href=.v" |sed -re 's/.*>v([0-9]+.[0-9]+.[0-9]+).*/\1/') - debug "getLastRelease: $result" - eval $1=\$result -} - -getCurrentRelease () { - local VERSION=$2 - local LINK=$(readlink $LINK_DIR/apache-tomcat-$VERSION) - local DIR=$(basename $LINK) - local result=${DIR##*-} - debug "getCurrentRelease: $result" - eval $1="$result" -} - -installRelease () { - local OLD_RELEASE=$1 - local RELEASE=$2 - local VERSION=${RELEASE%%.*} - local URL - getFileURL URL $RELEASE - mkdir -p $TARGET_DIR - curl -s "$URL" | tar --no-same-owner -C "$TARGET_DIR" -xz - local DIR=$(basename $URL .tar.gz) - local UNPACK_DIR=$TARGET_DIR/$DIR - local UNPACK_OLD_DIR=$TARGET_DIR/apache-tomcat-$OLD_RELEASE - cp $UNPACK_OLD_DIR/webapps/*.war $UNPACK_DIR/webapps - cp $UNPACK_OLD_DIR/conf/tomcat-users.xml $UNPACK_DIR/conf - local LINK=$LINK_DIR/${DIR%%.*} - sed -i 's/<Connector /<Connector URIEncoding="UTF-8" /g' $UNPACK_DIR/conf/server.xml - rm -f $LINK - ln -s $UNPACK_DIR $LINK - echo "new release installed in $LINK -> $UNPACK_DIR" -} - -update () { - local VERSION=$1 - local CURRENT_RELEASE - local LAST_RELEASE - getCurrentRelease CURRENT_RELEASE $VERSION - getLastRelease LAST_RELEASE $VERSION - if [ "$CURRENT_RELEASE" != "$LAST_RELEASE" ]; then - installRelease $CURRENT_RELEASE $LAST_RELEASE - fi -} - -update 7 Copied: scripts/redmine-tools/update-tomcat.sh (from rev 75, scripts/redmine-tools/update-tomcat-7.sh) =================================================================== --- scripts/redmine-tools/update-tomcat.sh (rev 0) +++ scripts/redmine-tools/update-tomcat.sh 2014-07-13 15:57:18 UTC (rev 96) @@ -0,0 +1,91 @@ +#!/bin/sh + +# +# USAGE: check-get-tomcat.sh [debug] +# +# verifie s'il y a ou non une nouvelle version tomcat par rapport a celle installee +# si c'est le cas: +# - telecharge le fichier +# - le decompresse +# - le met en place pour les diffentes instances souhaite +# - affiche le chemin des nouvelles instances mise en place si besoin +# +# l'administrateur devra alors redemarrer les tomcat des forges +# - service tomcat-7 restart +# + +DEBUG=false +#MIRROR=http://mirrors.linsrv.net/apache/tomcat +MIRROR=http://www.carfab.com/apachesoftware/tomcat +TARGET_DIR=/opt/repository +LINK_DIR=/opt + +if [ "$1" = "debug" ]; then + export DEBUG=true +fi + +debug () { + if [ "$DEBUG" = "true" ]; then + echo "$1" + fi +} + +getFileURL () { + local RELEASE=$2 + local VERSION=${2%%.*} + local result="$MIRROR/tomcat-$VERSION/v$RELEASE/bin/apache-tomcat-$RELEASE.tar.gz" + debug "getFileURL: $result" + eval $1=\$result +} + +# get the last release for specified tomcat version +# @param $1 returned value +# @param $2 tomcat version 6, 7 or 8 +getLastRelease () { + local VERSION=$2 + local result=$(curl -s $MIRROR/tomcat-$VERSION/ |grep "href=.v" |sed -re 's/.*>v([0-9]+.[0-9]+.[0-9]+).*/\1/') + debug "getLastRelease: $result" + eval $1=\$result +} + +getCurrentRelease () { + local VERSION=$2 + local LINK=$(readlink $LINK_DIR/apache-tomcat-$VERSION) + local DIR=$(basename $LINK) + local result=${DIR##*-} + debug "getCurrentRelease: $result" + eval $1="$result" +} + +installRelease () { + local OLD_RELEASE=$1 + local RELEASE=$2 + local VERSION=${RELEASE%%.*} + local URL + getFileURL URL $RELEASE + mkdir -p $TARGET_DIR + curl -s "$URL" | tar --no-same-owner -C "$TARGET_DIR" -xz + local DIR=$(basename $URL .tar.gz) + local UNPACK_DIR=$TARGET_DIR/$DIR + local UNPACK_OLD_DIR=$TARGET_DIR/apache-tomcat-$OLD_RELEASE + cp $UNPACK_OLD_DIR/webapps/*.war $UNPACK_DIR/webapps + cp $UNPACK_OLD_DIR/conf/tomcat-users.xml $UNPACK_DIR/conf + local LINK=$LINK_DIR/${DIR%%.*} + #sed -i 's/<Connector /<Connector URIEncoding="UTF-8" /g' $UNPACK_DIR/conf/server.xml + rm -f $LINK + ln -s $UNPACK_DIR $LINK + echo "new release installed in $LINK -> $UNPACK_DIR" +} + +update () { + local VERSION=$1 + local CURRENT_RELEASE + local LAST_RELEASE + getCurrentRelease CURRENT_RELEASE $VERSION + getLastRelease LAST_RELEASE $VERSION + if [ "$CURRENT_RELEASE" != "$LAST_RELEASE" ]; then + installRelease "$CURRENT_RELEASE" "$LAST_RELEASE" + fi +} + +update 8 \ No newline at end of file
participants (1)
-
tchemit@users.forge.codelutin.com