mirror of
https://github.com/YunoHost-Apps/mediawiki_ynh.git
synced 2024-09-03 19:46:05 +02:00
106 lines
4.2 KiB
Bash
106 lines
4.2 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
# If fpm_footprint doesn't exist, create it
|
|
if [ -z "${fpm_footprint:-}" ]; then
|
|
fpm_footprint=low
|
|
ynh_app_setting_set --app="$app" --key="fpm_footprint" --value="$fpm_footprint"
|
|
fi
|
|
|
|
# If fpm_usage doesn't exist, create it
|
|
if [ -z "${fpm_usage:-}" ]; then
|
|
fpm_usage=low
|
|
ynh_app_setting_set --app="$app" --key="fpm_usage" --value="$fpm_usage"
|
|
fi
|
|
|
|
# If create_account doesn't exist, create it
|
|
if [ -z "${create_account:-}" ]; then
|
|
create_account=false
|
|
ynh_app_setting_set --app="$app" --key="create_account" --value="$create_account"
|
|
fi
|
|
|
|
# Removed in dec. 2020
|
|
ldap_user=$(ynh_app_setting_get --app="$app" --key="ldap_user")
|
|
if [[ -n "${ldap_user:-}" ]]; then
|
|
yunohost user delete "$ldap_user"
|
|
ynh_app_setting_delete --app="$app" --key="ldap_user"
|
|
ynh_app_setting_delete --app="$app" --key="ldap_password"
|
|
fi
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading source files..." --weight=4
|
|
|
|
# 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"
|
|
|
|
# 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"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
chown -R "$app:www-data" "$install_dir"
|
|
|
|
#=================================================
|
|
# UPDATE A CONFIG FILE
|
|
#=================================================
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=4
|
|
|
|
if [ "$path" = "/" ]; then
|
|
# 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=""
|
|
else
|
|
mediawiki_path="$path"
|
|
fi
|
|
|
|
wiki_name_underscorified="${wiki_name//[^a-zA-Z0-9]/_}"
|
|
|
|
ynh_add_config --template="LocalSettings.php" --destination="$install_dir/LocalSettings.php"
|
|
|
|
# Check for admin password being too short for the new mediawiki requirements
|
|
password_length=$(ynh_app_setting_get --app="$app" --key=password | awk '{print length}')
|
|
if (( password_length < 10 )); then
|
|
ynh_print_warn -m "The current admin password is $password_length long. Mediawiki now requires a 10 chars minimum password."
|
|
ynh_print_warn -m "We are adapting the minimum length, but that would be great to change the admin password."
|
|
echo "\$wgPasswordPolicy['policies']['default']['MinimalPasswordLength'] = 10;" >> "$install_dir/LocalSettings.php"
|
|
fi
|
|
|
|
# This is required to update database schemas
|
|
"php$phpversion" "$install_dir/maintenance/update.php"
|
|
|
|
# Set permissions on app files
|
|
chown -R "$app:www-data" "$install_dir"
|
|
|
|
#=================================================
|
|
# REAPPLY SYSTEM CONFIGURATIONS
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
|
|
|
# Create a dedicated PHP-FPM config
|
|
ynh_add_fpm_config --phpversion="$phpversion" --usage="$fpm_usage" --footprint="$fpm_footprint"
|
|
|
|
# Create a dedicated NGINX config
|
|
ynh_add_nginx_config
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|