-
Notifications
You must be signed in to change notification settings - Fork 53
/
entrypoint.sh
161 lines (126 loc) · 3.49 KB
/
entrypoint.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#!/bin/bash
set -o errexit
main() {
show_motd
prepare_liferay_portal_properties
prepare_liferay_tomcat_config
prepare_liferay_deploy_directory
prepare_liferay_osgi_configs_directory
run_portal "$@"
}
show_motd() {
echo "Starting Liferay 7.3 instance.
LIFERAY_HOME: $LIFERAY_HOME
"
}
prepare_liferay_deploy_directory() {
if [ ! -d $LIFERAY_DEPLOY_DIR ]; then
echo "No deploy files found.
If you wish to deploy customizations to Liferay make
sure you include a 'deploy' directory in the root of
your project.
Continuing.
"
return 0
fi
echo "Deploy directory found.
The following contents are going to be synchronized
with Liferay:
"
tree $LIFERAY_DEPLOY_DIR
if [[ ! -d "$LIFERAY_HOME/osgi/modules" ]]; then
mkdir $LIFERAY_HOME/osgi/modules
fi
if [[ ! -d "$LIFERAY_HOME/osgi/war" ]]; then
mkdir $LIFERAY_HOME/osgi/war
fi
for lpkg in $LIFERAY_DEPLOY_DIR/*.lpkg; do
[ -e "$lpkg" ] && cp $LIFERAY_DEPLOY_DIR/*.lpkg $LIFERAY_HOME/osgi/marketplace
break
done
for jar in $LIFERAY_DEPLOY_DIR/*.jar; do
[ -e "$jar" ] && cp $LIFERAY_DEPLOY_DIR/*.jar $LIFERAY_HOME/osgi/modules
break
done
for war in $LIFERAY_DEPLOY_DIR/*.war; do
[ -e "$war" ] && cp $LIFERAY_DEPLOY_DIR/*.war $LIFERAY_HOME/osgi/war
break
done
echo "
Continuing.
"
}
prepare_liferay_osgi_configs_directory() {
if [[ ! -d "$LIFERAY_CONFIG_DIR/osgi" ]]; then
echo "No 'configs/osgi' directory found.
If you wish to deploy custom OSGi configurations to
Liferay make sure you include a 'configs/osgi' directory
in the root of your project.
Continuing.
"
return 0
fi
echo "OSGi configs directory found.
The following contents are going to be synchronized
with Liferay:
"
tree $LIFERAY_CONFIG_DIR/osgi
mkdir -p $LIFERAY_HOME/osgi/configs
cp -r $LIFERAY_CONFIG_DIR/osgi/* $LIFERAY_HOME/osgi/configs 2>/dev/null || true
echo "
Continuing.
"
}
prepare_liferay_portal_properties() {
if [[ ! -f "$LIFERAY_CONFIG_DIR/portal-ext.properties" ]]; then
echo "No 'configs/portal-ext.properties' file found.
If you wish to use a custom properties file make sure
you include a 'configs/portal-ext.properties' file in the
root of your project.
Continuing.
"
return 0
fi
echo "Portal properties (portal-ext.properties) file found.
"
cp -r $LIFERAY_CONFIG_DIR/portal-ext.properties $LIFERAY_HOME/portal-ext.properties
echo "
Continuing.
"
}
prepare_liferay_tomcat_config() {
if [[ ! -f "$LIFERAY_CONFIG_DIR/setenv.sh" ]]; then
echo "No 'configs/setenv.sh' file found.
If you wish to provide custom tomcat JVM settings, make sure
you include a 'configs/setenv.sh' file in the
root of your project.
Continuing.
"
return 0
fi
echo "Tomcat configuration (setenv.sh) file found.
"
cp -r $LIFERAY_CONFIG_DIR/setenv.sh $CATALINA_HOME/bin/setenv.sh
echo "
Continuing.
"
}
run_portal() {
set -e
# Drop root privileges if we are running liferay
# allow the container to be started with `--user`
if [ "$1" = 'catalina.sh' -a "$(id -u)" = '0' ]; then
# Change the ownership of Liferay Shared Volume to liferay
if [[ ! -d "$LIFERAY_SHARED" ]]; then
mkdir -p $LIFERAY_SHARED
fi
chown -R liferay:liferay $LIFERAY_SHARED
chown -R liferay:liferay $LIFERAY_HOME
set -- gosu liferay "$@"
fi
# As argument is not related to liferay,
# then assume that user wants to run his own process,
# for example a `bash` shell to explore this image
exec "$@"
}
main "$@"