1
0
Fork 0
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:
Yunohost-Bot 2024-08-31 01:05:18 +02:00 committed by Alexandre Aubin
parent 9d023852e1
commit 1e62cd710b
11 changed files with 83 additions and 97 deletions

3
.gitignore vendored
View file

@ -1,2 +1,5 @@
.apps.json .apps.json
.spdx_licenses .spdx_licenses
*~
*.sw[op]
.DS_Store

View file

@ -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

View file

@ -12,10 +12,10 @@ location __PATH__/ {
# Common parameter to increase upload size limit in conjunction with dedicated php-fpm file # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file
client_max_body_size 256M; client_max_body_size 256M;
try_files $uri $uri/ @rewrite___NAME__; try_files $uri $uri/ @rewrite___APP__;
location ~ [^/]\.php(/|$) { location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.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; fastcgi_index index.php;
include fastcgi_params; include fastcgi_params;
@ -48,6 +48,6 @@ location __PATH__/ {
include conf.d/yunohost_panel.conf.inc; include conf.d/yunohost_panel.conf.inc;
} }
location @rewrite___NAME__ { location @rewrite___APP__ {
rewrite ^/__PATH__/(.*)$ /__PATH__/index.php?title=$1&$args; rewrite ^/__PATH__/(.*)$ /__PATH__/index.php?title=$1&$args;
} }

View file

@ -20,7 +20,8 @@ userdoc = "https://www.mediawiki.org/wiki/Project:Help"
code = "https://github.com/wikimedia/mediawiki" code = "https://github.com/wikimedia/mediawiki"
[integration] [integration]
yunohost = ">= 11.2" yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all" architectures = "all"
multi_instance = true multi_instance = true
ldap = true ldap = true
@ -103,6 +104,7 @@ ram.runtime = "50M"
[resources.system_user] [resources.system_user]
[resources.install_dir] [resources.install_dir]
group = "www-data:r-x"
[resources.permissions] [resources.permissions]
main.url = "/" main.url = "/"

View file

@ -1,17 +1,5 @@
#!/bin/bash #!/bin/bash
#================================================= #=================================================
# COMMON VARIABLES # COMMON VARIABLES AND CUSTOM HELPERS
#=================================================
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
#================================================= #=================================================

View file

@ -8,34 +8,31 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= ynh_print_info "Declaring files to be backed up..."
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
#================================================= #=================================================
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$install_dir" ynh_backup "$install_dir"
#================================================= #=================================================
# SYSTEM CONFIGURATION # 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 # 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 # 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)."

View file

@ -10,19 +10,19 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# MODIFY URL IN NGINX CONF # 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 # 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 if [ "$change_domain" -eq 1 ]; then
ynh_replace_string --target_file="$install_dir/LocalSettings.php" \ ynh_replace --file="$install_dir/LocalSettings.php" \
--match_string="\$wgServer = \"https://$old_domain\";" \ --match="\$wgServer = \"https://$old_domain\";" \
--replace_string="\$wgServer = \"https://$new_domain\";" --replace="\$wgServer = \"https://$new_domain\";"
fi fi
if [ $change_path -eq 1 ]; then if [ $change_path -eq 1 ]; then
@ -38,13 +38,13 @@ if [ $change_path -eq 1 ]; then
new_scriptpath=$new_path new_scriptpath=$new_path
fi fi
ynh_replace_string --target_file="$install_dir/LocalSettings.php" \ ynh_replace --file="$install_dir/LocalSettings.php" \
--match_string="\$wgScriptPath = \"$old_scriptpath\";" \ --match="\$wgScriptPath = \"$old_scriptpath\";" \
--replace_string="\$wgScriptPath = \"$new_scriptpath\";" --replace="\$wgScriptPath = \"$new_scriptpath\";"
fi fi
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Change of URL completed for $app" --last ynh_script_progression "Change of URL completed for $app"

View file

@ -7,6 +7,8 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
ynh_app_setting_set --key=php_upload_max_filesize --value=256M
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
@ -14,13 +16,13 @@ source /usr/share/yunohost/helpers
secret=$(ynh_string_random --length=64) secret=$(ynh_string_random --length=64)
create_account=false create_account=false
ynh_app_setting_set --app="$app" --key="secret" --value="$secret" ynh_app_setting_set --key="secret" --value="$secret"
ynh_app_setting_set --app="$app" --key="create_account" --value="$create_account" ynh_app_setting_set --key="create_account" --value="$create_account"
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # 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 # 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"
@ -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/LDAPUserInfo" --source_id="ldap_userinfo"
# ynh_setup_source --dest_dir="$install_dir/extensions/LDAPAuthorization" --source_id="ldap_authorization" # ynh_setup_source --dest_dir="$install_dir/extensions/LDAPAuthorization" --source_id="ldap_authorization"
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 | 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 | chown -R "$app:www-data" "$install_dir"
#================================================= #=================================================
# RUN INSTALLATION OF MEDIAWIKI # RUN INSTALLATION OF MEDIAWIKI
#================================================= #=================================================
ynh_script_progression --message="Installing and configuring Mediawiki..." --weight=14 ynh_script_progression "Installing and configuring Mediawiki..."
if [ "$path" = "/" ]; then if [ "$path" = "/" ]; then
# MediaWiki expects a "" for the root URL which is typically assumed to be # MediaWiki expects a "" for the root URL which is typically assumed to be
@ -51,7 +52,7 @@ else
fi fi
pushd "$install_dir" pushd "$install_dir"
"php$phpversion" "$install_dir/maintenance/install.php" \ "php$php_version" "$install_dir/maintenance/install.php" \
--server "https://$domain" \ --server "https://$domain" \
--scriptpath "$mediawiki_path" \ --scriptpath "$mediawiki_path" \
--dbuser "$db_name" \ --dbuser "$db_name" \
@ -66,33 +67,32 @@ popd
#================================================= #=================================================
# APP INITIAL CONFIGURATION # 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 # save the original LocalSettings.php for eventual debugging
mv "$install_dir/LocalSettings.php" "$install_dir/LocalSettings.php.orig" mv "$install_dir/LocalSettings.php" "$install_dir/LocalSettings.php.orig"
wiki_name_underscorified="${wiki_name//[^a-zA-Z0-9]/_}" 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 # This is required to update database schemas
"php$phpversion" "$install_dir/maintenance/update.php" "php$php_version" "$install_dir/maintenance/update.php"
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"
#================================================= #=================================================
# SYSTEM CONFIGURATION # 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 # Create a dedicated PHP-FPM config
ynh_add_fpm_config --usage=low --footprint=low ynh_config_add_phpfpm
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config ynh_config_add_nginx
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression "Installation of $app completed"

View file

@ -10,16 +10,16 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# REMOVE SYSTEM CONFIGURATIONS # 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 # Remove the dedicated NGINX config
ynh_remove_nginx_config ynh_config_remove_nginx
# Remove the dedicated PHP-FPM config # Remove the dedicated PHP-FPM config
ynh_remove_fpm_config ynh_config_remove_phpfpm
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression "Removal of $app completed"

View file

@ -11,39 +11,38 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # 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" ynh_restore "$install_dir"
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"
#================================================= #=================================================
# RESTORE THE MYSQL DATABASE # 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 # 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 # 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_systemctl --service="php$php_version-fpm" --action=reload
ynh_systemd_action --service_name=nginx --action=reload ynh_systemctl --service=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --last ynh_script_progression "Restoration completed for $app"

View file

@ -7,41 +7,44 @@
source _common.sh source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
ynh_app_setting_set_default --key=php_upload_max_filesize --value=256M
#================================================= #=================================================
# ENSURE DOWNWARD COMPATIBILITY # 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 fpm_footprint doesn't exist, create it
if [ -z "${fpm_footprint:-}" ]; then if [ -z "${fpm_footprint:-}" ]; then
fpm_footprint=low 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 fi
# If fpm_usage doesn't exist, create it # If fpm_usage doesn't exist, create it
if [ -z "${fpm_usage:-}" ]; then if [ -z "${fpm_usage:-}" ]; then
fpm_usage=low 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 fi
# If create_account doesn't exist, create it # 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 if [ -z "${create_account:-}" ]; then
create_account=false 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 fi
# Removed in dec. 2020 # 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 if [[ -n "${ldap_user:-}" ]]; then
yunohost user delete "$ldap_user" yunohost user delete "$ldap_user"
ynh_app_setting_delete --app="$app" --key="ldap_user" ynh_app_setting_delete --key="ldap_user"
ynh_app_setting_delete --app="$app" --key="ldap_password" ynh_app_setting_delete --key="ldap_password"
fi fi
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # 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 # 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"
@ -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/LDAPUserInfo" --source_id="ldap_userinfo"
# ynh_setup_source --dest_dir="$install_dir/extensions/LDAPAuthorization" --source_id="ldap_authorization" # ynh_setup_source --dest_dir="$install_dir/extensions/LDAPAuthorization" --source_id="ldap_authorization"
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 | 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 | chown -R "$app:www-data" "$install_dir"
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================
ynh_script_progression --message="Updating a configuration file..." --weight=4 ynh_script_progression "Updating configuration..."
if [ "$path" = "/" ]; then if [ "$path" = "/" ]; then
# MediaWiki expects a "" for the root URL which is typically assumed to be # 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]/_}" 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 # 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 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 "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." 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 fi
# This is required to update database schemas # 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 # 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 # 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 # 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 # Create a dedicated NGINX config
ynh_add_nginx_config ynh_config_add_nginx
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression "Upgrade of $app completed"