1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mastodon_ynh.git synced 2024-09-03 19:46:02 +02:00

enh configpanel for s3

This commit is contained in:
Tagadda 2023-07-23 06:08:42 +02:00 committed by Félix Piédallu
parent 8003baea29
commit 6067cb5cd3
4 changed files with 90 additions and 5 deletions

View file

@ -78,11 +78,14 @@ DEFAULT_LOCALE=__LANGUAGE__
# File storage (optional)
# -----------------------
S3_ENABLED=false
# S3_BUCKET=files.example.com
# AWS_ACCESS_KEY_ID=
# AWS_SECRET_ACCESS_KEY=
# S3_ALIAS_HOST=files.example.com
S3_ENABLED=__S3_ENABLED__
S3_ENDPOINT=__S3_ENDPOINT__
S3_BUCKET=__S3_BUCKET__
AWS_ACCESS_KEY_ID=__S3_ACCESS_KEY_ID__
AWS_SECRET_ACCESS_KEY=__S3_ACCESS_KEY_SECRET__
S3_ALIAS_HOST=__S3_ALIAS_HOST__
#S3_PERMISSION=
S3_FORCE_SINGLE_REQUEST=true
# IP and session retention
# -----------------------

47
config_panel.toml Normal file
View file

@ -0,0 +1,47 @@
version = "1.0"
[main]
[main.s3]
services = ["__APP__-web", "__APP__-sidekiq"]
name = "S3 Configuration"
optional = true
[main.s3.s3_enabled]
ask.en = "Enable S3-compatible media storage"
type = "boolean"
yes = "true"
no = "false"
bind = "S3_ENABLED:__INSTALL_DIR__/live/.env.production"
[main.s3.s3_endpoint]
ask = "S3 Endpoint"
example = "https://minio.domain.tld"
type = "url"
bind = "S3_ENDPOINT:__INSTALL_DIR__/live/.env.production"
visible = "s3_enabled"
[main.s3.s3_bucket]
ask = "S3 Bucket"
type = "string"
example = "mastodata"
bind = "S3_BUCKET:__INSTALL_DIR__/live/.env.production"
visible = "s3_enabled"
[main.s3.s3_access_key_id]
ask = "S3 Access Key ID"
type = "string"
bind = "AWS_ACCESS_KEY_ID:__INSTALL_DIR__/live/.env.production"
visible = "s3_enabled"
[main.s3.s3_access_key_secret]
ask = "S3 Access Key Secret"
type = "password"
bind = "AWS_SECRET_ACCESS_KEY:__INSTALL_DIR__/live/.env.production"
visible = "s3_enabled"
[main.s3.s3_alias_host]
ask = "S3 Alias Host"
help = "https://docs.joinmastodon.org/admin/optional/object-storage-proxy/"
type = "string"
bind = "S3_ALIAS_HOST:/var/www/__APP__/live/.env.production"
visible = "s3_enabled"

View file

@ -14,6 +14,20 @@ admin_mail=$(ynh_user_get_info --username=$admin --key=mail)
# Set `service` settings to support `yunohost app shell` command
ynh_app_setting_set --app="$app" --key=service --value="$app-web.service"
# Define config_panel settings keys...
s3_enabled=false
ynh_app_setting_set --app=$app --key=s3_enabled --value=false
s3_endpoint=""
ynh_app_setting_set --app=$app --key=s3_endpoint --value=""
s3_bucket=""
ynh_app_setting_set --app=$app --key=s3_bucket --value=""
s3_access_key_id=""
ynh_app_setting_set --app=$app --key=s3_access_key_id --value=""
s3_access_key_secret=""
ynh_app_setting_set --app=$app --key=s3_access_key_secret --value=""
s3_alias_host=""
ynh_app_setting_set --app=$app --key=s3_alias_host --value=""
#=================================================
# APP "BUILD" (DEPLOYING SOURCES, VENV, COMPILING ETC)
#=================================================

View file

@ -40,6 +40,27 @@ if [[ -z "${service:-}" ]]; then
ynh_app_setting_set --app="$app" --key=service --value="$service"
fi
# If s3_enabled doesn't exist, create it
if [[ -z "$s3_enabled" ]]; then
s3_enabled=$(ynh_read_var_in_file --file="$config" --key="S3_ENABLED")
ynh_app_setting_set --app=$app --key=s3_enabled --value=$s3_enabled
s3_endpoint=$(ynh_read_var_in_file --file="$config" --key="S3_ENDPOINT")
ynh_app_setting_set --app=$app --key=s3_endpoint --value=$s3_endpoint
s3_bucket=$(ynh_read_var_in_file --file="$config" --key="S3_BUCKET")
ynh_app_setting_set --app=$app --key=s3_bucket --value=$s3_bucket
s3_access_key_id=$(ynh_read_var_in_file --file="$config" --key="AWS_ACCESS_KEY_ID")
ynh_app_setting_set --app=$app --key=s3_access_key_id --value=$s3_access_key_id
s3_access_key_secret=$(ynh_read_var_in_file --file="$config" --key="AWS_SECRET_ACCESS_KEY")
ynh_app_setting_set --app=$app --key=s3_access_key_secret --value=$s3_access_key_secret
s3_alias_host=$(ynh_read_var_in_file --file="$config" --key="S3_ALIAS_HOST")
ynh_app_setting_set --app=$app --key=s3_alias_host --value=$s3_alias_host
fi
# Remove previous added repository
ynh_remove_extra_repo