From a1a33f786128f219fb9247796ba508012773761f Mon Sep 17 00:00:00 2001 From: Thatoo Date: Tue, 30 Jul 2019 23:07:10 +0200 Subject: [PATCH] Make available upgrades known by yunohost (#14) Make available upgrades known by yunohost --- conf/app.src | 6 ++++++ scripts/install | 7 +++---- scripts/upgrade | 25 ++++++++++++++++++------- 3 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 conf/app.src diff --git a/conf/app.src b/conf/app.src new file mode 100644 index 0000000..a08af47 --- /dev/null +++ b/conf/app.src @@ -0,0 +1,6 @@ +SOURCE_URL=https://github.com/duniter/cesium/releases/download/v1.3.11/cesium-v1.3.11-web.zip +SOURCE_SUM=fcac385f959178fc4ef8ac323b482c7d618bc48f67d6cc189229f91629b144be +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=zip +SOURCE_IN_SUBDIR=false +SOURCE_FILENAME= diff --git a/scripts/install b/scripts/install index f884ffc..46e9a75 100755 --- a/scripts/install +++ b/scripts/install @@ -22,10 +22,9 @@ sudo yunohost app checkurl "${domain}${path}" -a "$app" \ # Retrieve sources and install them src_path=/var/www/$app sudo mkdir -p $src_path -url=$(curl -s https://api.github.com/repos/duniter/cesium/releases | grep "browser_" | grep "web" | head -1 | cut -d\" -f4) -wget -nc --quiet $url -P /tmp -sudo unzip -q /tmp/cesium-*-web.zip -d $src_path -sudo rm -f /tmp/cesium-*-web.zip + # Download, check integrity, uncompress and patch the source from app.src + ynh_script_progression --message="Setting up source files..." --time --weight=1 + ynh_setup_source --dest_dir=$src_path sudo chown -R www-data: $src_path # Modify Nginx configuration file and copy it to Nginx conf directory diff --git a/scripts/upgrade b/scripts/upgrade index 3b35c9e..ab93dc2 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,19 +12,30 @@ domain=$(ynh_app_setting_get "$app" domain) path=$(ynh_app_setting_get "$app" path) is_public=$(ynh_app_setting_get "$app" is_public) +### This helper will compare the version of the currently installed app and the version of the upstream package. +### $upgrade_type can have 2 different values +### - UPGRADE_APP if the upstream app version has changed +### - UPGRADE_PACKAGE if only the YunoHost package has changed +### ynh_check_app_version_changed will stop the upgrade if the app is up to date. +### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. +upgrade_type=$(ynh_check_app_version_changed) + # Remove trailing "/" for next commands path=${path%/} # Retreive sources and install them src_path=/var/www/$app -sudo rm -rf $src_path -sudo mkdir -p $src_path -url=$(curl -s https://api.github.com/repos/duniter/cesium/releases | grep "browser_" | grep "web" | head -1 | cut -d\" -f4) -wget -nc --quiet $url -P /tmp +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + sudo rm -rf $src_path + sudo mkdir -p $src_path + ynh_script_progression --message="Upgrading source files..." --time --weight=1 + + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir=$src_path + sudo chown -R www-data: $src_path +fi -sudo unzip -q /tmp/cesium-*-web.zip -d $src_path -sudo rm -f /tmp/cesium-*-web.zip -sudo chown -R www-data: $src_path # Modify Nginx configuration file and copy it to Nginx conf directory nginx_conf=../conf/nginx.conf