diff --git a/manifest.json b/manifest.json index fbbe9f5..d3b06e7 100644 --- a/manifest.json +++ b/manifest.json @@ -1,83 +1,92 @@ { - "name": "Flarum", - "id": "flarum", - "packaging_format": 1, - "description": { - "en": "Flarum (open-source forum software) package for YunoHost.", - "fr": "Package Flarum (système de forum libre) pour YunoHost.", - "de": "Flarum (Open Source) ist ein Programmpaket für Yunohost." - }, - "url": "http://flarum.org/", - "license": "MIT", - "version": "0.1.0-beta.7", - "maintainer": { - "name": "Titus PiJean", - "email": "tituspijean@outlook.com" - }, - "requirements": { - "yunohost": ">= 2.4.0" - }, - "multi_instance": true, - "services": [ - "nginx", - "php5-fpm", - "mysql" - ], - "arguments": { - "install" : [ - { - "name": "domain", - "type": "domain", - "ask": { - "en": "Choose a domain name for Flarum", - "fr": "Choisissez un nom de domaine pour Flarum", - "de": "Wählen einen Domain-Namen für Flarum" - }, - "example": "example.com" - }, - { - "name": "path", - "type": "path", - "ask": { - "en": "Choose a path for Flarum", - "fr": "Choisissez un chemin pour Flarum", - "de": "Wählen einen Pfad für Flarum" - }, - "example": "/flarum", - "default": "/flarum" - }, - { - "name": "admin", - "type": "user", - "ask": { - "en": "Choose the admin user (required for automatic post-installation)", - "fr": "Choisissez l’administrateur (nécessaire pour la post-installation automatique)", - "de": "Wählen einen Administrator (erforderlich für die automatische Nachinstallation)" - }, - "example": "johndoe", - "optional": true - }, - { - "name": "title", - "ask": { - "en": "Choose a title for your forum (required for automatic post-installation)", - "fr": "Choisissez un titre pour votre forum (nécessaire pour la post-installation automatique)", - "de": "Wählen einen Titel für eure Internetforum (erforderlich für die automatische Nachinstallation)" - }, - "example": "My forum", - "default": "", - "optional": true - }, - { - "name": "is_public", - "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?", - "de": "Ist es eine öffentliche Applikation ?" - }, - "default": true - } - ] - } -} + "name": "Flarum", + "id": "flarum", + "packaging_format": 1, + "description": { + "en": "Flarum (open-source forum software) package for YunoHost.", + "fr": "Package Flarum (système de forum libre) pour YunoHost.", + "de": "Flarum (Open Source) ist ein Programmpaket für Yunohost." + }, + "url": "http://flarum.org/", + "license": "MIT", + "version": "0.1.0-beta.7", + "maintainer": { + "name": "Titus PiJean", + "email": "tituspijean@outlook.com" + }, + "requirements": { + "yunohost": ">= 2.4.0" + }, + "multi_instance": true, + "services": [ + "nginx", + "php5-fpm", + "mysql" + ], + "arguments": { + "install": [{ + "name": "domain", + "type": "domain", + "ask": { + "en": "Choose a domain name for Flarum", + "fr": "Choisissez un nom de domaine pour Flarum", + "de": "Wählen einen Domain-Namen für Flarum" + }, + "example": "example.com" + }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for Flarum", + "fr": "Choisissez un chemin pour Flarum", + "de": "Wählen einen Pfad für Flarum" + }, + "example": "/flarum", + "default": "/flarum" + }, + { + "name": "admin", + "type": "user", + "ask": { + "en": "Choose the admin user (required for automatic post-installation)", + "fr": "Choisissez l’administrateur (nécessaire pour la post-installation automatique)", + "de": "Wählen einen Administrator (erforderlich für die automatische Nachinstallation)" + }, + "example": "johndoe", + "optional": true + }, + { + "name": "title", + "ask": { + "en": "Choose a title for your forum (required for automatic post-installation)", + "fr": "Choisissez un titre pour votre forum (nécessaire pour la post-installation automatique)", + "de": "Wählen einen Titel für eure Internetforum (erforderlich für die automatische Nachinstallation)" + }, + "example": "My forum", + "default": "", + "optional": true + }, + { + "name": "is_public", + "type": "boolean", + "ask": { + "en": "Is it a public application?", + "fr": "Est-ce une application publique ?", + "de": "Ist es eine öffentliche Applikation ?" + }, + "default": true + }, + { + "name": "language", + "ask": { + "en": "Choose the application language", + "fr": "Choisissez la langue de l'application", + "de": "Wählen Sie eine Sprache" + }, + "choices": ["fr", "en", "de"], + "default": "en" + } + ] + } +} \ No newline at end of file diff --git a/scripts/_common.sh b/scripts/_common.sh index cd38698..553c49a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -47,6 +47,35 @@ init_composer() { # || ynh_die "Unable to update core dependencies with Composer" } +# Install and initialize Composer in the given directory +# usage: init_composer destdir +install_and_activate_extension() { + local AS_USER=$1 + local WORKDIR=$2 + local DB_NAME=$3 + local EXTENSION=$4 + local SHORT_EXTENSION=$5 + local sql_command + local old_extensions_enabled + local addition + local new_extensions_enabled + + # Install extension + exec_composer $AS_USER $WORKDIR "require $EXTENSION --ansi" + + # Retrieve current extensions + sql_command="SELECT \`value\` FROM settings WHERE \`key\` = 'extensions_enabled'" + old_extensions_enabled=$(ynh_mysql_execute_as_root "$sql_command" $db_name | tail -1) + + # Append the extension name at the end of the list + addition=",\"${SHORT_EXTENSION}\"]" + 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" $DB_NAME + +} + # Send an email to inform the administrator # # usage: ynh_send_readme_to_admin app_message [recipients] diff --git a/scripts/install b/scripts/install index e56e205..4e25d76 100644 --- a/scripts/install +++ b/scripts/install @@ -39,6 +39,7 @@ path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN title=$YNH_APP_ARG_TITLE is_public=$YNH_APP_ARG_IS_PUBLIC +language=$YNH_APP_ARG_LANGUAGE flarum_version="v0.1.0-beta.7" #=================================================== @@ -66,6 +67,7 @@ ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url ynh_app_setting_set $app admin $admin ynh_app_setting_set $app is_public $is_public +ynh_app_setting_set $app language $language ynh_app_setting_set $app final_path $final_path ynh_app_setting_set $app flarum_version $flarum_version @@ -200,23 +202,26 @@ if [[ -n $admin && -n $title ]]; then ('mail_port', '587');" ynh_mysql_execute_as_root "$sql_command" $db_name - # Install the SSOwat auth extension - exec_composer $app $final_path "require tituspijean/flarum-ext-auth-ssowat:0.4.x-dev --ansi" - + # Install and active the SSOwat auth extension + install_and_activate_extension $app $final_path $db_name "tituspijean/flarum-ext-auth-ssowat:0.4.x-dev" "tituspijean-auth-ssowat" # Configure SSOwat auth extension ssowatdomain=$(