mirror of
https://github.com/YunoHost-Apps/framaforms_ynh.git
synced 2024-09-03 18:36:12 +02:00
173 lines
8.6 KiB
Bash
173 lines
8.6 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Setting up source files..." --weight=9
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
ynh_setup_source --dest_dir="$install_dir/app"
|
|
|
|
chmod 750 "$install_dir"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:www-data "$install_dir"
|
|
|
|
#=================================================
|
|
# PHP-FPM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
|
|
|
|
# Create a dedicated PHP-FPM config
|
|
ynh_add_fpm_config
|
|
|
|
#=================================================
|
|
# NGINX CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring NGINX web server..." --weight=1
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
#=================================================
|
|
# SPECIFIC SETUP
|
|
#=================================================
|
|
# CREATE DRUSH ALIAS
|
|
#=================================================
|
|
ynh_script_progression --message="Creating Drush alias..." --weight=2
|
|
|
|
mkdir -p "$install_dir/.drush"
|
|
drush_aliasconfig="$install_dir/.drush/$app.aliases.drushrc.php"
|
|
|
|
ynh_add_config --template="../conf/yoursite.aliases.drushrc.php" --destination="$drush_aliasconfig"
|
|
|
|
chmod 400 "$drush_aliasconfig"
|
|
chown $app:$app "$drush_aliasconfig"
|
|
|
|
#=================================================
|
|
# INSTALL COMPOSER
|
|
#=================================================
|
|
ynh_script_progression --message="Installing Composer..." --weight=31
|
|
|
|
mkdir -p "$install_dir/.composer"
|
|
|
|
ynh_add_config --template="../conf/composer.json" --destination="$install_dir/.composer/composer.json"
|
|
|
|
ynh_install_composer --phpversion="$phpversion" --workdir="$install_dir/.composer"
|
|
|
|
export PATH="$install_dir/.composer/vendor/bin:$PATH"
|
|
|
|
#=================================================
|
|
# INITIALIZE TMP AND PRIVATE DIRECTORY
|
|
#=================================================
|
|
ynh_script_progression --message="Initializing tmp and private directory..." --weight=1
|
|
|
|
mkdir -p "$install_dir/app/sites/default/files"
|
|
mkdir -p "$install_dir/app/sites/default/files/tmp"
|
|
|
|
chmod 750 "$install_dir"
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R $app:www-data "$install_dir"
|
|
chmod 2775 "$install_dir/app/sites/default/files"
|
|
|
|
#=================================================
|
|
# CREATE DATA DIRECTORY
|
|
#=================================================
|
|
ynh_script_progression --message="Creating a data directory..."
|
|
|
|
mkdir -p $data_dir
|
|
|
|
chmod 750 "$data_dir"
|
|
chmod -R o-rwx "$data_dir"
|
|
chown -R $app:www-data "$data_dir"
|
|
|
|
#=================================================
|
|
# ADD A CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Adding a configuration file..." --weight=1
|
|
|
|
ynh_add_config --template="../conf/default.settings.php" --destination="$install_dir/app/sites/default/settings.php"
|
|
|
|
chmod 600 "$install_dir/app/sites/default/settings.php"
|
|
chown $app:$app "$install_dir/app/sites/default/settings.php"
|
|
|
|
#=================================================
|
|
# INSTALLING FRAMAFORMS WITH DRUSH
|
|
#=================================================
|
|
ynh_script_progression --message="Installing database..." --weight=19
|
|
|
|
update-alternatives --set php /usr/bin/php$phpversion
|
|
ynh_exec_as $app env PATH=$PATH 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_as $app env PATH=$PATH drush @$app variable-set update_notify_emails "$admin_mail"
|
|
ynh_exec_as $app env PATH=$PATH drush @$app variable-set file_private_path "/home/yunohost.app/$app/data" 2>&1
|
|
ynh_exec_as $app env PATH=$PATH drush @$app pm-enable framaforms_feature -y --resolve-dependencies 2>&1
|
|
ynh_exec_as $app env PATH=$PATH drush @$app php-eval "module_load_include('inc', 'framaforms', 'includes/framaforms.pages');create_all_pages();" 2>&1 || true
|
|
|
|
#=================================================
|
|
# IMPORTING LANGUAGE PACK
|
|
#=================================================
|
|
ynh_script_progression --message="Importing language pack..." --weight=5
|
|
|
|
ynh_exec_as $app env PATH=$PATH drush @$app pm-download -y drush_language 2>&1
|
|
ynh_exec_as $app env PATH=$PATH drush @$app pm-download -y l10n_update 2>&1
|
|
ynh_exec_as $app env PATH=$PATH drush @$app pm-enable -y l10n_update 2>&1
|
|
ynh_exec_as $app env PATH=$PATH drush @$app language-add $language -y 2>&1
|
|
ynh_exec_as $app env PATH=$PATH drush @$app language-default $language -y 2>&1
|
|
ynh_exec_as $app env PATH=$PATH drush @$app cache-clear drush -y 2>&1
|
|
ynh_exec_as $app env PATH=$PATH drush @$app l10n-update-refresh -y 2>&1
|
|
ynh_exec_as $app env PATH=$PATH drush @$app l10n-update -y 2>&1
|
|
|
|
# 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_as $app env PATH=$PATH drush @$app pm-update -y
|
|
|
|
#=================================================
|
|
# REMOVING BRANDING AND CHANGING DEFAULT SETTINGS
|
|
#=================================================
|
|
ynh_script_progression --message="Removing branding and change default settings..." --weight=1
|
|
|
|
ynh_exec_as $app env PATH=$PATH drush @$app vset error_level 0
|
|
ynh_exec_as $app env PATH=$PATH drush @$app vset framaforms_notification_period_value $expiration
|
|
ynh_exec_as $app env PATH=$PATH drush @$app vset framaforms_deletion_period_value $deletion
|
|
# Remove framaforms footer
|
|
ynh_exec_as $app env PATH=$PATH drush @$app sql-query "UPDATE block SET region='-1', status=0 WHERE delta='framaforms_footer' AND region='footer'"
|
|
|
|
#=================================================
|
|
# CONFIGURING LDAP
|
|
#=================================================
|
|
ynh_script_progression --message="Configuring LDAP authentication..." --weight=1
|
|
|
|
ynh_exec_as $app env PATH=$PATH drush @$app pm-download ldap
|
|
ynh_exec_as $app env PATH=$PATH 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_as $app env PATH=$PATH drush @$app sql-query "INSERT INTO public.ldap_servers VALUES ('localhost', 1, 'localhost', 1, 'default', 'ldap://127.0.0.1', 389, 0, 0, 3, '', NULL, 'a:2:{i:0;s:27:\"ou=users,dc=yunohost,dc=org\";i:1;s:32:\"ou=permission,dc=yunohost,dc=org\";}', 'uid', 'uid', 'mail', '', '', '', 0, 'cn=%username,ou=users,dc=yunohost,dc=org', '', '', '', 0, 'permissionynh', 0, 1, 'permission', 'memberuid', 'dn', 0, '', '$app.main', '', 0, 1000, 0);"
|
|
ynh_exec_as $app env PATH=$PATH drush @$app sql-query "INSERT INTO public.ldap_authorization VALUES (1, 'localhost', 'drupal_role', 'ldap_authorization_drupal_role', 1, 1, 0, 'a:2:{i:0;a:6:{s:12:\"user_entered\";s:24:\"utilisateur authentifié\";s:4:\"from\";s:51:\"cn=$app.main,ou=permission,dc=yunohost,dc=org\";s:10:\"normalized\";s:24:\"utilisateur authentifié\";s:10:\"simplified\";s:24:\"utilisateur authentifié\";s:5:\"valid\";b:0;s:13:\"error_message\";s:112:\"Role <em class=\"placeholder\">utilisateur authentifié</em>_name does not exist and role creation is not enabled.\";}i:1;a:6:{s:12:\"user_entered\";s:13:\"administrator\";s:4:\"from\";s:52:\"cn=$app.admin,ou=permission,dc=yunohost,dc=org\";s:10:\"normalized\";s:13:\"administrator\";s:10:\"simplified\";s:13:\"administrator\";s:5:\"valid\";b:0;s:13:\"error_message\";s:101:\"Role <em class=\"placeholder\">administrator</em>_name does not exist and role creation is not enabled.\";}}', 1, 0, 1, 1, 1, 1);"
|
|
|
|
cat ../conf/ldap.conf | ynh_exec_as $app env PATH=$PATH drush @$app variable-set --format=yaml ldap_authentication_conf -
|
|
|
|
update-alternatives --set php /usr/bin/php${YNH_DEFAULT_PHP_VERSION}
|
|
|
|
#=================================================
|
|
# SETUP THE CRON FILE
|
|
#=================================================
|
|
ynh_script_progression --message="Setuping the cron file..."
|
|
|
|
ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app"
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|