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

Improve extension activation commands

This commit is contained in:
tituspijean 2022-12-21 16:55:53 +01:00
parent 89478f48a0
commit 82e6e95c51
No known key found for this signature in database
GPG key ID: EF3B0D7CC0A94720

View file

@ -43,9 +43,10 @@ activate_flarum_extension() {
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" $database | 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 # Use jq to test presence of the extension in the list of enabled extensions
addition=",\"${short_extension}\"]" # if not, then add it.
new_extensions_enabled=${old_extensions_enabled::-1}$addition new_extensions_enabled=$(jq -jrc --arg short_extension 'if (any(index("$short_extension")) | not) then . |= + $short_extension else . end' <<< $old_extensions_enabled)
# 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" $database ynh_mysql_execute_as_root "$sql_command" $database