mirror of
https://github.com/YunoHost-Apps/lufi_ynh.git
synced 2024-09-03 19:36:28 +02:00
[fix] change helper for find port
This commit is contained in:
parent
bb5c53431b
commit
76e29da369
2 changed files with 17 additions and 20 deletions
|
@ -108,25 +108,6 @@ CHECK_MD5_CONFIG () { # Created a backup of the config file if it was changed.
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
FIND_PORT () { # Search free port
|
|
||||||
if [ YNH_VERSION = "2.5" ]; then
|
|
||||||
# $1 = Port number to start the search.
|
|
||||||
port=$1
|
|
||||||
while ! sudo yunohost app checkport $port ; do
|
|
||||||
port=$((port+1))
|
|
||||||
done
|
|
||||||
CHECK_VAR "$port" "port empty"
|
|
||||||
else
|
|
||||||
# $1 = Port number to start the search.
|
|
||||||
port=$1
|
|
||||||
if [ "$(sudo yunohost tools port-available $port)" = "True" ]; then
|
|
||||||
port=$((port+1))
|
|
||||||
fi
|
|
||||||
CHECK_VAR "$port" "port empty"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
### REMOVE SCRIPT
|
### REMOVE SCRIPT
|
||||||
|
|
||||||
REMOVE_NGINX_CONF () { # Delete nginx configuration
|
REMOVE_NGINX_CONF () { # Delete nginx configuration
|
||||||
|
@ -179,6 +160,22 @@ REMOVE_SYS_USER () { # Delete user
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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
|
||||||
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP
|
# BACKUP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -38,7 +38,7 @@ CHECK_FINALPATH # Check final path
|
||||||
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
domain_regex=$(echo "$domain" | sed 's@-@.@g')
|
||||||
CHECK_VAR "$domain_regex" "domain_regex empty"
|
CHECK_VAR "$domain_regex" "domain_regex empty"
|
||||||
|
|
||||||
FIND_PORT 8095 # Check port availability
|
port=$(ynh_find_port 8096) # Check port availability
|
||||||
|
|
||||||
# Save app settings
|
# Save app settings
|
||||||
ynh_app_setting_set $app admin $admin
|
ynh_app_setting_set $app admin $admin
|
||||||
|
|
Loading…
Add table
Reference in a new issue