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] [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