mirror of
https://github.com/YunoHost-Apps/question2answer_ynh.git
synced 2024-09-03 20:16:07 +02:00
94 lines
5 KiB
Bash
Executable file
94 lines
5 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
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 "Setting up source files..."
|
|
|
|
# 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_replace \
|
|
--file="$install_dir/qa-include/pages/login.php" \
|
|
--match="require_once QA_INCLUDE_DIR . 'db/selects.php';" \
|
|
--replace="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
|
|
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
|
|
#=================================================
|
|
# ADD A CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression "Adding $app's configuration..."
|
|
|
|
mv "$install_dir/qa-config-example.php" "$install_dir/qa-config.php"
|
|
|
|
ynh_replace --file="$install_dir/qa-config.php" --match="your-mysql-username" --replace="$db_user"
|
|
ynh_replace --file="$install_dir/qa-config.php" --match="your-mysql-password" --replace="$db_pwd"
|
|
ynh_replace --file="$install_dir/qa-config.php" --match="your-mysql-db-name" --replace="$db_name"
|
|
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
|
|
#=================================================
|
|
# SYSTEM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression "Adding system configurations related to $app..."
|
|
|
|
# Create a dedicated PHP-FPM config
|
|
ynh_config_add_phpfpm
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_config_add_nginx
|
|
|
|
#=================================================
|
|
# SETUP APPLICATION WITH CURL
|
|
#=================================================
|
|
ynh_script_progression "Finalizing installation..."
|
|
|
|
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_config_add --template="ldap.sql" --destination="$install_dir/ldap.sql"
|
|
ynh_mysql_db_shell " < "$install_dir/ldap.sql""
|
|
ynh_safe_rm "$install_dir/ldap.sql"
|
|
|
|
# Calculate and store the config file checksum into the app settings
|
|
ynh_store_file_checksum "$install_dir/qa-config.php"
|
|
|
|
# Set permissions to app files
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 750 "$install_dir"
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
|
|
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R "$app:www-data" "$install_dir"
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression "Installation of $app completed"
|