-
Notifications
You must be signed in to change notification settings - Fork 39
/
postinst
139 lines (125 loc) · 5.69 KB
/
postinst
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
#!/bin/bash
set -e
echo "running post install"
HOST_IP_LIST=`ifconfig | sed -n -e 's/:127\.0\.0\.1 //g' -e 's/ *inet addr:\([0-9.]\+\).*/\1/gp'`
HOSTIP=`echo $HOST_IP_LIST | cut -d' ' -f1`
if [ -f /opt/contrail/contrail_server_manager/IP.txt ];
then
HOSTIP=$(cat /opt/contrail/contrail_server_manager/IP.txt)
fi
mkdir -p /var/log/contrail/
# Newly added from setup.sh
# Modify webui config file
WEBUI_CONF_FILE=/etc/contrail/config.global.sm.js
SM_CONF_FILE=/usr/src/contrail/contrail-web-server-manager/webroot/common/api/sm.config.js
WEBUI_PATH=/usr/src/contrail/contrail-web-server-manager
WEBUI_STORAGE_PATH=/usr/src/contrail/contrail-web-storage
WEBUI_WEBCONTROLLER_PATH=/usr/src/contrail/contrail-web-controller
WEBUI_STORAGE_PATH=/usr/src/contrail/contrail-web-storage
set +e
grep "config.featurePkg" $WEBUI_CONF_FILE
if [ $? != 0 ]; then
echo "config.featurePkg = {};" >> $WEBUI_CONF_FILE
echo "config.featurePkg.serverManager = {};" >> $WEBUI_CONF_FILE
fi
grep "config.featurePkg.serverManager" $WEBUI_CONF_FILE
if [ $? != 0 ]; then
echo "config.featurePkg.serverManager = {};" >> $WEBUI_CONF_FILE
fi
grep "config.featurePkg.serverManager.path" $WEBUI_CONF_FILE
if [ $? == 0 ]; then
sed -i "s|config.featurePkg.serverManager.path = .*|config.featurePkg.serverManager.path = '$WEBUI_PATH';|g" $WEBUI_CONF_FILE
else
echo "config.featurePkg.serverManager.path = '$WEBUI_PATH';" >> $WEBUI_CONF_FILE
fi
grep "config.featurePkg.serverManager.enable" $WEBUI_CONF_FILE
if [ $? == 0 ]; then
sed -i "s/config.featurePkg.serverManager.enable = .*/config.featurePkg.serverManager.enable = true;/g" $WEBUI_CONF_FILE
else
echo "config.featurePkg.serverManager.enable = true;" >> $WEBUI_CONF_FILE
fi
grep "config.featurePkg.webController = {};" $WEBUI_CONF_FILE
if [ $? != 0 ]; then
echo "config.featurePkg.webController = {};" >> $WEBUI_CONF_FILE
fi
grep "config.featurePkg.webController.path" $WEBUI_CONF_FILE
if [ $? == 0 ]; then
sed -i "s|config.featurePkg.webController.path = .*|config.featurePkg.webController.path = '$WEBUI_WEBCONTROLLER_PATH';|g" $WEBUI_CONF_FILE
else
echo "config.featurePkg.webController.path = '$WEBUI_WEBCONTROLLER_PATH';" >> $WEBUI_CONF_FILE
fi
grep "config.featurePkg.webController.enable" $WEBUI_CONF_FILE
if [ $? == 0 ]; then
sed -i "s/config.featurePkg.webController.enable = .*/config.featurePkg.webController.enable = false;/g" $WEBUI_CONF_FILE
else
echo "config.featurePkg.webController.enable = false;" >> $WEBUI_CONF_FILE
fi
grep "config.featurePkg.webStorage = {};" $WEBUI_CONF_FILE
if [ $? != 0 ]; then
echo "config.featurePkg.webStorage = {};" >> $WEBUI_CONF_FILE
fi
grep "config.featurePkg.webStorage.path" $WEBUI_CONF_FILE
if [ $? == 0 ]; then
sed -i "s|config.featurePkg.webStorage.path = .*|config.featurePkg.webStorage.path = '$WEBUI_STORAGE_PATH';|g" $WEBUI_CONF_FILE
else
echo "config.featurePkg.webStorage.path = '$WEBUI_STORAGE_PATH';" >> $WEBUI_CONF_FILE
fi
grep "config.featurePkg.webStorage.enable" $WEBUI_CONF_FILE
if [ $? == 0 ]; then
sed -i "s/config.featurePkg.webStorage.enable = .*/config.featurePkg.webStorage.enable = false;/g" $WEBUI_CONF_FILE
else
echo "config.featurePkg.webStorage.enable = false;" >> $WEBUI_CONF_FILE
fi
grep "config.orchestration" $WEBUI_CONF_FILE
if [ $? == 0 ]; then
sed -i "s/config.orchestration = .*/config.orchestration = {};/g" $WEBUI_CONF_FILE
else
echo "config.orchestration = {};" >> $WEBUI_CONF_FILE
fi
grep "config.orchestration.Manager" $WEBUI_CONF_FILE
if [ $? == 0 ]; then
sed -i "s/config.orchestration.Manager = .*/config.orchestration.Manager = 'none'/g" $WEBUI_CONF_FILE
else
echo "config.orchestration.Manager = 'none';" >> $WEBUI_CONF_FILE
fi
grep "config.discoveryService" $WEBUI_CONF_FILE
if [ $? == 0 ]; then
sed -i "s/config.discoveryService = .*/config.discoveryService = {};/g" $WEBUI_CONF_FILE
else
echo "config.discoveryService = {};" >> $WEBUI_CONF_FILE
fi
grep "config.discoveryService.enable" $WEBUI_CONF_FILE
if [ $? == 0 ]; then
sed -i "s/config.discoveryService.enable = .*/config.discoveryService.enable = false;/g" $WEBUI_CONF_FILE
else
echo "config.discoveryService.enable = false;" >> $WEBUI_CONF_FILE
fi
grep "config.multi_tenancy" $WEBUI_CONF_FILE
if [ $? == 0 ]; then
sed -i "s/config.multi_tenancy = .*/config.multi_tenancy = {};/g" $WEBUI_CONF_FILE
else
echo "config.multi_tenancy = {};" >> $WEBUI_CONF_FILE
fi
grep "config.multi_tenancy.enabled" $WEBUI_CONF_FILE
if [ $? == 0 ]; then
sed -i "s/config.multi_tenancy.enabled = .*/config.multi_tenancy.enabled = false;/g" $WEBUI_CONF_FILE
else
echo "config.multi_tenancy.enabled = false;" >> $WEBUI_CONF_FILE
fi
sed -i "s|module.exports =.*|module.exports = config;|g" $WEBUI_CONF_FILE
sed -i "s/config.featurePkg.webController.enable = .*/config.featurePkg.webController.enable = false;/g" $WEBUI_CONF_FILE
sed -i "s/config.featurePkg.webStorage.enable = .*/config.featurePkg.webStorage.enable = false;/g" $WEBUI_CONF_FILE
sed -i "s/config.http_port = .*/config.http_port = '9080';/g" $WEBUI_CONF_FILE
sed -i "s/config.https_port = .*/config.https_port = '9143';/g" $WEBUI_CONF_FILE
sed -i "s/config.jobServer.server_port = .*/config.jobServer.server_port = '3004';/g" $WEBUI_CONF_FILE
sed -i "s/config.kue.ui_port = .*/config.kue.ui_port = '3006'/g" $WEBUI_CONF_FILE
sed -i "s/smConfig.sm.server_ip = .*/smConfig.sm.server_ip = '$HOSTIP';/g" $SM_CONF_FILE
sed -i "s/smConfig.sm.server_port = .*/smConfig.sm.server_port = 9001;/g" $SM_CONF_FILE
sed -i "s/smConfig.sm.introspect_ip = .*/smConfig.sm.introspect_ip = '$HOSTIP';/g" $SM_CONF_FILE
sed -i "s/smConfig.sm.introspect_port = .*/smConfig.sm.introspect_port = 8106;/g" $SM_CONF_FILE
set -e
# start redis & supervisord
service redis-server restart
service supervisor restart
# start webui
service supervisor-webui-sm restart