mirror of
https://github.com/YunoHost-Apps/mediawiki_ynh.git
synced 2024-09-03 19:46:05 +02:00
[autopatch] Automatic patch attempt for helpers 2.1
This commit is contained in:
parent
9d023852e1
commit
1e62cd710b
11 changed files with 83 additions and 97 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1,5 @@
|
|||
.apps.json
|
||||
.spdx_licenses
|
||||
*~
|
||||
*.sw[op]
|
||||
.DS_Store
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
; Additional php.ini defines, specific to this pool of workers.
|
||||
|
||||
php_admin_value[upload_max_filesize] = 256M
|
||||
php_admin_value[post_max_size] = 256M
|
|
@ -12,10 +12,10 @@ location __PATH__/ {
|
|||
# Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
|
||||
client_max_body_size 256M;
|
||||
|
||||
try_files $uri $uri/ @rewrite___NAME__;
|
||||
try_files $uri $uri/ @rewrite___APP__;
|
||||
location ~ [^/]\.php(/|$) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
|
||||
fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock;
|
||||
|
||||
fastcgi_index index.php;
|
||||
include fastcgi_params;
|
||||
|
@ -48,6 +48,6 @@ location __PATH__/ {
|
|||
include conf.d/yunohost_panel.conf.inc;
|
||||
}
|
||||
|
||||
location @rewrite___NAME__ {
|
||||
location @rewrite___APP__ {
|
||||
rewrite ^/__PATH__/(.*)$ /__PATH__/index.php?title=$1&$args;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,8 @@ userdoc = "https://www.mediawiki.org/wiki/Project:Help"
|
|||
code = "https://github.com/wikimedia/mediawiki"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.2"
|
||||
yunohost = ">= 11.2.18"
|
||||
helpers_version = "2.1"
|
||||
architectures = "all"
|
||||
multi_instance = true
|
||||
ldap = true
|
||||
|
@ -103,6 +104,7 @@ ram.runtime = "50M"
|
|||
[resources.system_user]
|
||||
|
||||
[resources.install_dir]
|
||||
group = "www-data:r-x"
|
||||
|
||||
[resources.permissions]
|
||||
main.url = "/"
|
||||
|
|
|
@ -1,17 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -8,34 +8,31 @@
|
|||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# DECLARE DATA AND CONF FILES TO BACKUP
|
||||
#=================================================
|
||||
ynh_print_info --message="Declaring files to be backed up..."
|
||||
ynh_print_info "Declaring files to be backed up..."
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="$install_dir"
|
||||
ynh_backup "$install_dir"
|
||||
|
||||
#=================================================
|
||||
# SYSTEM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_print_info --message="Backing up the MySQL database..."
|
||||
ynh_print_info "Backing up the MySQL database..."
|
||||
|
||||
ynh_mysql_dump_db --database="$db_name" > db.sql
|
||||
ynh_mysql_dump_db > db.sql
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||
|
|
|
@ -10,19 +10,19 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1
|
||||
ynh_script_progression "Updating NGINX web server configuration..."
|
||||
|
||||
ynh_change_url_nginx_config
|
||||
ynh_config_change_url_nginx
|
||||
|
||||
#=================================================
|
||||
# SET NEW URL
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting the new URL..." --weight=1
|
||||
ynh_script_progression "Setting the new URL..."
|
||||
|
||||
if [ "$change_domain" -eq 1 ]; then
|
||||
ynh_replace_string --target_file="$install_dir/LocalSettings.php" \
|
||||
--match_string="\$wgServer = \"https://$old_domain\";" \
|
||||
--replace_string="\$wgServer = \"https://$new_domain\";"
|
||||
ynh_replace --file="$install_dir/LocalSettings.php" \
|
||||
--match="\$wgServer = \"https://$old_domain\";" \
|
||||
--replace="\$wgServer = \"https://$new_domain\";"
|
||||
fi
|
||||
|
||||
if [ $change_path -eq 1 ]; then
|
||||
|
@ -38,13 +38,13 @@ if [ $change_path -eq 1 ]; then
|
|||
new_scriptpath=$new_path
|
||||
fi
|
||||
|
||||
ynh_replace_string --target_file="$install_dir/LocalSettings.php" \
|
||||
--match_string="\$wgScriptPath = \"$old_scriptpath\";" \
|
||||
--replace_string="\$wgScriptPath = \"$new_scriptpath\";"
|
||||
ynh_replace --file="$install_dir/LocalSettings.php" \
|
||||
--match="\$wgScriptPath = \"$old_scriptpath\";" \
|
||||
--replace="\$wgScriptPath = \"$new_scriptpath\";"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||
ynh_script_progression "Change of URL completed for $app"
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
ynh_app_setting_set --key=php_upload_max_filesize --value=256M
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
@ -14,13 +16,13 @@ source /usr/share/yunohost/helpers
|
|||
secret=$(ynh_string_random --length=64)
|
||||
create_account=false
|
||||
|
||||
ynh_app_setting_set --app="$app" --key="secret" --value="$secret"
|
||||
ynh_app_setting_set --app="$app" --key="create_account" --value="$create_account"
|
||||
ynh_app_setting_set --key="secret" --value="$secret"
|
||||
ynh_app_setting_set --key="create_account" --value="$create_account"
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=4
|
||||
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"
|
||||
|
@ -32,13 +34,12 @@ ynh_setup_source --dest_dir="$install_dir/extensions/PluggableAuth" --source_id=
|
|||
# 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"
|
||||
|
||||
#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"
|
||||
#=================================================
|
||||
# RUN INSTALLATION OF MEDIAWIKI
|
||||
#=================================================
|
||||
ynh_script_progression --message="Installing and configuring Mediawiki..." --weight=14
|
||||
ynh_script_progression "Installing and configuring Mediawiki..."
|
||||
|
||||
if [ "$path" = "/" ]; then
|
||||
# MediaWiki expects a "" for the root URL which is typically assumed to be
|
||||
|
@ -51,7 +52,7 @@ else
|
|||
fi
|
||||
|
||||
pushd "$install_dir"
|
||||
"php$phpversion" "$install_dir/maintenance/install.php" \
|
||||
"php$php_version" "$install_dir/maintenance/install.php" \
|
||||
--server "https://$domain" \
|
||||
--scriptpath "$mediawiki_path" \
|
||||
--dbuser "$db_name" \
|
||||
|
@ -66,33 +67,32 @@ popd
|
|||
#=================================================
|
||||
# APP INITIAL CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding $app's configuration files..." --weight=1
|
||||
ynh_script_progression "Adding $app's configuration files..."
|
||||
|
||||
# save the original LocalSettings.php for eventual debugging
|
||||
mv "$install_dir/LocalSettings.php" "$install_dir/LocalSettings.php.orig"
|
||||
|
||||
wiki_name_underscorified="${wiki_name//[^a-zA-Z0-9]/_}"
|
||||
|
||||
ynh_add_config --template="LocalSettings.php" --destination="$install_dir/LocalSettings.php"
|
||||
ynh_config_add --template="LocalSettings.php" --destination="$install_dir/LocalSettings.php"
|
||||
|
||||
# This is required to update database schemas
|
||||
"php$phpversion" "$install_dir/maintenance/update.php"
|
||||
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
"php$php_version" "$install_dir/maintenance/update.php"
|
||||
|
||||
#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 --message="Adding system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Adding system configurations related to $app..."
|
||||
|
||||
# Create a dedicated PHP-FPM config
|
||||
ynh_add_fpm_config --usage=low --footprint=low
|
||||
ynh_config_add_phpfpm
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
|
|
@ -10,16 +10,16 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# REMOVE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Removing system configurations related to $app..."
|
||||
|
||||
# Remove the dedicated NGINX config
|
||||
ynh_remove_nginx_config
|
||||
ynh_config_remove_nginx
|
||||
|
||||
# Remove the dedicated PHP-FPM config
|
||||
ynh_remove_fpm_config
|
||||
ynh_config_remove_phpfpm
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
ynh_script_progression "Removal of $app completed"
|
||||
|
|
|
@ -11,39 +11,38 @@ source /usr/share/yunohost/helpers
|
|||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the app main directory..." --weight=1
|
||||
ynh_script_progression "Restoring the app main directory..."
|
||||
|
||||
ynh_restore_file --origin_path="$install_dir"
|
||||
|
||||
chmod -R o-rwx "$install_dir"
|
||||
chown -R "$app:www-data" "$install_dir"
|
||||
ynh_restore "$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"
|
||||
#=================================================
|
||||
# RESTORE THE MYSQL DATABASE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring the MySQL database..." --weight=5
|
||||
ynh_script_progression "Restoring the MySQL database..."
|
||||
|
||||
ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql
|
||||
ynh_mysql_db_shell < ./db.sql
|
||||
|
||||
#=================================================
|
||||
# RESTORE SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Restoring system configurations related to $app..."
|
||||
|
||||
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
|
||||
ynh_script_progression "Reloading NGINX web server and PHP-FPM..."
|
||||
|
||||
ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload
|
||||
ynh_systemd_action --service_name=nginx --action=reload
|
||||
ynh_systemctl --service="php$php_version-fpm" --action=reload
|
||||
ynh_systemctl --service=nginx --action=reload
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Restoration completed for $app" --last
|
||||
ynh_script_progression "Restoration completed for $app"
|
||||
|
|
|
@ -7,41 +7,44 @@
|
|||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
ynh_app_setting_set_default --key=php_upload_max_filesize --value=256M
|
||||
|
||||
#=================================================
|
||||
# ENSURE DOWNWARD COMPATIBILITY
|
||||
#=================================================
|
||||
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
||||
ynh_script_progression "Ensuring downward compatibility..."
|
||||
|
||||
# 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"
|
||||
#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | ynh_app_setting_set --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"
|
||||
#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | ynh_app_setting_set --key="fpm_usage" --value="$fpm_usage"
|
||||
fi
|
||||
|
||||
# If create_account doesn't exist, create it
|
||||
# FIXMEhelpers2.1: maybe replace with: ynh_app_setting_set_default --key=create_account --value=false
|
||||
if [ -z "${create_account:-}" ]; then
|
||||
create_account=false
|
||||
ynh_app_setting_set --app="$app" --key="create_account" --value="$create_account"
|
||||
ynh_app_setting_set --key="create_account" --value="$create_account"
|
||||
fi
|
||||
|
||||
# Removed in dec. 2020
|
||||
ldap_user=$(ynh_app_setting_get --app="$app" --key="ldap_user")
|
||||
ldap_user=$(ynh_app_setting_get --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"
|
||||
ynh_app_setting_delete --key="ldap_user"
|
||||
ynh_app_setting_delete --key="ldap_password"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=4
|
||||
ynh_script_progression "Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
|
@ -53,13 +56,12 @@ ynh_setup_source --dest_dir="$install_dir/extensions/PluggableAuth" --source_id=
|
|||
# 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"
|
||||
|
||||
#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"
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating a configuration file..." --weight=4
|
||||
ynh_script_progression "Updating configuration..."
|
||||
|
||||
if [ "$path" = "/" ]; then
|
||||
# MediaWiki expects a "" for the root URL which is typically assumed to be
|
||||
|
@ -72,10 +74,10 @@ fi
|
|||
|
||||
wiki_name_underscorified="${wiki_name//[^a-zA-Z0-9]/_}"
|
||||
|
||||
ynh_add_config --template="LocalSettings.php" --destination="$install_dir/LocalSettings.php"
|
||||
ynh_config_add --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}')
|
||||
password_length=$(ynh_app_setting_get --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."
|
||||
|
@ -83,24 +85,23 @@ if (( password_length < 10 )); then
|
|||
fi
|
||||
|
||||
# This is required to update database schemas
|
||||
"php$phpversion" "$install_dir/maintenance/update.php"
|
||||
"php$php_version" "$install_dir/maintenance/update.php"
|
||||
|
||||
# Set permissions on app files
|
||||
chown -R "$app:www-data" "$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"
|
||||
#=================================================
|
||||
# REAPPLY SYSTEM CONFIGURATIONS
|
||||
#=================================================
|
||||
ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1
|
||||
ynh_script_progression "Upgrading system configurations related to $app..."
|
||||
|
||||
# Create a dedicated PHP-FPM config
|
||||
ynh_add_fpm_config --phpversion="$phpversion" --usage="$fpm_usage" --footprint="$fpm_footprint"
|
||||
ynh_config_add_phpfpm
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
ynh_script_progression "Upgrade of $app completed"
|
||||
|
|
Loading…
Reference in a new issue