diff --git a/config_panel.toml b/config_panel.toml index 143cbd3..29d256b 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -3,6 +3,14 @@ version = "1.0" [main] name = "BookStack configuration" + [main.maintenance_mode] + name = "Maintenance mode" + + [main.maintenance_mode.maintenance_mode] + ask = "Enable maintenance mode" + type = "boolean" + default = "0" + [main.php_fpm_config] name = "PHP-FPM configuration" diff --git a/scripts/config b/scripts/config index 91c2de7..0a9e083 100644 --- a/scripts/config +++ b/scripts/config @@ -22,6 +22,16 @@ current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) # SPECIFIC GETTERS FOR TOML SHORT KEY #================================================= +get__maintenance_mode() { + # Maintenance mode status + if [ -f $final_path/.maintenance ] + then + echo "1" + else + echo "0" + fi +} + get__fpm_footprint() { # Free footprint value for php-fpm # Check if current_fpm_footprint is an integer @@ -49,6 +59,20 @@ get__free_footprint() { # SPECIFIC SETTERS FOR TOML SHORT KEYS #================================================= +set__maintenance_mode() { + if [ "$maintenance_mode" -eq "1" ]; then + # If maintenance_mode was set to 1, enable maintenance mode + (cd "$final_path" && ynh_exec_as "$app" \ + echo "Site under maintenance." > .maintenance) + ynh_print_info "Maintenance mode disabled" + elif [ "$maintenance_mode" -eq "0" ]; then + # If maintenance_mode was set to 0, disable maintenance mode + ynh_secure_remove --file=$final_path/.maintenance + ynh_print_info "Maintenance mode enabled" + fi + ynh_app_setting_set --app=$app --key=maintenance_mode --value="$maintenance_mode" +} + set__fpm_footprint() { if [ "$fpm_footprint" != "specific" ] then