Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a config_panel.toml #395

Draft
wants to merge 1 commit into
base: testing
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions conf/.env.production.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
# -----------------------
Expand Down
47 changes: 47 additions & 0 deletions config_panel.toml
Original file line number Diff line number Diff line change
@@ -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"
14 changes: 14 additions & 0 deletions scripts/install
Original file line number Diff line number Diff line change
Expand Up @@ -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)
#=================================================
Expand Down
21 changes: 21 additions & 0 deletions scripts/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down