1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/framaforms_ynh.git synced 2024-09-03 18:36:12 +02:00
framaforms_ynh/scripts/install

145 lines
6.9 KiB
Bash

#!/bin/bash
#=================================================
# 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")
ynh_app_setting_set --key="password" --value="$password"
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression "Setting up source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir/app"
mkdir -p "$install_dir/app/sites/default/files"
mkdir -p "$install_dir/app/sites/default/files/tmp"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
chmod 2775 "$install_dir/app/sites/default/files"
chmod -R o-rwx "$data_dir"
chown -R "$app:www-data" "$data_dir"
#=================================================
# CREATE DRUSH ALIAS
#=================================================
ynh_script_progression "Creating Drush alias..."
mkdir -p "$install_dir/.drush"
drush_aliasconfig="$install_dir/.drush/$app.aliases.drushrc.php"
ynh_config_add --template="yoursite.aliases.drushrc.php" --destination="$drush_aliasconfig"
chmod 400 "$drush_aliasconfig"
chown "$app:$app" "$drush_aliasconfig"
#=================================================
# INSTALL COMPOSER
#=================================================
ynh_script_progression "Installing Composer..."
mkdir -p "$install_dir/.composer"
ynh_config_add --template="composer.json" --destination="$install_dir/.composer/composer.json"
ynh_composer_install
ynh_composer_exec install --no-dev # FIXMEhelpers2.1 (replace with composer_workdir=... prior to calling this helper, default is $intall_dir) --workdir="$install_dir/.composer"
#=================================================
# ADD A CONFIGURATION
#=================================================
ynh_script_progression "Adding $app's configuration file..."
ynh_config_add --template="default.settings.php" --destination="$install_dir/app/sites/default/settings.php"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 600 "$install_dir/app/sites/default/settings.php"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown "$app:$app" "$install_dir/app/sites/default/settings.php"
#=================================================
# INSTALLING FRAMAFORMS WITH DRUSH
#=================================================
ynh_script_progression "Installing database..."
# Chown from composer/drush install
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
_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"
_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"
_ynh_exec_with_drush_php drush "@$app" pm-enable framaforms_feature -y --resolve-dependencies
_ynh_exec_with_drush_php drush "@$app" php-eval "module_load_include('inc', 'framaforms', 'includes/framaforms.pages');create_all_pages();" || true
#=================================================
# IMPORTING LANGUAGE PACK
#=================================================
ynh_script_progression "Importing language pack..."
_ynh_exec_with_drush_php drush "@$app" pm-download -y drush_language
_ynh_exec_with_drush_php drush "@$app" pm-download -y l10n_update
_ynh_exec_with_drush_php drush "@$app" pm-enable -y l10n_update
_ynh_exec_with_drush_php drush "@$app" language-add "$language" -y
_ynh_exec_with_drush_php drush "@$app" language-default "$language" -y
_ynh_exec_with_drush_php drush "@$app" cache-clear drush -y
_ynh_exec_with_drush_php drush "@$app" l10n-update-refresh -y
_ynh_exec_with_drush_php drush "@$app" l10n-update -y
# We don't upgrade module to avoid to erase framaforms change
# in drupal core and modules code
# see https://framagit.org/framasoft/framaforms/-/wikis/modifications
# _ynh_exec_with_drush_php drush "@$app" pm-update -y
#=================================================
# REMOVING BRANDING AND CHANGING DEFAULT SETTINGS
#=================================================
ynh_script_progression "Removing branding and change default settings..."
_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"
# Remove framaforms footer
_ynh_exec_with_drush_php drush "@$app" sql-query "UPDATE block SET region='-1', status=0 WHERE delta='framaforms_footer' AND region='footer'"
#=================================================
# CONFIGURING LDAP
#=================================================
ynh_script_progression "Configuring LDAP authentication..."
_ynh_exec_with_drush_php drush "@$app" pm-download ldap-7.x-2.6
_ynh_exec_with_drush_php drush "@$app" pm-enable -y ldap_servers ldap_user ldap_authentication ldap_authorization ldap_authorization_drupal_role
# Generated with sudo -u postgres pg_dump -a -t ldap_servers --inserts framaforms
_ynh_exec_with_drush_php drush "@$app" sql-query < ../conf/ldap.sql
_ynh_exec_with_drush_php drush "@$app" variable-set --format=yaml ldap_authentication_conf - < ../conf/ldap.conf
#=================================================
# SYSTEM CONFIGURATION
#=================================================
ynh_script_progression "Adding system configurations related to $app..."
# Create a dedicated PHP-FPM config
ynh_config_add_phpfpm
# Create a dedicated NGINX config
ynh_config_add_nginx
ynh_config_add --template="cron" --destination="/etc/cron.d/$app"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression "Installation of $app completed"