From 85780b0cdf7d173bf577ce7f080581808772d664 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 26 Feb 2024 00:44:32 +0100 Subject: [PATCH] resolve version conflict --- conf/app.ini | 19 +++-- config_panel.toml | 133 ++++++++++++++++++++++++++++++++ doc/PRE_UPGRADE.d/1.21.6-0~ynh2 | 2 + scripts/install | 28 +++++++ scripts/upgrade | 29 +++++++ 5 files changed, 206 insertions(+), 5 deletions(-) create mode 100644 config_panel.toml create mode 100644 doc/PRE_UPGRADE.d/1.21.6-0~ynh2 diff --git a/conf/app.ini b/conf/app.ini index ac50d96..4458280 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -39,11 +39,13 @@ FROM = "Forgejo" FORCE_TRUST_SERVER_CERT = true [service] -REGISTER_EMAIL_CONFIRM = false -ENABLE_NOTIFY_MAIL = true -DISABLE_REGISTRATION = true -ENABLE_CAPTCHA = false -REQUIRE_SIGNIN_VIEW = false +REGISTER_EMAIL_CONFIRM = __REGISTER_EMAIL_CONFIRM__ +REGISTER_MANUAL_CONFIRM = __REGISTER_MANUAL_CONFIRM__ +DISABLE_REGISTRATION = __DISABLE_REGISTRATION__ +REQUIRE_SIGNIN_VIEW = __REQUIRE_SIGNIN_VIEW__ +ENABLE_NOTIFY_MAIL = __ENABLE_NOTIFY_MAIL__ +SHOW_REGISTRATION_BUTTON = __SHOW_REGISTRATION_BUTTON__ + ENABLE_REVERSE_PROXY_AUTHENTICATION = true ENABLE_REVERSE_PROXY_AUTO_REGISTRATION = true ENABLE_REVERSE_PROXY_EMAIL = true @@ -55,6 +57,13 @@ REPOSITORY_AVATAR_UPLOAD_PATH = __DATA_DIR__/data/repo-avatars [attachment] PATH = __DATA_DIR__/attachments +[mirror] +ENABLED = __MIRROR_ENABLED__ +DISABLE_NEW_PULL = __MIRROR_DISABLE_NEW_PULL__ +DISABLE_NEW_PUSH = __MIRROR_DISABLE_NEW_PUSH__ +DEFAULT_INTERVAL = __MIRROR_DEFAULT_INTERVAL__ +MIN_INTERVAL = __MIRROR_MIN_INTERVAL__ + [session] PROVIDER = memory diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..c56f738 --- /dev/null +++ b/config_panel.toml @@ -0,0 +1,133 @@ +version = "1.0" + +[main] + +services = [ "__APP__" ] + +name.en = "Config panel" +name.fr = "Panneau de configuration" + +help = "Here you can easily configure some things about your Forgejo instance." + +#################### +#### SERVICE CONFIG +#################### + + [main.service] + name = "Service config" + help = "" + + [main.service.register_email_confirm] + ask.en = "Email confirmation on registration?" + ask.fr = "Confirmation d'email à l'inscription ?" + bind = "REGISTER_EMAIL_CONFIRM:__INSTALL_DIR__/custom/conf/app.ini" + help.en = "REGISTER_EMAIL_CONFIRM: Whether a new user needs to confirm their email when registering." + help.fr = "REGISTER_EMAIL_CONFIRM : Si un nouvel utilisateur doit confirmer son adresse électronique lors de l'inscription." + type = "boolean" + yes = "true" + no = "false" + + [main.service.register_manual_confirm] + ask.en = "Email confirmation on registration?" + ask.fr = "Confirmation d'email à l'inscription ?" + bind = "REGISTER_MANUAL_CONFIRM:__INSTALL_DIR__/custom/conf/app.ini" + help.en = "REGISTER_MANUAL_CONFIRM: Whether a new user needs to be confirmed manually after registration. (Requires `REGISTER_EMAIL_CONFIRM` to be disabled.)" + help.fr = "REGISTER_MANUAL_CONFIRM : Si un nouvel utilisateur doit être confirmé manuellement après son inscription. (Nécessite que `REGISTER_EMAIL_CONFIRM` soit désactivé)." + type = "boolean" + yes = "true" + no = "false" + + [main.service.disable_registration] + ask.en = "Email confirmation on registration?" + ask.fr = "Confirmation d'email à l'inscription ?" + bind = "DISABLE_REGISTRATION:__INSTALL_DIR__/custom/conf/app.ini" + help.en = "DISABLE_REGISTRATION: Disallow registration, only allow admins to create accounts." + help.fr = "DISABLE_REGISTRATION : Ne pas autoriser l'inscription, permettre uniquement aux administrateurs de créer des comptes." + type = "boolean" + yes = "true" + no = "false" + + [main.service.require_signin_view] + ask.en = "Email confirmation on registration?" + ask.fr = "Confirmation d'email à l'inscription ?" + bind = "REQUIRE_SIGNIN_VIEW:__INSTALL_DIR__/custom/conf/app.ini" + help.en = "REQUIRE_SIGNIN_VIEW: User must sign in to view anything." + help.fr = "REQUIRE_SIGNIN_VIEW : L'utilisateur doit s'identifier pour visualiser le contenu." + type = "boolean" + yes = "true" + no = "false" + + [main.service.mail_notification] + ask.en = "Mail notification?" + ask.fr = "Notification par courriel ?" + bind = "ENABLE_NOTIFY_MAIL:__INSTALL_DIR__/custom/conf/app.ini" + type = "boolean" + yes = "true" + no = "false" + + [main.service.show_registration_button] + ask.en = "Show Registration button?" + ask.fr = "Afficher le bouton d'inscription ?" + bind = "SHOW_REGISTRATION_BUTTON:__INSTALL_DIR__/custom/conf/app.ini" + type = "boolean" + yes = "true" + no = "false" + + + #################### + #### MIRROR CONFIG + #################### + +[main.mirror] +name = "Mirror config" +help = "Config pertaining to repo mirroring." + + [main.mirror.enabled] + ask.en = "Enable the mirror functionality?" + ask.fr = "Activer la fonctionnalité mirroir ?" + bind = "mirror>ENABLED:__INSTALL_DIR__/custom/conf/app.ini" + type = "boolean" + yes = "true" + no = "false" + help.en = "Set to **false** to disable all mirrors. Pre-existing mirrors remain valid but won't be updated; may be converted to regular repo." + help.fr = "Définir à **false** pour désactiver tous les miroirs. Les miroirs préexistants restent valables mais ne seront pas mis à jour ; ils peuvent être convertis en dépôts normaux." + + [main.mirror.disable_new_pull] + ask.en = "Disable pull mirroring?" + ask.fr = "Désactiver les miroirs pull ?" + bind = "mirror>DISABLE_NEW_PULL:__INSTALL_DIR__/custom/conf/app.ini" + type = "boolean" + yes = "true" + no = "false" + help.en = "Disable the creation of **new** pull mirrors. Pre-existing mirrors remain valid. Will be ignored if `mirror.ENABLED` is `false`." + help.fr = "Désactive la création de **nouveaux** miroirs pull. Les miroirs préexistants restent valables. Sera ignoré si `mirror.ENABLED` est `false`." + + [main.mirror.disable_new_push] + ask.en = "Disable push mirroring?" + ask.fr = "Désactiver les miroirs push ?" + bind = "mirror>DISABLE_NEW_PULL:__INSTALL_DIR__/custom/conf/app.ini" + type = "boolean" + yes = "true" + no = "false" + help.en = "Disable the creation of **new** push mirrors. Pre-existing mirrors remain valid. Will be ignored if `mirror.ENABLED` is `false`." + help.fr = "Désactive la création de **nouveaux** miroirs push. Les miroirs préexistants restent valables. Sera ignoré si `mirror.ENABLED` est `false`." + + [main.mirror.default_interval] + ask.en = "Default duration between each check?" + ask.fr = "Durée par défaut entre chaque contrôle ?" + bind = "mirror>DEFAULT_INTERVAL:__INSTALL_DIR__/custom/conf/app.ini" + type = "string" + help.en = "Examples: '8h', '30m'" + help.fr = "Exemples : '8h', '30m'" + pattern.regexp = '^[0-9]+(m$|h$|d$)$' + pattern.error = "Must begin with one or more digits and end with 'm', 'h' or 'd'." + + [main.mirror.min_interval] + ask.en = "Minimum duration between each check?" + ask.fr = "Durée minimale entre chaque contrôle ?" + bind = "mirror>MIN_INTERVAL:__INSTALL_DIR__/custom/conf/app.ini" + type = "string" + help.en = "Examples: '2h', '10m'" + help.fr = "Exemples : '2h', '10m'" + pattern.regexp = '(?!^[0-1]m$)(^[0-9]+(m$|h$|d$)$)' + pattern.error = "Must begin with one or more digits and end with 'm', 'h' or 'd'. Must not be more than '1m'." diff --git a/doc/PRE_UPGRADE.d/1.21.6-0~ynh2 b/doc/PRE_UPGRADE.d/1.21.6-0~ynh2 new file mode 100644 index 0000000..857a30c --- /dev/null +++ b/doc/PRE_UPGRADE.d/1.21.6-0~ynh2 @@ -0,0 +1,2 @@ +Starting with this update, you can configure your instance using the config panel integrated in Yunohost, you will find it in the web admin interface of your Yunohost by following these steps: +`Applications > Forgejo > Config Panel` diff --git a/scripts/install b/scripts/install index 4441ee9..5cb2691 100644 --- a/scripts/install +++ b/scripts/install @@ -40,6 +40,34 @@ ynh_app_setting_set --app=$app --key=oauth2_jwt_secret --value=$oauth2_jwt_secre #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 +register_email_confirm=false +register_manual_confirm=false +disable_registration=true +require_signin_view=false +enable_notify_mail=true +show_registration_button=true + +mirror_enabled=true +mirror_disable_new_pull=false +mirror_disable_new_push=false +mirror_default_interval="8h" +mirror_min_interval="10m" + +ynh_app_setting_set --app="$app" --key=register_email_confirm --value=$register_email_confirm +ynh_app_setting_set --app="$app" --key=register_manual_confirm --value=$register_manual_confirm +ynh_app_setting_set --app="$app" --key=disable_registration --value=$disable_registration +ynh_app_setting_set --app="$app" --key=require_signin_view --value=$require_signin_view +ynh_app_setting_set --app="$app" --key=enable_notify_mail --value=$enable_notify_mail +ynh_app_setting_set --app="$app" --key=show_registration_button --value=$show_registration_button + +ynh_app_setting_set --app="$app" --key=mirror_enabled --value=$mirror_enabled +ynh_app_setting_set --app="$app" --key=mirror_disable_new_pull --value=$mirror_disable_new_pull +ynh_app_setting_set --app="$app" --key=mirror_disable_new_push --value=$mirror_disable_new_push +ynh_app_setting_set --app="$app" --key=mirror_default_interval --value=$mirror_default_interval +ynh_app_setting_set --app="$app" --key=mirror_min_interval --value=$mirror_min_interval + + + ssh_port=$(grep -P "Port\s+\d+" /etc/ssh/sshd_config | grep -P -o "\d+") ynh_add_config --template="app.ini" --destination="$install_dir/custom/conf/app.ini" diff --git a/scripts/upgrade b/scripts/upgrade index eefa6ad..102266f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -80,6 +80,35 @@ if [ -z ${oauth2_jwt_secret:-} ]; then ynh_app_setting_set --app=$app --key=oauth2_jwt_secret --value=$oauth2_jwt_secret fi +# if we update from a version prior to the config panel, create new settings +if [ -z "${register_email_confirm:-}" ]; then + register_email_confirm=false + register_manual_confirm=false + disable_registration=true + require_signin_view=false + enable_notify_mail=true + show_registration_button=true + + mirror_enabled=true + mirror_disable_new_pull=false + mirror_disable_new_push=false + mirror_default_interval="8h" + mirror_min_interval="10m" + + ynh_app_setting_set --app="$app" --key=register_email_confirm --value=$register_email_confirm + ynh_app_setting_set --app="$app" --key=register_manual_confirm --value=$register_manual_confirm + ynh_app_setting_set --app="$app" --key=disable_registration --value=$disable_registration + ynh_app_setting_set --app="$app" --key=require_signin_view --value=$require_signin_view + ynh_app_setting_set --app="$app" --key=enable_notify_mail --value=$enable_notify_mail + ynh_app_setting_set --app="$app" --key=show_registration_button --value=$show_registration_button + + ynh_app_setting_set --app="$app" --key=mirror_enabled --value=$mirror_enabled + ynh_app_setting_set --app="$app" --key=mirror_disable_new_pull --value=$mirror_disable_new_pull + ynh_app_setting_set --app="$app" --key=mirror_disable_new_push --value=$mirror_disable_new_push + ynh_app_setting_set --app="$app" --key=mirror_default_interval --value=$mirror_default_interval + ynh_app_setting_set --app="$app" --key=mirror_min_interval --value=$mirror_min_interval +fi + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #=================================================