Homepage › Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Tip: Script to find double ports assignments › Reply To: Tip: Script to find double ports assignments
We have many sites so I wrote something to list ports defined in all our NetConfigs, too.
I can pipe that to a file or grep to check if that port is already defined.
We also define many ports in the /etc/services file so we have to search that file too.
At one point we discussed using the /etc/serviecs file exclusively so all ports would be defined in a central location but that never came to pass.
We have also found it benificail to require all ports to be unique across all our cloverleaf servers for both test and prodcution.
In fact, this is one of our in-house standards it has been so benificial.
Here is the script I wrote that we have been using to list what ports are defined in all our NetConfigs
# Begin Module Header ==============================================================================
#
#——
# Name:
#——
#
# list_ports.ksh
#
#———
# Purpose:
#———
#
# list all the ports defined in the NetConfig for all sites
#
#——-
# Notes:
#——-
#
# Assumption:
#
# – all sites have a NetConfig file
#
# Normal Usage:
#
# list_ports.ksh > x.x
#
#———
# History:
#———
#
# 2001.01.30 Russ Ross
# – wrote initial version
#
# End of Module Header =============================================================================
saveDir=`pwd`
siteList=`list_sites.ksh`
cd $HCIROOT
for site in $siteList; do
cd $site
echo ” ”
echo “———————————”
echo “Ports defined in $HCIROOT/$site”
echo “———————————”
echo ” ”
portList=`grep “{ PORT [0-9].* }” NetConfig | awk ‘{print $3}’ |sort -n`
for port in $portList; do
echo $port
done
cd – $1>/dev/null
done
cd $saveDir
echo ” “
#!/usr/bin/ksh
# Begin Module Header ==============================================================================
#
#——
# Name:
#——
#
# list_sites.ksh
#
#———
# Purpose:
#———
#
# List all the sites for the current $HCIROOT
#
#——–
# Inputs:
#——–
#
# none
#
#——-
# Notes:
#——-
#
# This script assumes the proper environment is set when it is called
# and all sites are symbolic links at the $HCIROOT level
#
#———
# History:
#———
#
# 2001.02.22 Russ Ross
# – wrote initial version.
#
# 2001.07.25 Russ Ross
# – modified to look for $HCIROOT/*/siteInfo files to determine the list of sites,
# previously had looked for symbolic links in the $HCIROOT directory which only
# works if everyone follows MDACC conventions
#
# 2003.11.17 Russ Ross
# – modified to execlude siteProto from the list of sites
#
# End of Module Header =============================================================================
#—————————————————————————————–
# get a list of all the sites for the current $HCIROOT
# (Note: there is an assumption that all sites are a symbolic link at the $HCIROOT level)
#—————————————————————————————–
(cd $HCIROOT; ls ./*/siteInfo 2>/dev/null) | awk -F/ ‘{print $2}’ | grep -v siteProto | sort
Russ Ross
RussRoss318@gmail.com