mirror of
https://github.com/YunoHost-Apps/freshrss_ynh.git
synced 2024-09-03 18:36:33 +02:00
Merge pull request #18 from plopoyop/update-refactoring
Update refactoring
This commit is contained in:
commit
472c5cdf68
2 changed files with 71 additions and 15 deletions
34
scripts/_common.sh
Normal file
34
scripts/_common.sh
Normal file
|
@ -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"
|
||||||
|
}
|
|
@ -1,19 +1,41 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#backup data folder
|
# Exit on command errors and treat unset variables as an error
|
||||||
final_path=/var/www/freshrss
|
set -eu
|
||||||
#
|
|
||||||
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/
|
|
||||||
|
|
||||||
|
# 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
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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 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/
|
||||||
|
|
||||||
|
# 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 "$FINAL_PATH"
|
||||||
|
sudo cp -r "$TMPDIR" "$FINAL_PATH"
|
||||||
|
|
||||||
|
|
||||||
|
#install extention for api
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y php5-gmp
|
sudo apt-get install -y php5-gmp
|
||||||
|
|
Loading…
Reference in a new issue