blob: b4402d01f4792d0c9de34520d4343fb529ca1bfe [file] [log] [blame]
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -07001#!/bin/bash
2
3# Copyright 2017-present Open Networking Foundation
4#
Jeremy Ronquillo5263c732020-10-13 09:42:19 -07005# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
Jeremy Ronquillo6be909e2020-08-24 09:36:13 -07006
7#Below are the list of ports which are required to be free, for the SEBA services to use. If any new services get added into SEBA, Update the required node ports below and also add it to the arrray portlist.
8
9#Service name : node Port number
10#onos-debugger: 30555
11#onos-openflow: 31653
12#onos-ssh: 30115
13#onos-ui: 30120
14#xos-chameleon: 30006
15#xos-core: 30010, 30011
16#xos-core-prometheus: 30009
17#xos-gui: 30001
18#xos-tosca: 30007
19#xos-ws: 30008
20#ingress-nginx: 30080, 30443
21#vcli: 30110
22#voltha: 30125, 30613, 32443, 31390
23#kpi-exporter: 31080
24#logging-elasticsearch-client: 31636
25#logging-kibana: 30601
26#nem-monitoring-grafana: 31300
27#nem-monitoring-prometheus-server: 31301
28
29declare -a portlist=("30555" "31653" "30115" "30120" "30006" "30010" "30011" "30009" "30001" "30007" "30008" "30080" "30443" "30110" "30125" "30613" "32443" "31390" "31080" "31636" "30601" "31300" "31301")
30
31number_of_ports_in_use=0
32
33#Below loop is to check whether any port in the list is already being used
34for port in "${portlist[@]}"
35do
36 if netstat -lntp | grep :":$port" > /dev/null ; then
37 used_process=$(netstat -lntp | grep :":$port" | tr -s ' ' | cut -f7 -d' ')
38 echo "ERROR: Process with PID/Program_name $used_process is already listening on port: $port needed by SEBA"
39 number_of_ports_in_use=$((number_of_ports_in_use+1))
40 fi
41done
42
43#If any of the ports are already used then the user will be notified to kill the running services before installing SEBA
44if [ $number_of_ports_in_use -gt 0 ]
45 then
46 echo "Kill the running services mentioned above before proceeding to install SEBA"
47 echo "Terminating make"
48 exit 1
49fi
50
51#The ports that are required by SEBA components will be added to the reserved port list
52var=$(printf '%s,' "${portlist[@]}")
53echo "$var" > /proc/sys/net/ipv4/ip_local_reserved_ports
54echo "SUCCESS: Added ports required for SEBA services to ip_local_reserved_ports"
55