diff --git a/conf/woodpecker-server.conf b/conf/woodpecker-server.conf index 89991af..d6ad5cf 100644 --- a/conf/woodpecker-server.conf +++ b/conf/woodpecker-server.conf @@ -10,7 +10,7 @@ # Enable pretty-printed debug output. # Default: false -#WOODPECKER_DEBUG_PRETTY= +WOODPECKER_DEBUG_PRETTY=true # Disable colored debug output. # Default: true @@ -144,3 +144,10 @@ WOODPECKER_DATABASE_DATASOURCE=postgres://__DB_USER__:__DB_PWD__@localhost:5432/ # Default: empty # Example: WOODPECKER_LIMIT_CPU_SET=1,2 #WOODPECKER_LIMIT_CPU_SET= + + +## Forge configuration from yunohost +__CONFIG_FORGE_TYPE__ +__CONFIG_FORGE_URL__ +__CONFIG_FORGE_CLIENT__ +__CONFIG_FORGE_SECRET__ diff --git a/manifest.toml b/manifest.toml index cb84d96..9bcdb7a 100644 --- a/manifest.toml +++ b/manifest.toml @@ -45,12 +45,31 @@ ram.runtime = "200M" type = "group" default = "visitors" - # [install.language] - # ask.en = "Choose the application language" - # ask.fr = "Choisissez la langue de l'application" - # type = "select" - # choices = ["fr", "en"] - # default = "fr" + [install.forge_type] + ask.en = "Select the kind of forge you're connecting Woodpecker to" + ask.fr = "Sélectionnez le type de forge à laquelle vous connectez Woodpecker" + type = "select" + choices.github = "Github" + choices.gitlab = "Gitlab" + choices.gitea = "Gitea / Forgejo" + choices.bitbucket = "Bitbucket" + + [install.forge_url] + ask.en = "Provide the forge URL" + ask.fr = "Entrez l'URL de la forge" + type = "string" + help.en = "Useless for Bitbucket and Github.com." + help.fr = "Inutile pour Bitbucket et Github.com." + + [install.forge_client] + ask.en = "Provide the forge OAuth Client ID" + ask.fr = "Entrez l'ID de client OAuth de la forge" + type = "string" + + [install.forge_secret] + ask.en = "Provide the forge OAuth secret" + ask.fr = "Entrez le secret OAuth de la forge" + type = "string" # [install.admin] # type = "user" diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..2b0f23a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,6 +8,19 @@ # PERSONAL HELPERS #================================================= +_woodpecker_set_forge_config() { + FORGE=$(printf '%s\n' "$forge_type" | awk '{ print toupper($0) }') + config_forge_type="WOODPECKER_${FORGE}=true" + config_forge_client="WOODPECKER_${FORGE}_CLIENT=$forge_client" + config_forge_secret="WOODPECKER_${FORGE}_SECRET=$forge_secret" + + if [[ -n "$forge_url" ]]; then + config_forge_url="WOODPECKER_${FORGE}_URL=$forge_url" + else + config_forge_url="# no forge url" + fi +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 7c974b0..e7b6b08 100755 --- a/scripts/install +++ b/scripts/install @@ -70,6 +70,7 @@ ynh_use_logrotate ynh_script_progression --message="Adding a configuration file..." --weight=1 path_no_trailing_slash=${path%/} +_woodpecker_set_forge_config ynh_add_config --template="woodpecker-server.conf" --destination="$install_dir/woodpecker-server.conf" # chmod 400 "$install_dir/some_config_file"