2019-08-24 12:54:18 +02:00
|
|
|
#=================================================
|
|
|
|
# COMMON VARIABLES
|
|
|
|
#=================================================
|
2018-02-15 18:37:46 +01:00
|
|
|
|
2019-08-24 12:54:18 +02:00
|
|
|
# dependencies used by the app
|
2020-04-06 10:54:13 +02:00
|
|
|
pkg_dependencies=""
|
|
|
|
extra_pkg_dependencies="php7.3-curl php7.3-dom php7.3-gd php7.3-json php7.3-mbstring php7.3-pdo-mysql php7.3-tokenizer php7.3-zip"
|
2018-02-15 18:37:46 +01:00
|
|
|
|
2019-08-24 12:54:18 +02:00
|
|
|
# Version numbers
|
|
|
|
php_version="7.3"
|
2020-03-14 21:22:33 +01:00
|
|
|
project_version="0.1.0-beta.12"
|
|
|
|
core_version="0.1.0-beta.12"
|
2020-03-18 21:27:22 +01:00
|
|
|
ssowat_version="0.1.0-beta.12"
|
2018-02-15 18:37:46 +01:00
|
|
|
|
2019-08-24 12:54:18 +02:00
|
|
|
#=================================================
|
|
|
|
# PERSONAL HELPERS
|
|
|
|
#=================================================
|
2018-02-14 10:48:34 +01:00
|
|
|
|
2018-02-18 14:52:12 +01:00
|
|
|
# Install extension, and activate it in database
|
2019-08-24 12:54:18 +02:00
|
|
|
# usage: install_and_activate_extension $user $php_version $final_path $db_name $extension $short_extension
|
2018-02-18 14:52:12 +01:00
|
|
|
# $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
|
2018-02-18 14:38:26 +01:00
|
|
|
install_and_activate_extension() {
|
2020-04-21 00:00:02 +02:00
|
|
|
# Declare an array to define the options of this helper.
|
|
|
|
local legacy_args=uvwdes
|
|
|
|
declare -Ar args_array=( [u]=user= [v]=phpversion= [w]=workdir= [d]=database= [e]=extension= [s]=short_extension )
|
|
|
|
local user
|
|
|
|
local phpversion
|
|
|
|
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}"
|
|
|
|
|
2018-02-18 14:38:26 +01:00
|
|
|
local sql_command
|
|
|
|
local old_extensions_enabled
|
|
|
|
local addition
|
|
|
|
local new_extensions_enabled
|
|
|
|
|
|
|
|
# Install extension
|
2020-04-21 00:00:02 +02:00
|
|
|
ynh_composer_exec --user=$user --phpversion="${phpversion}" --workdir="$workdir" --commands="require $extension"
|
2018-02-18 14:38:26 +01:00
|
|
|
|
|
|
|
# Retrieve current extensions
|
|
|
|
sql_command="SELECT \`value\` FROM settings WHERE \`key\` = 'extensions_enabled'"
|
2020-04-21 00:00:02 +02:00
|
|
|
old_extensions_enabled=$(ynh_mysql_execute_as_root "$sql_command" $database | tail -1)
|
2018-02-18 14:38:26 +01:00
|
|
|
|
|
|
|
# Append the extension name at the end of the list
|
2020-04-21 00:00:02 +02:00
|
|
|
addition=",\"${short_extension}\"]"
|
2018-02-18 14:38:26 +01:00
|
|
|
new_extensions_enabled=${old_extensions_enabled::-1}$addition
|
|
|
|
# Update activated extensions list
|
|
|
|
sql_command="UPDATE \`settings\` SET \`value\`='$new_extensions_enabled' WHERE \`key\`='extensions_enabled';"
|
2020-04-21 00:00:02 +02:00
|
|
|
ynh_mysql_execute_as_root "$sql_command" $database
|
2018-02-18 14:38:26 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-08-24 12:54:18 +02:00
|
|
|
#=================================================
|
|
|
|
# EXPERIMENTAL HELPERS
|
|
|
|
#=================================================
|
2018-07-10 23:43:14 +02:00
|
|
|
|
2019-08-24 12:54:18 +02:00
|
|
|
# See ynh_* scripts
|