mirror of
https://github.com/YunoHost-Apps/dokuwiki_ynh.git
synced 2024-09-03 18:26:20 +02:00
[autopatch] Automatic patch attempt for helpers 2.1
This commit is contained in:
parent
9aa1e83c98
commit
3c36ac0df4
12 changed files with 98 additions and 292 deletions
|
@ -1,7 +0,0 @@
|
|||
; Additional 'php.ini' parameters for this YunoHost package/application
|
||||
|
||||
; Common values to change to increase file upload limit
|
||||
; Tips: you need to do modify nginx config too: "client_max_body_size"
|
||||
php_admin_value[upload_max_filesize] = 25M
|
||||
php_admin_value[post_max_size] = 25M
|
||||
;source: https://www.dokuwiki.org/faq:uploadsize
|
|
@ -14,11 +14,11 @@ location __PATH__/ {
|
|||
# Common parameter to increase upload size limit in conjuction with dedicated php-fpm file
|
||||
client_max_body_size 25M;
|
||||
|
||||
try_files $uri $uri/ @__NAME__ ;
|
||||
try_files $uri $uri/ @__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,7 +48,7 @@ location __PATH__/ {
|
|||
}
|
||||
|
||||
# rewrites "doku.php/" out of the URLs if you set the userwrite setting to .htaccess in dokuwiki confi$
|
||||
location @__NAME__ {
|
||||
location @__APP__ {
|
||||
rewrite ^__PATH__/_media/(.*) __PATH__/lib/exe/fetch.php?media=$1 last;
|
||||
rewrite ^__PATH__/_detail/(.*) __PATH__/lib/exe/detail.php?media=$1 last;
|
||||
rewrite ^__PATH__/_export/([^/]+)/(.*) __PATH__/doku.php?do=export_$1&id=$2 last;
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
version = "1.0"
|
||||
|
||||
[main]
|
||||
name = "Dokuwiki configuration"
|
||||
|
||||
[main.php_fpm_config]
|
||||
name = "PHP-FPM configuration"
|
||||
|
||||
[main.php_fpm_config.fpm_footprint]
|
||||
ask = "Memory footprint of the service?"
|
||||
choices = ["low", "medium", "high", "specific"]
|
||||
default = "low"
|
||||
help = "low <= 20Mb per pool. medium between 20Mb and 40Mb per pool. high > 40Mb per pool.<br>Use specific to set a value with the following option."
|
||||
|
||||
[main.php_fpm_config.free_footprint]
|
||||
ask = "Memory footprint of the service?"
|
||||
type = "number"
|
||||
default = "0"
|
||||
help = "Free field to specify exactly the footprint in Mb if you don't want to use one of the three previous values."
|
||||
|
||||
[main.php_fpm_config.fpm_usage]
|
||||
ask = "Expected usage of the service?"
|
||||
choices = ["low", "medium", "high"]
|
||||
default = "low"
|
||||
help = "low: Personal usage, behind the SSO. No RAM footprint when not used, but the impact on the processor can be high if many users are using the service.<br>medium: Low usage, few people or/and publicly accessible. Low RAM footprint, medium processor footprint when used.<br>high: High usage, frequently visited website. High RAM footprint, but lower on processor usage and quickly responding."
|
|
@ -20,7 +20,8 @@ admindoc = "https://www.dokuwiki.org/manual"
|
|||
code = "https://github.com/dokuwiki/dokuwiki"
|
||||
|
||||
[integration]
|
||||
yunohost = ">= 11.2"
|
||||
yunohost = ">= 11.2.18"
|
||||
helpers_version = "2.1"
|
||||
architectures = "all"
|
||||
multi_instance = true
|
||||
|
||||
|
@ -66,6 +67,7 @@ ram.runtime = "50M"
|
|||
[resources.system_user]
|
||||
|
||||
[resources.install_dir]
|
||||
group = "www-data:r-x"
|
||||
|
||||
[resources.permissions]
|
||||
main.url = "/"
|
||||
|
|
|
@ -1,19 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# COMMON VARIABLES
|
||||
# COMMON VARIABLES AND CUSTOM HELPERS
|
||||
#=================================================
|
||||
# PHP APP SPECIFIC
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# EXPERIMENTAL HELPERS
|
||||
#=================================================
|
||||
|
||||
#=================================================
|
||||
# FUTURE OFFICIAL HELPERS
|
||||
#=================================================
|
||||
|
|
|
@ -1,47 +1,38 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
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"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP THE PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
|
||||
ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# BACKUP FAIL2BAN CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf"
|
||||
ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf"
|
||||
ynh_backup "/etc/fail2ban/jail.d/$app.conf"
|
||||
ynh_backup "/etc/fail2ban/filter.d/$app.conf"
|
||||
|
||||
#=================================================
|
||||
# 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)."
|
||||
|
|
|
@ -1,34 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# STANDARD MODIFICATIONS
|
||||
#=================================================
|
||||
# MODIFY URL IN NGINX CONF
|
||||
#=================================================
|
||||
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=2
|
||||
ynh_script_progression "Updating NGINX web server configuration..."
|
||||
|
||||
ynh_change_url_nginx_config
|
||||
ynh_config_change_url_nginx
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC MODIFICATIONS
|
||||
#=================================================
|
||||
# UPGRADE FAIL2BAN
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=6
|
||||
ynh_script_progression "Reconfiguring Fail2Ban..."
|
||||
|
||||
ynh_add_fail2ban_config --logpath="/var/log/nginx/$new_domain-error.log" --failregex="^.*authentication failure. while reading response header from upstream, client: <HOST>,.*POST $new_path.*$" --max_retry=5
|
||||
ynh_config_add_fail2ban --logpath="/var/log/nginx/$new_domain-error.log" --failregex="^.*authentication failure. while reading response header from upstream, client: <HOST>,.*POST $new_path.*$"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Change of URL completed for $app" --last
|
||||
ynh_script_progression "Change of URL completed for $app"
|
||||
|
|
|
@ -1,95 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC STARTING
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
ynh_abort_if_errors
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS
|
||||
#=================================================
|
||||
|
||||
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||
current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC GETTERS FOR TOML SHORT KEY
|
||||
#=================================================
|
||||
|
||||
get__fpm_footprint() {
|
||||
# Free footprint value for php-fpm
|
||||
# Check if current_fpm_footprint is an integer
|
||||
if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null
|
||||
then
|
||||
echo "specific"
|
||||
else
|
||||
echo "$current_fpm_footprint"
|
||||
fi
|
||||
}
|
||||
|
||||
get__free_footprint() {
|
||||
# Free footprint value for php-fpm
|
||||
# Check if current_fpm_footprint is an integer
|
||||
if [ "$current_fpm_footprint" -eq "$current_fpm_footprint" ] 2> /dev/null
|
||||
then
|
||||
# If current_fpm_footprint is an integer, that's a numeric value for the footprint
|
||||
echo "$current_fpm_footprint"
|
||||
else
|
||||
echo "0"
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETTERS FOR TOML SHORT KEYS
|
||||
#=================================================
|
||||
|
||||
set__fpm_footprint() {
|
||||
if [ "$fpm_footprint" != "specific" ]
|
||||
then
|
||||
ynh_app_setting_set --app=$app --key=fpm_footprint --value="$fpm_footprint"
|
||||
fi
|
||||
}
|
||||
|
||||
set__free_footprint() {
|
||||
if [ "$fpm_footprint" == "specific" ]
|
||||
then
|
||||
ynh_app_setting_set --app=$app --key=fpm_footprint --value="$free_footprint"
|
||||
fi
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
|
||||
ynh_app_config_validate() {
|
||||
_ynh_app_config_validate
|
||||
|
||||
if [ "${changed[fpm_usage]}" == "true" ] || [ "${changed[fpm_footprint]}" == "true" ] || [ "${changed[free_footprint]}" == "true" ]; then
|
||||
# If fpm_footprint is set to 'specific', use $free_footprint value.
|
||||
if [ "$fpm_footprint" == "specific" ]
|
||||
then
|
||||
fpm_footprint=$free_footprint
|
||||
fi
|
||||
|
||||
if [ "$fpm_footprint" == "0" ]
|
||||
then
|
||||
ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below."
|
||||
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
ynh_app_config_apply() {
|
||||
_ynh_app_config_apply
|
||||
|
||||
ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint
|
||||
}
|
||||
|
||||
ynh_app_config_run $1
|
|
@ -1,58 +1,53 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
ynh_app_setting_set --key=php_upload_max_filesize --value=25M
|
||||
|
||||
#=================================================
|
||||
# RETRIEVE ARGUMENTS FROM THE MANIFEST
|
||||
#=================================================
|
||||
|
||||
fpm_footprint="low"
|
||||
fpm_free_footprint=0
|
||||
fpm_usage="low"
|
||||
#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | fpm_footprint="low"
|
||||
#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | fpm_free_footprint=0
|
||||
#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | fpm_usage="low"
|
||||
|
||||
#=================================================
|
||||
# STORE SETTINGS FROM MANIFEST
|
||||
#=================================================
|
||||
|
||||
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$fpm_footprint
|
||||
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
|
||||
ynh_app_setting_set --app=$app --key=fpm_usage --value=$fpm_usage
|
||||
#REMOVEME? Everything about fpm_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_footprint --value=$fpm_footprint
|
||||
#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_free_footprint --value=$fpm_free_footprint
|
||||
#REMOVEME? Everything about fpm_usage is removed in helpers2.1... | ynh_app_setting_set --key=fpm_usage --value=$fpm_usage
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Setting up source files..." --weight=2
|
||||
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"
|
||||
|
||||
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"
|
||||
#=================================================
|
||||
# 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=$fpm_usage --footprint=$fpm_footprint
|
||||
ynh_config_add_phpfpm
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC SETUP
|
||||
#=================================================
|
||||
# ADD A CONFIGURATION
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=2
|
||||
ynh_script_progression "Adding $app's configuration..."
|
||||
|
||||
# Loading order of configuration files
|
||||
#
|
||||
|
@ -64,31 +59,29 @@ ynh_script_progression --message="Adding a configuration file..." --weight=2
|
|||
#
|
||||
# See https://www.dokuwiki.org/plugin:config#protecting_settings
|
||||
|
||||
|
||||
### Copy YunoHost specific configuration
|
||||
# This File cannot be modified directly by DokuWiki, only by hand or by YunoHost
|
||||
# It will only be updated by YunoHost package or directly by adventurous users
|
||||
|
||||
|
||||
# Customize admin group in case of multiple wiki install managed by different admins
|
||||
# dokuwiki.admin; dokuwiki__1.admin; etc
|
||||
ynh_add_config --template="../conf/local.protected.php" --destination="$install_dir/conf/local.protected.php"
|
||||
ynh_config_add --template="local.protected.php" --destination="$install_dir/conf/local.protected.php"
|
||||
|
||||
# This file might be modified by DokuWiki admin panel or by plugins
|
||||
# It will not be modified by Yunohost in order to keep user settings
|
||||
|
||||
# Set the "language"
|
||||
ynh_add_config --template="../conf/local.php" --destination="$install_dir/conf/local.php"
|
||||
ynh_config_add --template="local.php" --destination="$install_dir/conf/local.php"
|
||||
|
||||
# Restrict user rights by enforcing "read-only" mode for all users
|
||||
# See https://www.dokuwiki.org/acl#background_info
|
||||
# Default is "8"
|
||||
ynh_add_config --template="../conf/acl.auth.php" --destination="$install_dir/conf/acl.auth.php"
|
||||
ynh_config_add --template="acl.auth.php" --destination="$install_dir/conf/acl.auth.php"
|
||||
|
||||
#=================================================
|
||||
# CREATE DEFAULT FILES
|
||||
#=================================================
|
||||
ynh_script_progression --message="Creating default files..." --weight=1
|
||||
ynh_script_progression "Creating default files..."
|
||||
|
||||
# For securing DokuWiki installation, create default files that will be writable in the "conf" folder.
|
||||
# Other files will be read ony and owned by root.
|
||||
|
@ -109,18 +102,16 @@ cp --archive $install_dir/inc/preload.php.dist $install_dir/inc/preload.php
|
|||
cp --archive ../conf/plugins.local.php $install_dir/conf
|
||||
cp --archive ../conf/plugins.local.php $install_dir/conf/plugins.local.php.bak
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# SETUP FAIL2BAN
|
||||
#=================================================
|
||||
ynh_script_progression --message="Configuring Fail2Ban..." --weight=7
|
||||
ynh_script_progression "Configuring Fail2Ban..."
|
||||
|
||||
# Create a dedicated Fail2Ban config
|
||||
ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-error.log" --failregex="^.*authentication failure. while reading response header from upstream, client: <HOST>,.*POST $path.*$" --max_retry=5
|
||||
ynh_config_add_fail2ban --logpath="/var/log/nginx/$domain-error.log" --failregex="^.*authentication failure. while reading response header from upstream, client: <HOST>,.*POST $path.*$"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Installation of $app completed" --last
|
||||
ynh_script_progression "Installation of $app completed"
|
||||
|
|
|
@ -1,30 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# REMOVE NGINX CONFIGURATION
|
||||
#=================================================
|
||||
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
|
||||
|
||||
# Remove the dedicated Fail2Ban config
|
||||
ynh_remove_fail2ban_config
|
||||
ynh_config_remove_fail2ban
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Removal of $app completed" --last
|
||||
ynh_script_progression "Removal of $app completed"
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
|
||||
source ../settings/scripts/_common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
@ -13,38 +7,35 @@ 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 PHP-FPM CONFIGURATION
|
||||
#=================================================
|
||||
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"
|
||||
|
||||
ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
|
||||
ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
|
||||
ynh_systemd_action --action=restart --service_name=fail2ban
|
||||
ynh_restore "/etc/fail2ban/jail.d/$app.conf"
|
||||
ynh_restore "/etc/fail2ban/filter.d/$app.conf"
|
||||
ynh_systemctl --action=restart --service=fail2ban
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# RELOAD NGINX AND PHP-FPM
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=2
|
||||
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"
|
||||
|
|
|
@ -1,43 +1,31 @@
|
|||
#!/bin/bash
|
||||
|
||||
#=================================================
|
||||
# GENERIC START
|
||||
#=================================================
|
||||
# IMPORT GENERIC HELPERS
|
||||
#=================================================
|
||||
|
||||
source _common.sh
|
||||
source /usr/share/yunohost/helpers
|
||||
|
||||
#=================================================
|
||||
# CHECK VERSION
|
||||
#=================================================
|
||||
ynh_app_setting_set_default --key=php_upload_max_filesize --value=25M
|
||||
|
||||
upgrade_type=$(ynh_check_app_version_changed)
|
||||
|
||||
#=================================================
|
||||
# STANDARD UPGRADE STEPS
|
||||
#=================================================
|
||||
# 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_free_footprint doesn't exist, create it
|
||||
if [ -z "${fpm_free_footprint:-}" ]; then
|
||||
fpm_free_footprint=0
|
||||
ynh_app_setting_set --app=$app --key=fpm_free_footprint --value=$fpm_free_footprint
|
||||
#REMOVEME? Everything about fpm_free_footprint is removed in helpers2.1... | ynh_app_setting_set --key=fpm_free_footprint --value=$fpm_free_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
|
||||
|
||||
# Yunohost specific configuration, if it isn't exist already
|
||||
|
@ -67,14 +55,14 @@ fi
|
|||
# Create file if it does not exist
|
||||
if [ ! -f "$install_dir/conf/local.php" ]; then
|
||||
# Set the default "language"
|
||||
ynh_add_config --template="../conf/local.php" --destination="$install_dir/conf/local.php"
|
||||
ynh_config_add --template="local.php" --destination="$install_dir/conf/local.php"
|
||||
fi
|
||||
|
||||
# Do not overwrite existing ACL configuration file as it could have user customization's and settings.
|
||||
# Create file if it does not exist
|
||||
# See https://www.dokuwiki.org/acl#background_info
|
||||
if [ ! -f "$install_dir/conf/acl.auth.php" ]; then
|
||||
ynh_add_config --template="../conf/acl.auth.php" --destination="$install_dir/conf/acl.auth.php"
|
||||
ynh_config_add --template="acl.auth.php" --destination="$install_dir/conf/acl.auth.php"
|
||||
fi
|
||||
|
||||
# For securing DokuWiki installation, create default files that will be writable in the "conf" folder.
|
||||
|
@ -104,7 +92,6 @@ if [ ! -f "$install_dir/conf/plugins.local.php.bak" ]; then
|
|||
cp --archive ../conf/plugins.local.php $install_dir/conf/plugins.local.php.bak
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -f "$install_dir/inc/preload.php" ]; then
|
||||
# if template exists
|
||||
if [ -f "$install_dir/inc/preload.php.dist" ]; then
|
||||
|
@ -116,45 +103,44 @@ fi
|
|||
# purge "LOGAUTHERROR PLUGIN" as not compatible and not maintained anymore
|
||||
# See https://www.dokuwiki.org/plugin:logautherror
|
||||
if [ -d "$install_dir/lib/plugins/logautherror" ]; then
|
||||
ynh_script_progression --message="Purge "LOGAUTHERROR PLUGIN" as not maintained anymore" --weight=1
|
||||
ynh_secure_remove --file "$install_dir/lib/plugins/logautherror"
|
||||
ynh_script_progression "Purge "LOGAUTHERROR PLUGIN" as not maintained anymore"
|
||||
ynh_safe_rm "$install_dir/lib/plugins/logautherror"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
|
||||
if ynh_app_upstream_version_changed
|
||||
then
|
||||
ynh_script_progression --message="Upgrading source files..." --weight=2
|
||||
ynh_script_progression "Upgrading source files..."
|
||||
|
||||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source --dest_dir="$install_dir"
|
||||
fi
|
||||
|
||||
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"
|
||||
#=================================================
|
||||
# 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 --usage=$fpm_usage --footprint=$fpm_footprint
|
||||
ynh_config_add_phpfpm
|
||||
|
||||
# Create a dedicated NGINX config
|
||||
ynh_add_nginx_config
|
||||
ynh_config_add_nginx
|
||||
|
||||
#=================================================
|
||||
# SPECIFIC UPGRADE
|
||||
#=================================================
|
||||
# UPGRADE DOKUWIKI
|
||||
#=================================================
|
||||
|
||||
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||
# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
|
||||
if ynh_app_upstream_version_changed
|
||||
then
|
||||
ynh_script_progression --message="Upgrading DokuWiki..." --weight=7
|
||||
ynh_script_progression "Upgrading DokuWiki..."
|
||||
|
||||
# Remove upgrade notification inside Dokuwiki's admin panel
|
||||
# See https://www.dokuwiki.org/update_check
|
||||
|
@ -164,8 +150,8 @@ then
|
|||
# See https://www.dokuwiki.org/install:unused_files
|
||||
if [ -f "$install_dir/data/deleted.files" ]; then
|
||||
|
||||
# Feed output of grep[...] line by line to 'ynh_secure_remove'
|
||||
# 'ynh_secure_remove' can only work file by file. Cannot work with a list
|
||||
# Feed output of grep[...] line by line to 'ynh_safe_rm '
|
||||
# 'ynh_safe_rm ' can only work file by file. Cannot work with a list
|
||||
# This is a (complicated) workaround this limitation
|
||||
while IFS= read -r line; do
|
||||
|
||||
|
@ -177,18 +163,18 @@ then
|
|||
### 673
|
||||
#
|
||||
# Spam sample:
|
||||
#Attention : /!\ Packager ! You provided more than one argument to ynh_secure_remove but it will be ignored... Use this helper with one argument at time.
|
||||
#Attention : /!\ Packager ! You provided more than one argument to ynh_safe_rm but it will be ignored... Use this helper with one argument at time.
|
||||
#Info : 'inc/parser/spamcheck.php' wasn't deleted because it doesn't exist.
|
||||
#Attention : /!\ Packager ! You provided more than one argument to ynh_secure_remove but it will be ignored... Use this helper with one argument at time.
|
||||
#Attention : /!\ Packager ! You provided more than one argument to ynh_secure_remove but it will be ignored... Use this helper with one argument at time.
|
||||
#Attention : /!\ Packager ! You provided more than one argument to ynh_safe_rm but it will be ignored... Use this helper with one argument at time.
|
||||
#Attention : /!\ Packager ! You provided more than one argument to ynh_safe_rm but it will be ignored... Use this helper with one argument at time.
|
||||
#Info : 'lib/images/favicon.ico' wasn't deleted because it doesn't exist.
|
||||
#Info : 'lib/images/thumbup.gif' wasn't deleted because it doesn't exist.
|
||||
#Attention : /!\ Packager ! You provided more than one argument to ynh_secure_remove but it will be ignored... Use this helper with one argument at time.
|
||||
#Attention : /!\ Packager ! You provided more than one argument to ynh_safe_rm but it will be ignored... Use this helper with one argument at time.
|
||||
#Info : 'lib/images/toolbar/code.png' wasn't deleted because it doesn't exist.
|
||||
#Attention : /!\ Packager ! You provided more than one argument to ynh_secure_remove but it will be ignored... Use this helper with one argument at time.
|
||||
#Attention : /!\ Packager ! You provided more than one argument to ynh_safe_rm but it will be ignored... Use this helper with one argument at time.
|
||||
#Info : 'lib/images/toolbar/empty.png' wasn't deleted because it doesn't exist.
|
||||
if [ -f "$line" ]; then
|
||||
ynh_secure_remove --file "$line"
|
||||
ynh_safe_rm "$line"
|
||||
fi
|
||||
done < <(grep --null --extended-regexp --invert-match '^($|#)' "$install_dir/data/deleted.files" | xargs --null --max-args=1 || true)
|
||||
# ^ ^ First < is redirection, second is process substitution.
|
||||
|
@ -196,10 +182,10 @@ then
|
|||
|
||||
# Previous attemps if someone reads this one day
|
||||
###grep --extended-regexp --invert-match '^($|#)' data/deleted.files | xargs --max-args=1 rm --verbose --force --dir 2>&1 || true
|
||||
###grep --extended-regexp --invert-match '^($|#)' data/deleted.files | xargs --max-args=1 ynh_secure_remove --file 2>&1
|
||||
###grep --extended-regexp --invert-match '^($|#)' data/deleted.files | xargs --max-args=1 ynh_safe_rm 2>&1
|
||||
|
||||
###grep --null --extended-regexp --invert-match '^($|#)' data/deleted.files > toto.list
|
||||
###xargs --null --verbose --max-args=1 --arg-file=toto.list ynh_secure_remove 2>&1
|
||||
###xargs --null --verbose --max-args=1 --arg-file=toto.list ynh_safe_rm 2>&1
|
||||
fi
|
||||
|
||||
# TODO Taken from old "upgrade" script. Should check if it is needed and what it does
|
||||
|
@ -218,34 +204,32 @@ fi
|
|||
# Stolen from https://github.com/YunoHost-Apps/grav_ynh/blob/testing/scripts/upgrade#L189
|
||||
if [ -x "$install_dir/bin/plugin.php" ]; then
|
||||
pushd "$install_dir"
|
||||
ynh_exec_warn_less ynh_exec_as $app php$phpversion bin/plugin.php --no-colors extension upgrade || ynh_print_warn --message="Automatic plugin upgrade has failed, you can upgrade them from your DokuWiki admin panel."
|
||||
ynh_hide_warnings ynh_exec_as_app php$php_version bin/plugin.php --no-colors extension upgrade || ynh_print_warn "Automatic plugin upgrade has failed, you can upgrade them from your DokuWiki admin panel."
|
||||
popd
|
||||
else
|
||||
ynh_print_warn --message="Automatic plugin cannot be done, you have to upgrade them from your DokuWiki admin panel."
|
||||
ynh_print_warn "Automatic plugin cannot be done, you have to upgrade them from your DokuWiki admin panel."
|
||||
fi
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# UPDATE A CONFIG FILE
|
||||
#=================================================
|
||||
ynh_script_progression --message="Adding a configuration file..." --weight=2
|
||||
ynh_script_progression "Adding $app's configuration..."
|
||||
|
||||
# Customize admin group in case of multiple wiki install managed by different admins
|
||||
# dokuwiki.admin; dokuwiki__1.admin; etc
|
||||
ynh_add_config --template="../conf/local.protected.php" --destination="$install_dir/conf/local.protected.php"
|
||||
ynh_config_add --template="local.protected.php" --destination="$install_dir/conf/local.protected.php"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
#=================================================
|
||||
# UPGRADE FAIL2BAN
|
||||
#=================================================
|
||||
ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=7
|
||||
ynh_script_progression "Reconfiguring Fail2Ban..."
|
||||
|
||||
# Create a dedicated Fail2Ban config
|
||||
ynh_add_fail2ban_config --logpath="/var/log/nginx/$domain-error.log" --failregex="^.*authentication failure. while reading response header from upstream, client: <HOST>,.*POST $path.*$" --max_retry=5
|
||||
ynh_config_add_fail2ban --logpath="/var/log/nginx/$domain-error.log" --failregex="^.*authentication failure. while reading response header from upstream, client: <HOST>,.*POST $path.*$"
|
||||
|
||||
#=================================================
|
||||
# END OF SCRIPT
|
||||
#=================================================
|
||||
|
||||
ynh_script_progression --message="Upgrade of $app completed" --last
|
||||
ynh_script_progression "Upgrade of $app completed"
|
||||
|
|
Loading…
Add table
Reference in a new issue