1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/minetest_ynh.git synced 2024-09-03 20:36:00 +02:00

fix ynh_find_port

This commit is contained in:
Rafi594 2019-10-26 22:42:12 +02:00
parent fcaab2c4d9
commit d8ed05e786
2 changed files with 18 additions and 1 deletions

View file

@ -12,6 +12,23 @@ pkg_dependencies="build-essential libirrlicht-dev cmake libbz2-dev libpng-dev li
# PERSONAL HELPERS # PERSONAL HELPERS
#================================================= #=================================================
# To remove once https://github.com/YunoHost/yunohost/pull/827 get merged
ynh_find_port () {
# Declare an array to define the options of this helper.
local legacy_args=p
declare -Ar args_array=( [p]=port= )
local port
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
test -n "$port" || ynh_die --message="The argument of ynh_find_port must be a valid port."
while ss -nltu | grep -q -w :$port # Check if the port is free
do
port=$((port+1)) # Else, pass to next port
done
echo $port
}
#================================================= #=================================================
# EXPERIMENTAL HELPERS # EXPERIMENTAL HELPERS
#================================================= #=================================================

View file

@ -6,8 +6,8 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
source _common.sh
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE