diff --git a/README.md b/README.md index d6a7457..5d8f603 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Piwigo for YunoHost Extensions make Piwigo easily customizable. Icing on the cake, Piwigo is free and opensource. -**Shipped version:** 2.8.3 +**Shipped version:** 2.8.5 ![](http://piwigo.org/screenshots/homepage/piwigo-batch-manager.png) diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..2eda7f1 --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,21 @@ +# +# Common variables +# + +# Application version +VERSION="2.8.5" + +# Remote URL to fetch application source archive +APPLICATION_SOURCE_URL="http://piwigo.org/download/dlcounter.php?code=${VERSION}" + +# Download and extract application sources to the given directory +# usage: extract_application_to DESTDIR +extract_application() { + local DESTDIR=$1 + archive="${DESTDIR}/application.zip" + wget -q -O "$archive" "$APPLICATION_SOURCE_URL" \ +|| ynh_die "Unable to download application archive" + sudo unzip -qq "$archive" -d "$DESTDIR" \ + || ynh_die "Unable to extract application archive" + rm "$archive" +} \ No newline at end of file diff --git a/scripts/install b/scripts/install index 1ea12cd..ea94e17 100644 --- a/scripts/install +++ b/scripts/install @@ -5,6 +5,9 @@ set -eu app=$YNH_APP_INSTANCE_NAME +# Source local helpers +source ./_common.sh + # Retrieve arguments domain=$YNH_APP_ARG_DOMAIN path=$YNH_APP_ARG_PATH @@ -30,11 +33,8 @@ ynh_app_setting_set "$app" language "$language" sudo yunohost app checkurl "${domain}${path}" -a "$app" \ || ynh_die "Path not available: ${domain}${path}" -# Download sources -sudo wget -q http://piwigo.org/download/dlcounter.php?code=2.8.3 -O piwigo.zip - -# Uncompress -sudo unzip -qq piwigo.zip -d .. +# Download and extract application +extract_application .. # Copy source files src_path=/var/www/$app diff --git a/scripts/upgrade b/scripts/upgrade index bea56e5..7fe4279 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,13 +1,15 @@ #!/bin/bash -# ===================== -# TODO -# ===================== # Exit on command errors and treat unset variables as an error set -eu +shopt -s extglob # sets extended pattern matching options in the bash shell + app=$YNH_APP_INSTANCE_NAME +# Source local helpers +source ./_common.sh + # Source YunoHost helpers source /usr/share/yunohost/helpers @@ -21,16 +23,13 @@ language=$(ynh_app_setting_get "$app" language) # Remove trailing "/" for next commands path=${path%/} -# Download sources -sudo wget -q http://piwigo.org/download/dlcounter.php?code=2.8.3 -O piwigo.zip - -# Uncompress -sudo unzip -qq piwigo.zip -d ../ +# Download and extract application +extract_application .. # Copy source files src_path=/var/www/$app sudo mkdir -p $src_path -sudo cp -Raf ../piwigo/. $src_path +sudo cp -Raf ../piwigo/!(upload) $src_path datapath=/home/yunohost.app/$app