From 40355e522b0c1729214fd9fabf54fadd08515e1a Mon Sep 17 00:00:00 2001 From: ljf Date: Sun, 10 Dec 2023 23:10:07 +0100 Subject: [PATCH] [enh] Config panel with useful parameters --- conf/config.json | 9 +++++++++ config_panel.toml | 33 ++++++++++----------------------- scripts/config | 43 ++++++++++++++----------------------------- scripts/install | 13 ++++++++++++- 4 files changed, 45 insertions(+), 53 deletions(-) diff --git a/conf/config.json b/conf/config.json index 1cd7f95..297d3d0 100644 --- a/conf/config.json +++ b/conf/config.json @@ -1,5 +1,6 @@ { "system": { + "maintenance": false, "updatechecker": false, "memcache.local": "\\OC\\Memcache\\APCu", "integrity.check.disabled": true, @@ -12,6 +13,14 @@ "password": "" }, "hashing_default_password": true, + "has_internet_connection": true, + "default_phone_region": "", + "default_timezone": "Europe/Paris", + "trashbin_retention_obligation": "auto", + "version_retention_obligation": "auto", + "enable_previews": true, + "defaultapp": "dashboard,files", + "lost_password_link": "", "localstorage.allowsymlinks": true, "simpleSignUpLink.shown": false, "mail_smtpmode": "smtp", diff --git a/config_panel.toml b/config_panel.toml index 8f72fec..5e3ade8 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -2,19 +2,20 @@ version = "1.0" [main] name = "Nextcloud configuration" +services = ["php8.2-fpm"] [main.mode] name = "Modes" - [main.mode.maintenance_mode] + [main.mode.maintenance] ask = "Enable maintenance mode" type = "boolean" - default = "0" + bind = ":__INSTALL_DIR__/config/config.php" - [main.mode.closed_network_mode] + [main.mode.has_internet_connection] ask = "Enable closed network mode" type = "boolean" - default = "0" + bind = ":__INSTALL_DIR__/config/config.php" help = "Is Nextcloud connected to the Internet or running in a closed network?" [main.localization] @@ -23,14 +24,13 @@ name = "Nextcloud configuration" [main.localization.default_phone_region] ask = "Default phone region" type = "select" - default = "0" + bind = ":__INSTALL_DIR__/config/config.php" help = "It is required to allow inserting phone numbers in the user profiles starting without the country code (e.g. +49 for Germany)." [main.localization.default_timezone] ask = "Default timezone" type = "select" bind = ":__INSTALL_DIR__/config/config.php" - default = "Europe/Paris" help = "The default timezone parameter is only used when the timezone of the user can’t be determined." [main.account] @@ -40,7 +40,6 @@ name = "Nextcloud configuration" ask = "Lost password link" type = "url" bind = ":__INSTALL_DIR__/config/config.php" - default = "0" help = "Allow to redirect on a custom form to require a password reset (for example to ask you to reset it from this yunohost webadmin)" [main.account.logout_url] @@ -52,50 +51,38 @@ name = "Nextcloud configuration" [main.files] name = "Files" - [main.account.trashbin_retention_obligation] + [main.files.trashbin_retention_obligation] ask = "Trashbin retention" type = "string" bind = ":__INSTALL_DIR__/config/config.php" - default = "auto" help = "If the trash bin app is enabled (default), this setting defines the policy for when files and folders in the trash bin will be permanently deleted." - [main.account.version_retention_obligation] + [main.files.version_retention_obligation] ask = "Version retention" type = "string" bind = ":__INSTALL_DIR__/config/config.php" - default = "auto" help = "If the versions app is enabled (default), this setting defines the policy for when versions will be permanently deleted." - [main.account.enable_previews] + [main.files.enable_previews] ask = "Enable previews" type = "boolean" bind = ":__INSTALL_DIR__/config/config.php" - default = "1" help = "Info: Previews of photos and text documents could consume a lot of resources." [main.apps] name = "Apps" - [main.account.auto_update] + [main.apps.auto_update] ask = "Auto update apps" type = "boolean" - default = "1" help = "Automatically update apps each night" [main.apps.defaultapp] ask = "Default app to display" type = "tags" bind = ":__INSTALL_DIR__/config/config.php" - default = "dashboard,files" help = "Set the default app to open on login." - [main.apps.appsallowlist] - ask = "List of apps installable" - type = "tags" - bind = ":__INSTALL_DIR__/config/config.php" - default = "all" - help = "Filters allowed installable apps from the appstore." - [main.php_fpm_config] name = "PHP-FPM configuration" diff --git a/scripts/config b/scripts/config index 5a7a2ac..f7a56c4 100644 --- a/scripts/config +++ b/scripts/config @@ -21,21 +21,21 @@ current_fpm_footprint=$(ynh_app_setting_get --app=$app --key=fpm_footprint) #================================================= # SPECIFIC GETTERS FOR TOML SHORT KEY #================================================= +get__default_phone_region() { + cat << EOF +value: "$(ynh_read_var_in_file --file="$install_dir/config/config.php" --key="default_phone_region")" +choices: +EOF + jq '.[][] | " \"\(.alpha_2)\": \"\(.name)\""' -r /usr/share/iso-codes/json/iso_3166-1.json -get__maintenance_mode() { - # Maintenance mode status - maintenance_mode_status="$(cd "$install_dir" && ynh_exec_as "$app" \ - php${phpversion} --define apc.enable_cli=1 occ --no-interaction --no-ansi maintenance:mode)" 2> /dev/null - if echo $maintenance_mode_status | grep -q "disabled" - then - echo "0" - elif echo $maintenance_mode_status | grep -q "enabled" - then - echo "1" - else - ynh_print_err --message="Unexpected output from maintenance status check command." - exit 0 - fi +} + +get__default_timezone() { + cat << EOF +value: "$(ynh_read_var_in_file --file="$install_dir/config/config.php" --key="default_timezone")" +choices: +EOF + timedatectl list-timezones --no-pager | sed 's/^/ - /g' } get__fpm_footprint() { @@ -65,21 +65,6 @@ get__free_footprint() { # SPECIFIC SETTERS FOR TOML SHORT KEYS #================================================= -set__maintenance_mode() { - if [ "$maintenance_mode" -eq "0" ]; then - # If maintenance_mode was set to 0, disable maintenance mode - (cd "$install_dir" && ynh_exec_as "$app" \ - php${phpversion} --define apc.enable_cli=1 occ --no-interaction --no-ansi maintenance:mode --off) - ynh_print_info "Maintenance mode disabled" - elif [ "$maintenance_mode" -eq "1" ]; then - # If maintenance_mode was set to 1, enable maintenance mode - (cd "$install_dir" && ynh_exec_as "$app" \ - php${phpversion} --define apc.enable_cli=1 occ --no-interaction --no-ansi maintenance:mode --on) - 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 diff --git a/scripts/install b/scripts/install index a169962..e8c8831 100755 --- a/scripts/install +++ b/scripts/install @@ -24,12 +24,23 @@ phpflags="--define apc.enable_cli=1" # STORE SETTINGS FROM MANIFEST #================================================= -ynh_app_setting_set --app=$app --key=maintenance_mode --value=$maintenance_mode +ynh_app_setting_set --app=$app --key=maintenance --value=$maintenance_mode 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 ynh_app_setting_set --app=$app --key=phpflags --value=$phpflags +ynh_app_setting_set --app=$app --key=has_internet_connection --value=1 +ynh_app_setting_set --app=$app --key=default_phone_region --value="" +ynh_app_setting_set --app=$app --key=default_timezone --value="Europe/Paris" +ynh_app_setting_set --app=$app --key=lost_password_link --value="" +ynh_app_setting_set --app=$app --key=logout_url --value="" +ynh_app_setting_set --app=$app --key=trashbin_retention_obligation --value="auto" +ynh_app_setting_set --app=$app --key=version_retention_obligation --value="auto" +ynh_app_setting_set --app=$app --key=enable_previews --value=1 +ynh_app_setting_set --app=$app --key=auto_update --value=1 +ynh_app_setting_set --app=$app --key=defaultapp --value="dashboard,files" + #================================================= # CREATE A MYSQL DATABASE #=================================================