11#! /bin/bash
22
3+ OPT_PREFIX=" /opt/ibm"
4+ ORIGINAL_WLP_OUTPUT_DIR=" $OPT_PREFIX /wlp/output"
5+ ORIGINAL_SERVER_NAME=" defaultServer"
6+ IS_KERNEL=false
7+
38# If the Liberty server name is not defaultServer and defaultServer still exists migrate the contents
4- if [ " $SERVER_NAME " != " defaultServer " ] && [ -d " /opt/ibm/ wlp/usr/servers/defaultServer " ]; then
9+ if [ " $SERVER_NAME " != " $ORIGINAL_SERVER_NAME " ] && [ -d " $OPT_PREFIX / wlp/usr/servers/$ORIGINAL_SERVER_NAME " ]; then
510 # Create new Liberty server
6- /opt/ibm/wlp/bin/server create > /tmp/serverOutput
11+ if $IS_KERNEL ; then
12+ $OPT_PREFIX /wlp/bin/server create > /tmp/serverOutput
13+ else
14+ $OPT_PREFIX /wlp/bin/server create --template=javaee8 > /tmp/serverOutput
15+ fi
716 rc=$?
817 if [ $rc -ne 0 ]; then
918 cat /tmp/serverOutput
@@ -13,42 +22,40 @@ if [ "$SERVER_NAME" != "defaultServer" ] && [ -d "/opt/ibm/wlp/usr/servers/defau
1322 rm /tmp/serverOutput
1423
1524 # Verify server creation
16- if [ ! -d " /opt/ibm /wlp/usr/servers/$SERVER_NAME " ]; then
25+ if [ ! -d " $OPT_PREFIX /wlp/usr/servers/$SERVER_NAME " ]; then
1726 echo " The server name contains a character that is not valid."
1827 exit 1
1928 fi
20- chmod -R g+w /opt/ibm /wlp/usr/servers/$SERVER_NAME
29+ chmod -R g+w $OPT_PREFIX /wlp/usr/servers/$SERVER_NAME
2130
2231 # Delete old symlinks
23- rm /opt/ibm /links/output
24- rm /opt/ibm /links/config
32+ rm $OPT_PREFIX /links/output
33+ rm $OPT_PREFIX /links/config
2534
2635 # Add new output folder symlink and resolve group write permissions
27- mkdir -p $WLP_OUTPUT_DIR /$SERVER_NAME
28- ln -s $WLP_OUTPUT_DIR /$SERVER_NAME /opt/ibm/links/output
29- chmod g+w $WLP_OUTPUT_DIR /$SERVER_NAME
30- mkdir -p $WLP_OUTPUT_DIR /$SERVER_NAME /resources
31- mkdir -p $WLP_OUTPUT_DIR /$SERVER_NAME /workarea
32- mkdir -p $WLP_OUTPUT_DIR /$SERVER_NAME /logs
33- chmod -R g+w $WLP_OUTPUT_DIR /$SERVER_NAME /workarea
34- chmod -R g+w,o-rwx $WLP_OUTPUT_DIR /$SERVER_NAME /resources
35- chmod -R g+w,o-rwx $WLP_OUTPUT_DIR /$SERVER_NAME /logs
36-
37- # Hand over the SCC
38- if [ " $OPENJ9_SCC " = " true" ] && [ -d " /opt/ibm/wlp/output/defaultServer/.classCache" ]; then
39- mv /opt/ibm/wlp/output/defaultServer/.classCache $WLP_OUTPUT_DIR /$SERVER_NAME /
40- fi
41- rm -rf /opt/ibm/wlp/output/defaultServer
42-
43- # Add new server symlink and populate folder
44- mv /opt/ibm/wlp/usr/servers/defaultServer/* /opt/ibm/wlp/usr/servers/$SERVER_NAME /
45- ln -s /opt/ibm/wlp/usr/servers/$SERVER_NAME /opt/ibm/links/config
36+ SERVER_OUTPUT_DIR=$WLP_OUTPUT_DIR /$SERVER_NAME
37+ ORIGINAL_SERVER_OUTPUT_DIR=$ORIGINAL_WLP_OUTPUT_DIR /$ORIGINAL_SERVER_NAME
38+ mkdir -p $SERVER_OUTPUT_DIR
39+ ln -s $SERVER_OUTPUT_DIR $OPT_PREFIX /links/output
40+
41+ # Copy old /output folder contents
42+ cp -r $ORIGINAL_SERVER_OUTPUT_DIR /. $SERVER_OUTPUT_DIR / 2> /dev/null
43+ rm -rf $ORIGINAL_SERVER_OUTPUT_DIR
44+ chmod -R g+rw $SERVER_OUTPUT_DIR
45+ setfacl -R -dm g:root:rw $SERVER_OUTPUT_DIR
46+
47+ # Add new server symlink and copy over old /config folder contents
48+ cp -r $OPT_PREFIX /wlp/usr/servers/$ORIGINAL_SERVER_NAME /. $OPT_PREFIX /wlp/usr/servers/$SERVER_NAME / 2> /dev/null
49+ ln -s $OPT_PREFIX /wlp/usr/servers/$SERVER_NAME $OPT_PREFIX /links/config
4650 mkdir -p /config/configDropins/defaults
4751 mkdir -p /config/configDropins/overrides
48- chmod -R g+w /config
49-
50- rm -rf /opt/ibm/wlp/usr/servers/defaultServer
52+ if $IS_KERNEL ; then
53+ mkdir -p /config/dropins
54+ mkdir -p /config/apps
55+ fi
56+ chmod -R g+rw /config
57+ setfacl -R -dm g:root:rw /config
58+ rm -rf $OPT_PREFIX /wlp/usr/servers/$ORIGINAL_SERVER_NAME
5159fi
5260
53- echo " configure-liberty.sh script has been run" > /opt/ibm/wlp/configure-liberty.log
5461exit 0
0 commit comments