1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/piwigo_ynh.git synced 2024-09-03 20:06:03 +02:00
piwigo_ynh/scripts/_common.sh

42 lines
1,009 B
Bash
Raw Normal View History

#!/bin/bash
2017-01-03 18:32:00 +01:00
#
# Common variables
#
# Application version
VERSION="2.8.6"
2017-01-03 18:32:00 +01:00
# Remote URL to fetch application source archive
APPLICATION_SOURCE_URL="http://piwigo.org/download/dlcounter.php?code=${VERSION}"
#
# Common helpers
#
2017-01-03 18:32:00 +01:00
# Download and extract application sources to the given directory
# usage: extract_application_to DESTDIR
extract_application() {
local DESTDIR=$1
TMPDIR=$(mktemp -d)
chmod 755 $TMPDIR
archive="${TMPDIR}/application.zip"
2017-01-03 18:32:00 +01:00
wget -q -O "$archive" "$APPLICATION_SOURCE_URL" \
|| ynh_die "Unable to download application archive"
unzip -qq "$archive" -d "$TMPDIR" \
2017-01-03 18:32:00 +01:00
|| ynh_die "Unable to extract application archive"
rm "$archive"
sudo rsync -a "$TMPDIR"/*/* "$DESTDIR"
}
# Fix path if needed
# usage: fix_patch PATH_TO_FIX
fix_path() {
local path=$1
if [ "${path:0:1}" != "/" ] && [ ${#path} -gt 0 ]; then
path="/$path"
fi
if [ "${path:${#path}-1}" == "/" ] && [ ${#path} -gt 1 ]; then
path="${path:0:${#path}-1}"
fi
echo "$path"
2017-01-03 18:32:00 +01:00
}