1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/agendav_ynh.git synced 2024-09-03 20:36:12 +02:00

use dependencies helpers and ynh_setup_source to clean common.sh

This commit is contained in:
Jean-Baptiste Holcroft 2017-10-20 10:37:55 +02:00
parent 714ff54bf5
commit 5e79a11f75
7 changed files with 15 additions and 44 deletions

4
conf/app.src Normal file
View file

@ -0,0 +1,4 @@
SOURCE_URL=https://github.com/adobo/agendav/releases/download/2.0.0/agendav-2.0.0.tar.gz
SOURCE_SUM=142e8d9ea0e3e6feacd1523c5cabc834fe8bc3e9dbae03034089758b9c3abb92
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz

View file

@ -1,19 +1,8 @@
#!/bin/bash
#
# Common variables
#
# AgenDAV version
VERSION="2.0.0"
# Source tarball checksum
SOURCE_SHA256="142e8d9ea0e3e6feacd1523c5cabc834fe8bc3e9dbae03034089758b9c3abb92"
# Source tarball URL
SOURCE_URL="https://github.com/adobo/agendav/releases/download/${VERSION}/agendav-${VERSION}.tar.gz"
# App package root directory should be the parent folder
PKGDIR=$(cd ../; pwd)
# Associative array of languages
declare -A LANGUAGES=(
[nl]=nl_NL
@ -28,27 +17,4 @@ declare -A LANGUAGES=(
# Common helpers
#
# Source app helpers
source /usr/share/yunohost/helpers
# Download and extract AgenDAV sources to the given directory
# usage: extract_agendav DESTDIR
extract_agendav() {
local DESTDIR=$1
# retrieve and extract tarball
tarball_path="/tmp/agendav.tar.gz"
rm -f "$tarball_path"
wget -q -O "$tarball_path" "$SOURCE_URL" \
|| ynh_die "Unable to download AgenDAV archive"
echo "$SOURCE_SHA256 $tarball_path" | sha256sum -c >/dev/null \
|| ynh_die "Invalid checksum of downloaded archive"
tar xf "$tarball_path" -C "$DESTDIR" --strip-components 1 \
|| ynh_die "Unable to extract AgenDAV archive"
rm -rf "$tarball_path"
# apply patches
(cd "$DESTDIR" \
&& for p in ${PKGDIR}/patches/*.patch; do patch -p1 < $p; done) \
|| die "Unable to apply patches to AgenDAV"
}

View file

@ -49,12 +49,11 @@ else
fi
# Install dependencies
ynh_package_is_installed "php5-cli" \
|| ynh_package_install "php5-cli"
ynh_install_app_dependencies "php5-cli"
# Create tmp directory and fetch app inside
TMPDIR=$(mktemp -d)
extract_agendav "$TMPDIR"
ynh_setup_source "$TMPDIR"
# Generate random password and encryption key
dbpass=$(ynh_string_random)

View file

@ -23,6 +23,9 @@ rm -rf "/var/www/${app}" "/var/log/${app}"
rm -f "/etc/php5/fpm/pool.d/${app}.conf"
[[ -n $domain ]] && rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
# Reload services
service php5-fpm restart || true
service nginx reload || true

View file

@ -14,9 +14,6 @@ app="$YNH_APP_INSTANCE_NAME"
dbname=$app
dbuser=$app
# Source app helpers
source /usr/share/yunohost/helpers
# Retrieve old app settings
domain=$(ynh_app_setting_get "$app" domain)
path=$(ynh_app_setting_get "$app" path)
@ -25,6 +22,9 @@ dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
# Check web path availability
ynh_webpath_available "$domain" "$path"
# Install dependencies
ynh_install_app_dependencies "php5-cli"
# Check destination directory
DESTDIR="/var/www/$app"
[[ -d $DESTDIR ]] && ynh_die \

View file

@ -54,12 +54,11 @@ else
fi
# Install dependencies
ynh_package_is_installed "php5-cli" \
|| ynh_package_install "php5-cli"
ynh_install_app_dependencies "php5-cli"
# Create tmp directory and fetch app inside
TMPDIR=$(mktemp -d)
extract_agendav "$TMPDIR"
ynh_setup_source "$TMPDIR"
# Copy and set AgenDAV configuration
conf_path="${TMPDIR}/web/config/settings.php"