2017-04-26 19:01:53 +02:00
|
|
|
#
|
|
|
|
# Common variables
|
|
|
|
#
|
|
|
|
|
|
|
|
# Package version
|
2020-02-27 20:59:48 +01:00
|
|
|
VERSION="2020-02-26"
|
2017-04-26 19:01:53 +02:00
|
|
|
|
|
|
|
# Full sources tarball URL
|
2017-08-04 23:22:29 +02:00
|
|
|
SOURCE_URL="https://github.com/RSS-Bridge/rss-bridge/archive/${VERSION}.tar.gz"
|
2017-04-26 19:01:53 +02:00
|
|
|
|
|
|
|
# Full sources tarball checksum
|
2020-02-27 20:59:48 +01:00
|
|
|
SOURCE_SHA256="f4dd0dc07828cca0c533eb112134f2a29efe1e083d2e92f4c474e961af62b391"
|
2017-04-26 19:01:53 +02:00
|
|
|
|
|
|
|
# App package root directory should be the parent folder
|
|
|
|
PKGDIR=$(cd ../; pwd)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Common helpers
|
|
|
|
#
|
|
|
|
|
|
|
|
# Source app helpers
|
|
|
|
. /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
# Execute a command as another user
|
|
|
|
# usage: exec_as USER COMMAND [ARG ...]
|
|
|
|
exec_as() {
|
|
|
|
local USER=$1
|
|
|
|
shift 1
|
|
|
|
|
|
|
|
if [[ $USER = $(whoami) ]]; then
|
|
|
|
eval $@
|
|
|
|
else
|
|
|
|
# use sudo twice to be root and be allowed to use another user
|
|
|
|
sudo sudo -u "$USER" "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Download and extract sources to the given directory
|
2018-09-15 17:57:35 +02:00
|
|
|
# usage: extract_sources DESTDIR
|
2017-04-26 19:01:53 +02:00
|
|
|
extract_sources() {
|
|
|
|
local DESTDIR=$1
|
|
|
|
|
|
|
|
# retrieve and extract Roundcube tarball
|
|
|
|
wb_tarball="/tmp/sources.tar.gz"
|
|
|
|
rm -f "$wb_tarball"
|
|
|
|
wget -q -O "$wb_tarball" "$SOURCE_URL" \
|
|
|
|
|| ynh_die "Unable to download sources tarball"
|
|
|
|
echo "$SOURCE_SHA256 $wb_tarball" | sha256sum -c >/dev/null \
|
|
|
|
|| ynh_die "Invalid checksum of downloaded tarball"
|
2018-09-15 17:57:35 +02:00
|
|
|
tar xf "$wb_tarball" -C "$DESTDIR" --strip-components 1 \
|
2017-04-26 19:01:53 +02:00
|
|
|
|| ynh_die "Unable to extract sources tarball"
|
|
|
|
rm -f "$wb_tarball"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HUMAN_SIZE () { # Transforms a Kb-based size to a human-readable size
|
|
|
|
human=$(numfmt --to=iec --from-unit=1K $1)
|
|
|
|
echo $human
|
|
|
|
}
|
|
|
|
|
|
|
|
WARNING () { # Print on error output
|
|
|
|
$@ >&2
|
|
|
|
}
|
|
|
|
|
|
|
|
CHECK_SIZE () { # Check if enough disk space available on backup storage
|
|
|
|
file_to_analyse=$1
|
|
|
|
backup_size=$(sudo du --summarize "$file_to_analyse" | cut -f1)
|
|
|
|
free_space=$(sudo df --output=avail "/home/yunohost.backup" | sed 1d)
|
|
|
|
|
|
|
|
if [ $free_space -le $backup_size ]
|
|
|
|
then
|
|
|
|
WARNING echo "Not enough backup disk space for: $file_to_analyse."
|
|
|
|
WARNING echo "Space available: $(HUMAN_SIZE $free_space)"
|
|
|
|
ynh_die "Space needed: $(HUMAN_SIZE $backup_size)"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-24 22:24:23 +01:00
|
|
|
|