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