-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathset_up_bundle.sh
140 lines (88 loc) · 5.6 KB
/
set_up_bundle.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
# -----------------------------------------------------------------------------
# Checks for necessary dependencies before starting the process.
# -----------------------------------------------------------------------------
command -v grep >/dev/null 2>&1 || { echo >&2 "grep is required but not installed - aborting"; exit 1; }
command -v sed >/dev/null 2>&1 || { echo >&2 "sed is required but not installed - aborting"; exit 1; }
command -v unzip >/dev/null 2>&1 || { echo >&2 "unzip is required but not installed - aborting"; exit 1; }
command -v wget >/dev/null 2>&1 || { echo >&2 "wget is required but not installed - aborting"; exit 1; }
# -----------------------------------------------------------------------------
# Sets variables to use within script.
# -----------------------------------------------------------------------------
source variables.sh
fetch_dependency () {
CACHE_DIR=".cache"
url=$1
mkdir -p $CACHE_DIR
md5=$(echo -n "$url" | md5sum | cut -f1 -d' ')
if [ ! -e $CACHE_DIR/$md5 ]
then
wget -q $url -O $CACHE_DIR/$md5
fi
echo "$CACHE_DIR/$md5"
}
# --------------------------------------------------------------
# Initializes the server for Liferay DXP.
# --------------------------------------------------------------
echo "================== Extracting bundle archive... ==================="
mkdir $LIFERAY_HOME_PARENT_DIR/temp
BUNDLE_ZIPFILE=`fetch_dependency "http://mirrors.lax.liferay.com/files.liferay.com/private/ee/portal/7.0.10.1/liferay-dxp-digital-enterprise-tomcat-7.0-sp1-20161027112321352.zip"`
unzip -d $LIFERAY_HOME_PARENT_DIR/temp -q "$BUNDLE_ZIPFILE"
rm -rf $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME
mv $LIFERAY_HOME_PARENT_DIR/temp/liferay-* $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME
rm -rf $LIFERAY_HOME_PARENT_DIR/temp
rm -rf $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/work $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/tomcat-*/temp $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/tomcat-*/work
ln -s `ls $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME | grep "tomcat-"` $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/tomcat
echo "==================== Setting up DXP license... ===================="
mkdir $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/deploy/
cp license/* $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/deploy/
echo "=================== Applying configurations... ===================="
cp properties/* $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/tomcat/webapps/ROOT/WEB-INF/classes
for PROPERTY in ${PORTAL_EXTRA_PROPERTIES[@]}; do
echo -e "\n$PROPERTY" >> $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/tomcat/webapps/ROOT/WEB-INF/classes/portal-ext.properties
done
mkdir -p $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/osgi/configs
for FILENAME in configs/*; do
sed "s/indexNamePrefix = .*/indexNamePrefix = $INDEX_NAME/g" $FILENAME > $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/osgi/configs/$(basename "$FILENAME")
done
cp -br tomcat/* $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/tomcat/
echo "======================= Applying fixpack... ======================="
rm -rf $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/patching-tool/
LATEST_PATCHING_TOOL=patching-tool-`curl --silent http://mirrors.lax.liferay.com/files.liferay.com/private/ee/fix-packs/patching-tool/LATEST-2.0.txt`.zip
PATCHING_TOOL_ZIPFILE=`fetch_dependency "http://mirrors.lax.liferay.com/files.liferay.com/private/ee/fix-packs/patching-tool/${LATEST_PATCHING_TOOL}"`
unzip -d $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME -q "$PATCHING_TOOL_ZIPFILE"
chmod u+x $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/patching-tool/*.sh
echo -e "patching.mode=binary\nwar.path=../tomcat/webapps/ROOT/\nglobal.lib.path=../tomcat/lib/ext/\nliferay.home=../" > $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/patching-tool/default.properties
$LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/patching-tool/patching-tool.sh auto-discovery ..${PATCHING_DIR}
$LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/patching-tool/patching-tool.sh revert
rm -fr $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/patching-tool/patches/*
FIXPACK_ZIPFILE=`fetch_dependency "http://mirrors.lax.liferay.com/files.liferay.com/private/ee/fix-packs/7.0.10/${FIX_PACK}-7010.zip"`
cat "$FIXPACK_ZIPFILE" > $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/patching-tool/patches/patch.zip
PATCH_INFO=`$LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/patching-tool/patching-tool.sh info | grep '\[ x\]\|\[ D\]\|\[ o\]\|\[ s\]'`
if [[ ! -z ${PATCH_INFO} ]]
then
echo "Unable to patch:"
echo "${PATCH_INFO}"
rm /tmp/peek_redeploy.lock
exit 0
fi
$LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/patching-tool/patching-tool.sh install
$LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/patching-tool/patching-tool.sh update-plugins
rm -fr $LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/osgi/state
echo "====================== Deploying plugins... ======================="
mkdir -p "$LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/osgi/modules/"
for MODULE in ${DEPLOYABLE_URL_MODULES[@]}; do
filename=$(basename "$MODULE")
wget "$MODULE" -O "$filename"
mv -v "$filename" "$LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/osgi/modules/${filename/-[0-9]\.[0-9]\.[0-9]\.jar/.jar}"
done
for MODULE in ${DEPLOYABLE_PORTAL_MODULES[@]}; do
cd $PORTAL_REPO_DIR/modules/$MODULE
if [ -e $PORTAL_REPO_DIR/modules/$MODULE/build.xml ]
then
ant "-Dapp.server.deploy.dir=$LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME/deploy" deploy
else
$PORTAL_REPO_DIR/gradlew --no-daemon "-Dliferay.home=$LIFERAY_HOME_PARENT_DIR/$DESIRED_HOME_DIR_NAME" deploy
fi
done
echo "============================== Done. =============================="