#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source experimental_helpers/ynh_add_swap source /usr/share/yunohost/helpers #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= core_version=$(ynh_app_upstream_version) admin_mail=$(ynh_user_get_info --username=$admin --key=mail) #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_app_setting_set --app=$app --key=language --value="$language" ynh_app_setting_set --app=$app --key=project_version --value="$project_version" ynh_app_setting_set --app=$app --key=core_version --value="$core_version" ynh_app_setting_set --app=$app --key=ldap_version --value="$ldap_version" #================================================= # STANDARD MODIFICATIONS #================================================= #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=3 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" 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..." # Create a dedicated PHP-FPM config ynh_add_fpm_config --usage=low --footprint=low #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config #================================================= # SPECIFIC SETUP #================================================= # ADD SWAP #================================================= ynh_print_info --message="Adding swap..." if [ ${PACKAGE_CHECK_EXEC:-0} -eq 0 ]; then ynh_add_swap --size=$swap_needed fi #================================================= # INSTALL COMPOSER DEPENDENCIES #================================================= ynh_script_progression --message="Installing composer dependencies..." --weight=5 ynh_exec_warn_less ynh_install_composer --phpversion="$phpversion" --workdir="$install_dir" # Set Flarum version ynh_exec_warn_less ynh_composer_exec --phpversion=$phpversion --workdir=$install_dir --commands="require flarum/core:$core_version --prefer-lowest --no-update" # Require LDAP extension ynh_exec_warn_less ynh_composer_exec --phpversion=$phpversion --workdir=$install_dir --commands="require tituspijean/flarum-ext-auth-ldap:$ldap_version --no-update" # Update and download dependencies ynh_exec_warn_less ynh_composer_exec --phpversion=$phpversion --workdir=$install_dir --commands="update" #================================================= # FLARUM POST-INSTALL #================================================= ynh_script_progression --message="Configuring Flarum..." --weight=2 # Copy and populate configuration.yml to working directory ynh_add_config --template="../conf/configuration.yml" --destination="$install_dir/configuration.yml" # Execute post-installation pushd $install_dir ynh_exec_as $app php$phpversion -d $install_dir -d memory_limit=-1 flarum install -f configuration.yml # Delete configuration.yml as it contains sensitive data ynh_secure_remove --file="$install_dir/configuration.yml" popd # Email setup ynh_add_config --template="../conf/mail.sql.template" --destination="../conf/mail.sql" ynh_mysql_connect_as --user=$app --password="$db_pwd" --database=$db_name < ../conf/mail.sql # Enable and set up the LDAP auth extension ynh_script_progression --message="Enabling and configuring LDAP extension..." --weight=2 activate_flarum_extension $db_name "tituspijean-auth-ldap" ynh_add_config --template="../conf/ldap.sql.template" --destination="../conf/ldap.sql" ynh_mysql_connect_as --user=$app --password="$db_pwd" --database=$db_name < ../conf/ldap.sql # Install, activate and set language extensions case $language in fr) ynh_script_progression --message="Installing French extension..." --weight=2 ynh_exec_warn_less ynh_composer_exec --phpversion=$phpversion --workdir=$install_dir --commands="require qiaeru/lang-french:*" activate_flarum_extension $db_name "qiaeru-lang-french" sql_command="UPDATE \`settings\` SET \`value\` = 'fr' WHERE \`settings\`.\`key\` = 'default_locale'" ynh_mysql_execute_as_root --sql="$sql_command" --database=$db_name ;; de) ynh_script_progression --message="Installing German extension..." --weight=2 ynh_exec_warn_less ynh_composer_exec --phpversion=$phpversion --workdir=$install_dir --commands="require kakifrucht/flarum-de:*" activate_flarum_extension $db_name "kakifrucht-de" sql_command="UPDATE \`settings\` SET \`value\` = 'de' WHERE \`settings\`.\`key\` = 'default_locale'" ynh_mysql_execute_as_root --sql="$sql_command" --database=$db_name ;; esac # Set files and directories permissions chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= # GENERIC FINALIZATION #================================================= # SETUP LOGROTATE #================================================= ynh_script_progression --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) ynh_use_logrotate #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Installation of $app completed"