2019-08-24 12:54:18 +02:00
|
|
|
#=================================================
|
|
|
|
# COMMON VARIABLES
|
|
|
|
#=================================================
|
2018-02-15 18:37:46 +01:00
|
|
|
|
2020-06-12 16:47:52 +02:00
|
|
|
swap_needed=1024
|
|
|
|
|
2022-08-05 10:55:58 +02:00
|
|
|
# PHP
|
2021-05-05 00:02:53 +02:00
|
|
|
YNH_COMPOSER_VERSION="2.0.13"
|
2022-08-05 10:55:58 +02:00
|
|
|
|
2019-08-24 12:54:18 +02:00
|
|
|
# Version numbers
|
2022-11-19 07:25:56 +01:00
|
|
|
project_version="1.6.0"
|
2021-11-11 23:14:58 +01:00
|
|
|
#core_version is now retrieved from the manifest
|
|
|
|
ldap_version="*"
|
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
|
|
|
|
2020-05-17 14:56:21 +02:00
|
|
|
# Activate extension in Flarum's database
|
|
|
|
# usage: activate_flarum_extension $db_name $extension $short_extension
|
2018-02-18 14:52:12 +01:00
|
|
|
# $short_extension is the extension name written in database, how it is shortened is still a mystery
|
2020-05-17 14:56:21 +02:00
|
|
|
activate_flarum_extension() {
|
2020-04-21 00:00:02 +02:00
|
|
|
# Declare an array to define the options of this helper.
|
2020-05-17 14:56:21 +02:00
|
|
|
local legacy_args=ds
|
|
|
|
declare -Ar args_array=( [d]=database= [s]=short_extension )
|
2020-04-21 00:00:02 +02:00
|
|
|
local database
|
|
|
|
local short_extension
|
|
|
|
# Manage arguments with getopts
|
|
|
|
ynh_handle_getopts_args "$@"
|
|
|
|
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
|
|
|
|
|
|
|
|
# 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
|
|
|
|
2022-12-21 16:55:53 +01:00
|
|
|
# Use jq to test presence of the extension in the list of enabled extensions
|
|
|
|
# if not, then add it.
|
2023-01-08 17:05:51 +01:00
|
|
|
new_extensions_enabled=$(jq -jrc --arg short_extension $short_extension '. + [ $short_extension ] | unique' <<< $old_extensions_enabled)
|
2022-12-21 16:55:53 +01:00
|
|
|
|
2018-02-18 14:38:26 +01:00
|
|
|
# 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
|