Added jratecalc (no-public, Cho-Time GmbH project).
[jprojects-scripts.git] / dist.sh
1 #!/bin/bash
2
3 # Name of this project, detected by it's base path
4 NAME="${PWD##*/}"
5
6 # Generated JAR file
7 DIST="dist/${NAME}.jar"
8
9 # WildFly module base path
10 WILDFLY_MODULE_BASE_PATH="${HOME}/wildfly_domain/modules/org/mxchange"
11
12 # And for this "module" (as WildFly calls it)
13 WILDFLY_MODULE_PATH="${WILDFLY_MODULE_BASE_PATH}/${NAME}/main"
14
15 # module.xml
16 WILDFLY_MODULE_XML_FILE="wildfly/module.xml"
17
18 # Glassfish base path (domain)
19 GLASSFISH_BASE_PATH="${HOME}/gf_domain/domain/lib"
20
21 # Remote Glassfish path
22 GLASSFISH_SSH_PATH="/var/payara/domains/domain1/lib"
23
24 # Remote SSH server (password-less access)
25 GLASSFISH_SSH_SERVER="www.mxchange.org"
26
27 # Generate list
28 LIST=`find ../*/lib/${NAME}.jar`
29 LIST="${LIST} `find ../*/*-ejb/lib/${NAME}.jar`"
30 LIST="${LIST} ${WILDFLY_MODULE_PATH}"
31
32 if [ -d "${GLASSFISH_BASE_PATH}" ]
33 then
34         echo "$0: Glassfish personal domain found, adding to LIST ..."
35         LIST="${LIST} ${GLASSFISH_BASE_PATH}"
36 fi
37
38 if [ ! -f "${DIST}" ]
39 then
40         echo "$0: '${DIST}' not found."
41         exit 1
42 elif [ ! -d "${WILDFLY_MODULE_BASE_PATH}" ]
43 then
44         echo "$0: WildFly base path '${WILDFLY_MODULE_BASE_PATH}' not created."
45         exit 1
46 elif [ ! -d "${WILDFLY_MODULE_PATH}" ]
47 then
48         mkdir -vp "${WILDFLY_MODULE_PATH}"
49 fi
50
51 for target in ${LIST};
52 do
53         if [ -d "${target}" ]
54         then
55                 cp -v "${DIST}" "${target}"
56         elif [ -f "${target}" ]
57         then
58                 cp -v "${DIST}" "${target}"
59         else
60                 echo "$0: Target '${target}' not found."
61         fi
62
63 done
64
65 if [ -n "${GLASSFISH_SSH_PATH}" -a -n "${GLASSFISH_SSH_SERVER}" ]
66 then
67         echo "$0: Copying to remote '${GLASSFISH_SSH_SERVER}' ..."
68         scp "${DIST}" "${GLASSFISH_SSH_SERVER}:${GLASSFISH_SSH_PATH}"
69 fi
70
71 # Copy module.xml ...
72 if [ -f "${WILDFLY_MODULE_XML_FILE}" ]
73 then
74         echo "$0: Generating module.xml ..."
75         XML_CONTENT=`cat "${WILDFLY_MODULE_XML_FILE}"`
76         XML_CONTENT="${XML_CONTENT//NAME/$NAME}"
77         echo "${XML_CONTENT}" > "${WILDFLY_MODULE_PATH}/module.xml"
78 fi
79
80 echo "$0: All done."
81 exit 0