use ynh_port_available in ynh_find_port

This commit is contained in:
Kay0u 2020-04-25 01:03:33 +02:00
parent b6daf0c448
commit dd5699ee40
No known key found for this signature in database
GPG key ID: AE1DCADB6415A156

View file

@ -18,7 +18,7 @@ ynh_find_port () {
ynh_handle_getopts_args "$@"
test -n "$port" || ynh_die --message="The argument of ynh_find_port must be a valid port."
while ss --numeric --listening --tcp --udp | awk '{print$5}' | grep --quiet --extended-regexp ":$port$" # Check if the port is free
while ! ynh_port_available --port=$port
do
port=$((port+1)) # Else, pass to next port
done
@ -42,7 +42,7 @@ ynh_port_available () {
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
if ss --numeric --listening --tcp --udp | grep --quiet --word-regexp :$port
if ss --numeric --listening --tcp --udp | awk '{print$5}' | grep --quiet --extended-regexp ":$port$" # Check if the port is free
then
return 1
else