Continued:
[jprojects-scripts.git] / dist.sh
diff --git a/dist.sh b/dist.sh
index 54fcb45..fdd1e5d 100755 (executable)
--- a/dist.sh
+++ b/dist.sh
@@ -6,6 +6,9 @@ NAME="${PWD##*/}"
 # Generated JAR file
 DIST="dist/${NAME}.jar"
 
+# Configuration file
+DIST_CONFIG_FILE="${HOME}/.jprojects-dist.sh"
+
 # WildFly module base path
 WILDFLY_MODULE_BASE_PATH="${HOME}/wildfly_domain/modules/org/mxchange"
 
@@ -16,32 +19,47 @@ WILDFLY_MODULE_PATH="${WILDFLY_MODULE_BASE_PATH}/${NAME}/main"
 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"
+GLASSFISH_BASE_PATH="${HOME}/gf_domain/lib"
 
 # Windows personal domain
 PERSONAL_DOMAIN_PATH="${HOME}/personal_domain/lib"
 
+# Is the configuration file there?
+if [ ! -f "${DIST_CONFIG_FILE}" ]
+then
+       echo "$0: Configuration file '${DIST_CONFIG_FILE}' not found"
+       echo
+       echo "Following variables are needed for SSH upload:"
+       echo "- GLASSFISH_SSH_PATH"
+       echo "- GLASSFISH_SSH_USER"
+       echo "- GLASSFISH_SSH_SERVER"
+       echo
+       echo "And create a password-less SSH key."
+       sleep 3
+else
+       # Load it
+       source "${DIST_CONFIG_FILE}"
+fi
+
 # Generate list
-LIST=`find ../*/lib/${NAME}.jar`
-LIST="${LIST} `find ../*/*-ejb/lib/${NAME}.jar`"
+LIST=$(find ../*/lib/${NAME}.jar)
 LIST="${LIST} ${WILDFLY_MODULE_PATH}"
 
-if [ -d "${GLASSFISH_BASE_PATH}" ]
+if [ "${NAME}" != "jcore" -a "${NAME}" != "jcore-swing" ]
 then
-       echo "$0: Glassfish personal domain found, adding to LIST ..."
-       LIST="${LIST} ${GLASSFISH_BASE_PATH}"
-fi
+       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}"
+       if [ -d "${PERSONAL_DOMAIN_PATH}" ]
+       then
+               echo "$0: Personal domain found, adding to LIST ..."
+               LIST="${LIST} ${PERSONAL_DOMAIN_PATH}"
+       fi
+else
+       echo "$0: Not going to add '${NAME}' to distribution list, is JavaSE project."
 fi
 
 if [ ! -f "${DIST}" ]
@@ -51,7 +69,6 @@ then
 elif [ ! -d "${WILDFLY_MODULE_BASE_PATH}" ]
 then
        echo "$0: WildFly base path '${WILDFLY_MODULE_BASE_PATH}' not created."
-       exit 1
 elif [ ! -d "${WILDFLY_MODULE_PATH}" ]
 then
        mkdir -vp "${WILDFLY_MODULE_PATH}"
@@ -68,20 +85,24 @@ do
        else
                echo "$0: Project '${project}' not found."
        fi
-
 done
 
-if [ -n "${GLASSFISH_SSH_PATH}" -a -n "${GLASSFISH_SSH_SERVER}" ]
+if [ "$1" = "r" -o "${NAME}" = "jcore" -o "${NAME}" = "jcore-swing" ]
+then
+       echo "$0: Not uploading '${NAME}' or parameter 'r' provided."
+elif [ -n "${GLASSFISH_SSH_USER}" -a -n "${GLASSFISH_SSH_SERVER}" -a -n "${GLASSFISH_SSH_PATH}" ]
 then
        echo "$0: Copying to remote '${GLASSFISH_SSH_SERVER}' ..."
-       scp "${DIST}" "${GLASSFISH_SSH_SERVER}:${GLASSFISH_SSH_PATH}"
+       scp "${DIST}" "${GLASSFISH_SSH_USER}@${GLASSFISH_SSH_SERVER}:${GLASSFISH_SSH_PATH}" || exit 255
+else
+       echo "$0: SSH upload disabled."
 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=$(cat "${WILDFLY_MODULE_XML_FILE}")
        XML_CONTENT="${XML_CONTENT//NAME/$NAME}"
        echo "${XML_CONTENT}" > "${WILDFLY_MODULE_PATH}/module.xml"
 fi