From ce0abafcbad26c9c01112a6044eadf9bc834e6bf Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 01:26:34 +0200 Subject: [PATCH 1/8] Apply example_ynh --- README.md | 4 ++-- README_fr.md | 4 ++-- check_process | 4 ++++ manifest.json | 22 +------------------- scripts/backup | 2 +- scripts/change_url | 20 +++++++++--------- scripts/install | 52 +++++++++++++++++++++------------------------- scripts/remove | 8 +++---- scripts/restore | 26 ++++++++++------------- scripts/upgrade | 36 +++++++++++++------------------- 10 files changed, 73 insertions(+), 105 deletions(-) diff --git a/README.md b/README.md index 7910716..3d8d8be 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ LDAP module can be installed #### Supported architectures -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/civicrm_drupal7%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/civicrm_drupal7/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/civicrm_drupal7%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/civicrm_drupal7/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/civicrm_drupal7.svg)](https://ci-apps.yunohost.org/ci/apps/civicrm_drupal7/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/civicrm_drupal7.svg)](https://ci-apps-arm.yunohost.org/ci/apps/civicrm_drupal7/) ## Links diff --git a/README_fr.md b/README_fr.md index 6522a17..e40054a 100644 --- a/README_fr.md +++ b/README_fr.md @@ -29,8 +29,8 @@ Le module d'authentification LDAP peut être installé #### Architectures supportées -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/civicrm_drupal7%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/civicrm_drupal7/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/civicrm_drupal7%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/civicrm_drupal7/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/civicrm_drupal7.svg)](https://ci-apps.yunohost.org/ci/apps/civicrm_drupal7/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/civicrm_drupal7.svg)](https://ci-apps-arm.yunohost.org/ci/apps/civicrm_drupal7/) ## Liens diff --git a/check_process b/check_process index 962a7b4..ac4c2b5 100644 --- a/check_process +++ b/check_process @@ -19,6 +19,8 @@ upgrade=1 from_commit=b90ed18d3309d1124171a02934c4d0ae9b53a087 # 5.30.1-7.0~ynh1 upgrade=1 from_commit=a9d902b58a2114d6983fe84c3c0d3f6371335287 + # 5.34.0-7.0~ynh1 + upgrade=1 from_commit=df23950de037d65d55c4d3d8fef7eb651c02b7ba backup_restore=1 multi_instance=1 port_already_use=0 @@ -31,3 +33,5 @@ Notification=all name=5.13.4-7.0~ynh1 ; commit=a9d902b58a2114d6983fe84c3c0d3f6371335287 name=5.30.1-7.0~ynh1 + ; commit=df23950de037d65d55c4d3d8fef7eb651c02b7ba + name=5.34.0-7.0~ynh1 diff --git a/manifest.json b/manifest.json index f32d185..a0e6884 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "CRM for non-profits, NGOs and advocacy organizations.", "fr": "CRM pour organisations à but non lucratif et ONG." }, - "version": "5.34.0-7.0~ynh1", + "version": "5.34.0-7.0~ynh2", "url": "https://civicrm.org", "license": "AGPL-3.0-or-later", "maintainer": { @@ -26,38 +26,22 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain name for Drupal 7", - "fr": "Choisissez un nom de domaine pour Drupal 7" - }, "example": "example.com" }, { "name": "path", "type": "path", - "ask": { - "en": "Choose a path for Drupal 7", - "fr": "Choisissez un chemin pour Drupal 7" - }, "example": "/drupal7", "default": "/drupal7" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose an admin user", - "fr": "Choisissez l'administrateur" - }, "example": "johndoe" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, "default": true }, { @@ -73,10 +57,6 @@ { "name": "password", "type": "password", - "ask": { - "en": "Set the administrator password", - "fr": "Définissez le mot de passe administrateur" - }, "example": "Choose a password" }, { diff --git a/scripts/backup b/scripts/backup index 73cf595..c4314ac 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers diff --git a/scripts/change_url b/scripts/change_url index 3ecc370..4abd700 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -35,9 +35,9 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its url (may take a while)..." +ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -45,7 +45,7 @@ ynh_clean_setup () { # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -72,23 +72,23 @@ fi #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating nginx web server configuration..." +ynh_script_progression --message="Updating NGINX web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf -# Change the path in the nginx config file +# Change the path in the NGINX config file if [ $change_path -eq 1 ] then - # Make a backup of the original nginx config file if modified + # Make a backup of the original NGINX config file if modified ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for nginx helper + # Set global variables for NGINX helper domain="$old_domain" path_url="$new_path" - # Create a dedicated nginx config + # Create a dedicated NGINX config ynh_add_nginx_config fi -# Change the domain for nginx +# Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location @@ -114,7 +114,7 @@ ynh_add_config --template="../conf/yoursite.aliases.drushrc.php" --destination=" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/install b/scripts/install index 80ffac9..c2b3ac1 100644 --- a/scripts/install +++ b/scripts/install @@ -66,6 +66,14 @@ ynh_script_progression --message="Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # CREATE A MYSQL DATABASE #================================================= @@ -76,22 +84,6 @@ db_user=$db_name ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring nginx web server..." - -# Create a dedicated nginx config -ynh_add_nginx_config - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # CREATE FINAL PATH #================================================= @@ -100,12 +92,24 @@ ynh_script_progression --message="Creating final path..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path mkdir -p "$final_path/$app" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_script_progression --message="Configuring NGINX web server..." + +# Create a dedicated NGINX config +ynh_add_nginx_config + #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring php-fpm..." +ynh_script_progression --message="Configuring PHP-FPM..." -# Create a dedicated php-fpm config +# Create a dedicated PHP-FPM config ynh_add_fpm_config --package="$extra_php_dependencies" phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) @@ -149,7 +153,7 @@ chown -R $app: $final_path update-alternatives --set php /usr/bin/php$phpversion -pushd "$final_path" +pushd "$final_path" ynh_exec_warn_less sudo -u $app env PATH=$PATH drush pm-download -y drupal-7 --drupal-project-rename=$app popd @@ -194,14 +198,6 @@ ynh_store_file_checksum --file="$final_path/$app/sites/default/settings.php" #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions to app files -chown -R $app: $final_path - #================================================= # SETUP SSOWAT #================================================= @@ -218,7 +214,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/remove b/scripts/remove index 4b9eb04..516968d 100644 --- a/scripts/remove +++ b/scripts/remove @@ -50,17 +50,17 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." +ynh_script_progression --message="Removing NGINX web server configuration..." -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config #================================================= # REMOVE PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Removing php-fpm configuration..." +ynh_script_progression --message="Removing PHP-FPM configuration..." -# Remove the dedicated php-fpm config +# Remove the dedicated PHP-FPM config ynh_remove_fpm_config #================================================= diff --git a/scripts/restore b/scripts/restore index 5888e8e..4c4a581 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers @@ -23,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -49,17 +49,10 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the nginx configuration..." +ynh_script_progression --message="Restoring the NGINX web server configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE THE APP MAIN DIR -#================================================= -ynh_script_progression --message="Restoring the app main directory..." - -ynh_restore_file --origin_path="$final_path" - #================================================= # RECREATE THE DEDICATED USER #================================================= @@ -69,12 +62,15 @@ ynh_script_progression --message="Recreating the dedicated system user..." ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= -# RESTORE USER RIGHTS +# RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring user rights..." +ynh_script_progression --message="Restoring the app main directory..." -# Restore permissions on app files -chown -R $app: $final_path +ynh_restore_file --origin_path="$final_path" + +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" #================================================= # RESTORE THE PHP-FPM CONFIGURATION @@ -118,7 +114,7 @@ ynh_restore_file --origin_path="/etc/cron.d/$app" #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading nginx web server and php-fpm..." +ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." ynh_systemd_action --service_name=php$phpversion-fpm --action=reload ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index c2b38d3..6bb9013 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -52,7 +52,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -60,12 +60,20 @@ ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config #================================================= @@ -75,20 +83,12 @@ ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # PHP-FPM CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading php-fpm configuration..." +ynh_script_progression --message="Upgrading PHP-FPM configuration..." -# Create a dedicated php-fpm config +# Create a dedicated PHP-FPM config ynh_add_fpm_config --package="$extra_php_dependencies" phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) @@ -152,18 +152,10 @@ ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions on app files -chown -R $app: $final_path - #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload From 03053cf8c6765351d3fdcd5e3250d64e0d142c15 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 23:45:42 +0200 Subject: [PATCH 2/8] Apply example_ynh --- scripts/install | 3 +++ scripts/upgrade | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/scripts/install b/scripts/install index c2b3ac1..2e130d0 100644 --- a/scripts/install +++ b/scripts/install @@ -196,6 +196,9 @@ ynh_script_progression --message="Storing the config file checksum..." # Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$final_path/$app/sites/default/settings.php" +chmod 400 "$final_path/$app/sites/default/settings.php" +chown $app:$app "$final_path/$app/sites/default/settings.php" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 6bb9013..2494968 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -135,6 +135,10 @@ ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app variable-set --exact update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION} +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= From 11351017f3568b77238e2e1d657d239fff42f9bc Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 11 Apr 2021 22:42:27 +0200 Subject: [PATCH 3/8] Fix rights --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 2e130d0..1177486 100644 --- a/scripts/install +++ b/scripts/install @@ -94,7 +94,7 @@ mkdir -p "$final_path/$app" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 4c4a581..1853980 100644 --- a/scripts/restore +++ b/scripts/restore @@ -70,7 +70,7 @@ ynh_restore_file --origin_path="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # RESTORE THE PHP-FPM CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 2494968..9154fdb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -137,7 +137,7 @@ update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION} chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # STORE THE CONFIG FILE CHECKSUM From 0c95e118caa01d9b2cf45cdd8ece1a78a3a1f049 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 13 Apr 2021 01:04:08 +0200 Subject: [PATCH 4/8] Fix rights --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 1177486..5a83326 100644 --- a/scripts/install +++ b/scripts/install @@ -94,7 +94,7 @@ mkdir -p "$final_path/$app" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 1853980..89ccc1e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -70,7 +70,7 @@ ynh_restore_file --origin_path="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # RESTORE THE PHP-FPM CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 9154fdb..933fcc5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -137,7 +137,7 @@ update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION} chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # STORE THE CONFIG FILE CHECKSUM From b7f00004e9ad98aad01690b3311372ab7400b415 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 14 Apr 2021 20:00:14 +0200 Subject: [PATCH 5/8] Fix install --- scripts/install | 4 +++- scripts/upgrade | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 5a83326..c57dbd3 100644 --- a/scripts/install +++ b/scripts/install @@ -149,7 +149,9 @@ export PATH="$final_path/.composer/vendor/bin:$PATH" #================================================= ynh_script_progression --message="Installing Drupal and CiviCRM..." -chown -R $app: $final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" update-alternatives --set php /usr/bin/php$phpversion diff --git a/scripts/upgrade b/scripts/upgrade index 933fcc5..357aa7f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -118,6 +118,10 @@ ynh_script_progression --message="Upgrading Drupal..." ynh_backup_if_checksum_is_different --file="$final_path/$app/sites/default/settings.php" export PATH="$final_path/.composer/vendor/bin:$PATH" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + update-alternatives --set php /usr/bin/php$phpversion ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app variable-set --exact maintenance_mode 1 From 1735a1a3ad98ace39bdca0a9b554b0913f8d9748 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 15 Apr 2021 20:24:11 +0200 Subject: [PATCH 6/8] Fix chmod --- scripts/install | 65 +++++++++++++++++++++------------------------ scripts/restore | 14 +++++----- scripts/upgrade | 70 +++++++++++++++++++++++++++++-------------------- 3 files changed, 78 insertions(+), 71 deletions(-) diff --git a/scripts/install b/scripts/install index c57dbd3..497dc7f 100644 --- a/scripts/install +++ b/scripts/install @@ -92,7 +92,7 @@ ynh_script_progression --message="Creating final path..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path mkdir -p "$final_path/$app" -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" @@ -130,6 +130,7 @@ ynh_systemd_action --service_name=mysql --action="restart" ynh_script_progression --message="Creating Drush alias..." mkdir -p "$final_path/.drush" + ynh_add_config --template="../conf/yoursite.aliases.drushrc.php" --destination="$final_path/.drush/$app.aliases.drushrc.php" #================================================= @@ -138,6 +139,7 @@ ynh_add_config --template="../conf/yoursite.aliases.drushrc.php" --destination=" ynh_script_progression --message="Installing Composer..." mkdir -p "$final_path/.composer" + ynh_add_config --template="../conf/composer.json" --destination="$final_path/.composer/composer.json" ynh_install_composer --phpversion="$phpversion" --workdir="$final_path/.composer" @@ -149,7 +151,7 @@ export PATH="$final_path/.composer/vendor/bin:$PATH" #================================================= ynh_script_progression --message="Installing Drupal and CiviCRM..." -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" @@ -157,32 +159,36 @@ update-alternatives --set php /usr/bin/php$phpversion pushd "$final_path" ynh_exec_warn_less sudo -u $app env PATH=$PATH drush pm-download -y drupal-7 --drupal-project-rename=$app + + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app site-install $install_profil --account-name=$admin --account-pass=$password --account-mail=$admin_mail --db-url=mysql://$db_user:$db_pwd@localhost/$db_name --site-name="$app" --locale=$language --yes + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-download drush_language + #ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-download ldap + #ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-enable -y ldap_servers ldap_user ldap_authentication ldap_authorization ldap_authorization_drupal_role + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-download l10n_update + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-enable -y l10n_update + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app language-add $language + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app language-default $language + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app cache-clear drush + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app l10n-update-refresh + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app l10n-update + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-update + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app core-cron + + ynh_setup_source --dest_dir="$final_path/$app/sites/all/modules/civicrm" --source_id="civicrm-drupal" + ynh_setup_source --dest_dir="$final_path/$app/sites/all/modules/civicrm" --source_id="civicrm-l10n" + + chmod -R 750 "$final_path" + chmod -R o-rwx "$final_path" + chown -R $app:www-data "$final_path" + + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush --include="$final_path/$app/sites/all/modules/civicrm/drupal/drush" @$app civicrm-install --dbhost="localhost" --dbname="$db_name" --dbpass="$db_pwd" --dbuser="$db_user" --destination="sites/all/modules" --site_url="$domain$path_url" --ssl=on popd -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app site-install $install_profil --account-name=$admin --account-pass=$password --account-mail=$admin_mail --db-url=mysql://$db_user:$db_pwd@localhost/$db_name --site-name="$app" --locale=$language --yes -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-download drush_language -#ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-download ldap -#ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-enable -y ldap_servers ldap_user ldap_authentication ldap_authorization ldap_authorization_drupal_role -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-download l10n_update -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-enable -y l10n_update -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app language-add $language -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app language-default $language -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app cache-clear drush -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app l10n-update-refresh -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app l10n-update -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-update -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app core-cron - -ynh_setup_source --dest_dir="$final_path/$app/sites/all/modules/civicrm" --source_id="civicrm-drupal" -ynh_setup_source --dest_dir="$final_path/$app/sites/all/modules/civicrm" --source_id="civicrm-l10n" - -chown -R $app: $final_path -chmod 755 $final_path/$app/sites/default/ - -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush --include="$final_path/$app/sites/all/modules/civicrm/drupal/drush" @$app civicrm-install --dbhost="localhost" --dbname="$db_name" --dbpass="$db_pwd" --dbuser="$db_user" --destination="sites/all/modules" --site_url="$domain$path_url" --ssl=on - update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION} +ynh_store_file_checksum --file="$final_path/$app/sites/default/settings.php" +ynh_store_file_checksum --file="$final_path/$app/sites/default/civicrm.settings.php" + #================================================= # SETUP THE CRON FILE #================================================= @@ -190,17 +196,6 @@ ynh_script_progression --message="Setuping the cron file..." ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= -ynh_script_progression --message="Storing the config file checksum..." - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$final_path/$app/sites/default/settings.php" - -chmod 400 "$final_path/$app/sites/default/settings.php" -chown $app:$app "$final_path/$app/sites/default/settings.php" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 89ccc1e..75a1bc0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -68,7 +68,7 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" @@ -86,6 +86,12 @@ phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) #================================================= # SPECIFIC RESTORATION +#================================================= +# RESTORE THE CRON FILE +#================================================= + +ynh_restore_file --origin_path="/etc/cron.d/$app" + #================================================= # REINSTALL DEPENDENCIES #================================================= @@ -103,12 +109,6 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql -#================================================= -# RESTORE THE CRON FILE -#================================================= - -ynh_restore_file --origin_path="/etc/cron.d/$app" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 357aa7f..3bbe42e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -68,6 +68,19 @@ ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir="$final_path" +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= + +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + mkdir -p "$final_path/$app" +fi + +chmod -R 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -103,6 +116,13 @@ ynh_replace_string --match_string="thread_stack = 128K" --replace_string="thread ynh_systemd_action --service_name=mysql --action="restart" +#================================================= +# SETUP THE CRON FILE +#================================================= +ynh_script_progression --message="Setuping the cron file" + +ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" + #================================================= # UPGRADE COMPOSER #================================================= @@ -110,53 +130,45 @@ ynh_script_progression --message="Upgrading Composer..." ynh_install_composer --phpversion="$phpversion" --workdir="$final_path/.composer" +export PATH="$final_path/.composer/vendor/bin:$PATH" + #================================================= # UPGRADE DRUPAL #================================================= ynh_script_progression --message="Upgrading Drupal..." ynh_backup_if_checksum_is_different --file="$final_path/$app/sites/default/settings.php" -export PATH="$final_path/.composer/vendor/bin:$PATH" +ynh_backup_if_checksum_is_different --file="$final_path/$app/sites/default/civicrm.settings.php" -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" update-alternatives --set php /usr/bin/php$phpversion -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app variable-set --exact maintenance_mode 1 -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app cache-clear all -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-update -y drupal -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app cache-clear all -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app l10n-update-refresh -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app l10n-update +pushd "$final_path" + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app variable-set --exact maintenance_mode 1 + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app cache-clear all + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app pm-update -y drupal + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app cache-clear all + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app l10n-update-refresh + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app l10n-update -ynh_setup_source --dest_dir="$final_path/$app/sites/all/modules/civicrm" --source_id="civicrm-drupal" -ynh_setup_source --dest_dir="$final_path/$app/sites/all/modules/civicrm" --source_id="civicrm-l10n" -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush --include="$final_path/$app/sites/all/modules/civicrm/drupal/drush" @$app -y civicrm-upgrade-db + ynh_setup_source --dest_dir="$final_path/$app/sites/all/modules/civicrm" --source_id="civicrm-drupal" + ynh_setup_source --dest_dir="$final_path/$app/sites/all/modules/civicrm" --source_id="civicrm-l10n" + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush --include="$final_path/$app/sites/all/modules/civicrm/drupal/drush" @$app -y civicrm-upgrade-db -ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app variable-set --exact maintenance_mode 0 + ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app variable-set --exact maintenance_mode 0 + + chmod -R 750 "$final_path" + chmod -R o-rwx "$final_path" + chown -R $app:www-data "$final_path" +popd update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION} -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" - -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= -ynh_script_progression --message="Storing the config file checksum..." - -# Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="$final_path/$app/sites/default/settings.php" - -#================================================= -# SETUP THE CRON FILE -#================================================= -ynh_script_progression --message="Setuping the cron file" - -ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" +ynh_store_file_checksum --file="$final_path/$app/sites/default/civicrm.settings.php" #================================================= # GENERIC FINALIZATION From a41945032bdcb7c355a14bb6a9e382ee7abca97d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 17 Apr 2021 18:30:56 +0200 Subject: [PATCH 7/8] Fix recursive chmod --- scripts/install | 6 +++--- scripts/restore | 2 +- scripts/upgrade | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/install b/scripts/install index 497dc7f..7fee754 100644 --- a/scripts/install +++ b/scripts/install @@ -92,7 +92,7 @@ ynh_script_progression --message="Creating final path..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path mkdir -p "$final_path/$app" -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" @@ -151,7 +151,7 @@ export PATH="$final_path/.composer/vendor/bin:$PATH" #================================================= ynh_script_progression --message="Installing Drupal and CiviCRM..." -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" @@ -177,7 +177,7 @@ pushd "$final_path" ynh_setup_source --dest_dir="$final_path/$app/sites/all/modules/civicrm" --source_id="civicrm-drupal" ynh_setup_source --dest_dir="$final_path/$app/sites/all/modules/civicrm" --source_id="civicrm-l10n" - chmod -R 750 "$final_path" + chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" diff --git a/scripts/restore b/scripts/restore index 75a1bc0..c91e732 100644 --- a/scripts/restore +++ b/scripts/restore @@ -68,7 +68,7 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index 3bbe42e..64a6a6e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -77,7 +77,7 @@ then mkdir -p "$final_path/$app" fi -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" @@ -140,7 +140,7 @@ ynh_script_progression --message="Upgrading Drupal..." ynh_backup_if_checksum_is_different --file="$final_path/$app/sites/default/settings.php" ynh_backup_if_checksum_is_different --file="$final_path/$app/sites/default/civicrm.settings.php" -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" @@ -160,7 +160,7 @@ pushd "$final_path" ynh_exec_warn_less sudo -u $app env PATH=$PATH drush @$app variable-set --exact maintenance_mode 0 - chmod -R 750 "$final_path" + chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path" popd From 07fd6c326fd7e694fb69edbd4cb2a70e5fcc8ed3 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 20 Apr 2021 22:42:06 +0200 Subject: [PATCH 8/8] Fix permission on civicrm.settings.php --- scripts/install | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install b/scripts/install index 7fee754..ecf5b9d 100644 --- a/scripts/install +++ b/scripts/install @@ -177,6 +177,8 @@ pushd "$final_path" ynh_setup_source --dest_dir="$final_path/$app/sites/all/modules/civicrm" --source_id="civicrm-drupal" ynh_setup_source --dest_dir="$final_path/$app/sites/all/modules/civicrm" --source_id="civicrm-l10n" + touch "$final_path/$app/sites/default/civicrm.settings.php" + chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:www-data "$final_path"