From 6e66b323a46b55c908466dfaa2be8988eed3f88a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Tue, 30 Aug 2016 22:42:56 +0200 Subject: [PATCH 1/7] [enh][wip]new upgrade --- scripts/_common.sh | 34 ++++++++++++++++++++++++++++++++++ scripts/upgrade | 40 ++++++++++++++++++++++++++-------------- 2 files changed, 60 insertions(+), 14 deletions(-) create mode 100644 scripts/_common.sh diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..6aaedb0 --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,34 @@ +# +# Common variables +# + +# FreshRss version +VERSION="1.4.0" + +# Roundcube complete tarball checksum +FRESHRSS_SOURCE_SHA256="bcf8a7703b9258926ae5f76be8748a103d82df983e6097302977c9d83a2eca40" + +# Remote URL to fetch Roundcube source tarball +FRESHRSS_SOURCE_URL="https://github.com/FreshRSS/FreshRSS/archive/1.4.0.tar.gz" + +PKGDIR=$(cd ../; pwd) + +FINAL_PATH="/var/www/freshrss" +# +# Common helpers +# +# Download and extract FreshRss sources to the given directory +# usage: extract_freshrss DESTDIR +extract_freshrss() { + local DESTDIR=$1 + + # retrieve and extract FreshRss tarball + rc_tarball="${DESTDIR}/freshrss.tar.gz" + wget -q -O "$rc_tarball" "$FRESHRSS_SOURCE_URL" \ + || ynh_die "Unable to download FreshRss tarball" + echo "$FRESHRSS_SOURCE_SHA256 $rc_tarball" | sha256sum -c >/dev/null \ + || ynh_die "Invalid checksum of downloaded tarball" + tar xf "$rc_tarball" -C "$DESTDIR" --strip-components 1 \ + || ynh_die "Unable to extract FreshRss tarball" + rm "$rc_tarball" +} diff --git a/scripts/upgrade b/scripts/upgrade index f405d83..5fa9dea 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,19 +1,31 @@ #!/bin/bash -#backup data folder -final_path=/var/www/freshrss -# -if [ -f $final_path/data/user.php.dist ]; then - sudo rm $final_path/data/user.php.dist +#old version cleanup +if [ -f $FINAL_PATH/data/user.php.dist ]; then + sudo rm $FINAL_PATH/data/user.php.dist fi -#copy update script into freshrss path -sudo cp update-ynh.php $final_path/ -#execute update -sudo php $final_path/update-ynh.php -#remove update script -sudo rm $final_path/update-ynh.php -# Set permissions to freshrss directory -sudo chown -R www-data: $final_path/data/ -sudo chown -R www-data: $final_path/extensions/ +# Check destination directory +[[ ! -d $FINAL_PATH ]] && ynh_die \ +"The destination directory '$FINAL_PATH' does not exist.\ +The app is not correctly installed, you should remove it first." + +# Create tmp directory and install app inside +TMPDIR=$(ynh_mkdir_tmp) +extract_freshrss "$TMPDIR" + +# Restore config +sudo $FINAL_PATH/data/config.php $TMPDIR/data/config.php +sudo cp -r $FINAL_PATH/data/users/. $TMPDIR/data/users/ + +# Set permissions to freshrss directory +sudo chown -R www-data: $TMPDIR/data/ +sudo chown -R www-data: $TMPDIR/extensions/ + +# Clean up existing files and copy new files to the right place +sudo rm -rf "$DESTDIR" +sudo cp -r "$TMPDIR" "$DESTDIR" + + +#install extention for api sudo apt-get update sudo apt-get install -y php5-gmp From 683fc24db0cb2ac0330b0704fa2ecc284feb66eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Wed, 31 Aug 2016 08:44:08 +0200 Subject: [PATCH 2/7] [fix][wip]Forgot to import helpers --- scripts/upgrade | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 5fa9dea..9b92836 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,4 +1,13 @@ #!/bin/bash +# Exit on command errors and treat unset variables as an error +set -eu + +# Load common variables and helpers +. ./_common.sh + +# Source app helpers +. /usr/share/yunohost/helpers + #old version cleanup if [ -f $FINAL_PATH/data/user.php.dist ]; then sudo rm $FINAL_PATH/data/user.php.dist From b3072d233021d0a91219dfe4f8a48b63b33772a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Wed, 31 Aug 2016 08:45:09 +0200 Subject: [PATCH 3/7] [fix][wip]missing cp --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 9b92836..f55c89b 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,7 +23,7 @@ TMPDIR=$(ynh_mkdir_tmp) extract_freshrss "$TMPDIR" # Restore config -sudo $FINAL_PATH/data/config.php $TMPDIR/data/config.php +sudo cp $FINAL_PATH/data/config.php $TMPDIR/data/config.php sudo cp -r $FINAL_PATH/data/users/. $TMPDIR/data/users/ # Set permissions to freshrss directory From a6be7a7977767a6fa457176b15a06739f77a10c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Wed, 31 Aug 2016 08:46:18 +0200 Subject: [PATCH 4/7] [fix][wip]bad copy-paste --- scripts/upgrade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index f55c89b..c889739 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -31,8 +31,8 @@ sudo chown -R www-data: $TMPDIR/data/ sudo chown -R www-data: $TMPDIR/extensions/ # Clean up existing files and copy new files to the right place -sudo rm -rf "$DESTDIR" -sudo cp -r "$TMPDIR" "$DESTDIR" +sudo rm -rf "$FINAL_PATH" +sudo cp -r "$TMPDIR" "$FINAL_PATH" #install extention for api From 2f90d06f4ea91ac1a37dbe9f7f0515e15cab3f48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Wed, 31 Aug 2016 08:57:02 +0200 Subject: [PATCH 5/7] [fix][wip]remove install directive --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index c889739..0ebe8e9 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,6 +23,7 @@ TMPDIR=$(ynh_mkdir_tmp) extract_freshrss "$TMPDIR" # Restore config +sudo rm $final_path/data/do-install.txt sudo cp $FINAL_PATH/data/config.php $TMPDIR/data/config.php sudo cp -r $FINAL_PATH/data/users/. $TMPDIR/data/users/ From 15b9845b7576475d8a4bc8e54548c01d56093e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Wed, 31 Aug 2016 08:57:58 +0200 Subject: [PATCH 6/7] [fix][wip]bad copy paste --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 0ebe8e9..5521d7d 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,7 +23,7 @@ TMPDIR=$(ynh_mkdir_tmp) extract_freshrss "$TMPDIR" # Restore config -sudo rm $final_path/data/do-install.txt +sudo rm $FINAL_PATH/data/do-install.txt sudo cp $FINAL_PATH/data/config.php $TMPDIR/data/config.php sudo cp -r $FINAL_PATH/data/users/. $TMPDIR/data/users/ From f2a5586daa31e59eef4676dd0f3bc02a5b61f424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Wed, 31 Aug 2016 08:59:30 +0200 Subject: [PATCH 7/7] [fix][wip]try to work too fast, bad file name --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 5521d7d..f010277 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -23,7 +23,7 @@ TMPDIR=$(ynh_mkdir_tmp) extract_freshrss "$TMPDIR" # Restore config -sudo rm $FINAL_PATH/data/do-install.txt +sudo rm $TMPDIR/data/do-install.txt sudo cp $FINAL_PATH/data/config.php $TMPDIR/data/config.php sudo cp -r $FINAL_PATH/data/users/. $TMPDIR/data/users/