1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/kanboard_ynh.git synced 2024-09-03 19:36:17 +02:00

Download kanboard zip from kanboard.net website

This commit is contained in:
Jimmy Monin 2017-01-04 21:31:10 +01:00
parent 6e4f673ca9
commit 01f5b2ab23
4 changed files with 14 additions and 56 deletions

View file

@ -33,7 +33,7 @@ From command line:
Infos
-----
Kanboard v1.0.35
Kanboard v1.0.36
Yunohost forum thread: <https://forum.yunohost.org/t/kanboard-package/78>

View file

@ -5,8 +5,8 @@
# Application version
VERSION="1.0.36"
# Remote URL to fetch application source tarball
APPLICATION_SOURCE_URL="https://github.com/kanboard/kanboard/archive/v${VERSION}.tar.gz"
# Remote URL to fetch application source archive
APPLICATION_SOURCE_URL="https://kanboard.net/kanboard-${VERSION}.zip"
#
# Common helpers
@ -16,53 +16,11 @@ APPLICATION_SOURCE_URL="https://github.com/kanboard/kanboard/archive/v${VERSION}
# usage: extract_application_to DESTDIR
extract_application() {
local DESTDIR=$1
rc_tarball="${DESTDIR}/application.tar.gz"
wget -q -O "$rc_tarball" "$APPLICATION_SOURCE_URL" \
|| ynh_die "Unable to download application tarball"
tar xf "$rc_tarball" -C "$DESTDIR" --strip-components 1 \
|| ynh_die "Unable to extract application tarball"
rm "$rc_tarball"
}
# 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
}
# Execute a composer command from a given directory
# usage: composer_exec AS_USER WORKDIR COMMAND [ARG ...]
exec_composer() {
local AS_USER=$1
local WORKDIR=$2
shift 2
exec_as "$AS_USER" COMPOSER_HOME="${WORKDIR}/.composer" \
php "${WORKDIR}/composer.phar" $@ \
-d "${WORKDIR}" --quiet --no-interaction
}
# Install and initialize Composer in the given directory
# usage: init_composer DESTDIR [AS_USER]
init_composer() {
local DESTDIR=$1
local AS_USER=${2:-admin}
# install composer
curl -sS https://getcomposer.org/installer \
| exec_as "$AS_USER" COMPOSER_HOME="${DESTDIR}/.composer" \
php -- --quiet --install-dir="$DESTDIR" \
|| ynh_die "Unable to install Composer"
# update dependencies to create composer.lock
exec_composer "$AS_USER" "$DESTDIR" install --no-dev \
|| ynh_die "Unable to update application core dependencies"
archive="${DESTDIR}/application.zip"
wget -q -O "$archive" "$APPLICATION_SOURCE_URL" \
|| ynh_die "Unable to download application archive"
# Here we process with unzip as would tar "--strip-component" option
unzip -qq "$archive" -d "$DESTDIR" && rm "$archive" && f=("$DESTDIR"/*) && mv "$DESTDIR"/*/* "$DESTDIR" && rm -f "${f[@]}"/.htaccess && rmdir "${f[@]}" \
|| ynh_die "Unable to extract application archive"
chmod 755 $DESTDIR
}

View file

@ -46,9 +46,9 @@ ynh_app_setting_set $app adminusername $admin
ynh_app_setting_set $app is_public $is_public
# Create tmp directory and install app inside
TMPDIR=$(ynh_mkdir_tmp)
TMPDIR=`mktemp -d`
extract_application "$TMPDIR"
init_composer "$TMPDIR"
sudo mv "$TMPDIR" "$DESTDIR"
@ -89,6 +89,7 @@ then
fi
# Init database
#sudo chmod o+x ${DESTDIR} ${DESTDIR}/app/ ${DESTDIR}/app/Schema/ ${DESTDIR}/app/Schema/Sql
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ${DESTDIR}/app/Schema/Sql/mysql.sql
# Reload services

View file

@ -40,9 +40,8 @@ sudo rm -rf /var/lib/php5/session/*
sudo mv ${DESTDIR} ${DESTDIR}.old
# Create tmp directory and install app inside
TMPDIR=$(ynh_mkdir_tmp)
TMPDIR=`mktemp -d`
extract_application "$TMPDIR"
init_composer "$TMPDIR"
sudo mv "$TMPDIR" "$DESTDIR"