Initial commit to populate repo
Change-Id: Ic74d9808c0de92c46b14d3c15cca87b32148d760
diff --git a/scripts/portcheck.sh b/scripts/portcheck.sh
new file mode 100755
index 0000000..2d57f4e
--- /dev/null
+++ b/scripts/portcheck.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+# Copyright 2017-present Open Networking Foundation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+#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.
+
+#Service name : node Port number
+#onos-debugger: 30555
+#onos-openflow: 31653
+#onos-ssh: 30115
+#onos-ui: 30120
+#xos-chameleon: 30006
+#xos-core: 30010, 30011
+#xos-core-prometheus: 30009
+#xos-gui: 30001
+#xos-tosca: 30007
+#xos-ws: 30008
+#ingress-nginx: 30080, 30443
+#vcli: 30110
+#voltha: 30125, 30613, 32443, 31390
+#kpi-exporter: 31080
+#logging-elasticsearch-client: 31636
+#logging-kibana: 30601
+#nem-monitoring-grafana: 31300
+#nem-monitoring-prometheus-server: 31301
+
+declare -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")
+
+number_of_ports_in_use=0
+
+#Below loop is to check whether any port in the list is already being used
+for port in "${portlist[@]}"
+do
+ if netstat -lntp | grep :":$port" > /dev/null ; then
+ used_process=$(netstat -lntp | grep :":$port" | tr -s ' ' | cut -f7 -d' ')
+ echo "ERROR: Process with PID/Program_name $used_process is already listening on port: $port needed by SEBA"
+ number_of_ports_in_use=$((number_of_ports_in_use+1))
+ fi
+done
+
+#If any of the ports are already used then the user will be notified to kill the running services before installing SEBA
+if [ $number_of_ports_in_use -gt 0 ]
+ then
+ echo "Kill the running services mentioned above before proceeding to install SEBA"
+ echo "Terminating make"
+ exit 1
+fi
+
+#The ports that are required by SEBA components will be added to the reserved port list
+var=$(printf '%s,' "${portlist[@]}")
+echo "$var" > /proc/sys/net/ipv4/ip_local_reserved_ports
+echo "SUCCESS: Added ports required for SEBA services to ip_local_reserved_ports"
+