-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
116 lines (95 loc) · 3.1 KB
/
run.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
#!/bin/bash
# Fail fast
set -e
PROPFILE="$ORDS_HOME/params/ords_params.properties"
touch $PROPFILE
if [ ! -f "$PROPFILE" ]; then
echo "Unable to find properties file $PROPFILE"
exit 1
fi
setProperty() {
prop=$1
val=$2
if [ $(grep -c "$prop" "$PROPFILE") -eq 0 ]; then
echo "${prop}=$val" >> "$PROPFILE"
else
val=$(echo "$val" |sed 's#/#\\/#g')
sed -i "s/$prop=.*/$prop=$val/" "$PROPFILE"
fi
}
setPropsFromFile() {
file=$1
for l in $(grep '=' "$file" | grep -v '^ *#'); do
prop=$(echo "$l" |cut -d= -f1)
val=$(echo "$l" |cut -d= -f2)
setProperty "$prop" "$val"
done
}
setPropFromEnvPointingToFile() {
prop=$1
val=$2
[ -z "$val" ] && return
# If the value is a file, use the contents of that file as the new value
if [ -f "$val" ]; then
val=$(cat "$val")
setProperty "$prop" "$val"
else
# If it's not a file, use the value of the variable as the password
setProperty "$prop" "$val"
fi
}
if [ -f "$CONFIG_FILE" ]; then
setPropsFromFile "$CONFIG_FILE"
fi
setPropFromEnv() {
prop=$1
val=$2
# If no value was given, abort
[ -z "$val" ] && return
if [ $(grep -c "$prop" $PROPFILE) -eq 0 ]; then
setProperty "$prop" "$val"
fi
}
if [ -z "$CONFIG_FILE" ]; then
setPropFromEnv db.username "$DB_USERNAME"
setPropFromEnvPointingToFile db.password "$DB_PASSWORD"
setPropFromEnv db.hostname "$DB_HOSTNAME"
setPropFromEnv db.port "$DB_PORT"
setPropFromEnv db.servicename "$DB_SID"
setProperty plsql.gateway.add "true"
setProperty rest.services.apex.add "false"
setProperty rest.services.ords.add "false"
setProperty standalone.mode "false"
fi
if [ -n "$JMX_PORT" ]; then
export CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=$JMX_PORT -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
fi
if [ ! -f $ORDS_HOME/config/ords/standalone/standalone.properties ]; then
cd $ORDS_HOME
java -jar ords.war configdir $ORDS_HOME/config
java -jar ords.war
cp -arv $ORDS_HOME/config/ords $ORDS_HOME/config/$URI_PATH
fi;
cp $ORDS_HOME/ords.war /usr/local/tomcat/webapps/$URI_PATH.war
java -jar ords.war set-property jdbc.MaxLimit $DB_MAXTOTAL
java -jar ords.war set-property jdbc.MinLimit $DB_INITIALSIZE
java -jar ords.war set-property jdbc.InitialLimit $DB_INITIALSIZE
java -jar ords.war set-property db.sid $DB_SID
java -jar ords.war set-property db.port $DB_PORT
java -jar ords.war set-property db.hostname $DB_HOSTNAME
java -jar ords.war set-property misc.defaultPage $DEFAULT_PAGE
if [ ! -v $ORDS_DEBUG ]; then
java -jar ords.war set-property debug.debugger true
java -jar ords.war set-property debug.printDebugToScreen true
fi
cp $ORDS_HOME/config/ords/defaults.xml $ORDS_HOME/config/$URI_PATH/defaults.xml
cd /usr/local/tomcat/webapps
for war in /usr/local/tomcat/webapps/*.war; do
mkdir $(basename "$war" .war)
unzip -d $(basename "$war" .war) "$war"
rm "$war"
done
cp -r /opt/static/js /usr/local/tomcat/webapps/js
cp -r /opt/static/css /usr/local/tomcat/webapps/css
cp -r /opt/static /usr/local/tomcat/webapps/${URI_PATH}_static
exec catalina.sh run