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

58 lines
2 KiB
Bash
Raw Normal View History

2019-08-24 12:54:18 +02:00
#=================================================
# COMMON VARIABLES
#=================================================
2019-08-24 12:54:18 +02:00
# dependencies used by the app
2020-04-06 10:54:13 +02:00
pkg_dependencies=""
2020-06-12 01:55:21 +02:00
2020-06-12 16:47:52 +02:00
swap_needed=1024
2020-06-12 01:55:21 +02:00
YNH_PHP_VERSION="7.3"
extra_php_dependencies="php${YNH_PHP_VERSION}-curl php${YNH_PHP_VERSION}-dom php${YNH_PHP_VERSION}-gd php${YNH_PHP_VERSION}-json php${YNH_PHP_VERSION}-mbstring php${YNH_PHP_VERSION}-pdo-mysql php${YNH_PHP_VERSION}-tokenizer php${YNH_PHP_VERSION}-zip"
2019-08-24 12:54:18 +02:00
# Version numbers
2020-05-17 14:56:21 +02:00
project_version="~0.1.0-beta.13"
core_version="~0.1.0-beta.13"
ssowat_version="dev-0.1.0-beta.13"
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
# $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() {
# 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 )
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'"
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
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';"
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
#=================================================
2019-08-24 12:54:18 +02:00
# See ynh_* scripts