From 76e29da3694ba026d0b421344e7d113069326a9f Mon Sep 17 00:00:00 2001 From: magikcypress Date: Sat, 13 May 2017 15:47:35 +0200 Subject: [PATCH 1/5] [fix] change helper for find port --- scripts/.fonctions | 35 ++++++++++++++++------------------- scripts/install | 2 +- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/scripts/.fonctions b/scripts/.fonctions index b4dac42..fc80811 100644 --- a/scripts/.fonctions +++ b/scripts/.fonctions @@ -108,25 +108,6 @@ CHECK_MD5_CONFIG () { # Created a backup of the config file if it was changed. 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_NGINX_CONF () { # Delete nginx configuration @@ -179,6 +160,22 @@ REMOVE_SYS_USER () { # Delete user 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 #================================================= diff --git a/scripts/install b/scripts/install index 8abb53b..acf1b0f 100644 --- a/scripts/install +++ b/scripts/install @@ -38,7 +38,7 @@ CHECK_FINALPATH # Check final path domain_regex=$(echo "$domain" | sed 's@-@.@g') CHECK_VAR "$domain_regex" "domain_regex empty" -FIND_PORT 8095 # Check port availability +port=$(ynh_find_port 8096) # Check port availability # Save app settings ynh_app_setting_set $app admin $admin From 22afd029b04294e2ced8261cb1872e49bf52903b Mon Sep 17 00:00:00 2001 From: magikcypress Date: Sat, 13 May 2017 16:02:33 +0200 Subject: [PATCH 2/5] [fix] get source --- scripts/.fonctions | 2 +- sources/source_dir | 2 +- sources/source_md5 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/.fonctions b/scripts/.fonctions index fc80811..bdce6c5 100644 --- a/scripts/.fonctions +++ b/scripts/.fonctions @@ -70,7 +70,7 @@ SETUP_SOURCE () { # Download source, decompress and copu into $final_path src=$(cat ../sources/source_md5 | awk -F' ' {'print $2'}) sudo wget -nv -i ../sources/source_url -O $src # Checks the checksum of the downloaded source. - # md5sum -c ../sources/source_md5 --status || ynh_die "Corrupt source" + md5sum -c ../sources/source_md5 --status || ynh_die "Corrupt source" # Decompress source if [ "$(echo ${src##*.})" == "tgz" ]; then tar -x -f $src diff --git a/sources/source_dir b/sources/source_dir index d03fe76..3056570 100644 --- a/sources/source_dir +++ b/sources/source_dir @@ -1 +1 @@ -lufi-master-7db7688bc1e8bbe206f6717c98ece78d6e6a05fe \ No newline at end of file +lufi-master-67dba4bf918abba65bcfc25be04f0c3fcb166d0f \ No newline at end of file diff --git a/sources/source_md5 b/sources/source_md5 index 1e39d80..2f1ff14 100644 --- a/sources/source_md5 +++ b/sources/source_md5 @@ -1 +1 @@ -97091eb255f4b3389fd52e36b7860c1e lufi.zip \ No newline at end of file +8331e6bb4c92b8f2666254aa4b35b6e0 lufi.zip \ No newline at end of file From ba70aa1ee9d6627a81af27dc46534bc3a91eb440 Mon Sep 17 00:00:00 2001 From: magikcypress Date: Sat, 13 May 2017 17:15:51 +0200 Subject: [PATCH 3/5] [fix] generic function for restore --- scripts/remove | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/remove b/scripts/remove index 24167b6..eef6b33 100644 --- a/scripts/remove +++ b/scripts/remove @@ -3,6 +3,11 @@ # Exit on command errors and treat unset variables as an error set -u +if [ ! -e .fonctions ]; then + # Get file fonction if not been to the current directory + sudo cp ../settings/scripts/.fonctions ./.fonctions + sudo chmod a+rx .fonctions +fi source .fonctions # Loads the generic functions usually used in the script source /usr/share/yunohost/helpers # Source app helpers From 02a4339e1bf03f6fd570e65dddf890f6693f842d Mon Sep 17 00:00:00 2001 From: magikcypress Date: Sat, 13 May 2017 23:38:59 +0200 Subject: [PATCH 4/5] [fix] don't multi-instance with check_process --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index c929221..db2a351 100644 --- a/check_process +++ b/check_process @@ -15,7 +15,7 @@ setup_public=1 upgrade=1 backup_restore=1 - multi_instance=1 + multi_instance=0 wrong_user=1 wrong_path=1 incorrect_path=1 From 5035947f3fad47d907e1c95d03968b6a46d0c736 Mon Sep 17 00:00:00 2001 From: magikcypress Date: Mon, 15 May 2017 13:17:13 +0200 Subject: [PATCH 5/5] [fix] Change master source by a stable version --- sources/source_dir | 2 +- sources/source_md5 | 2 +- sources/source_url | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sources/source_dir b/sources/source_dir index 3056570..0e93133 100644 --- a/sources/source_dir +++ b/sources/source_dir @@ -1 +1 @@ -lufi-master-67dba4bf918abba65bcfc25be04f0c3fcb166d0f \ No newline at end of file +lufi-67dba4bf918abba65bcfc25be04f0c3fcb166d0f-67dba4bf918abba65bcfc25be04f0c3fcb166d0f \ No newline at end of file diff --git a/sources/source_md5 b/sources/source_md5 index 2f1ff14..bf85ca6 100644 --- a/sources/source_md5 +++ b/sources/source_md5 @@ -1 +1 @@ -8331e6bb4c92b8f2666254aa4b35b6e0 lufi.zip \ No newline at end of file +81ef9862cc7ebb245f68e0dd5fd8eebc lufi.zip \ No newline at end of file diff --git a/sources/source_url b/sources/source_url index f0f2bd1..f2b128e 100644 --- a/sources/source_url +++ b/sources/source_url @@ -1 +1 @@ -https://framagit.org/luc/lufi/repository/archive.zip?ref=master +https://framagit.org/luc/lufi/repository/archive.zip?ref=67dba4bf918abba65bcfc25be04f0c3fcb166d0f \ No newline at end of file