forked from strolch-li/strolch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
createBundle.sh
executable file
·94 lines (81 loc) · 2.29 KB
/
createBundle.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
projectName=strolch_bundle
ROOT="$(cd ${0%/*} ; pwd)"
projectVersion=$(grep -m 1 "<version>" pom.xml | tr '<>' '|' | cut -d '|' -f 3)
if [ $? != 0 ] ; then
echo "ERROR: Failed to parse version!"
fi
bundle_name="${projectName}-${projectVersion}"
workDir="${ROOT}/target/${bundle_name}"
DIST_STROLCH="/var/www/eitch/strolch.li/dist/${projectVersion}"
DEPLOY_SERVER="hosting.eitchnet.ch"
echo "INFO: Creating bundle ${bundle_name}"
# Create all needed packages
echo "INFO: Building projects..."
if ! mvn -DskipTests clean package ; then
echo "ERROR: Failed to build packages!"
exit 1
fi
# Make sure the work directory exists
if [ -d "${workDir}" ] ; then
if ! rm -rf "${workDir}" ; then
echo "ERROR: Failed to clean work dir ${workDir}."
exit 1
fi
fi
if ! mkdir -p "${workDir}" ; then
echo "ERROR: Failed to create work dir ${workDir}."
exit 1
fi
echo "INFO: Copying bundles..."
cd ${ROOT}
for project in ls * ; do
if [ ! -d ${project} ] ; then
continue
fi
if [ ${project} == "dev" ] || [ ${project} == "target" ] ; then
continue
fi
echo "INFO: Copying ${project} packages..."
if ls ${project}/target/*.jar 2>/dev/null ; then
if ! cp ${project}/target/*.jar "${workDir}" ; then
echo "ERROR: Failed to copy package for project ${project}."
exit 1
fi
fi
if ls ${project}/target/*.war 2>/dev/null ; then
if ! cp ${project}/target/*.war "${workDir}" ; then
echo "ERROR: Failed to copy wars for project ${project}."
exit 1
fi
fi
if ls ${project}/target/*.tar.gz 2>/dev/null ; then
if ! cp ${project}/target/*.tar.gz "${workDir}" ; then
echo "ERROR: Failed to copy tarballs for project ${project}."
exit 1
fi
fi
done
echo "INFO: Creating tarball..."
cd ${workDir}/..
if ! tar -cvzf ${bundle_name}.tar.gz ${bundle_name} ; then
echo "ERROR: Failed to make bundle."
exit 1
fi
if [ "$(hostname -f)" == "${DEPLOY_SERVER}" ] ; then
echo "INFO: Publishing..."
if ! mkdir -p ${DIST_STROLCH} ; then
echo "ERROR: Failed to create dist ${DIST_STROLCH}"
exit 1
fi
if ! cp ${workDir}/* "${DIST_STROLCH}" ; then
echo "ERROR: Failed to publish packages."
exit 1
fi
if ! mv ${bundle_name}.tar.gz "${DIST_STROLCH}" ; then
echo "ERROR: Failed to publish bundle."
exit 1
fi
fi
echo "Done."
exit 0