1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pihole_ynh.git synced 2024-09-03 20:05:58 +02:00

Fix restore

This commit is contained in:
Alexandre Aubin 2023-09-03 10:42:33 +02:00
parent f5e00322ba
commit 45da149eaa
5 changed files with 1 additions and 335 deletions

View file

@ -1,44 +0,0 @@
Changelog
=========
## Unreleased
- Nothing for now...
## [3.3.1~ynh6](https://github.com/YunoHost-Apps/pihole_ynh/pull/51) - 2020-03-29
#### Added
* [Add a changelog](https://github.com/YunoHost-Apps/pihole_ynh/pull/51/commits/7299718e45d115a9b22b1eeb59b37028a731b616)
#### Changed
- [Update to last standard](https://github.com/YunoHost-Apps/pihole_ynh/pull/51/commits/9294176a2d243d68b3095d0037466814d8efdcd5)
- [Update helpers](https://github.com/YunoHost-Apps/pihole_ynh/pull/51/commits/3be3dbca2fb0ec2887b7962aa5dcce4276ab31ce)
- [Use toml for actions and config-panel](https://github.com/YunoHost-Apps/pihole_ynh/pull/51/commits/b1ec989d2a74f6cefaf97eb1ed59dd6b9fc82bcf)
* [use scalable phpfpm](https://github.com/YunoHost-Apps/pihole_ynh/pull/51/commits/1bf6783e334cd1260f418d641d29e8e11c7e6edc)
- [Update to last standard](https://github.com/YunoHost-Apps/pihole_ynh/pull/51/commits/a719095dc51c8c7af8a6f34f75c92a08f45e0012)
## [3.3.1~ynh5](https://github.com/YunoHost-Apps/pihole_ynh/pull/39) - 2019-02-03
#### Added
- [Add progression bar](https://github.com/YunoHost-Apps/pihole_ynh/pull/39/commits/887e6fcc79bfd71fbd8a97b59f912ef029f90cdf)
* [Changelog & html email](https://github.com/YunoHost-Apps/pihole_ynh/pull/39/commits/2229f7817327ceb2d2ca41310493a5483fb94ef9)
#### Changed
- [Update php and nginx conf files to php7](https://github.com/YunoHost-Apps/pihole_ynh/pull/39/commits/65d1ba63fcaffba347ab01d690d9ced08837a69b)
## [3.3.1~ynh4](https://github.com/YunoHost-Apps/pihole_ynh/pull/36) - 2019-01-24
#### Fixed
- [Fix #37 for post_domain_add](https://github.com/YunoHost-Apps/pihole_ynh/pull/38/commits/d34d953efbc93e3d3e4547e3d8585a35c1eb8751)
## [3.3.1~ynh4](https://github.com/YunoHost-Apps/pihole_ynh/pull/36) - 2019-01-21
#### Added
- [Advertise config-panel and actions](https://github.com/YunoHost-Apps/pihole_ynh/pull/36/commits/a4a720a9e8bae6a6d4e43a860c71c9e8947fafea)
#### Fixed
- [Fix install issue](https://github.com/YunoHost-Apps/pihole_ynh/pull/36/commits/3b7e0608c42402433888f9129e8c9dacbb9f4797)
#### Changed
- [Update to last standart](https://github.com/YunoHost-Apps/pihole_ynh/pull/36/commits/0478648b332e312d980becea48e8381b01133c7b)

View file

@ -1,45 +0,0 @@
[reset_default_setupvars]
name = "Reset the config file and restore a default one."
command = "/bin/bash scripts/actions/reset_default_config \"setupVars.conf\""
# user = "root" # optional
# cwd = "/" # optional
# accepted_return_codes = [0, 1, 2, 3] # optional
accepted_return_codes = [0]
description = "Reset the config file setupVars.conf."
[reset_default_ftl]
name = "Reset the config file and restore a default one."
command = "/bin/bash scripts/actions/reset_default_config \"pihole-FTL.conf\""
# user = "root" # optional
# cwd = "/" # optional
# accepted_return_codes = [0, 1, 2, 3] # optional
accepted_return_codes = [0]
description = "Reset the config file pihole-FTL.conf."
[reset_default_nginx]
name = "Reset the nginx config for this app."
command = "/bin/bash scripts/actions/reset_default_system nginx"
# user = "root" # optional
# cwd = "/" # optional
# accepted_return_codes = [0, 1, 2, 3] # optional
accepted_return_codes = [0]
description = "Reset the nginx config for this app."
[reset_default_phpfpm]
name = "Reset the php-fpm config for this app."
command = "/bin/bash scripts/actions/reset_default_system phpfpm"
# user = "root" # optional
# cwd = "/" # optional
# accepted_return_codes = [0, 1, 2, 3] # optional
accepted_return_codes = [0]
description = "Reset the php-fpm config for this app."
[reset_default_app]
name = "Reset the app with a default configuration."
command = "/bin/bash scripts/actions/reset_default_app"
# user = "root" # optional
# cwd = "/" # optional
# accepted_return_codes = [0, 1, 2, 3] # optional
accepted_return_codes = [0]
description = "Reset the app to its default configuration to try to fix potential issues.<br>This action won't remove any data added to the app.<br>However, if you have modified any configuration, it will be overwritten."

View file

@ -1,70 +0,0 @@
version = "1.0"
name = "PiHole configuration panel"
[main]
name = "PiHole configuration"
[main.overwrite_files]
name = "Overwriting config files"
[main.overwrite_files.overwrite_setupvars]
ask = "Overwrite the config file setupVars.conf?"
type = "boolean"
default = true
help = "If the file is overwritten, a backup will be created."
[main.overwrite_files.overwrite_ftl]
ask = "Overwrite the config file pihole-FTL.conf?"
type = "boolean"
default = true
help = "If the file is overwritten, a backup will be created."
[main.overwrite_files.overwrite_nginx]
ask = "Overwrite the nginx config file?"
type = "boolean"
default = true
help = "If the file is overwritten, a backup will be created."
[main.overwrite_files.overwrite_phpfpm]
ask = "Overwrite the php-fpm config file?"
type = "boolean"
default = true
help = "If the file is overwritten, a backup will be created."
[main.global_config]
name = "Global configuration"
[main.global_config.email_type]
ask = "Send HTML email to admin?"
type = "boolean"
default = true
help = "Allow app scripts to send HTML mails instead of plain text."
[main.php_fpm_config]
name = "PHP-FPM configuration"
[main.php_fpm_config.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.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."
[main.php_fpm_config.force_max_children]
ask = "Force the value of pm.max_children?"
type = "number"
default = "0"
help = "Do not change this value unless you're sure about what you're doing !<br>pm.max_children is automatically defined by this formula: $max_ram / 2 / $footprint<br>You can force that value, and ignore the formula by changing the value here.<br>To reset to the default value, set to 0."

View file

@ -1,174 +0,0 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
app=$YNH_APP_INSTANCE_NAME
fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# SPECIFIC CODE
#=================================================
# LOAD VALUES
#=================================================
# Load the real value from the app config or elsewhere.
# Then get the value from the form.
# If the form has a value for a variable, take the value from the form,
# Otherwise, keep the value from the app config.
# Overwrite setupVars.conf file
old_overwrite_setupvars="$(ynh_app_setting_get --app=$app --key=overwrite_setupvars)"
overwrite_setupvars="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETUPVARS:-$old_overwrite_setupvars}"
# Overwrite pihole-FTL.conf file
old_overwrite_ftl="$(ynh_app_setting_get --app=$app --key=overwrite_ftl)"
overwrite_ftl="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_FTL:-$old_overwrite_ftl}"
# Overwrite nginx configuration
old_overwrite_nginx="$(ynh_app_setting_get --app=$app --key=overwrite_nginx)"
overwrite_nginx="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX:-$old_overwrite_nginx}"
# Overwrite php-fpm configuration
old_overwrite_phpfpm="$(ynh_app_setting_get --app=$app --key=overwrite_phpfpm)"
overwrite_phpfpm="${YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM:-$old_overwrite_phpfpm}"
# Type of admin mail configuration
old_admin_mail_html="$(ynh_app_setting_get --app=$app --key=admin_mail_html)"
admin_mail_html="${YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE:-$old_admin_mail_html}"
# Footprint for php-fpm
old_fpm_footprint="$(ynh_app_setting_get --app=$app --key=fpm_footprint)"
fpm_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT:-$old_fpm_footprint}"
# Free footprint value for php-fpm
# Check if fpm_footprint is an integer
if [ "$fpm_footprint" -eq "$fpm_footprint" ] 2> /dev/null
then
# If fpm_footprint is an integer, that's a numeric value for the footprint
old_free_footprint=$fpm_footprint
fpm_footprint=specific
else
old_free_footprint=0
fi
free_footprint="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT:-$old_free_footprint}"
# Usage for php-fpm
old_fpm_usage="$(ynh_app_setting_get --app=$app --key=fpm_usage)"
fpm_usage="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE:-$old_fpm_usage}"
# php_forced_max_children for php-fpm
old_php_forced_max_children="$(ynh_app_setting_get --app=$app --key=php_forced_max_children)"
# If php_forced_max_children isn't into settings.yml, get the current value from the fpm config
if [ -z "$old_php_forced_max_children" ]; then
old_php_forced_max_children="$(grep "^pm.max_children" "$fpm_config_dir/pool.d/$app.conf" | awk '{print $3}')"
fi
php_forced_max_children="${YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FORCE_MAX_CHILDREN:-$old_php_forced_max_children}"
#=================================================
# SHOW_CONFIG FUNCTION FOR 'SHOW' COMMAND
#=================================================
show_config() {
# here you are supposed to read some config file/database/other then print the values
# ynh_return "YNH_CONFIG_${PANEL_ID}_${SECTION_ID}_${OPTION_ID}=value"
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_SETUPVARS=$overwrite_setupvars"
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_FTL=$overwrite_ftl"
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_NGINX=$overwrite_nginx"
ynh_return "YNH_CONFIG_MAIN_OVERWRITE_FILES_OVERWRITE_PHPFPM=$overwrite_phpfpm"
ynh_return "YNH_CONFIG_MAIN_GLOBAL_CONFIG_EMAIL_TYPE=$admin_mail_html"
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FOOTPRINT=$fpm_footprint"
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FREE_FOOTPRINT=$free_footprint"
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_USAGE=$fpm_usage"
ynh_return "YNH_CONFIG_MAIN_PHP_FPM_CONFIG_FORCE_MAX_CHILDREN=$php_forced_max_children"
}
#=================================================
# MODIFY THE CONFIGURATION
#=================================================
apply_config() {
#=================================================
# MODIFY OVERWRITTING SETTINGS
#=================================================
# Set overwrite_setupvars
ynh_app_setting_set --app=$app --key=overwrite_setupvars --value="$overwrite_setupvars"
# Set overwrite_ftl
ynh_app_setting_set --app=$app --key=overwrite_ftl --value="$overwrite_ftl"
# Set overwrite_nginx
ynh_app_setting_set --app=$app --key=overwrite_nginx --value="$overwrite_nginx"
# Set overwrite_phpfpm
ynh_app_setting_set --app=$app --key=overwrite_phpfpm --value="$overwrite_phpfpm"
#=================================================
# MODIFY EMAIL SETTING
#=================================================
# Set admin_mail_html
ynh_app_setting_set --app=$app --key=admin_mail_html --value="$admin_mail_html"
#=================================================
# RECONFIGURE PHP-FPM
#=================================================
if [ "$fpm_usage" != "$old_fpm_usage" ] || \
[ "$fpm_footprint" != "$old_fpm_footprint" ] || \
[ "$free_footprint" != "$old_free_footprint" ] || \
[ "$php_forced_max_children" != "$old_php_forced_max_children" ]
then
# If fpm_footprint is set to 'specific', use $free_footprint value.
if [ "$fpm_footprint" = "specific" ]
then
fpm_footprint=$free_footprint
fi
if [ "$php_forced_max_children" != "$old_php_forced_max_children" ]
then
# Set php_forced_max_children
if [ $php_forced_max_children -ne 0 ]
then
ynh_app_setting_set --app=$app --key=php_forced_max_children --value="$php_forced_max_children"
else
# If the value is set to 0, remove the setting
ynh_app_setting_delete --app=$app --key=php_forced_max_children
fi
fi
if [ "$fpm_footprint" != "0" ]
then
ynh_add_fpm_config --usage=$fpm_usage --footprint=$fpm_footprint --dedicated_service
else
ynh_print_err --message="When selecting 'specific', you have to set a footprint value into the field below."
fi
fi
}
#=================================================
# GENERIC FINALIZATION
#=================================================
# SELECT THE ACTION FOLLOWING THE GIVEN ARGUMENT
#=================================================
case $1 in
show) show_config;;
apply) apply_config;;
esac

View file

@ -37,7 +37,6 @@ admin=$(ynh_app_setting_get --app=$app --key=admin)
fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
fpm_usage=$(ynh_app_setting_get --app=$app --key=fpm_usage)
fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)
fpm_service=$(ynh_app_setting_get --app=$app --key=fpm_service)
#=================================================
# CHECK IF THE APP CAN BE RESTORED
@ -260,7 +259,7 @@ ynh_systemd_action --service_name=pihole-FTL --action=restart --log_path="/var/l
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1
ynh_systemd_action --service_name=$fpm_service --action=reload
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
#=================================================