From 03feb876a284d4807b5a1584f6a0fa6186ec9ad9 Mon Sep 17 00:00:00 2001 From: nemsia Date: Wed, 10 May 2017 22:17:00 +0200 Subject: [PATCH 1/3] [enh] Add ynh_find_port helper --- scripts/functions.sh | 17 +++++++++++++++++ scripts/install | 5 +---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/functions.sh b/scripts/functions.sh index 9dd401b..6a50fe7 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -56,3 +56,20 @@ 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 d3584e1..ebb64fb 100755 --- a/scripts/install +++ b/scripts/install @@ -22,10 +22,7 @@ sudo yunohost app checkurl "${domain}${path}" -a "$app" \ || ynh_die "Path not available: ${domain}${path}" # Check port availability -sudo yunohost app checkport $port -if [[ ! $? -eq 0 ]]; then - ynh_die "Port not available: ${port}" -fi +port=$(ynh_find_port $port) # Check node availability if curl --output /dev/null --silent --head --fail "$sync_node:$sync_port/node/summary"; then From 2ef0c293b30b8876e85b700c4bbf18c6c8ad6af4 Mon Sep 17 00:00:00 2001 From: nemsia Date: Wed, 10 May 2017 22:18:31 +0200 Subject: [PATCH 2/3] [fix] Switch to latest duniter release --- scripts/functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/functions.sh b/scripts/functions.sh index 6a50fe7..1c61168 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -2,7 +2,7 @@ INSTALL_DUNITER_DEBIAN_PACKAGE () { # Retrieve url of last version and version number -url=$(curl -s https://api.github.com/repos/duniter/duniter/releases | grep "browser_" | grep $arch | grep "linux" | grep "server" | sort -r | head -1 | cut -d\" -f4) +url=$(curl -s https://api.github.com/repos/duniter/duniter/releases/latest | grep "browser_" | grep $arch | grep "linux" | grep "server" | sort -r | head -1 | cut -d\" -f4) version=$(echo $url | cut -d/ -f8) # Retrieve debian package and install it From 3960ca8e79de7bdad83256c774fd69a0e92af82e Mon Sep 17 00:00:00 2001 From: nemsia Date: Wed, 10 May 2017 23:38:13 +0200 Subject: [PATCH 3/3] Revert "[enh] Add ynh_find_port helper" This reverts commit 03feb876a284d4807b5a1584f6a0fa6186ec9ad9. --- scripts/functions.sh | 17 ----------------- scripts/install | 5 ++++- 2 files changed, 4 insertions(+), 18 deletions(-) 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