war 파일을 풀고 묶고 자동화

gimslab:/data/myapp/war]cat rewar.sh
VERBOSE=N
WAR=myapp.war
TMPDIR=ztmp_war_exploded


function build_war {
        if [ ! -d ${TMPDIR} ]; then
                info cannot access ${TMPDIR} dir
                exit 1
        fi

        if [ -f ${WAR} ]; then
                timestamp=`date '+%y%m%d_%H%M%S'`
                info rename old war to ${WAR}__${timestamp}
                mv $WAR ${WAR}__${timestamp}
        fi

        cd ${TMPDIR}
        info building ${WAR} ....
        jar cf ../${WAR} *
        info war created. restart WAS.
        cd ..
        if [ ! "${1}" = "-r" ]; then
                debug remove temp dir ${TMPDIR}.
                info if you want to reuse tmp dir. use -r option
                rm -rf ${TMPDIR}/*
                rmdir ${TMPDIR}
        else
                debug temp dir is not removed.
        fi
}


function explode_war {
        if [ ! -f ${WAR} ]; then
                info NOT FOUND WAR \(${WAR}\)
                exit 1
        fi

        debug mkdir ${TMPDIR}
        mkdir ${TMPDIR}
        if [ ! -d ${TMPDIR} ]; then
                info cannot access ${TMPDIR} dir
                exit 1
        fi
        cd ${TMPDIR}
        info exploding '${WAR}' file into '${TMPDIR}' dir ....
        jar xf ../${WAR}
        cd ..
        info war exploded. rerun this script to build war
}

function debug {
        if [ "${VERBOSE}" = "Y" ]; then
                echo $@
        fi
}

function info {
        echo $@
}


if [ -d ${TMPDIR} ]; then
        debug "tmpdir \(${TMPDIR}\) exist. building war..."
        build_war ${1}
else
        debug ${TMPDIR} NOT exists.
        explode_war
fi

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2012-10-26 17:06:48
Processing time 0.0054 sec