First attempt at detecting called port with getopts

This commit is contained in:
Raphael 2010-10-13 10:27:29 -07:00
parent ccdc259838
commit 3f9a51fa3f

View file

@ -3,10 +3,19 @@
# Start diaspora websocket and main services
#
# Is someone listening on 3000 already? (ipv4 only test ?)
services=$( netstat -nl | grep '[^:]:3000[ \t]')
# Is someone listening on the port already? (ipv4 only test ?)
PORT=3000
while getopts ":p:" OPTION
do
if OPTION='p'
then
PORT=$OPTARG
fi
done
services=$( netstat -nl | grep '[^:]:'+ $PORT +'[ \t]')
test -n "$services" && {
echo "Warning: something is already using port 3000"
echo "Warning: something is already using port " + $PORT
echo " $services"
}