From a0d4407fdb999a4b6cfa421597cdbb3cce68549e Mon Sep 17 00:00:00 2001 From: ljf Date: Sun, 16 Aug 2020 12:13:44 +0200 Subject: [PATCH] [fix] Db installation --- manifest.json | 10 +++++++++ scripts/backup | 6 ++++++ scripts/install | 57 +++++++++++++++++++++++++++---------------------- scripts/remove | 10 +++++++++ 4 files changed, 57 insertions(+), 26 deletions(-) diff --git a/manifest.json b/manifest.json index 7357b20..343f40f 100644 --- a/manifest.json +++ b/manifest.json @@ -51,6 +51,16 @@ }, "example": "Choose a password" }, + { + "name": "language", + "type": "string", + "ask": { + "en": "Choose the application language", + "fr": "Choisissez la langue de l'application" + }, + "choices": ["fr", "en"], + "default": "en" + }, { "name": "is_public", "ask": { diff --git a/scripts/backup b/scripts/backup index a3dffc5..96a1261 100644 --- a/scripts/backup +++ b/scripts/backup @@ -56,6 +56,12 @@ ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" #================================================= # SPECIFIC BACKUP +#================================================= +# BACKUP A CRON FILE +#================================================= + +ynh_backup --src_path="/etc/cron.d/$app" + #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= diff --git a/scripts/install b/scripts/install index 793b9f3..baeb14d 100644 --- a/scripts/install +++ b/scripts/install @@ -26,6 +26,7 @@ domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC password=$YNH_APP_ARG_PASSWORD +language=$YNH_APP_ARG_LANGUAGE app=$YNH_APP_INSTANCE_NAME @@ -49,6 +50,7 @@ ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=password --value=$password ynh_app_setting_set --app=$app --key=is_public --value=$is_public +ynh_app_setting_set --app=$app --key=language --value=$language #================================================= # STANDARD MODIFICATIONS @@ -134,14 +136,6 @@ ynh_install_composer --phpversion="$phpversion" --workdir="$final_path/.composer export PATH="$final_path/.composer/vendor/bin:$PATH" -#================================================= -# INITIALIZE POSTGRESQL DATABASE -#================================================= -ynh_script_progression --message="Initializing PostgreSQL database..." --weight=8 - -ynh_replace_string --match_string="betaforms" --replace_string="$db_user" --target_file="$final_path/framaforms.sql" -ynh_psql_execute_file_as_root --file="$final_path/framaforms.sql" --database="$db_name" - #================================================= # INITIALIZE TMP AND PRIVATE DIRECTORY #================================================= @@ -182,30 +176,31 @@ ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" #================================================= # CHANGE ADMIN PASSWORD AND APPLY CUSTOM CONF #================================================= -ynh_script_progression --message="Changing admin password..." --weight=19 +ynh_script_progression --message="Installing database..." --weight=19 chown -R $app: $final_path -update-alternatives --set php /usr/bin/php7.3 - -ynh_exec_as $app env PATH=$PATH drush @$app user-password "admin" --password="$password" 2>&1 -ynh_exec_as $app env PATH=$PATH drush @$app variable-set site_name "Framaforms" 2>&1 -ynh_exec_as $app env PATH=$PATH drush @$app variable-set site_mail "no-reply@$domain" 2>&1 +update-alternatives --set php /usr/bin/php$phpversion +ynh_exec_as $app env PATH=$PATH drush @$app site-install framaforms_org install_configure_form.site_contact_url="https://forum.yunohost.org/t/framaforms-create-polls-using-drag-and-drop/8208" install_configure_form.site_default_country=FR -y --locale="$language" --account-name="admin" --account-pass="$password" --site-name="Framaforms" --site-mail="no-reply@$domain" 2>&1 ynh_exec_as $app env PATH=$PATH drush @$app variable-set file_private_path "/home/yunohost.app/$app/data" 2>&1 - +ynh_exec_as $app env PATH=$PATH drush @$app pm-enable framaforms_feature -y --resolve-dependencies 2>&1 +ynh_exec_as $app env PATH=$PATH drush @$app php-eval "module_load_include('inc', 'framaforms', 'includes/framaforms.pages');create_all_pages();" 2>&1 || true +sudo -u $app env PATH=$PATH drush @$app pm-download -y drush_language +#sudo -u $app env PATH=$PATH drush @$app pm-download ldap +#sudo -u $app env PATH=$PATH drush @$app pm-enable -y ldap_servers ldap_user ldap_authentication ldap_authorization ldap_authorization_drupal_role +sudo -u $app env PATH=$PATH drush @$app pm-download -y l10n_update +sudo -u $app env PATH=$PATH drush @$app pm-enable -y l10n_update +sudo -u $app env PATH=$PATH drush @$app language-add $language -y +sudo -u $app env PATH=$PATH drush @$app language-default $language -y +sudo -u $app env PATH=$PATH drush @$app cache-clear drush -y +sudo -u $app env PATH=$PATH drush @$app l10n-update-refresh -y +sudo -u $app env PATH=$PATH drush @$app l10n-update -y +sudo -u $app env PATH=$PATH drush @$app pm-update -y || true +sudo -u $app env PATH=$PATH drush @$app core-cron -y || true # Remove some Framasoft branding -ynh_exec_as $app env PATH=$PATH drush @$app sql-query "UPDATE block_custom SET body='' WHERE bid=12" 2>&1 +#ynh_exec_as $app env PATH=$PATH drush @$app sql-query "UPDATE block_custom SET body='' WHERE bid=12" 2>&1 -# Fix some link if install on subpath -ynh_exec_as $app env PATH=$PATH drush @$app sql-query "UPDATE block_custom SET body=REPLACE(body, 'href=\"/', 'href=\"')" 2>&1 -ynh_exec_as $app env PATH=$PATH drush @$app sql-query "UPDATE field_data_body SET body_value=REPLACE(body_value, 'src=\"/', 'src=\"')" 2>&1 -ynh_exec_as $app env PATH=$PATH drush @$app sql-query "UPDATE field_data_body SET body_value=REPLACE(body_value, 'href=\"/', 'href=\"')" 2>&1 -ynh_exec_as $app env PATH=$PATH drush @$app cache-clear all 2>&1 -#ynh_exec_as $app env PATH=$PATH drush @$app pm-download ldap -#ynh_exec_as $app env PATH=$PATH drush @$app pm-enable -y ldap_servers ldap_user ldap_authentication ldap_authorization ldap_authorization_drupal_role -#ynh_exec_as $app env PATH=$PATH drush @$app core-cron - -update-alternatives --set php /usr/bin/php7.0 +update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION} #================================================= # STORE THE CONFIG FILE CHECKSUM @@ -215,6 +210,16 @@ ynh_script_progression --message="Storing the config file checksum..." --weight= # Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$config_file" +#================================================= +# SETUP THE CRON FILE +#================================================= +ynh_script_progression --message="Setuping the cron file..." + +cp ../conf/cron /etc/cron.d/$app + +ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="/etc/cron.d/$app" +ynh_replace_string --match_string="__APP__" --replace_string="$app" --target_file="/etc/cron.d/$app" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/remove b/scripts/remove index 0317ca6..bc8e4ad 100644 --- a/scripts/remove +++ b/scripts/remove @@ -63,6 +63,16 @@ ynh_script_progression --message="Removing php-fpm configuration..." --weight=1 # Remove the dedicated php-fpm config ynh_remove_fpm_config +#================================================= +# SPECIFIC REMOVE +#================================================= +# REMOVE THE CRON FILE +#================================================= +ynh_script_progression --message="Removing the cron file..." + +# Remove a cron file +ynh_secure_remove --file="/etc/cron.d/$app" + #================================================= # GENERIC FINALIZATION #=================================================