Add jwt secret because gitea edit config if not present

This commit is contained in:
Josué Tille 2023-12-13 10:38:10 +01:00
parent 676d283d14
commit b7b73bbf89
No known key found for this signature in database
GPG Key ID: 716A6C99B04194EF
3 changed files with 13 additions and 3 deletions

View File

@ -2,7 +2,7 @@
APP_NAME = Gitea APP_NAME = Gitea
RUN_USER = __APP__ RUN_USER = __APP__
RUN_MODE = prod RUN_MODE = prod
WORK_PATH =__INSTALL_DIR__ WORK_PATH = __INSTALL_DIR__
[actions] [actions]
ENABLED = false ENABLED = false
@ -78,7 +78,7 @@ logger.access.MODE =
logger.router.MODE = router logger.router.MODE = router
logger.xorm.MODE = xorm logger.xorm.MODE = xorm
REDIRECT_MACARON_LOG= true REDIRECT_MACARON_LOG = true
MACARON = file MACARON = file
[log.file] [log.file]
@ -101,3 +101,6 @@ SECRET_KEY = __SECRET_KEY__
REVERSE_PROXY_AUTHENTICATION_USER = REMOTE-USER REVERSE_PROXY_AUTHENTICATION_USER = REMOTE-USER
REVERSE_PROXY_TRUSTED_PROXIES = 127.0.0.0/8,::1/128 REVERSE_PROXY_TRUSTED_PROXIES = 127.0.0.0/8,::1/128
INTERNAL_TOKEN = __INTERNAL_TOKEN__ INTERNAL_TOKEN = __INTERNAL_TOKEN__
[oauth2]
JWT_SECRET = __JWT_SECRET__

View File

@ -45,10 +45,12 @@ ynh_script_progression --message="Configuring application, step 1/2..."
internal_token=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret INTERNAL_TOKEN) internal_token=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret INTERNAL_TOKEN)
secret_key=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret SECRET_KEY) secret_key=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret SECRET_KEY)
lfs_jwt_secret=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET) lfs_jwt_secret=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET)
jwt_secret=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET)
ynh_app_setting_set --app="$app" --key=internal_token --value="$internal_token" ynh_app_setting_set --app="$app" --key=internal_token --value="$internal_token"
ynh_app_setting_set --app="$app" --key=secret_key --value="$secret_key" ynh_app_setting_set --app="$app" --key=secret_key --value="$secret_key"
ynh_app_setting_set --app="$app" --key=lfs_jwt_secret --value="$lfs_jwt_secret" ynh_app_setting_set --app="$app" --key=lfs_jwt_secret --value="$lfs_jwt_secret"
ynh_app_setting_set --app "$app" --key jwt_secret --value="$jwt_secret"
ynh_add_config --template='app.ini' --destination="$install_dir/custom/conf/app.ini" ynh_add_config --template='app.ini' --destination="$install_dir/custom/conf/app.ini"

View File

@ -81,6 +81,11 @@ if [[ -z "${lfs_jwt_secret:-}" ]]; then
ynh_app_setting_set --app "$app" --key lfs_jwt_secret --value="$lfs_jwt_secret" ynh_app_setting_set --app "$app" --key lfs_jwt_secret --value="$lfs_jwt_secret"
fi fi
if [[ -z "${jwt_secret:-}" ]]; then
jwt_secret=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET)
ynh_app_setting_set --app "$app" --key jwt_secret --value="$jwt_secret"
fi
#================================================= #=================================================
# UPDATE A CONFIG FILE # UPDATE A CONFIG FILE
#================================================= #=================================================