diff --git a/scripts/functions.sh b/scripts/functions.sh index 1c61168..6b574df 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -56,20 +56,3 @@ fi # Remove Duniter package sudo dpkg -r duniter } - -# Find a free port and return it -# -# example: port=$(ynh_find_port 8080) -# -# usage: ynh_find_port begin_port -# | arg: begin_port - port to start to search -ynh_find_port () { - port=$1 - test -n "$port" || ynh_die "The argument of ynh_find_port must be a valid port." - while netcat -z 127.0.0.1 $port # Check if the port is free - do - port=$((port+1)) # Else, pass to next port - done - echo $port -} - diff --git a/scripts/install b/scripts/install index ebb64fb..d3584e1 100755 --- a/scripts/install +++ b/scripts/install @@ -22,7 +22,10 @@ sudo yunohost app checkurl "${domain}${path}" -a "$app" \ || ynh_die "Path not available: ${domain}${path}" # Check port availability -port=$(ynh_find_port $port) +sudo yunohost app checkport $port +if [[ ! $? -eq 0 ]]; then + ynh_die "Port not available: ${port}" +fi # Check node availability if curl --output /dev/null --silent --head --fail "$sync_node:$sync_port/node/summary"; then