Skip to content

Commit

Permalink
Download kanboard zip from kanboard.net website
Browse files Browse the repository at this point in the history
  • Loading branch information
JimboJoe committed Jan 4, 2017
1 parent 6e4f673 commit 01f5b2a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 56 deletions.
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
60 changes: 9 additions & 51 deletions scripts/_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
5 changes: 3 additions & 2 deletions scripts/install
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions scripts/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 01f5b2a

Please sign in to comment.