1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/civicrm_drupal7_ynh.git synced 2024-09-03 18:16:19 +02:00
civicrm_drupal7_ynh/scripts/install
2024-02-01 22:16:33 +01:00

114 lines
4.5 KiB
Bash

#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# INITIALIZE AND STORE SETTINGS
#=================================================
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
#=================================================
# CREATE FINAL PATH
#=================================================
ynh_script_progression --message="Creating final path..."
mkdir -p "$install_dir/$app/sites/all/modules"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
#=================================================
# SPECIFIC SETUP
#=================================================
# CREATE DRUSH ALIAS
#=================================================
ynh_script_progression --message="Creating Drush alias..."
mkdir -p "$install_dir/.drush"
ynh_add_config --template="yoursite.aliases.drushrc.php" --destination="$install_dir/.drush/$app.aliases.drushrc.php"
#=================================================
# INSTALL COMPOSER
#=================================================
ynh_script_progression --message="Installing Composer..."
mkdir -p "$install_dir/.composer"
ynh_add_config --template="composer.json" --destination="$install_dir/.composer/composer.json"
ynh_install_composer --workdir="$install_dir/.composer"
export PATH="$install_dir/.composer/vendor/bin:$PATH"
#=================================================
# INSTALL DRUPAL AND CIVICRM
#=================================================
ynh_script_progression --message="Installing Drupal and CiviCRM..."
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
pushd "$install_dir"
_ynh_exec_with_drush_php drush pm-download -y drupal-7 --drupal-project-rename="$app"
_ynh_exec_with_drush_php 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_with_drush_php drush "@$app" pm-download drush_language
# _ynh_exec_with_drush_php drush "@$app" pm-download ldap
# _ynh_exec_with_drush_php drush "@$app" pm-enable -y ldap_servers ldap_user ldap_authentication ldap_authorization ldap_authorization_drupal_role
_ynh_exec_with_drush_php drush "@$app" pm-download l10n_update
_ynh_exec_with_drush_php drush "@$app" pm-enable -y l10n_update
_ynh_exec_with_drush_php drush "@$app" language-add "$language"
_ynh_exec_with_drush_php drush "@$app" language-default "$language"
_ynh_exec_with_drush_php drush "@$app" cache-clear drush
_ynh_exec_with_drush_php drush "@$app" l10n-update-refresh
_ynh_exec_with_drush_php drush "@$app" l10n-update
_ynh_exec_with_drush_php drush "@$app" pm-update
_ynh_exec_with_drush_php drush "@$app" core-cron
ynh_setup_source --dest_dir="$install_dir/$app/sites/all/modules/civicrm" --source_id="civicrm-drupal"
ynh_setup_source --dest_dir="$install_dir/$app/sites/all/modules/civicrm" --source_id="civicrm-l10n"
touch "$install_dir/$app/sites/default/civicrm.settings.php"
chmod 750 "$install_dir"
chmod -R o-rwx "$install_dir"
chown -R "$app:www-data" "$install_dir"
_ynh_exec_with_drush_php drush --include="$install_dir/$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" --ssl=on
popd
ynh_store_file_checksum --file="$install_dir/$app/sites/default/settings.php"
ynh_store_file_checksum --file="$install_dir/$app/sites/default/civicrm.settings.php"
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
# Create a dedicated NGINX config
ynh_add_nginx_config
# Create a Cron job
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed"