Nico Huber | a1a296f | 2023-06-25 10:07:07 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | set -e |
| 4 | |
Nico Huber | f020152 | 2023-07-21 13:59:04 +0000 | [diff] [blame] | 5 | config=/var/gerrit/etc/gerrit.config |
| 6 | |
Nico Huber | d9d54fe | 2023-07-21 04:07:05 +0000 | [diff] [blame] | 7 | { |
Nico Huber | f020152 | 2023-07-21 13:59:04 +0000 | [diff] [blame] | 8 | git config -f ${config} --unset-all auth.trustedOpenID || true |
Nico Huber | 2a939a0 | 2023-07-25 21:48:52 +0000 | [diff] [blame^] | 9 | git config -f ${config} auth.gitBasicAuthPolicy HTTP |
| 10 | git config -f ${config} auth.type OAUTH |
Nico Huber | d9d54fe | 2023-07-21 04:07:05 +0000 | [diff] [blame] | 11 | } |
| 12 | |
Nico Huber | 5407310 | 2023-06-25 11:36:59 +0000 | [diff] [blame] | 13 | if [ "${GITHUB_OAUTH_CLIENT_ID}" -a "${GITHUB_OAUTH_CLIENT_SECRET}" ]; then |
Nico Huber | f020152 | 2023-07-21 13:59:04 +0000 | [diff] [blame] | 14 | git config -f ${config} \ |
Nico Huber | 5407310 | 2023-06-25 11:36:59 +0000 | [diff] [blame] | 15 | plugin.gerrit-oauth-provider-github-oauth.root-url "https://github.com/" |
Nico Huber | f020152 | 2023-07-21 13:59:04 +0000 | [diff] [blame] | 16 | git config -f ${config} \ |
Nico Huber | 5407310 | 2023-06-25 11:36:59 +0000 | [diff] [blame] | 17 | plugin.gerrit-oauth-provider-github-oauth.client-id "${GITHUB_OAUTH_CLIENT_ID}" |
Nico Huber | f020152 | 2023-07-21 13:59:04 +0000 | [diff] [blame] | 18 | git config -f ${config} \ |
Nico Huber | 5407310 | 2023-06-25 11:36:59 +0000 | [diff] [blame] | 19 | plugin.gerrit-oauth-provider-github-oauth.client-secret "${GITHUB_OAUTH_CLIENT_SECRET}" |
| 20 | fi |
| 21 | |
Nico Huber | 177e610 | 2023-07-25 13:39:16 +0000 | [diff] [blame] | 22 | if [ "${GERRIT_USER_EMAIL}" -a "${GERRIT_MAIL_PASSWORD}" ]; then |
Nico Huber | f020152 | 2023-07-21 13:59:04 +0000 | [diff] [blame] | 23 | git config -f ${config} user.email ${GERRIT_USER_EMAIL} |
| 24 | git config -f ${config} sendemail.smtpServer mail.${SA_PUBLIC_DOMAIN_NAME} |
| 25 | git config -f ${config} sendemail.smtpServerPort 465 |
| 26 | git config -f ${config} sendemail.smtpEncryption ssl |
| 27 | git config -f ${config} sendemail.smtpUser ${GERRIT_USER_EMAIL} |
Nico Huber | 177e610 | 2023-07-25 13:39:16 +0000 | [diff] [blame] | 28 | git config -f ${config} sendemail.smtpPass ${GERRIT_MAIL_PASSWORD} |
Nico Huber | f020152 | 2023-07-21 13:59:04 +0000 | [diff] [blame] | 29 | git config -f ${config} sendemail.html false |
Nico Huber | b650ed4 | 2023-07-20 17:08:54 +0000 | [diff] [blame] | 30 | fi |
| 31 | |
Nico Huber | 7f8dc5b | 2023-07-25 16:48:01 +0000 | [diff] [blame] | 32 | if [ "${GERRIT_KC_PASSWORD}" ]; then |
| 33 | kc_oauth=plugin.gerrit-oauth-provider-keycloak-oauth |
| 34 | |
| 35 | git config -f ${config} ${kc_oauth}.root-url https://id.${SA_PUBLIC_DOMAIN_NAME}/ |
| 36 | git config -f ${config} ${kc_oauth}.realm sourcearcade |
| 37 | git config -f ${config} ${kc_oauth}.client-id gerrit |
| 38 | git config -f ${config} ${kc_oauth}.client-secret ${GERRIT_KC_PASSWORD} |
| 39 | git config -f ${config} ${kc_oauth}.use-preferred-username true |
Nico Huber | 7f8dc5b | 2023-07-25 16:48:01 +0000 | [diff] [blame] | 40 | fi |
| 41 | |
Nico Huber | a1a296f | 2023-06-25 10:07:07 +0000 | [diff] [blame] | 42 | exec /entrypoint.sh "$@" |