From bde493dec035e7201446b323bc07dd30f4be02e9 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 19 Apr 2016 21:04:50 +0200 Subject: [PATCH] added dist.sh --- dist.sh | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 dist.sh diff --git a/dist.sh b/dist.sh new file mode 100755 index 0000000..8d5e1cc --- /dev/null +++ b/dist.sh @@ -0,0 +1,88 @@ +#!/bin/bash + +# Name of this project, detected by it's base path +NAME="${PWD##*/}" + +# Generated JAR file +DIST="dist/${NAME}.jar" + +# WildFly module base path +WILDFLY_MODULE_BASE_PATH="${HOME}/wildfly_domain/modules/org/mxchange" + +# And for this "module" (as WildFly calls it) +WILDFLY_MODULE_PATH="${WILDFLY_MODULE_BASE_PATH}/${NAME}/main" + +# module.xml +WILDFLY_MODULE_XML_FILE="wildfly/module.xml" + +# Glassfish base path (domain) +GLASSFISH_BASE_PATH="${HOME}/gf_domain/domain/lib" + +# Remote Glassfish path +GLASSFISH_SSH_PATH="/var/payara/domains/domain1/lib" + +# Remote SSH server (password-less access) +GLASSFISH_SSH_SERVER="www.mxchange.org" + +# Windows personal domain +PERSONAL_DOMAIN_PATH="${HOME}/personal_domain/lib" + +# Generate list +LIST=`find ../*/lib/${NAME}.jar` +LIST="${LIST} ${WILDFLY_MODULE_PATH}" + +if [ -d "${GLASSFISH_BASE_PATH}" ] +then + echo "$0: Glassfish personal domain found, adding to LIST ..." + LIST="${LIST} ${GLASSFISH_BASE_PATH}" +fi + +if [ -d "${PERSONAL_DOMAIN_PATH}" ] +then + echo "$0: Personal domain found, adding to LIST ..." + LIST="${LIST} ${PERSONAL_DOMAIN_PATH}" +fi + +if [ ! -f "${DIST}" ] +then + echo "$0: '${DIST}' not found." + exit 1 +elif [ ! -d "${WILDFLY_MODULE_BASE_PATH}" ] +then + echo "$0: WildFly base path '${WILDFLY_MODULE_BASE_PATH}' not created." +elif [ ! -d "${WILDFLY_MODULE_PATH}" ] +then + mkdir -vp "${WILDFLY_MODULE_PATH}" +fi + +for project in ${LIST}; +do + if [ -d "${project}" ] + then + cp -v "${DIST}" "${project}" + elif [ -f "${project}" ] + then + cp -v "${DIST}" "${project}" + else + echo "$0: Project '${project}' not found." + fi + +done + +if [ -n "${GLASSFISH_SSH_PATH}" -a -n "${GLASSFISH_SSH_SERVER}" ] +then + echo "$0: Copying to remote '${GLASSFISH_SSH_SERVER}' ..." + scp "${DIST}" "${GLASSFISH_SSH_SERVER}:${GLASSFISH_SSH_PATH}" +fi + +# Copy module.xml ... +if [ -f "${WILDFLY_MODULE_XML_FILE}" ] +then + echo "$0: Generating module.xml ..." + XML_CONTENT=`cat "${WILDFLY_MODULE_XML_FILE}"` + XML_CONTENT="${XML_CONTENT//NAME/$NAME}" + echo "${XML_CONTENT}" > "${WILDFLY_MODULE_PATH}/module.xml" +fi + +echo "$0: All done." +exit 0 -- 2.39.5