-
Notifications
You must be signed in to change notification settings - Fork 41
/
entrypoint.sh
70 lines (53 loc) · 2.34 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
#!/bin/bash
export DOCKER_CONTAINER_IP=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
if [ "$1" = 'run' ]; then
if [ -z "$HYBRIS_HOME" ]; then
HYBRIS_HOME="/home/hybris"
fi
if [ ! -d "$HYBRIS_HOME/config" ]; then
cd $HYBRIS_HOME
# unzip the artifacts created by production ant target
echo "Unzipping hybris production archives ..."
for z in hybrisServer*.zip; do unzip $z -d $(dirname $HYBRIS_HOME) ; done
# add container ip to cluster configuration of hybris instance
echo "cluster.broadcast.method.jgroups.tcp.bind_addr=$DOCKER_CONTAINER_IP" >> config/local.properties
# add database properties passed as environment variables
if [ ! -z "$HYBRIS_DB_URL" ]; then
echo "db.url=$HYBRIS_DB_URL" >> config/local.properties
fi
if [ ! -z "$HYBRIS_DB_DRIVER" ]; then
echo "db.driver=$HYBRIS_DB_DRIVER" >> config/local.properties
fi
if [ ! -z "$HYBRIS_DB_USER" ]; then
echo "db.username=$HYBRIS_DB_USER" >> config/local.properties
fi
if [ ! -z "$HYBRIS_DB_PASSWORD" ]; then
echo "db.password=$HYBRIS_DB_PASSWORD" >> config/local.properties
fi
# add datahub properties passed as environment variables
if [ ! -z "$HYBRIS_DATAHUB_URL" ]; then
echo "datahubadapter.datahuboutbound.url=$HYBRIS_DATAHUB_URL" >> config/local.properties
fi
fi
cd ${PLATFORM_HOME}
# fix ownership of files
chown -R hybris $HYBRIS_HOME
chmod +x hybrisserver.sh
# if initialize system is wanted we do it before starting the hybris server
if [ "$HYBRIS_INITIALIZE_SYSTEM" = "yes" ]; then
# set ant environment
source ./setantenv.sh
# run hybris update with predefined config and without rebuilding
gosu hybris ant initialize -Dde.hybris.platform.ant.production.skip.build=true
fi
# if update system is wanted we do it before starting the hybris server
if [ "$HYBRIS_UPDATE_SYSTEM" = "yes" ]; then
# set ant environment
source ./setantenv.sh
# run hybris update with predefined config
gosu hybris ant updatesystem -DconfigFile=$HYBRIS_HOME/updateRunningSystem.config
fi
# run hybris commerce suite as user hybris
exec gosu hybris ./hybrisserver.sh $2
fi
exec "$@"