#!/bin/bash #================================================= # GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers #================================================= # INITIALIZE AND STORE SETTINGS #================================================= admin_email=$(ynh_user_get_info --username="$admin" --key=mail) #================================================= # 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" ynh_setup_source --source_id="ldap" --dest_dir="$install_dir/qa-plugin/qa-ldap-login" ynh_exec_warn ls -lah "$install_dir/qa-plugin/qa-ldap-login" ynh_replace_string \ --target_file="$install_dir/qa-include/pages/login.php" \ --match_string="require_once QA_INCLUDE_DIR . 'db/selects.php';" \ --replace_string="require_once QA_INCLUDE_DIR . 'db/selects.php';\r\n require_once QA_INCLUDE_DIR . '../qa-plugin/qa-ldap-login/qa-ldap-process.php';" if [ "$language" == "fr" ]; then ynh_setup_source --source_id="lang_fr" --dest_dir="$install_dir/qa-lang/fr" fi chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R "$app:www-data" "$install_dir" #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." mv "$install_dir/qa-config-example.php" "$install_dir/qa-config.php" ynh_replace_string --target_file="$install_dir/qa-config.php" --match_string="your-mysql-username" --replace_string="$db_user" ynh_replace_string --target_file="$install_dir/qa-config.php" --match_string="your-mysql-password" --replace_string="$db_pwd" ynh_replace_string --target_file="$install_dir/qa-config.php" --match_string="your-mysql-db-name" --replace_string="$db_name" #================================================= # 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 #================================================= # SETUP APPLICATION WITH CURL #================================================= ynh_script_progression --message="Finalizing installation..." --weight=4 admin_temp_pass=$(ynh_string_random --length=10) ynh_local_curl "/index.php?qa=install" "create=Set+up+the+Database+including+User+Management" ynh_local_curl "/index.php?qa=install" "handle=$admin" "password=$admin_temp_pass" "email=$admin_email" "super=Set+up+the+Super+Administrator" ynh_local_curl_csrf "/index.php?qa=admin&qa_1=general" \ "$(myynh_urlencode "option_site_title=$q2a_name")" \ "$(myynh_urlencode "option_site_url=https://$domain$path")" \ "option_neat_urls=0" \ "option_site_language=$language" \ "option_site_theme=SnowFlat" \ "option_site_theme_mobile=SnowFlat" \ "option_site_text_direction=ltr" \ "option_tags_or_categories=tc" \ "dosaveoptions=1" \ "has_js=0" ynh_add_config --template="ldap.sql" --destination="$install_dir/ldap.sql" ynh_mysql_execute_file_as_root --database="$db_name" --file="$install_dir/ldap.sql" ynh_secure_remove --file="$install_dir/ldap.sql" # Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$install_dir/qa-config.php" # Set permissions to app files chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R "$app:www-data" "$install_dir" #================================================= # END OF SCRIPT #================================================= ynh_script_progression --message="Installation of $app completed" --last