2014-10-20 18:55:53 +02:00
|
|
|
#!/bin/bash
|
2015-10-27 16:03:21 +01:00
|
|
|
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
2017-06-17 17:49:26 +02:00
|
|
|
# GENERIC START
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
2017-06-05 13:11:48 +02:00
|
|
|
source _common.sh
|
2017-06-02 18:23:51 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
2024-01-24 11:39:24 +01:00
|
|
|
# INITIALIZE AND STORE SETTINGS
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
|
|
|
|
2024-01-24 11:39:24 +01:00
|
|
|
admin_email=$(ynh_user_get_info --username="$admin" --key=mail)
|
2017-06-02 18:23:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-01-24 11:39:24 +01:00
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
2024-01-24 11:39:24 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=3
|
2014-10-20 18:55:53 +02:00
|
|
|
|
2024-01-24 11:39:24 +01:00
|
|
|
# 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"
|
2017-06-02 18:23:51 +02:00
|
|
|
|
2024-01-24 11:39:24 +01:00
|
|
|
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';"
|
2022-07-29 22:43:23 +02:00
|
|
|
|
2024-01-24 11:39:24 +01:00
|
|
|
if [ "$language" == "fr" ]; then
|
|
|
|
ynh_setup_source --source_id="lang_fr" --dest_dir="$install_dir/qa-lang/fr"
|
|
|
|
fi
|
2018-06-28 22:05:35 +02:00
|
|
|
|
2024-01-24 11:39:24 +01:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2017-06-02 18:23:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-01-24 11:39:24 +01:00
|
|
|
# ADD A CONFIGURATION
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
2024-01-24 11:39:24 +01:00
|
|
|
ynh_script_progression --message="Adding a configuration file..."
|
2017-06-02 18:23:51 +02:00
|
|
|
|
2024-01-24 11:39:24 +01:00
|
|
|
mv "$install_dir/qa-config-example.php" "$install_dir/qa-config.php"
|
2017-06-02 18:23:51 +02:00
|
|
|
|
2024-01-24 11:39:24 +01:00
|
|
|
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"
|
2022-07-29 22:43:23 +02:00
|
|
|
|
2021-03-25 17:37:29 +01:00
|
|
|
#=================================================
|
2024-01-24 11:39:24 +01:00
|
|
|
# SYSTEM CONFIGURATION
|
2021-03-25 17:37:29 +01:00
|
|
|
#=================================================
|
2024-01-24 11:39:24 +01:00
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
2021-03-25 17:37:29 +01:00
|
|
|
|
2022-07-29 22:43:23 +02:00
|
|
|
# Create a dedicated PHP-FPM config
|
|
|
|
ynh_add_fpm_config
|
2021-03-26 11:22:22 +01:00
|
|
|
|
2020-08-02 15:41:28 +02:00
|
|
|
# Create a dedicated NGINX config
|
2018-05-27 15:44:58 +02:00
|
|
|
ynh_add_nginx_config
|
2017-06-02 18:23:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
2017-06-17 17:49:26 +02:00
|
|
|
# SETUP APPLICATION WITH CURL
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
2021-02-22 11:52:00 +01:00
|
|
|
ynh_script_progression --message="Finalizing installation..." --weight=4
|
|
|
|
|
2022-07-29 22:43:23 +02:00
|
|
|
admin_temp_pass=$(ynh_string_random --length=10)
|
2021-03-26 18:13:57 +01:00
|
|
|
|
2021-02-22 11:52:00 +01:00
|
|
|
ynh_local_curl "/index.php?qa=install" "create=Set+up+the+Database+including+User+Management"
|
2024-01-24 11:39:24 +01:00
|
|
|
ynh_local_curl "/index.php?qa=install" "handle=$admin" "password=$admin_temp_pass" "email=$admin_email" "super=Set+up+the+Super+Administrator"
|
2024-01-24 12:09:43 +01:00
|
|
|
ynh_local_curl_csrf "/index.php?qa=admin&qa_1=general" \
|
2024-01-24 11:39:24 +01:00
|
|
|
"$(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"
|
2018-06-28 22:05:35 +02:00
|
|
|
|
2017-06-02 18:23:51 +02:00
|
|
|
# Calculate and store the config file checksum into the app settings
|
2024-01-24 11:39:24 +01:00
|
|
|
ynh_store_file_checksum --file="$install_dir/qa-config.php"
|
2017-06-02 18:23:51 +02:00
|
|
|
|
|
|
|
# Set permissions to app files
|
2024-01-24 11:39:24 +01:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2019-02-10 15:02:38 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2021-02-22 11:52:00 +01:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|