1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/flarum_ynh.git synced 2024-09-03 18:36:24 +02:00

Merge pull request #86 from YunoHost-Apps/fix-folder-access

Hotfix for folder access with php
This commit is contained in:
Titus PiJean 2018-08-17 12:49:31 +02:00 committed by GitHub
commit 405176ff13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View file

@ -21,10 +21,12 @@ exec_composer() {
# Do not run composer as root # Do not run composer as root
if [ $AS_USER = "root" ] ; then ynh_die "Do not run composer as root" ; fi if [ $AS_USER = "root" ] ; then ynh_die "Do not run composer as root" ; fi
pushd "${WORKDIR}"
exec_as "$AS_USER" COMPOSER_HOME="${WORKDIR}/.composer" \ exec_as "$AS_USER" COMPOSER_HOME="${WORKDIR}/.composer" \
php "${WORKDIR}/composer.phar" $@ \ php -d memory_limit=-1 \
-d "${WORKDIR}" -d memory_limit=-1 --quiet --no-interaction "${WORKDIR}/composer.phar" $@ \
--quiet --no-interaction
popd
} }
# Install and initialize Composer in the given directory # Install and initialize Composer in the given directory
@ -41,7 +43,7 @@ init_composer() {
| COMPOSER_HOME="${WORKDIR}/.composer" \ | COMPOSER_HOME="${WORKDIR}/.composer" \
php -- --quiet --install-dir="$WORKDIR" \ php -- --quiet --install-dir="$WORKDIR" \
|| ynh_die "Unable to install Composer" || ynh_die "Unable to install Composer"
chmod +x "${WORKDIR}/composer.phar"
# update dependencies to create composer.lock # update dependencies to create composer.lock
#exec_composer "$AS_USER" "$WORKDIR" install --no-dev \ #exec_composer "$AS_USER" "$WORKDIR" install --no-dev \
# || ynh_die "Unable to update core dependencies with Composer" # || ynh_die "Unable to update core dependencies with Composer"
@ -63,7 +65,7 @@ install_and_activate_extension() {
local new_extensions_enabled local new_extensions_enabled
# Install extension # Install extension
exec_composer $AS_USER $WORKDIR "require $EXTENSION --ansi" exec_composer $AS_USER $WORKDIR "require $EXTENSION --ansi -d $WORKDIR"
# Retrieve current extensions # Retrieve current extensions
sql_command="SELECT \`value\` FROM settings WHERE \`key\` = 'extensions_enabled'" 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 # Send the email to the recipients
echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
} }

View file

@ -100,7 +100,7 @@ sudo chown -R $app:www-data $tmp
sudo chmod -R 0775 $tmp sudo chmod -R 0775 $tmp
# Install Flarum # 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 # Copy Flarum to working directory and clean temp directory
sudo cp -Rf $tmp/* $final_path sudo cp -Rf $tmp/* $final_path
@ -176,6 +176,7 @@ if [[ -n $admin && -n $title ]]; then
# Copy the configuration.yml to working directory # Copy the configuration.yml to working directory
finalflarumconf="$final_path/configuration.yml" finalflarumconf="$final_path/configuration.yml"
cp ../conf/configuration.yml $finalflarumconf cp ../conf/configuration.yml $finalflarumconf
chown $app:www-data $finalflarumconf
# Generate admin password and retrieve their email address # Generate admin password and retrieve their email address
admin_pwd=$(ynh_string_random 8) admin_pwd=$(ynh_string_random 8)
admin_mail=$(ynh_user_get_info $admin mail) 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%__ADMIN_EML__%$admin_mail%g" $finalflarumconf
sed -i "s@__FORUM_TITLE__@$title@g" $finalflarumconf sed -i "s@__FORUM_TITLE__@$title@g" $finalflarumconf
# Execute post-installation # Execute post-installation
cd $final_path pushd $final_path
exec_as $app "php -d memory_limit=-1 flarum install -f configuration.yml" exec_as $app "php -d $final_path -d memory_limit=-1 flarum install -f configuration.yml"
# Delete configuration.yml as it sensitive data # Delete configuration.yml as it sensitive data
ynh_secure_remove $finalflarumconf ynh_secure_remove $finalflarumconf
popd
# Email setup # Email setup
sql_command="REPLACE INTO \`settings\` (\`key\`, \`value\`) VALUES sql_command="REPLACE INTO \`settings\` (\`key\`, \`value\`) VALUES