2018-04-29 13:00:03 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
2020-03-29 05:02:23 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2018-04-29 13:00:03 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-03-16 13:58:59 +01:00
|
|
|
# INITIALIZE AND STORE SETTINGS
|
2018-04-29 13:00:03 +02:00
|
|
|
#=================================================
|
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
admin_mail=$(ynh_user_get_info --username="$admin" --key="mail")
|
2018-04-29 13:00:03 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
ynh_app_setting_set --app="$app" --key="password" --value="$password"
|
2018-04-29 13:00:03 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2019-06-19 18:03:19 +02:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=9
|
2019-06-14 18:57:58 +02:00
|
|
|
|
2018-04-29 13:00:03 +02:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2024-03-16 13:58:59 +01:00
|
|
|
ynh_setup_source --dest_dir="$install_dir/app"
|
2020-06-03 01:58:54 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
mkdir -p "$install_dir/app/sites/default/files"
|
|
|
|
mkdir -p "$install_dir/app/sites/default/files/tmp"
|
2020-06-03 01:58:54 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
|
|
|
chmod 2775 "$install_dir/app/sites/default/files"
|
2022-07-29 01:12:30 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
chmod -R o-rwx "$data_dir"
|
|
|
|
chown -R "$app:www-data" "$data_dir"
|
2022-07-29 01:12:30 +02:00
|
|
|
|
2019-06-19 02:18:00 +02:00
|
|
|
#=================================================
|
|
|
|
# CREATE DRUSH ALIAS
|
|
|
|
#=================================================
|
2019-06-19 18:03:19 +02:00
|
|
|
ynh_script_progression --message="Creating Drush alias..." --weight=2
|
2019-06-19 02:18:00 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
mkdir -p "$install_dir/.drush"
|
|
|
|
drush_aliasconfig="$install_dir/.drush/$app.aliases.drushrc.php"
|
2021-03-24 12:47:13 +01:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
ynh_add_config --template="yoursite.aliases.drushrc.php" --destination="$drush_aliasconfig"
|
2019-06-19 02:18:00 +02:00
|
|
|
|
2021-05-18 04:25:18 +02:00
|
|
|
chmod 400 "$drush_aliasconfig"
|
2024-03-16 13:58:59 +01:00
|
|
|
chown "$app:$app" "$drush_aliasconfig"
|
2021-05-18 04:25:18 +02:00
|
|
|
|
2019-06-19 02:18:00 +02:00
|
|
|
#=================================================
|
|
|
|
# INSTALL COMPOSER
|
|
|
|
#=================================================
|
2019-06-19 18:03:19 +02:00
|
|
|
ynh_script_progression --message="Installing Composer..." --weight=31
|
2019-06-19 02:18:00 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
mkdir -p "$install_dir/.composer"
|
2019-06-19 02:18:00 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
ynh_add_config --template="composer.json" --destination="$install_dir/.composer/composer.json"
|
2021-05-15 19:19:38 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
ynh_install_composer --phpversion="$phpversion" --workdir="$install_dir/.composer"
|
2021-05-15 19:19:38 +02:00
|
|
|
|
2024-03-16 14:17:25 +01:00
|
|
|
export PATH="$install_dir/.composer/vendor/bin:$PATH"
|
2019-06-19 02:18:00 +02:00
|
|
|
|
2018-05-01 22:36:16 +02:00
|
|
|
#=================================================
|
2021-05-15 19:19:38 +02:00
|
|
|
# ADD A CONFIGURATION
|
2018-05-01 22:36:16 +02:00
|
|
|
#=================================================
|
2024-03-16 13:58:59 +01:00
|
|
|
ynh_script_progression --message="Adding $app's configuration file..." --weight=1
|
2018-05-01 22:36:16 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
ynh_add_config --template="default.settings.php" --destination="$install_dir/app/sites/default/settings.php"
|
2018-05-01 22:36:16 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
chmod 600 "$install_dir/app/sites/default/settings.php"
|
|
|
|
chown "$app:$app" "$install_dir/app/sites/default/settings.php"
|
2019-06-19 02:18:00 +02:00
|
|
|
|
|
|
|
#=================================================
|
2020-09-22 02:05:24 +02:00
|
|
|
# INSTALLING FRAMAFORMS WITH DRUSH
|
2019-06-19 02:18:00 +02:00
|
|
|
#=================================================
|
2020-08-16 12:13:44 +02:00
|
|
|
ynh_script_progression --message="Installing database..." --weight=19
|
2019-06-19 02:18:00 +02:00
|
|
|
|
2024-03-16 14:25:35 +01:00
|
|
|
# Chown from composer/drush install
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
_ynh_exec_with_drush_php 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="$admin_mail" 2>&1
|
|
|
|
_ynh_exec_with_drush_php drush "@$app" variable-set update_notify_emails "$admin_mail"
|
|
|
|
_ynh_exec_with_drush_php drush "@$app" variable-set file_private_path "/home/yunohost.app/$app/data" 2>&1
|
|
|
|
_ynh_exec_with_drush_php drush "@$app" pm-enable framaforms_feature -y --resolve-dependencies 2>&1
|
|
|
|
_ynh_exec_with_drush_php drush "@$app" php-eval "module_load_include('inc', 'framaforms', 'includes/framaforms.pages');create_all_pages();" 2>&1 || true
|
2020-09-22 02:05:24 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# IMPORTING LANGUAGE PACK
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Importing language pack..." --weight=5
|
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
_ynh_exec_with_drush_php drush "@$app" pm-download -y drush_language 2>&1
|
|
|
|
_ynh_exec_with_drush_php drush "@$app" pm-download -y l10n_update 2>&1
|
|
|
|
_ynh_exec_with_drush_php drush "@$app" pm-enable -y l10n_update 2>&1
|
|
|
|
_ynh_exec_with_drush_php drush "@$app" language-add "$language" -y 2>&1
|
|
|
|
_ynh_exec_with_drush_php drush "@$app" language-default "$language" -y 2>&1
|
|
|
|
_ynh_exec_with_drush_php drush "@$app" cache-clear drush -y 2>&1
|
|
|
|
_ynh_exec_with_drush_php drush "@$app" l10n-update-refresh -y 2>&1
|
|
|
|
_ynh_exec_with_drush_php drush "@$app" l10n-update -y 2>&1
|
2020-09-22 02:05:24 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
# We don't upgrade module to avoid to erase framaforms change
|
2020-09-22 02:05:24 +02:00
|
|
|
# in drupal core and modules code
|
|
|
|
# see https://framagit.org/framasoft/framaforms/-/wikis/modifications
|
2024-03-16 13:58:59 +01:00
|
|
|
# _ynh_exec_with_drush_php drush "@$app" pm-update -y
|
2020-09-22 02:05:24 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# REMOVING BRANDING AND CHANGING DEFAULT SETTINGS
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Removing branding and change default settings..." --weight=1
|
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
_ynh_exec_with_drush_php drush "@$app" vset error_level 0
|
|
|
|
_ynh_exec_with_drush_php drush "@$app" vset framaforms_notification_period_value "$expiration"
|
|
|
|
_ynh_exec_with_drush_php drush "@$app" vset framaforms_deletion_period_value "$deletion"
|
2020-09-22 02:05:24 +02:00
|
|
|
# Remove framaforms footer
|
2024-03-16 13:58:59 +01:00
|
|
|
_ynh_exec_with_drush_php drush "@$app" sql-query "UPDATE block SET region='-1', status=0 WHERE delta='framaforms_footer' AND region='footer'"
|
2020-09-22 02:05:24 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CONFIGURING LDAP
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring LDAP authentication..." --weight=1
|
|
|
|
|
2024-03-16 18:16:16 +01:00
|
|
|
_ynh_exec_with_drush_php drush "@$app" pm-download ldap-7.x-2.6
|
2024-03-16 13:58:59 +01:00
|
|
|
_ynh_exec_with_drush_php drush "@$app" pm-enable -y ldap_servers ldap_user ldap_authentication ldap_authorization ldap_authorization_drupal_role
|
2020-09-22 02:05:24 +02:00
|
|
|
# Generated with sudo -u postgres pg_dump -a -t ldap_servers --inserts framaforms
|
2024-03-18 13:44:22 +01:00
|
|
|
_ynh_exec_with_drush_php drush "@$app" sql-query < ../conf/ldap.sql
|
2024-03-16 13:58:59 +01:00
|
|
|
_ynh_exec_with_drush_php drush "@$app" variable-set --format=yaml ldap_authentication_conf - < ../conf/ldap.conf
|
2020-08-16 12:13:44 +02:00
|
|
|
|
2018-04-29 13:00:03 +02:00
|
|
|
#=================================================
|
2024-03-16 13:58:59 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2018-04-29 13:00:03 +02:00
|
|
|
#=================================================
|
2024-03-16 13:58:59 +01:00
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
2018-04-29 13:00:03 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
# Create a dedicated PHP-FPM config
|
|
|
|
ynh_add_fpm_config --usage=low --footprint=low
|
2021-02-03 21:57:21 +01:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2019-06-14 18:57:58 +02:00
|
|
|
|
2024-03-16 13:58:59 +01:00
|
|
|
ynh_add_config --template="cron" --destination="/etc/cron.d/$app"
|
2019-06-14 18:57:58 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2018-04-29 13:00:03 +02:00
|
|
|
|
2019-06-19 18:03:19 +02:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|