From 103af5dba17ed04c0570d3a36d61e0f26b3a2c4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Fri, 19 Jan 2018 20:55:44 +0100 Subject: [PATCH] Use helper ynh_setup_source --- conf/arm.src | 11 +++++ conf/i386.src | 11 +++++ conf/x86-64.src | 11 +++++ scripts/_common.sh | 49 ++----------------- scripts/install | 10 ++-- scripts/upgrade | 9 ++-- sources/patches/arm-sso_auth.patch | 1 + sources/patches/i386-sso_auth.patch | 1 + .../x86-64-sso_auth.patch} | 0 9 files changed, 45 insertions(+), 58 deletions(-) create mode 100644 conf/arm.src create mode 100644 conf/i386.src create mode 100644 conf/x86-64.src create mode 120000 sources/patches/arm-sso_auth.patch create mode 120000 sources/patches/i386-sso_auth.patch rename sources/{sso_auth.patch => patches/x86-64-sso_auth.patch} (100%) diff --git a/conf/arm.src b/conf/arm.src new file mode 100644 index 0000000..f7a422f --- /dev/null +++ b/conf/arm.src @@ -0,0 +1,11 @@ +SOURCE_URL=https://github.com/haiwen/seafile-rpi/releases/download/v6.2.3/seafile-server_6.2.3_stable_pi.tar.gz +SOURCE_SUM=e23af4882e8b20c8ded8c052e9863a52dbb685f16deff0322e21d6e9ded35b56 +# (Optional) Program to check the integrity (sha256sum, md5sum...) +# default: sha256 +SOURCE_SUM_PRG=sha256sum +# (Optional) Archive format +# default: tar.gz +SOURCE_FORMAT=tar.gz +# (Optional) Put false if sources are directly in the archive root +# default: true +SOURCE_IN_SUBDIR=true diff --git a/conf/i386.src b/conf/i386.src new file mode 100644 index 0000000..dc05a03 --- /dev/null +++ b/conf/i386.src @@ -0,0 +1,11 @@ +SOURCE_URL=https://download.seadrive.org/seafile-server_6.2.3_i386.tar.gz +SOURCE_SUM=4439e13211a4c0dd7831d728fc50371d9be0e31dfa344b1c951de90b42afe0bf +# (Optional) Program to check the integrity (sha256sum, md5sum...) +# default: sha256 +SOURCE_SUM_PRG=sha256sum +# (Optional) Archive format +# default: tar.gz +SOURCE_FORMAT=tar.gz +# (Optional) Put false if sources are directly in the archive root +# default: true +SOURCE_IN_SUBDIR=true diff --git a/conf/x86-64.src b/conf/x86-64.src new file mode 100644 index 0000000..290e34b --- /dev/null +++ b/conf/x86-64.src @@ -0,0 +1,11 @@ +SOURCE_URL=https://download.seadrive.org/seafile-server_6.2.3_x86-64.tar.gz +SOURCE_SUM=166a022786c8bb85d5890741f9632f10df3ba299736c59576ab1f6e4f6597ac8 +# (Optional) Program to check the integrity (sha256sum, md5sum...) +# default: sha256 +SOURCE_SUM_PRG=sha256sum +# (Optional) Archive format +# default: tar.gz +SOURCE_FORMAT=tar.gz +# (Optional) Put false if sources are directly in the archive root +# default: true +SOURCE_IN_SUBDIR=true diff --git a/scripts/_common.sh b/scripts/_common.sh index f955505..0886fbb 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,11 +3,6 @@ # Retrieve arguments app=$YNH_APP_INSTANCE_NAME -## Adapt sha256sum while you update app -x86_64sum="166a022786c8bb85d5890741f9632f10df3ba299736c59576ab1f6e4f6597ac8" -i386sum="4439e13211a4c0dd7831d728fc50371d9be0e31dfa344b1c951de90b42afe0bf" -armsum="e23af4882e8b20c8ded8c052e9863a52dbb685f16deff0322e21d6e9ded35b56" - # Detect the system architecture to download the right tarball # NOTE: `uname -m` is more accurate and universal than `arch` # See https://en.wikipedia.org/wiki/Uname @@ -64,7 +59,6 @@ set_path_2() { config_nginx() { - # In the 3.x seafile version package the seahub_port and fileserver_port wasn't saved in the settings. If the settings is empty we try to get it and save in the settings if [[ -z $seahub_port ]] || [[ -z $fileserver_port ]] @@ -87,35 +81,9 @@ config_nginx() { systemctl reload nginx.service } -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' - sha256sum=$armsum - elif [[ $1 == 'x86-64' ]] - then - wget -q -O '/tmp/seafile_src.tar.gz' 'https://download.seadrive.org/seafile-server_'$2'_x86-64.tar.gz' - sha256sum=$x86_64sum - else - wget -q -O '/tmp/seafile_src.tar.gz' 'https://download.seadrive.org/seafile-server_'$2'_i386.tar.gz' - sha256sum=$i386sum - fi - - if [[ ! -e '/tmp/seafile_src.tar.gz' ]] || [[ $(sha256sum '/tmp/seafile_src.tar.gz' | cut -d' ' -f1) != $sha256sum ]] - then - ynh_die "Error : can't get seafile source" - fi -} - -extract_source() { - mkdir -p $final_path/seafile-server-$seafile_version - tar xzf '/tmp/seafile_src.tar.gz' - mv seafile-server-$seafile_version/* $final_path/seafile-server-$seafile_version - mv '/tmp/seafile_src.tar.gz' $final_path/installed/seafile-server_${seafile_version}.tar.gz - - local old_dir=$(pwd) - (cd "$final_path/seafile-server-$seafile_version" && patch -p1 < $YNH_CWD/../sources/sso_auth.patch) || ynh_die "Unable to apply patches" - cd $old_dir +install_source() { + mkdir "$final_path/seafile-server-$seafile_version" + ynh_setup_source "$final_path/seafile-server-$seafile_version" "$architecture" } install_dependance() { @@ -129,14 +97,3 @@ ynh_clean_setup () { pkill -f ccnet-server pkill -f "seahub" } - -# Get application version from manifest -# -# usage: ynh_app_version -ynh_app_version() { - manifest_path="../manifest.json" - if [ ! -e "$manifest_path" ]; then - manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place - fi - echo $(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file. -} \ No newline at end of file diff --git a/scripts/install b/scripts/install index 676e274..1899424 100644 --- a/scripts/install +++ b/scripts/install @@ -46,9 +46,6 @@ ynh_app_setting_set $app webdav_port $webdav_port ynh_app_setting_set $app is_public $is_public ynh_app_setting_set $app installed_version $seafile_version -# Download new version from sources -get_source $architecture $seafile_version - # Retrieve admin email admin_email=$(yunohost user info $admin | grep mail: | sed "s/mail: //g") @@ -56,13 +53,14 @@ admin_email=$(yunohost user info $admin | grep mail: | sed "s/mail: //g") install_dependance # Copy files to the right place -test -e $final_path && rm -rf "$final_path" -test -e $seafile_data && rm -rf "$seafile_data" +test -e $seafile_data && ynh_secure_remove "$seafile_data" mkdir -p $final_path mkdir -p $final_path/installed mkdir -p $final_path/logs mkdir -p $final_path/seafile-data -extract_source + +# Download new version from sources +install_source # init databases dbuser=seafile diff --git a/scripts/upgrade b/scripts/upgrade index 302af73..4605550 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -27,15 +27,12 @@ get_configuration # Create special path with / at the end set_path_2 -# Download new version from sources -get_source $architecture $seafile_version - # stop seafile server systemctl stop seafile-server.service # extract new version -test -e $final_path/seafile-server-$seafile_version && rm -rf "$final_path/seafile-server-$seafile_version" -extract_source +test -e $final_path/seafile-server-$seafile_version && ynh_secure_remove "$final_path/seafile-server-$seafile_version" +install_source # permission to execute update script and expect helper chmod +x ../conf/upgrade_*.exp @@ -148,7 +145,7 @@ systemctl daemon-reload chown -R $seafile_user:$seafile_user $final_path # delete seafile cache -rm -rf /tmp/seahub_cache +ynh_secure_remove /tmp/seahub_cache # restart seafile server systemctl start seafile-server.service diff --git a/sources/patches/arm-sso_auth.patch b/sources/patches/arm-sso_auth.patch new file mode 120000 index 0000000..7546b84 --- /dev/null +++ b/sources/patches/arm-sso_auth.patch @@ -0,0 +1 @@ +x86-64-sso_auth.patch \ No newline at end of file diff --git a/sources/patches/i386-sso_auth.patch b/sources/patches/i386-sso_auth.patch new file mode 120000 index 0000000..7546b84 --- /dev/null +++ b/sources/patches/i386-sso_auth.patch @@ -0,0 +1 @@ +x86-64-sso_auth.patch \ No newline at end of file diff --git a/sources/sso_auth.patch b/sources/patches/x86-64-sso_auth.patch similarity index 100% rename from sources/sso_auth.patch rename to sources/patches/x86-64-sso_auth.patch