From 5813e82dbfb0939cccf4a908f3ae910310fae162 Mon Sep 17 00:00:00 2001 From: Josue-T Date: Sat, 18 Feb 2017 11:20:20 +0100 Subject: [PATCH 1/6] Create check_process (#1) --- check_process | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 check_process diff --git a/check_process b/check_process new file mode 100644 index 0000000..fd8e7ff --- /dev/null +++ b/check_process @@ -0,0 +1,39 @@ +;; Nom du test + auto_remove=1 +# Commentaire ignoré + ; Manifest + domain="domain.tld" (DOMAIN) + path="/path" (PATH) + server_name="Seafile" + admin="john" (USER) + admin_password="Sup3rS3cr3t" (PASSWORD) + is_public="Yes" (PUBLIC|public=Yes|private=No) + architecture="x86-64" + ; Checks + pkg_linter=1 + setup_sub_dir=1 + setup_root=1 + setup_nourl=0 + setup_private=1 + setup_public=1 + upgrade=1 + backup_restore=1 + multi_instance=0 + wrong_user=1 + wrong_path=1 + incorrect_path=1 + corrupt_source=0 + fail_download_source=0 + port_already_use=1 (8000) + final_path_already_use=0 +;;; Levels + Level 1=auto + Level 2=auto + Level 3=auto + Level 4=0 + Level 5=auto + Level 6=auto + Level 7=auto + Level 8=0 + Level 9=0 + Level 10=0 From 7873d1b4fd2b3218953a0e3ebdaadd0d4d49d642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Tue, 28 Feb 2017 13:24:18 +0100 Subject: [PATCH 2/6] Update to seafile 6.0.8 --- check_process | 6 ++-- scripts/_common.sh | 8 +++--- scripts/restore | 70 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 7 deletions(-) diff --git a/check_process b/check_process index fd8e7ff..985cb0d 100644 --- a/check_process +++ b/check_process @@ -22,10 +22,10 @@ wrong_user=1 wrong_path=1 incorrect_path=1 - corrupt_source=0 - fail_download_source=0 + corrupt_source=1 + fail_download_source=1 port_already_use=1 (8000) - final_path_already_use=0 + final_path_already_use=1 ;;; Levels Level 1=auto Level 2=auto diff --git a/scripts/_common.sh b/scripts/_common.sh index 3c3b02e..e84dd44 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -1,11 +1,11 @@ #!/bin/bash -seafile_version=6.0.7 +seafile_version=6.0.8 ## Adapt md5sum while you update app -x86_64sum="4ca3c1fc93e5b786eb5d3509f4a3b01a" -i386sum="743565be00189698318c8def0fbdaac0" -armsum="ee3ef5330a51498faf861594e0fe744a" +x86_64sum="353de460ed8a08f176103e96f1384ff3" +i386sum="9a4bc83576ec74b46a907ca081d4914d" +armsum="d7a0bd1d0a3948e1d3bc175e6d1ddca8" init_script() { # Exit on command errors and treat unset variables as an error diff --git a/scripts/restore b/scripts/restore index 541d0c3..175beea 100644 --- a/scripts/restore +++ b/scripts/restore @@ -7,6 +7,13 @@ ######## We implement manually this fonctions +seafile_version=6.0.7 + +## Adapt md5sum while you update app +x86_64sum="4ca3c1fc93e5b786eb5d3509f4a3b01a" +i386sum="743565be00189698318c8def0fbdaac0" +armsum="ee3ef5330a51498faf861594e0fe744a" + init_script() { # Exit on command errors and treat unset variables as an error set -eu @@ -18,6 +25,60 @@ init_script() { app=$YNH_APP_INSTANCE_NAME } +set_configuration() { + if [[ -e /var/www/$app ]] + then + final_path=/var/www/$app + seafile_user=www-data + elif [[ -e /opt/yunohost/$app ]] + then + final_path=/opt/yunohost/$app + seafile_user=seafile + else + ynh_die "Error : can't find seafile path" + fi +} + +get_source() { + if [[ $1 == 'arm' ]] + then + wget -q -O '/tmp/seafile_src.tar.gz' 'https://github.com/haiwen/seafile-rpi/releases/download/v'$2'/seafile-server_'$2'_stable_pi.tar.gz' + md5sum=$armsum + elif [[ $1 == 'x86-64' ]] + then + wget -q -O '/tmp/seafile_src.tar.gz' 'https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_'$2'_x86-64.tar.gz' + md5sum=$x86_64sum + else + wget -q -O '/tmp/seafile_src.tar.gz' 'https://bintray.com/artifact/download/seafile-org/seafile/seafile-server_'$2'_i386.tar.gz' + md5sum=$i386sum + fi + + if [[ ! -e '/tmp/seafile_src.tar.gz' ]] || [[ $(md5sum '/tmp/seafile_src.tar.gz' | cut -d' ' -f1) != $md5sum ]] + then + ynh_die "Error : can't get seafile source" + fi +} + +CHECK_VAR () { # Vérifie que la variable n'est pas vide. +# $1 = Variable à vérifier +# $2 = Texte à afficher en cas d'erreur + 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 @@ -27,6 +88,15 @@ 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 From c33e8b4396b12c4a6e7cfe93c312b6d8e8f9bacb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Tue, 7 Mar 2017 15:44:28 +0100 Subject: [PATCH 3/6] Use new findport fonction --- scripts/_common.sh | 31 ++++++++++++------------------- scripts/install | 9 +++------ scripts/restore | 23 ----------------------- 3 files changed, 15 insertions(+), 48 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index e84dd44..0e1e07c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -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 } diff --git a/scripts/install b/scripts/install index b9b11a2..570de8d 100644 --- a/scripts/install +++ b/scripts/install @@ -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 diff --git a/scripts/restore b/scripts/restore index 175beea..df56646 100644 --- a/scripts/restore +++ b/scripts/restore @@ -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 From 3035e1d53c41a0f6c10946bccb28a648ed27ca6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Tue, 7 Mar 2017 16:12:01 +0100 Subject: [PATCH 4/6] Use new findport fonction --- scripts/restore | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/scripts/restore b/scripts/restore index 0d72e0c..05f15de 100644 --- a/scripts/restore +++ b/scripts/restore @@ -41,7 +41,7 @@ set_configuration() { get_source() { if [[ $1 == 'arm' ]] - then + theng wget -q -O '/tmp/seafile_src.tar.gz' 'https://github.com/haiwen/seafile-rpi/releases/download/v'$2'/seafile-server_'$2'_stable_pi.tar.gz' md5sum=$armsum elif [[ $1 == 'x86-64' ]] @@ -74,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 From 97c9fab47c4df85834d01f5b464def3e033f6fca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Tue, 7 Mar 2017 16:13:38 +0100 Subject: [PATCH 5/6] Fix typo --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 05f15de..df56646 100644 --- a/scripts/restore +++ b/scripts/restore @@ -41,7 +41,7 @@ set_configuration() { get_source() { if [[ $1 == 'arm' ]] - theng + then wget -q -O '/tmp/seafile_src.tar.gz' 'https://github.com/haiwen/seafile-rpi/releases/download/v'$2'/seafile-server_'$2'_stable_pi.tar.gz' md5sum=$armsum elif [[ $1 == 'x86-64' ]] From d6c36242c809e8591c52f8004e3fac9b2b255327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Fri, 14 Apr 2017 14:03:41 +0200 Subject: [PATCH 6/6] Solve issue : https://github.com/YunoHost-Apps/seafile_ynh/issues/19 --- conf/install.exp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conf/install.exp b/conf/install.exp index bfefcc4..f286406 100644 --- a/conf/install.exp +++ b/conf/install.exp @@ -52,4 +52,6 @@ send "seahubdb\r"; expect "Press ENTER to continue, or Ctrl-C to abort" send "\r"; +sleep 8 + interact