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
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
|
|
|
|
2022-07-29 22:43:23 +02:00
|
|
|
email=$(ynh_user_get_info --username=$admin --key=mail)
|
|
|
|
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2021-02-22 11:52:00 +01:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=3
|
2017-06-02 18:23:51 +02:00
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-03-29 16:46:28 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2017-06-02 18:23:51 +02:00
|
|
|
|
2023-03-29 17:08:56 +02:00
|
|
|
if [ $language == "fr" ]; then
|
2023-09-28 22:03:16 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir/qa-lang/fr" --source_id="fr"
|
2023-03-29 17:08:56 +02:00
|
|
|
fi
|
|
|
|
|
2023-03-29 16:46:28 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2022-07-29 22:43:23 +02:00
|
|
|
|
2021-03-25 17:37:29 +01:00
|
|
|
#=================================================
|
2022-07-29 22:43:23 +02:00
|
|
|
# PHP-FPM CONFIGURATION
|
2021-03-25 17:37:29 +01:00
|
|
|
#=================================================
|
2022-07-29 22:43:23 +02:00
|
|
|
ynh_script_progression --message="Configuring PHP-FPM..." --weight=1
|
2021-03-25 17:37:29 +01:00
|
|
|
|
2022-07-29 22:43:23 +02:00
|
|
|
# Create a dedicated PHP-FPM config
|
2023-09-28 22:03:16 +02:00
|
|
|
ynh_add_fpm_config
|
2017-06-02 18:23:51 +02: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
|
|
|
|
|
|
|
#=================================================
|
2022-07-29 22:43:23 +02:00
|
|
|
# SPECIFIC SETUP
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
2022-07-29 22:43:23 +02:00
|
|
|
# DOWNLOAD AND UNPACK LDAP PLUGIN
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
2022-07-29 22:43:23 +02:00
|
|
|
ynh_script_progression --message="Setting up LDAP plugin..." --weight=3
|
2017-06-02 18:23:51 +02:00
|
|
|
|
2022-07-29 22:43:23 +02:00
|
|
|
wget -O qa-ldap-login.zip https://github.com/zakkak/qa-ldap-login/archive/$ldap_login_commit.zip 2>&1
|
2018-06-28 22:05:35 +02:00
|
|
|
|
2023-03-29 16:46:28 +02:00
|
|
|
unzip qa-ldap-login.zip -d $install_dir/qa-plugin
|
|
|
|
mv $install_dir/qa-plugin/qa-ldap-login-$ldap_login_commit $install_dir/qa-plugin/qa-ldap-login
|
2022-07-29 22:43:23 +02:00
|
|
|
|
|
|
|
ynh_replace_string\
|
|
|
|
--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';"\
|
2023-03-29 16:46:28 +02:00
|
|
|
--target_file="$install_dir/qa-include/pages/login.php"
|
2017-06-02 18:23:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
2022-07-29 22:43:23 +02:00
|
|
|
# ADD A CONFIGURATION
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
2022-07-29 22:43:23 +02:00
|
|
|
ynh_script_progression --message="Adding a configuration file..."
|
2017-06-02 18:23:51 +02:00
|
|
|
|
2023-03-29 17:08:56 +02:00
|
|
|
ynh_add_config --template="../conf/qa-config.php" --destination="$install_dir/qa-config.php"
|
2018-06-28 22:05:35 +02:00
|
|
|
|
2023-03-29 17:08:56 +02:00
|
|
|
chmod 400 "$install_dir/qa-config.php"
|
|
|
|
chown $app:$app "$install_dir/qa-config.php"
|
2017-06-02 18:23:51 +02:00
|
|
|
|
2023-03-29 19:10:54 +02:00
|
|
|
# Calculate and store the config file checksum into the app settings
|
|
|
|
ynh_store_file_checksum --file="$install_dir/qa-config.php"
|
|
|
|
|
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
|
|
|
#=================================================
|
2022-07-29 22:43:23 +02:00
|
|
|
ynh_script_progression --message="Setuping application with CURL..."
|
2017-06-02 18:23:51 +02:00
|
|
|
|
2017-06-17 17:49:26 +02:00
|
|
|
# Set the app as temporarily public for curl call
|
2021-02-22 11:52:00 +01:00
|
|
|
ynh_script_progression --message="Configuring SSOwat..." --weight=4
|
2017-06-02 18:23:51 +02:00
|
|
|
|
|
|
|
# Installation with curl
|
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"
|
2021-03-26 18:13:57 +01:00
|
|
|
ynh_local_curl "/index.php?qa=install" "handle=$admin" "password=$admin_temp_pass" "email=$email" "super=Set+up+the+Super+Administrator"
|
2021-02-22 11:52:00 +01:00
|
|
|
ynh_local_curl_csrf "/index.php?qa=admin&qa_1=general"\
|
2021-03-26 18:20:59 +01:00
|
|
|
`myynh_urlencode "option_site_title=$q2a_name"`\
|
2023-03-29 16:46:28 +02:00
|
|
|
`myynh_urlencode "option_site_url=https://$domain$path"`\
|
2021-02-22 11:52:00 +01:00
|
|
|
"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"
|
|
|
|
|
2021-03-26 18:13:57 +01:00
|
|
|
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="../conf/ldap.sql"
|
2023-03-29 19:10:54 +02:00
|
|
|
ynh_replace_string --match_string="__EMAIL__" --replace_string="$email" --target_file="../conf/ldap.sql"
|
2017-06-02 18:23:51 +02:00
|
|
|
|
2023-03-29 19:17:52 +02:00
|
|
|
ynh_mysql_connect_as --database="$db_name" --user="$db_user" --password="$db_pwd" < ../conf/ldap.sql
|
2017-06-02 18:23:51 +02:00
|
|
|
|
|
|
|
#=================================================
|
2017-06-17 17:49:26 +02:00
|
|
|
# SECURE FILES AND DIRECTORIES
|
2017-06-02 18:23:51 +02:00
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Set permissions to app files
|
2023-03-29 16:46:28 +02:00
|
|
|
chown -R $app: $install_dir
|
2017-06-02 18:23:51 +02:00
|
|
|
|
2023-03-29 16:46:28 +02:00
|
|
|
chmod o-rwx $install_dir
|
|
|
|
chown $app:www-data $install_dir
|
2021-04-08 15:04:33 +02:00
|
|
|
|
2021-02-22 11:52:00 +01:00
|
|
|
# Remove database initialization file
|
2023-03-29 17:08:56 +02:00
|
|
|
ynh_secure_remove --file="$install_dir/qa-include/qa-install.php"
|
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
|