Merge pull request #957 from YunoHost/port-available-in-find-port

use ynh_port_available in ynh_find_port
This commit is contained in:
Alexandre Aubin 2020-04-27 21:43:49 +02:00 committed by GitHub
commit fec63602c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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