-
Notifications
You must be signed in to change notification settings - Fork 64
/
service.sh
executable file
·177 lines (149 loc) · 6.32 KB
/
service.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#! /bin/bash
TOP_DIR=`pwd`
CONTRAIL_USER=$(whoami)
CONTRAIL_SRC=${CONTRAIL_SRC:-/opt/stack/contrail}
source functions
source localrc
function pywhere()
{
module=$1
python -c "import $module; import os; print os.path.dirname($module.__file__)"
}
function _start_service()
{
service=$1
if is_ubuntu; then
REDIS_CONF="/etc/redis/redis.conf"
CASS_PATH="/usr/sbin/cassandra"
else
REDIS_CONF="/etc/redis.conf"
CASS_PATH="$CONTRAIL_SRC/third_party/apache-cassandra-2.0.2/bin/cassandra"
fi
if [ "$INSTALL_PROFILE" = "ALL" ]; then
case $service in
redis) echo "starting redis"
redis-cli flushall
screen_it redis "sudo redis-server $REDIS_CONF"
;;
cass) echo "starting cassandra"
screen_it cass "sudo $CASS_PATH -f"
;;
zk) echo "starting zookeeper"
screen_it zk "cd $CONTRAIL_SRC/third_party/zookeeper-3.4.6; ./bin/zkServer.sh start"
;;
ifmap) echo "starting ifmap"
if [[ "$CONTRAIL_DEFAULT_INSTALL" != "True" ]]; then
screen_it ifmap "cd $CONTRAIL_SRC/build/packages/ifmap-server; java -jar ./irond.jar"
else
screen_it ifmap "cd /usr/share/ifmap-server; java -jar ./irond.jar"
fi
;;
disco) echo "starting disco"
screen_it disco "python $(pywhere discovery)/disc_server_zk.py --reset_config --conf_file /etc/contrail/discovery.conf"
;;
apisrv) echo "starting apiserver"
screen_it apiSrv "python $(pywhere vnc_cfg_api_server)/vnc_cfg_api_server.py --conf_file /etc/contrail/contrail-api.conf --rabbit_password ${RABBIT_PASSWORD}"
;;
schema) echo "starting schema"
screen_it schema "python $(pywhere schema_transformer)/to_bgp.py --reset_config --conf_file /etc/contrail/contrail-schema.conf"
;;
svc-mon) echo "starting svc-mon"
screen_it svc-mon "python $(pywhere svc_monitor)/svc_monitor.py --reset_config --conf_file /etc/contrail/svc-monitor.conf"
;;
control) echo "starting control"
if [[ "$CONTRAIL_DEFAULT_INSTALL" != "True" ]]; then
screen_it control "export LD_LIBRARY_PATH=/opt/stack/contrail/build/lib; $CONTRAIL_SRC/build/production/control-node/control-node --conf_file /etc/contrail/contrail-control.conf ${CERT_OPTS} ${LOG_LOCAL}"
else
screen_it control "export LD_LIBRARY_PATH=/usr/lib; /usr/bin/control-node --conf_file /etc/contrail/contrail-control.conf ${CERT_OPTS} ${LOG_LOCAL}"
fi
;;
collector) echo "starting collector"
if [[ "$CONTRAIL_DEFAULT_INSTALL" != "True" ]]; then
screen_it collector "sudo PATH=$PATH:$TOP_DIR/bin LD_LIBRARY_PATH=/opt/stack/contrail/build/lib $CONTRAIL_SRC/build/production/analytics/vizd"
else
screen_it collector "sudo PATH=$PATH:/usr/bin LD_LIBRARY_PATH=/usr/lib /usr/bin/contrail-collector"
fi
;;
analytics-api) echo "starting analytics-api"
screen_it analytics-api "python $(pywhere opserver)/opserver.py"
;;
query-engine) echo "starting query-engine"
if [[ "$CONTRAIL_DEFAULT_INSTALL" != "True" ]]; then
screen_it query-engine "sudo PATH=$PATH:$TOP_DIR/bin LD_LIBRARY_PATH=/opt/stack/contrail/build/lib $CONTRAIL_SRC/build/production/query_engine/qed"
else
screen_it query-engine "sudo PATH=$PATH:/usr/bin LD_LIBRARY_PATH=/usr/lib /usr/bin/contrail-query-engine"
fi
;;
agent) echo "starting agent"
screen_it agent "sudo $TOP_DIR/bin/vnsw.hlpr"
;;
redis-w ) echo "starting redis-w "
screen_it redis-w "sudo redis-server /etc/contrail/redis-webui.conf"
;;
ui-jobs) echo "starting ui-jobs"
if [[ "$CONTRAIL_DEFAULT_INSTALL" != "True" ]]; then
screen_it ui-jobs "cd /opt/stack/contrail/contrail-web-core; sudo node jobServerStart.js"
else
screen_it ui-jobs "cd /var/lib/contrail-webui-bundle; sudo node jobServerStart.js"
fi
;;
ui-webs) echo "starting ui-webs"
if [[ "$CONTRAIL_DEFAULT_INSTALL" != "True" ]]; then
screen_it ui-webs "cd /opt/stack/contrail/contrail-web-core; sudo node webServerStart.js"
else
screen_it ui-webs "cd /var/lib/contrail-webui-bundle; sudo node webServerStart.js"
fi
;;
*) echo "please verify the service entered"
;;
esac
else
case $service in
agent) echo "starting agent"
screen_it agent "sudo $TOP_DIR/bin/vnsw.hlpr"
;;
*) echo "please verify the service entered in compute mode"
;;
esac
fi
}
function start_service()
{
if [[ -f $TOP_DIR/status/contrail/$1.pid ]]; then
echo "$1 is already running"
exit
else
_start_service $1
fi
}
function stop_service()
{
echo "stopping the service $1"
screen_stop $1
}
function restart_service()
{
if [[ -f $TOP_DIR/status/contrail/$1.pid ]]; then
echo "$1 is already running,stopping it"
stop_service $1
fi
echo "restarting service $1"
_start_service $1
}
OPTION=$2
ARGS_COUNT=$#
if [ "$USE_SCREEN" = "False" ]; then
if [ $ARGS_COUNT -eq 2 ] && [ "$OPTION" == "start" ] || [ "$OPTION" == "restart" ] || [ "$OPTION" == "stop" ] ;
then
${OPTION}_service $1
else
echo "Usage :: service.sh servicename [option]"
echo "ex: service.sh servicename start"
echo "[options]:"
echo "start"
echo "stop"
echo "restart"
fi
else
echo "screens enabled"
fi