mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
Use new findport fonction (#20)
* Create check_process (#1) * Update to seafile 6.0.8 * Use new findport fonction * Use new findport fonction * Fix typo
This commit is contained in:
parent
e64fc0fc9c
commit
d560d8d852
3 changed files with 15 additions and 48 deletions
|
@ -58,20 +58,6 @@ CHECK_VAR () { # Vérifie que la variable n'est pas vide.
|
|||
test -n "$1" || (echo "$2" >&2 && false)
|
||||
}
|
||||
|
||||
# Ignore the yunohost-cli log to prevent errors with conditionals commands
|
||||
# usage: NO_LOG COMMAND
|
||||
# Simply duplicate the log, execute the yunohost command and replace the log without the result of this command
|
||||
# It's a very badly hack...
|
||||
# Petite copie perso à mon usage ;)
|
||||
NO_LOG () {
|
||||
ynh_cli_log=/var/log/yunohost/yunohost-cli.log
|
||||
sudo cp -a ${ynh_cli_log} ${ynh_cli_log}-move
|
||||
eval $@
|
||||
exit_code=$?
|
||||
sudo mv ${ynh_cli_log}-move ${ynh_cli_log}
|
||||
return $?
|
||||
}
|
||||
|
||||
CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence à la fin.
|
||||
if [ "${path:0:1}" != "/" ]; then # Si le premier caractère n'est pas un /
|
||||
path="/$path" # Ajoute un / en début de path
|
||||
|
@ -81,11 +67,18 @@ CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence
|
|||
fi
|
||||
}
|
||||
|
||||
FIND_PORT () { # Cherche un port libre.
|
||||
# $1 = Numéro de port pour débuter la recherche.
|
||||
# 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
|
||||
while ! sudo yunohost app checkport $port ; do
|
||||
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
|
||||
CHECK_VAR "$port" "port empty"
|
||||
echo $port
|
||||
}
|
||||
|
|
|
@ -48,12 +48,9 @@ sudo mv seafile-server-$seafile_version/* $final_path/seafile-server-$seafile_ve
|
|||
sudo mv '/tmp/seafile_src.tar.gz' $final_path/installed/seafile-server_${seafile_version}.tar.gz
|
||||
|
||||
# Find available ports
|
||||
NO_LOG FIND_PORT 8000
|
||||
seahub_port=$port
|
||||
NO_LOG FIND_PORT 8082
|
||||
fileserver_port=$port
|
||||
NO_LOG FIND_PORT 8080
|
||||
webdav_port=$port
|
||||
seahub_port=$(ynh_find_port 8000)
|
||||
fileserver_port=$(ynh_find_port 8082)
|
||||
webdav_port=$(ynh_find_port 8080)
|
||||
|
||||
# store config in yunohost
|
||||
ynh_app_setting_set $app seahub_port $seahub_port
|
||||
|
|
|
@ -65,20 +65,6 @@ CHECK_VAR () { # Vérifie que la variable n'est pas vide.
|
|||
test -n "$1" || (echo "$2" >&2 && false)
|
||||
}
|
||||
|
||||
# Ignore the yunohost-cli log to prevent errors with conditionals commands
|
||||
# usage: NO_LOG COMMAND
|
||||
# Simply duplicate the log, execute the yunohost command and replace the log without the result of this command
|
||||
# It's a very badly hack...
|
||||
# Petite copie perso à mon usage ;)
|
||||
NO_LOG () {
|
||||
ynh_cli_log=/var/log/yunohost/yunohost-cli.log
|
||||
sudo cp -a ${ynh_cli_log} ${ynh_cli_log}-move
|
||||
eval $@
|
||||
exit_code=$?
|
||||
sudo mv ${ynh_cli_log}-move ${ynh_cli_log}
|
||||
return $?
|
||||
}
|
||||
|
||||
CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence à la fin.
|
||||
if [ "${path:0:1}" != "/" ]; then # Si le premier caractère n'est pas un /
|
||||
path="/$path" # Ajoute un / en début de path
|
||||
|
@ -88,15 +74,6 @@ CHECK_PATH () { # Vérifie la présence du / en début de path. Et son absence
|
|||
fi
|
||||
}
|
||||
|
||||
FIND_PORT () { # Cherche un port libre.
|
||||
# $1 = Numéro de port pour débuter la recherche.
|
||||
port=$1
|
||||
while ! sudo yunohost app checkport $port ; do
|
||||
port=$((port+1))
|
||||
done
|
||||
CHECK_VAR "$port" "port empty"
|
||||
}
|
||||
|
||||
######## End of common fonctions
|
||||
|
||||
# Init script
|
||||
|
|
Loading…
Reference in a new issue