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

[fix] general fixes

At that point I do not care about proper titles.
This commit is contained in:
tituspijean 2020-04-21 00:00:02 +02:00
parent 8ba8b17ac9
commit 0728ea096b
10 changed files with 278 additions and 207 deletions

View file

@ -15,7 +15,7 @@
"email": "tituspijean@outlook.com" "email": "tituspijean@outlook.com"
}, },
"requirements": { "requirements": {
"yunohost": ">= 3.7" "yunohost": ">= 3.7.0"
}, },
"multi_instance": true, "multi_instance": true,
"services": [ "services": [

View file

@ -21,30 +21,40 @@ ssowat_version="0.1.0-beta.12"
# $extension is the "vendor/extension-name" string from packagist # $extension is the "vendor/extension-name" string from packagist
# $short_extension is the extension name written in database, how it is shortened is still a mystery # $short_extension is the extension name written in database, how it is shortened is still a mystery
install_and_activate_extension() { install_and_activate_extension() {
local AS_USER=$1 # Declare an array to define the options of this helper.
local PHP_VERSION=$2 local legacy_args=uvwdes
local WORKDIR=$3 declare -Ar args_array=( [u]=user= [v]=phpversion= [w]=workdir= [d]=database= [e]=extension= [s]=short_extension )
local DB_NAME=$4 local user
local EXTENSION=$5 local phpversion
local SHORT_EXTENSION=$6 local workdir
local database
local extension
local short_extension
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
user="${user:-$app}"
phpversion="${phpversion:-$php_version}"
workdir="${workdir:-$final_path}"
database="${database:-$db_name}"
local sql_command local sql_command
local old_extensions_enabled local old_extensions_enabled
local addition local addition
local new_extensions_enabled local new_extensions_enabled
# Install extension # Install extension
ynh_composer_exec $AS_USER $PHP_VERSION $WORKDIR "require $EXTENSION -n --ansi -d $WORKDIR" ynh_composer_exec --user=$user --phpversion="${phpversion}" --workdir="$workdir" --commands="require $extension"
# 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'"
old_extensions_enabled=$(ynh_mysql_execute_as_root "$sql_command" $db_name | tail -1) old_extensions_enabled=$(ynh_mysql_execute_as_root "$sql_command" $database | tail -1)
# Append the extension name at the end of the list # Append the extension name at the end of the list
addition=",\"${SHORT_EXTENSION}\"]" addition=",\"${short_extension}\"]"
new_extensions_enabled=${old_extensions_enabled::-1}$addition new_extensions_enabled=${old_extensions_enabled::-1}$addition
# Update activated extensions list # Update activated extensions list
sql_command="UPDATE \`settings\` SET \`value\`='$new_extensions_enabled' WHERE \`key\`='extensions_enabled';" sql_command="UPDATE \`settings\` SET \`value\`='$new_extensions_enabled' WHERE \`key\`='extensions_enabled';"
ynh_mysql_execute_as_root "$sql_command" $DB_NAME ynh_mysql_execute_as_root "$sql_command" $database
} }

View file

@ -1,88 +1,159 @@
#!/bin/bash #!/bin/bash
# Pin a repository. # From PR https://github.com/YunoHost/yunohost/pull/881
# # _ynh_install_app_dependencies has a different name to not be override by source /usr/share/yunohost/helpers
# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append]
# | arg: -p, --package - Packages concerned by the pin. Or all, *.
# | arg: -i, --pin - Filter for the pin.
# | arg: -p, --priority - Priority for the pin
# | arg: -n, --name - Name for the files for this repo, $app as default value.
# | arg: -a, --append - Do not overwrite existing files.
#
# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning.
#
ynh_pin_repo () {
# Declare an array to define the options of this helper.
local legacy_args=pirna
declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append )
local package
local pin
local priority
local name
local append
# Manage arguments with getopts
ynh_handle_getopts_args "$@"
package="${package:-*}"
priority=${priority:-50}
name="${name:-$app}"
append=${append:-0}
if [ $append -eq 1 ] # Define and install dependencies with a equivs control file
then #
append="tee -a" # This helper can/should only be called once per app
else #
append="tee" # example : _ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5"
fi #
# usage: _ynh_install_app_dependencies dep [dep [...]]
# | arg: dep - the package name to install in dependence. Writing "dep3|dep4|dep5" can be used to specify alternatives. For example : dep1 dep2 "dep3|dep4|dep5" will require to install dep1 and dep 2 and (dep3 or dep4 or dep5).
#
# Requires YunoHost version 2.6.4 or higher.
_ynh_install_app_dependencies () {
local dependencies=$@
# Add a comma for each space between packages. But not add a comma if the space separate a version specification. (See below)
dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')"
local dependencies=${dependencies//|/ | }
local manifest_path="../manifest.json"
if [ ! -e "$manifest_path" ]; then
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
fi
mkdir -p "/etc/apt/preferences.d" local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file.
echo "Package: $package if [ ${#version} -eq 0 ]; then
Pin: $pin version="1.0"
Pin-Priority: $priority" \ fi
| $append "/etc/apt/preferences.d/$name" local dep_app=${app//_/-} # Replace all '_' by '-'
# Handle specific versions
if [[ "$dependencies" =~ [\<=\>] ]]
then
# Replace version specifications by relationships syntax
# https://www.debian.org/doc/debian-policy/ch-relationships.html
# Sed clarification
# [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice.
# [\<=\>] matches < = or >
# \+ matches one or more occurence of the previous characters, for >= or >>.
# [^,]\+ matches all characters except ','
# Ex: 'package>=1.0' will be replaced by 'package (>= 1.0)'
dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')"
fi
#
# Epic ugly hack to fix the goddamn dependency nightmare of sury
# Sponsored by the "Djeezusse Fokin Kraiste Why Do Adminsys Has To Be So Fucking Complicated I Should Go Grow Potatoes Instead Of This Shit" collective
# https://github.com/YunoHost/issues/issues/1407
#
# If we require to install php dependency
if echo $dependencies | grep -q 'php';
then
# And we have packages from sury installed (7.0.33-10+weirdshiftafter instead of 7.0.33-0 on debian)
if dpkg --list | grep "php7.0" | grep -q -v "7.0.33-0+deb9"
then
# And sury ain't already installed
if ! grep -nrq "sury" /etc/apt/sources.list*
then
# Re-add sury
ynh_install_extra_repo --repo="https://packages.sury.org/php/ $(lsb_release -sc) main" --key="https://packages.sury.org/php/apt.gpg" --name=extra_php_version
# Pin this sury repository to prevent sury of doing shit
ynh_pin_repo --package="*" --pin="origin \"packages.sury.org\"" --priority=200 --name=extra_php_version
ynh_pin_repo --package="php7.0*" --pin="origin \"packages.sury.org\"" --priority=600 --name=extra_php_version --append
fi
fi
fi
cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build
Section: misc
Priority: optional
Package: ${dep_app}-ynh-deps
Version: ${version}
Depends: ${dependencies}
Architecture: all
Description: Fake package for ${app} (YunoHost app) dependencies
This meta-package is only responsible of installing its dependencies.
EOF
ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \
|| ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies
rm /tmp/${dep_app}-ynh-deps.control
ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies"
} }
# Add a repository. # Add dependencies to install with _ynh_install_app_dependencies
# #
# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append] # [internal]
# | arg: -u, --uri - Uri of the repository.
# | arg: -s, --suite - Suite of the repository.
# | arg: -c, --component - Component of the repository.
# | arg: -n, --name - Name for the files for this repo, $app as default value.
# | arg: -a, --append - Do not overwrite existing files.
# #
# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable # usage: ynh_add_app_dependencies --package=phpversion [--replace]
# uri suite component # | arg: -p, --package - Packages to add as dependencies for the app.
# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable # | arg: -r, --replace - Replace dependencies instead of adding to existing ones.
# ynh_add_app_dependencies () {
ynh_add_repo () {
# Declare an array to define the options of this helper. # Declare an array to define the options of this helper.
local legacy_args=uscna local legacy_args=pr
declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append ) declare -Ar args_array=( [p]=package= [r]=replace)
local uri local package
local suite local replace
local component # Manage arguments with getopts
ynh_handle_getopts_args "$@"
replace=${replace:-0}
local current_dependencies=""
if [ $replace -eq 0 ]
then
local dep_app=${app//_/-} # Replace all '_' by '-'
if ynh_package_is_installed --package="${dep_app}-ynh-deps"
then
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) "
fi
current_dependencies=${current_dependencies// | /|}
fi
_ynh_install_app_dependencies "${current_dependencies}${package}"
}
# Install packages from an extra repository properly.
#
# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name]
# | arg: -r, --repo - Complete url of the extra repository.
# | arg: -p, --package - The packages to install from this extra repository
# | arg: -k, --key - url to get the public key.
# | arg: -n, --name - Name for the files for this repo, $app as default value.
ynh_install_extra_app_dependencies () {
# Declare an array to define the options of this helper.
local legacy_args=rpkn
declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= )
local repo
local package
local key
local name local name
local append
# Manage arguments with getopts # Manage arguments with getopts
ynh_handle_getopts_args "$@" ynh_handle_getopts_args "$@"
name="${name:-$app}" name="${name:-$app}"
append=${append:-0} key=${key:-}
if [ $append -eq 1 ] # Set a key only if asked
if [ -n "$key" ]
then then
append="tee -a" key="--key=$key"
else
append="tee"
fi fi
# Add an extra repository for those packages
ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name
mkdir -p "/etc/apt/sources.list.d" # Install requested dependencies from this extra repository.
# Add the new repo in sources.list.d ynh_add_app_dependencies --package="$package"
echo "deb $uri $suite $component" \
| $append "/etc/apt/sources.list.d/$name.list" # Remove this extra repository after packages are installed
ynh_remove_extra_repo --name=$app
} }
# Add an extra repository correctly, pin it and get the key. # Add an extra repository correctly, pin it and get the key.
# #
# [internal]
#
# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append] # usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append]
# | arg: -r, --repo - Complete url of the extra repository. # | arg: -r, --repo - Complete url of the extra repository.
# | arg: -k, --key - url to get the public key. # | arg: -k, --key - url to get the public key.
@ -102,7 +173,7 @@ ynh_install_extra_repo () {
ynh_handle_getopts_args "$@" ynh_handle_getopts_args "$@"
name="${name:-$app}" name="${name:-$app}"
append=${append:-0} append=${append:-0}
key=${key:-0} key=${key:-}
priority=${priority:-} priority=${priority:-}
if [ $append -eq 1 ] if [ $append -eq 1 ]
@ -154,6 +225,8 @@ ynh_install_extra_repo () {
# Remove an extra repository and the assiociated configuration. # Remove an extra repository and the assiociated configuration.
# #
# [internal]
#
# usage: ynh_remove_extra_repo [--name=name] # usage: ynh_remove_extra_repo [--name=name]
# | arg: -n, --name - Name for the files for this repo, $app as default value. # | arg: -n, --name - Name for the files for this repo, $app as default value.
ynh_remove_extra_repo () { ynh_remove_extra_repo () {
@ -174,121 +247,88 @@ ynh_remove_extra_repo () {
ynh_package_update ynh_package_update
} }
# Install packages from an extra repository properly. # Add a repository.
# #
# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name] # [internal]
# | arg: -r, --repo - Complete url of the extra repository. #
# | arg: -p, --package - The packages to install from this extra repository # usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append]
# | arg: -k, --key - url to get the public key. # | arg: -u, --uri - Uri of the repository.
# | arg: -s, --suite - Suite of the repository.
# | arg: -c, --component - Component of the repository.
# | arg: -n, --name - Name for the files for this repo, $app as default value. # | arg: -n, --name - Name for the files for this repo, $app as default value.
ynh_install_extra_app_dependencies () { # | arg: -a, --append - Do not overwrite existing files.
#
# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable
# uri suite component
# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable
#
ynh_add_repo () {
# Declare an array to define the options of this helper. # Declare an array to define the options of this helper.
local legacy_args=rpkn local legacy_args=uscna
declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= ) declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append )
local repo local uri
local package local suite
local key local component
local name local name
local append
# Manage arguments with getopts # Manage arguments with getopts
ynh_handle_getopts_args "$@" ynh_handle_getopts_args "$@"
name="${name:-$app}" name="${name:-$app}"
key=${key:-0} append=${append:-0}
# Set a key only if asked if [ $append -eq 1 ]
if [ -n "$key" ]
then then
key="--key=$key" append="tee -a"
else
append="tee"
fi fi
# Add an extra repository for those packages
ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name
# Install requested dependencies from this extra repository. mkdir -p "/etc/apt/sources.list.d"
ynh_add_app_dependencies --package="$package" # Add the new repo in sources.list.d
echo "deb $uri $suite $component" \
# Remove this extra repository after packages are installed | $append "/etc/apt/sources.list.d/$name.list"
ynh_remove_extra_repo --name=$app
} }
#================================================= # Pin a repository.
# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies
# Define and install dependencies with a equivs control file
# This helper can/should only be called once per app
# #
# usage: ynh_install_app_dependencies dep [dep [...]] # [internal]
# | arg: dep - the package name to install in dependence
# You can give a choice between some package with this syntax : "dep1|dep2"
# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5"
# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5)
# #
# Requires YunoHost version 2.6.4 or higher. # usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append]
ynh_install_app_dependencies () { # | arg: -p, --package - Packages concerned by the pin. Or all, *.
local dependencies=$@ # | arg: -i, --pin - Filter for the pin.
dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')" # | arg: -p, --priority - Priority for the pin
dependencies=${dependencies//|/ | } # | arg: -n, --name - Name for the files for this repo, $app as default value.
local manifest_path="../manifest.json" # | arg: -a, --append - Do not overwrite existing files.
if [ ! -e "$manifest_path" ]; then #
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place # See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning.
fi #
ynh_pin_repo () {
local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file.
if [ ${#version} -eq 0 ]; then
version="1.0"
fi
local dep_app=${app//_/-} # Replace all '_' by '-'
# Handle specific versions
if [[ "$dependencies" =~ [\<=\>] ]]
then
# Replace version specifications by relationships syntax
# https://www.debian.org/doc/debian-policy/ch-relationships.html
# Sed clarification
# [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice.
# [\<=\>] matches < = or >
# \+ matches one or more occurence of the previous characters, for >= or >>.
# [^,]\+ matches all characters except ','
# Ex: package>=1.0 will be replaced by package (>= 1.0)
dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')"
fi
cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build
Section: misc
Priority: optional
Package: ${dep_app}-ynh-deps
Version: ${version}
Depends: ${dependencies}
Architecture: all
Description: Fake package for $app (YunoHost app) dependencies
This meta-package is only responsible of installing its dependencies.
EOF
ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \
|| ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies
rm /tmp/${dep_app}-ynh-deps.control
ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies"
}
ynh_add_app_dependencies () {
# Declare an array to define the options of this helper. # Declare an array to define the options of this helper.
local legacy_args=pr local legacy_args=pirna
declare -Ar args_array=( [p]=package= [r]=replace) declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append )
local package local package
local replace local pin
local priority
local name
local append
# Manage arguments with getopts # Manage arguments with getopts
ynh_handle_getopts_args "$@" ynh_handle_getopts_args "$@"
replace=${replace:-0} package="${package:-*}"
priority=${priority:-50}
name="${name:-$app}"
append=${append:-0}
local current_dependencies="" if [ $append -eq 1 ]
if [ $replace -eq 0 ]
then then
local dep_app=${app//_/-} # Replace all '_' by '-' append="tee -a"
if ynh_package_is_installed --package="${dep_app}-ynh-deps" else
then append="tee"
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) "
fi
current_dependencies=${current_dependencies// | /|}
fi fi
ynh_install_app_dependencies "${current_dependencies}${package}" mkdir -p "/etc/apt/preferences.d"
echo "Package: $package
Pin: $pin
Pin-Priority: $priority
" \
| $append "/etc/apt/preferences.d/$name"
} }

View file

@ -2,9 +2,8 @@
# Execute a command with Composer # Execute a command with Composer
# #
# usage: ynh_composer_exec --user=user --phpversion=phpversion [--workdir=$final_path] --commands="commands" # usage: ynh_composer_exec [--phpversion=phpversion] [--workdir=$final_path] --commands="commands"
# | arg: -u, --user - The user to perform the command with. # | arg: -v, --phpversion - PHP version to use with composer
# | arg: -v, --phpversion - The php version to perform the command with.
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
# | arg: -c, --commands - Commands to execute. # | arg: -c, --commands - Commands to execute.
ynh_composer_exec () { ynh_composer_exec () {
@ -17,39 +16,42 @@ ynh_composer_exec () {
local commands local commands
# Manage arguments with getopts # Manage arguments with getopts
ynh_handle_getopts_args "$@" ynh_handle_getopts_args "$@"
workdir="${workdir:-$final_path}" user="${user:-$app}"
phpversion="${phpversion:-7.0}" phpversion="${phpversion:-7.0}"
workdir="${workdir:-$final_path}"
exec_as $user COMPOSER_HOME="$workdir/.composer" \ exec_as $user COMPOSER_HOME="$workdir/.composer" \
php${phpversion} "$workdir/composer.phar" $commands \ php${phpversion} "$workdir/composer.phar" $commands \
-d "$workdir" --quiet --no-interaction -d "$workdir" --quiet --no-interaction
} }
# Install and initialize Composer in the given directory # Install and initialize Composer in the given directory
# #
# usage: ynh_install_composer --user=user --phpversion=phpversion [--workdir=$final_path] # usage: ynh_install_composer [--phpversion=phpversion] [--workdir=$final_path] [--install_args="--optimize-autoloader"]
# | arg: -u, --user - The user to perform the command with. # | arg: -v, --phpversion - PHP version to use with composer
# | arg: -v, --phpversion - The php version to perform the command with.
# | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path. # | arg: -w, --workdir - The directory from where the command will be executed. Default $final_path.
# | arg: -a, --install_args - Additional arguments provided to the composer install. Argument --no-dev already include
ynh_install_composer () { ynh_install_composer () {
# Declare an array to define the options of this helper. # Declare an array to define the options of this helper.
local legacy_args=uvw local legacy_args=uvwa
declare -Ar args_array=( [u]=user= [v]=phpversion= [w]=workdir= ) declare -Ar args_array=( [u]=user= [v]=phpversion= [w]=workdir= [a]=install_args=)
local user local user
local phpversion local phpversion
local workdir local workdir
local install_args
# Manage arguments with getopts # Manage arguments with getopts
ynh_handle_getopts_args "$@" ynh_handle_getopts_args "$@"
user="${user:-root}" user="${user:-$app}"
workdir="${workdir:-$final_path}" workdir="${workdir:-$final_path}"
phpversion="${phpversion:-7.0}" phpversion="${phpversion:-7.0}"
install_args="${install_args:-}"
curl -sS https://getcomposer.org/installer \ exec_as $user COMPOSER_HOME="$workdir/.composer" \
| exec_as $user COMPOSER_HOME="$workdir/.composer" \ curl -sS https://getcomposer.org/installer \
php${phpversion} -- --quiet --install-dir="$workdir" \ | php${phpversion} -- --quiet --install-dir="$workdir" \
|| ynh_die "Unable to install Composer." || ynh_die "Unable to install Composer."
# update dependencies to create composer.lock # update dependencies to create composer.lock
ynh_composer_exec --user=$app --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev" \ ynh_composer_exec --user=$user --phpversion="${phpversion}" --workdir="$workdir" --commands="install --no-dev $install_args" \
|| ynh_die "Unable to update core dependencies with Composer." || ynh_die "Unable to update core dependencies with Composer."
} }

View file

@ -75,4 +75,3 @@ ynh_remove_php () {
ynh_secure_remove /etc/php/ynh_app_version ynh_secure_remove /etc/php/ynh_app_version
fi fi
} }

View file

@ -7,12 +7,12 @@
#================================================= #=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source experimental_helpers/_ynh_add_extra_apt_repos
source experimental_helpers/ynh_add_extra_apt_repos__3 source experimental_helpers/ynh_install_php
source experimental_helpers/ynh_install_php__3
source experimental_helpers/ynh_exec_as source experimental_helpers/ynh_exec_as
source experimental_helpers/ynh_composer__2 source experimental_helpers/ynh_composer
source experimental_helpers/ynh_send_readme_to_admin__2 source experimental_helpers/ynh_send_readme_to_admin
source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
@ -101,7 +101,7 @@ fi
#================================================= #=================================================
ynh_print_info --message="Installing dependencies..." ynh_print_info --message="Installing dependencies..."
ynh_install_app_dependencies "$pkg_dependencies" _ynh_install_app_dependencies "$pkg_dependencies"
#================================================= #=================================================
# CREATE A MYSQL DATABASE # CREATE A MYSQL DATABASE
@ -161,13 +161,27 @@ ynh_add_fpm_config $php_version
#================================================= #=================================================
ynh_script_progression --message="Installing Composer and Flarum..." --time --weight=1 ynh_script_progression --message="Installing Composer and Flarum..." --time --weight=1
# Setting user rights # Set right permissions
chown -R $app:www-data $final_path chown -R $app: $final_path
chmod -R 775 $final_path chmod -R 775 $final_path
# Install Composer and Flarum # Install Composer and Flarum
ynh_install_composer --user=$app --phpversion=$php_version --workdir=$final_path ynh_install_composer --user=$app --phpversion=$php_version --workdir=$final_path
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
### For security reason, any app should set the permissions to root: before anything else.
### Then, if write authorization is needed, any access should be given only to directories
### that really need such authorization.
# Set right permissions
chown -R $app: $final_path
chown -R $app:www-data $final_path/storage
chmod -R 775 $final_path
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
@ -257,7 +271,7 @@ esac
if [ $bazaar_extension -eq 1 ]; then if [ $bazaar_extension -eq 1 ]; then
ynh_script_progression --message="Installing Bazaar extension..." --time --weight=2 ynh_script_progression --message="Installing Bazaar extension..." --time --weight=2
ynh_composer_exec --user=$app --phpversion=$php_version --workdir=$final_path \ ynh_composer_exec --phpversion=$php_version --workdir=$final_path \
--commands="require extiverse/bazaar --ansi" --commands="require extiverse/bazaar --ansi"
fi fi

View file

@ -7,8 +7,8 @@
#================================================= #=================================================
source _common.sh source _common.sh
source experimental_helpers/ynh_add_extra_apt_repos__3 source experimental_helpers/_ynh_add_extra_apt_repos
source experimental_helpers/ynh_install_php__3 source experimental_helpers/ynh_install_php
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================

View file

@ -8,11 +8,11 @@
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source ../settings/scripts/experimental_helpers/ynh_add_extra_apt_repos__3 source ../settings/scripts/experimental_helpers/_ynh_add_extra_apt_repos
source ../settings/scripts/experimental_helpers/ynh_install_php__3 source ../settings/scripts/experimental_helpers/ynh_install_php
source ../settings/scripts/experimental_helpers/ynh_exec_as source ../settings/scripts/experimental_helpers/ynh_exec_as
source ../settings/scripts/experimental_helpers/ynh_composer__2 source ../settings/scripts/experimental_helpers/ynh_composer
source ../settings/scripts/experimental_helpers/ynh_send_readme_to_admin__2 source ../settings/scripts/experimental_helpers/ynh_send_readme_to_admin
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================

View file

@ -7,12 +7,12 @@
#================================================= #=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source experimental_helpers/_ynh_add_extra_apt_repos
source experimental_helpers/ynh_add_extra_apt_repos__3 source experimental_helpers/ynh_install_php
source experimental_helpers/ynh_install_php__3
source experimental_helpers/ynh_exec_as source experimental_helpers/ynh_exec_as
source experimental_helpers/ynh_composer__2 source experimental_helpers/ynh_composer
source experimental_helpers/ynh_send_readme_to_admin__2 source experimental_helpers/ynh_send_readme_to_admin
source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
@ -150,7 +150,7 @@ fi
#================================================= #=================================================
ynh_print_info --message="Upgrading dependencies..." ynh_print_info --message="Upgrading dependencies..."
ynh_install_app_dependencies "$pkg_dependencies" _ynh_install_app_dependencies "$pkg_dependencies"
#================================================= #=================================================
# CREATE DEDICATED USER # CREATE DEDICATED USER
@ -159,6 +159,8 @@ ynh_script_progression --message="Making sure dedicated system user exists..." -
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_system_user_create $app $final_path ynh_system_user_create $app $final_path
# Adding it to www-data group
usermod -a -G www-data $app
#================================================= #=================================================
# PHP-FPM CONFIGURATION # PHP-FPM CONFIGURATION
@ -190,6 +192,10 @@ then
# Download, check integrity, uncompress and patch the source from app.src # Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$final_path" ynh_setup_source --dest_dir="$final_path"
# Setting user rights
chown -R $app:www-data $final_path
chmod -R 775 $final_path
# Install Composer and Flarum # Install Composer and Flarum
ynh_install_composer --user=$app --phpversion=$php_version --workdir=$final_path ynh_install_composer --user=$app --phpversion=$php_version --workdir=$final_path