From 274a9a70c85c843ee8330d6802a6b20cbf560b50 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Wed, 15 Aug 2018 18:28:59 +0200 Subject: [PATCH] Hotfix for folder access with php Closes #85 --- scripts/_common.sh | 13 +++++++------ scripts/install | 8 +++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index cf6b544..38e1984 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -21,10 +21,12 @@ exec_composer() { # Do not run composer as root if [ $AS_USER = "root" ] ; then ynh_die "Do not run composer as root" ; fi - + pushd "${WORKDIR}" exec_as "$AS_USER" COMPOSER_HOME="${WORKDIR}/.composer" \ - php "${WORKDIR}/composer.phar" $@ \ - -d "${WORKDIR}" -d memory_limit=-1 --quiet --no-interaction + php -d memory_limit=-1 \ + "${WORKDIR}/composer.phar" $@ \ + --quiet --no-interaction + popd } # Install and initialize Composer in the given directory @@ -41,7 +43,7 @@ init_composer() { | COMPOSER_HOME="${WORKDIR}/.composer" \ php -- --quiet --install-dir="$WORKDIR" \ || ynh_die "Unable to install Composer" - + chmod +x "${WORKDIR}/composer.phar" # update dependencies to create composer.lock #exec_composer "$AS_USER" "$WORKDIR" install --no-dev \ # || ynh_die "Unable to update core dependencies with Composer" @@ -63,7 +65,7 @@ install_and_activate_extension() { local new_extensions_enabled # Install extension - exec_composer $AS_USER $WORKDIR "require $EXTENSION --ansi" + exec_composer $AS_USER $WORKDIR "require $EXTENSION --ansi -d $WORKDIR" # Retrieve current extensions sql_command="SELECT \`value\` FROM settings WHERE \`key\` = 'extensions_enabled'" @@ -138,4 +140,3 @@ $(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" # Send the email to the recipients echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" } - diff --git a/scripts/install b/scripts/install index 2ee61a2..41a889b 100644 --- a/scripts/install +++ b/scripts/install @@ -100,7 +100,7 @@ sudo chown -R $app:www-data $tmp sudo chmod -R 0775 $tmp # Install Flarum -exec_composer $app $final_path "create-project flarum/flarum $tmp $flarum_version --stability=beta --ansi" +exec_composer $app $final_path "create-project flarum/flarum $tmp $flarum_version --stability=beta --ansi -d $tmp" # Copy Flarum to working directory and clean temp directory sudo cp -Rf $tmp/* $final_path @@ -176,6 +176,7 @@ if [[ -n $admin && -n $title ]]; then # Copy the configuration.yml to working directory finalflarumconf="$final_path/configuration.yml" cp ../conf/configuration.yml $finalflarumconf + chown $app:www-data $finalflarumconf # Generate admin password and retrieve their email address admin_pwd=$(ynh_string_random 8) admin_mail=$(ynh_user_get_info $admin mail) @@ -189,10 +190,11 @@ if [[ -n $admin && -n $title ]]; then sed -i "s%__ADMIN_EML__%$admin_mail%g" $finalflarumconf sed -i "s@__FORUM_TITLE__@$title@g" $finalflarumconf # Execute post-installation - cd $final_path - exec_as $app "php -d memory_limit=-1 flarum install -f configuration.yml" + pushd $final_path + exec_as $app "php -d $final_path -d memory_limit=-1 flarum install -f configuration.yml" # Delete configuration.yml as it sensitive data ynh_secure_remove $finalflarumconf + popd # Email setup sql_command="REPLACE INTO \`settings\` (\`key\`, \`value\`) VALUES