2019-02-27 23:52:47 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2020-06-10 15:24:30 +02:00
|
|
|
|
2019-02-27 23:52:47 +01:00
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
|
|
|
#=================================================
|
2020-06-10 15:24:30 +02:00
|
|
|
|
2022-04-13 01:23:40 +02:00
|
|
|
secret=$(ynh_string_random --length=64)
|
2022-11-13 23:39:11 +01:00
|
|
|
create_account=false
|
|
|
|
|
2024-04-12 10:35:52 +02:00
|
|
|
ynh_app_setting_set --app="$app" --key="secret" --value="$secret"
|
|
|
|
ynh_app_setting_set --app="$app" --key="create_account" --value="$create_account"
|
2019-02-27 23:52:47 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
2019-07-27 22:09:37 +02:00
|
|
|
ynh_script_progression --message="Setting up source files..." --weight=4
|
2019-02-27 23:52:47 +01:00
|
|
|
|
2024-04-12 10:35:52 +02:00
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
|
|
|
ynh_setup_source --dest_dir="$install_dir/extensions/LDAPAuthentication2" --source_id="ldap_authentication2"
|
|
|
|
ynh_setup_source --dest_dir="$install_dir/extensions/LDAPProvider" --source_id="ldap_provider"
|
|
|
|
ynh_setup_source --dest_dir="$install_dir/extensions/PluggableAuth" --source_id="pluggable_auth"
|
2023-05-26 20:39:50 +02:00
|
|
|
|
2024-04-12 10:35:52 +02:00
|
|
|
# ynh_setup_source --dest_dir="$install_dir/extensions/LDAPGroups" --source_id="ldap_groups"
|
|
|
|
# ynh_setup_source --dest_dir="$install_dir/extensions/LDAPUserInfo" --source_id="ldap_userinfo"
|
|
|
|
# ynh_setup_source --dest_dir="$install_dir/extensions/LDAPAuthorization" --source_id="ldap_authorization"
|
2019-02-27 23:52:47 +01:00
|
|
|
|
2023-04-10 16:26:24 +02:00
|
|
|
chmod -R o-rwx "$install_dir"
|
2024-04-12 10:35:52 +02:00
|
|
|
chown -R "$app:www-data" "$install_dir"
|
2019-02-27 23:52:47 +01:00
|
|
|
|
|
|
|
#=================================================
|
2019-07-27 22:09:37 +02:00
|
|
|
# RUN INSTALLATION OF MEDIAWIKI
|
2019-02-27 23:52:47 +01:00
|
|
|
#=================================================
|
2020-06-10 15:24:30 +02:00
|
|
|
ynh_script_progression --message="Installing and configuring Mediawiki..." --weight=14
|
2023-04-10 16:33:31 +02:00
|
|
|
|
2023-04-10 16:26:24 +02:00
|
|
|
if [ "$path" = "/" ]; then
|
2023-08-29 08:13:06 +02:00
|
|
|
# MediaWiki expects a "" for the root URL which is typically assumed to be
|
|
|
|
# "/" by other application packages. Therefore, we assume end-users will do
|
|
|
|
# this as well and make sure to ensure an "" in all cases where "/" is
|
|
|
|
# specified
|
|
|
|
mediawiki_path=""
|
2019-02-28 22:45:05 +01:00
|
|
|
else
|
2023-08-29 08:13:06 +02:00
|
|
|
mediawiki_path="$path"
|
2019-02-28 22:45:05 +01:00
|
|
|
fi
|
|
|
|
|
2024-04-12 10:35:52 +02:00
|
|
|
pushd "$install_dir"
|
2023-08-29 08:13:06 +02:00
|
|
|
"php$phpversion" "$install_dir/maintenance/install.php" \
|
|
|
|
--server "https://$domain" \
|
|
|
|
--scriptpath "$mediawiki_path" \
|
|
|
|
--dbuser "$db_name" \
|
|
|
|
--dbpass "$db_pwd" \
|
|
|
|
--dbname "$db_name" \
|
|
|
|
--dbprefix "mdk_" \
|
|
|
|
--lang "$language" \
|
|
|
|
--pass "$password" \
|
|
|
|
"$wiki_name" "$admin"
|
2024-04-12 10:35:52 +02:00
|
|
|
popd
|
2019-07-27 22:09:37 +02:00
|
|
|
|
|
|
|
#=================================================
|
2024-04-12 10:35:52 +02:00
|
|
|
# APP INITIAL CONFIGURATION
|
2019-07-27 22:09:37 +02:00
|
|
|
#=================================================
|
2024-04-12 10:35:52 +02:00
|
|
|
ynh_script_progression --message="Adding $app's configuration files..." --weight=1
|
2019-07-27 22:09:37 +02:00
|
|
|
|
2023-08-29 08:13:06 +02:00
|
|
|
# save the original LocalSettings.php for eventual debugging
|
|
|
|
mv "$install_dir/LocalSettings.php" "$install_dir/LocalSettings.php.orig"
|
2019-02-27 23:52:47 +01:00
|
|
|
|
2023-09-15 16:27:26 +02:00
|
|
|
wiki_name_underscorified="${wiki_name//[^a-zA-Z0-9]/_}"
|
|
|
|
|
2024-04-12 10:35:52 +02:00
|
|
|
ynh_add_config --template="LocalSettings.php" --destination="$install_dir/LocalSettings.php"
|
2020-06-10 15:24:30 +02:00
|
|
|
|
2023-09-15 16:22:18 +02:00
|
|
|
# This is required to update database schemas
|
2023-04-10 16:26:24 +02:00
|
|
|
"php$phpversion" "$install_dir/maintenance/update.php"
|
2019-02-27 23:52:47 +01:00
|
|
|
|
2024-04-12 10:35:52 +02:00
|
|
|
chown -R "$app:www-data" "$install_dir"
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SYSTEM CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Adding system configurations related to $app..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated PHP-FPM config
|
|
|
|
ynh_add_fpm_config --usage=low --footprint=low
|
|
|
|
|
|
|
|
# Create a dedicated NGINX config
|
|
|
|
ynh_add_nginx_config
|
2019-02-27 23:52:47 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2020-06-10 15:24:30 +02:00
|
|
|
|
2019-07-27 22:09:37 +02:00
|
|
|
ynh_script_progression --message="Installation of $app completed" --last
|