diff --git a/conf/nginx.conf b/conf/nginx.conf index db3e9e6..a6db09c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -9,7 +9,7 @@ location __PATH__/ { proxy_pass http://localhost:__PORT__; - client_max_body_size 50M; + client_max_body_size __CLIENT_MAX_BODY_SIZE__; # Include SSOWAT user panel. include conf.d/yunohost_panel.conf.inc; diff --git a/config_panel.toml b/config_panel.toml index ea34ec9..f8cf80b 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -1,204 +1,190 @@ -## Config panel are available from webadmin > Apps > YOUR_APP > Config Panel Button -## Those panels let user configure some params on their apps using a friendly interface, -## and remove the need to manually edit files from the command line. - -## From a packager perspective, this .toml is coupled to the scripts/config script, -## which may be used to define custom getters/setters. However, most use cases -## should be covered automagically by the core, thus it may not be necessary -## to define a scripts/config at all! - -## ----------------------------------------------------------------------------- -## IMPORTANT: In accordance with YunoHost's spirit, please keep things simple and -## do not overwhelm the admin with tons of misunderstandable or advanced settings. -## ----------------------------------------------------------------------------- - -## The top level describe the entire config panels screen. - -## The version is a required property. -## Here a small reminder to associate config panel version with YunoHost version -## | Config | YNH | Config panel small change log | -## | ------ | --- | ------------------------------------------------------- | -## | 0.1 | 3.x | 0.1 config script not compatible with YNH >= 4.3 | -## | 1.0 | 4.3.x | The new config panel system with 'bind' property | version = "1.0" -## (optional) i18n property let you internationalize questions, however this feature -## is only available in core configuration panel (like yunohost domain config). -## So in app config panel this key is ignored for now, but you can internationalize -## by using a lang dictionary (see property name bellow) -# i18n = "prefix_translation_key" +[gotosocial] -################################################################################ -#### ABOUT PANELS -################################################################################ - -## The next level describes web admin panels -## You have to choose an ID for each panel, in this example the ID is "main" -## Keep in mind this ID will be used in CLI to refer to your question, so choose -## something short and meaningfull. -## In the webadmin, each panel corresponds to a distinct tab / form -[main] - -## Define the label for your panel -## Internationalization works similarly to the 'description' and 'ask' questions in the manifest -name.en = "GoToSocial administration panel" -name.fr = "Interface d'admin de GoToSocial" - -## (optional) If you need to trigger a service reload-or-restart after the user -## change a question in this panel, you can add your service in the list. services = ["__APP__"] -# or services = ["nginx", "__APP__"] to also reload-or-restart nginx -## (optional) This help properties is a short help displayed on the same line -## than the panel title but not displayed in the tab. -# help = "" +name.en = "GoToSocial configuration panel" +name.fr = "Configuration de GoToSocial" -############################################################################ -#### ABOUT SECTIONS -############################################################################ +help.en = "" +help.fr = "" -## A panel is composed of one or several sections. -## -## Sections are meant to group questions together when they correspond to -## a same subtopic. This impacts the rendering in terms of CLI prompts -## and HTML forms -## -## You should choose an ID for your section, and prefix it with the panel ID -## (Be sure to not make a typo in the panel ID, which would implicitly create -## an other entire panel) -## -## We use the context of pepettes_ynh as an example, -## which is a simple donation form app written in python, -## and for which the admin will want to edit the configuration -[main.customization] +#### ACCOUNTS CONFIG -## (optional) Defining a proper title for sections is not mandatory -## and depends on the exact rendering you're aiming for the CLI / webadmin -name = "" +[gotosocial.accounts] -## (optional) This help properties is a short help displayed on the same line -## than the section title, meant to provide additional details -# help = "" +name.en = "Account config" +name.fr = "Configuration des inscriptions" -## (optional) As for panel, you can specify to trigger a service -## reload-or-restart after the user change a question in this section. -## This property is added to the panel property, it doesn't deactivate it. -## So no need to replicate, the service list from panel services property. -# services = [] +help.en = "Config pertaining to creation and maintenance of accounts on the server, as well as defaults for new accounts." +help.fr = "" -## (optional) By default all questions are optionals, but you can specify a -## default behaviour for question in the section +[gotosocial.accounts.registration-open] +ask.en = "Open registrations?" +ask.fr = "" +bind = "accounts-registration-open:__FINALPATH__/config.yaml" +default = "false" +help.en = "Do we want people to be able to just submit sign up requests, or do we want invite only?" +help.fr = "" +type = "boolean" -optional = false -## (optional) It's also possible with the 'visible' property to only -## display the section depending on the user's answers to previous questions. -## -## Be careful that the 'visible' property should only refer to **previous** questions -## Hence, it should not make sense to have a "visible" property on the very first section. -## -## Also, keep in mind that this feature only works in the webadmin and not in CLI -## (therefore a user could be prompted in CLI for a question that may not be relevant) -# visible = true +[gotosocial.accounts.approval-required] +ask.en = "Approval required?" +ask.fr = "" +bind = "accounts-approval-required:__FINALPATH__/config.yaml" +default = "true" +help.en = "Do sign up requests require approval from an admin/moderator before an account can sign in/use the server?" +help.fr = "" +type = "boolean" -######################################################################## -#### ABOUT QUESTIONS -######################################################################## +[gotosocial.accounts.reason-required] +ask.en = "Reason required?" +ask.fr = "" +bind = "accounts-reason-required:__FINALPATH__/config.yaml" +default = "true" +help.en = "Are sign up requests required to submit a reason for the request (eg., an explanation of why they want to join the instance)?" +help.fr = "" +type = "boolean" -## A section is compound of one or several questions. +#### MEDIA CONFIG -## --------------------------------------------------------------------- -## IMPORTANT: as for panel and section you have to choose an ID, but this -## one should be unique in all this document, even if the question is in -## an other panel. -## --------------------------------------------------------------------- +[gotosocial.media] +name.en = "Media config" +name.fr = "Configuration des médias" -## You can use same questions types and properties than in manifest.yml -## install part. However, in YNH 4.3, a lot of change has been made to -## extend availables questions types list. -## See: TODO DOC LINK +help.en = "Config pertaining to user media uploads (videos, image, image descriptions)." +help.fr = "" -[main.customization.project_name] +[gotosocial.media.image-max-size] +ask.en = "Maximum allowed image upload size in bytes." +ask.fr = "" +bind = "media-image-max-size:__FINALPATH__/config.yaml" +default = "2097152" +help.en = "Default: 2097152 -- aka 2MB" +help.fr = "" +type = "number" -## (required) The ask property is equivalent to the ask property in -## the manifest. However, in config panels, questions are displayed on the -## left side and therefore have less space to be rendered. Therefore, -## it is better to use a short question, and use the "help" property to -## provide additional details if necessary. -ask.en = "Name of the project" +[gotosocial.media.video-max-size] +ask.en = "Maximum allowed video upload size in bytes." +ask.fr = "" +bind = "media-video-max-size:__FINALPATH__/config.yaml" +default = "10485760" +help.en = "Default: 10485760 -- aka 10MB" +help.fr = "" +type = "number" -## (required) The type property indicates how the question should be -## displayed, validated and managed. Some types have specific properties. -## -## Types available: string, boolean, number, range, text, password, path -## email, url, date, time, color, select, domain, user, tags, file. -## -## For a complete list with specific properties, see: TODO DOC LINK +[gotosocial.media.description-min-chars] +ask.en = "Minimum amount of characters required as an image or video description." +ask.fr = "" +bind = "media-description-min-chars:__FINALPATH__/config.yaml" +default = "0" +help.en = "Default: 0 (not required)" +help.fr = "" +type = "number" +[gotosocial.media.description-max-chars] +ask.en = "Maximum amount of characters permitted in an image or video description." +ask.fr = "" +bind = "media-description-max-chars:__FINALPATH__/config.yaml" +default = "500" +help.en = "Default: 500." +help.fr = "" +type = "number" + +[gotosocial.media.remote-cache-days] +ask.en = "Number of days to cache media from remote instances before they are removed from the cache." +ask.fr = "" +bind = "media-remote-cache-days:__FINALPATH__/config.yaml" +default = "30" +help.en = """\ +Default: 30.\ +A job will run every day at midnight to clean up any remote media older than the given amount of days. \ +When remote media is removed from the cache, it is deleted from storage but the database entries for the media are kept so that it can be fetched again if requested by a user.\ +If this is set to 0, then media from remote instances will be cached indefinitely.\ +""" +help.fr = "" +type = "number" + +### STATUSES CONFIG + +[gotosocial.statuses] +name.en = "Status config" +name.fr = "Configuration des status" + +help.en = "Config pertaining to the creation of statuses/posts, and permitted limits." +help.fr = "" + +[gotosocial.statuses.max-chars] +ask.en = "Maximum amount of characters permitted for a new status." +ask.fr = "" +bind = "statuses-max-chars:__FINALPATH__/config.yaml" +default = "5000" +help.en = "Default: 5000. Note that going way higher than the default might break federation." +help.fr = "" +type = "number" + +[gotosocial.statuses.cw-max-chars] +ask.en = "Maximum amount of characters allowed in the CW/subject header of a status." +ask.fr = "" +bind = "statuses-cw-max-chars:__FINALPATH__/config.yaml" +default = "100" +help.en = "Default: 100. Note that going way higher than the default might break federation." +help.fr = "" +type = "number" + +[gotosocial.statuses.poll-max-options] +ask.en = "Maximum amount of options to permit when creating a new poll." +ask.fr = "" +bind = "statuses-poll-max-options:__FINALPATH__/config.yaml" +default = "6" +help.en = "Default: 6. Note that going way higher than the default might break federation." +help.fr = "" +type = "number" + +[gotosocial.statuses.poll-option-max-chars] +ask.en = "Maximum amount of characters to permit per poll option when creating a new poll." +ask.fr = "" +bind = "statuses-poll-option-max-chars:__FINALPATH__/config.yaml" +default = "50" +help.en = "Default: 50. Note that going way higher than the default might break federation." +help.fr = "" +type = "number" + +[gotosocial.statuses.media-max-files] +ask.en = "Maximum amount of media files that can be attached to a new status." +ask.fr = "" +bind = "statuses-media-max-files:__FINALPATH__/config.yaml" +default = "6" +help.en = "Default: 6. Note that going way higher than the default might break federation." +help.fr = "" +type = "number" + +### NGINX CONFIG + +[nginx] + +services = ["nginx"] + +name.en = "nginx configuration" +name.fr = "Configuration de nginx" + +[nginx.config] +name.en = "nginx configuration" +name.fr = "Configuration de nginx" + +help.en = "Config pertaining to the Web server." +help.fr = "" + +[nginx.config.max-client_max_body_size] +ask.en = "Sets the maximum allowed size of uploaded files." +ask.fr = "" +bind = "client_max_body_size:/etc/nginx/conf.d/__DOMAIN__/__APP__.conf" +default = "50M" +help.en = "Default: 50M." +help.fr = "" type = "string" -######################################################################## -#### ABOUT THE BIND PROPERTY -######################################################################## - -## (recommended) 'bind' property is a powerful feature that let you -## configure how and where the data will be read, validated and written. - -## By default, 'bind property is in "settings" mode, it means it will -## **only** read and write the value in application settings file. -## bind = "settings" - -## However, settings usually correspond to key/values in actual app configurations -## Hence, a more useful mode is to have bind = ":FILENAME". In that case, YunoHost -## will automagically find a line with "KEY=VALUE" in FILENAME -## (with the adequate separator between KEY and VALUE) -## -## YunoHost will then use this value for the read/get operation. -## During write/set operations, YunoHost will overwrite the value -## in **both** FILENAME and in the app's settings.yml - -## Configuration file format supported: yaml, toml, json, ini, env, php, -## python. The feature probably works with others formats, but should be tested carefully. - -## Note that this feature only works with relatively simple cases -## such as `KEY: VALUE`, but won't properly work with -## complex data structures like multilin array/lists or dictionnaries. -## It also doesn't work with XML format, custom config function call, php define(), ... - -## More info on TODO -# bind = ":/var/www/__APP__/settings.py" - -## By default, bind = ":FILENAME" will use the question ID as KEY -## ... but the question ID may sometime not be the exact KEY name in the configuration file. -## -## In particular, in pepettes, the python variable is 'name' and not 'project_name' -## (c.f. https://github.com/YunoHost-Apps/pepettes_ynh/blob/5cc2d3ffd6529cc7356ff93af92dbb6785c3ab9a/conf/settings.py##L11 ) -## -## In that case, the key name can be specified before the column ':' - -bind = "name:/var/www/__APP__/settings.py" - -## --------------------------------------------------------------------- -## IMPORTANT: other 'bind' mode exists: -## -## bind = "FILENAME" (with no column character before FILENAME) -## may be used to bind to the **entire file content** (instead of a single KEY/VALUE) -## This could be used to expose an entire configuration file, or binary files such as images -## For example: -## bind = "/var/www/__APP__/img/logo.png" -## -## bind = "null" can be used to disable reading / writing in settings. -## This creates sort of a "virtual" or "ephemeral" question which is not related to any actual setting -## In this mode, you are expected to define custom getter/setters/validators in scripts/config: -## -## getter: get__QUESTIONID() -## setter: set__QUESTIONID() -## validator: validate__QUESTIONID() -## -## You can also specify a common getter / setter / validator, with the -## function 'bind' mode, for example here it will try to run -## get__array_settings() first. -# bind = "array_settings()" -## --------------------------------------------------------------------- ## --------------------------------------------------------------------- ## IMPORTANT: with the exception of bind=null questions, @@ -207,87 +193,3 @@ bind = "name:/var/www/__APP__/settings.py" ## Not doing so may result in inconsistencies between the config panel mechanism ## and the use of ynh_add_config ## --------------------------------------------------------------------- - -######################################################################## -#### OTHER GENERIC PROPERTY FOR QUESTIONS -######################################################################## - -## (optional) An help text for the question -help = "Fill the name of the project which will received donation" - -## (optional) An example display as placeholder in web form -# example = "YunoHost" - -## (optional) set to true in order to redact the value in operation logs -# redact = false - -## (optional) A validation pattern -## --------------------------------------------------------------------- -## IMPORTANT: your pattern should be between simple quote, not double. -## --------------------------------------------------------------------- -pattern.error = "The name should be at least 3 chars and less than 30 chars. Alphanumeric chars are accepted" -pattern.regexp = '^\w{3,30}$' - -## Note: visible and optional properties are also available for questions - -[main.customization.contact_url] -ask = "Contact url" -bind = ":/var/www/__APP__/settings.py" -example = "mailto: contact@example.org" -help = "mailto: accepted" -pattern.error = "Should be https or mailto:" -pattern.regexp = '^mailto:[^@]+@[^@]+|https://$' -type = "url" - -[main.customization.logo] - -accept = ".png" -ask = "Logo" -bind = "__FINALPATH__/img/logo.png" -help = "Fill with an already resized logo" -type = "file" -[main.customization.favicon] -accept = ".png" -ask = "Favicon" -bind = "__FINALPATH__/img/favicon.png" -help = "Fill with an already sized favicon" -type = "file" - - -[main.stripe] -name = "Stripe general info" -optional = false - -# The next alert is overwrited with a getter from the config script -[main.stripe.amount] -ask = "Donation in the month : XX € - type = "alert" - style = "success" - - [main.stripe.publishable_key] - ask = "Publishable key" - type = "string" - redact = true - help = "Indicate here the stripe publishable key" - bind = ":/var/www/__APP__/settings.py" - - [main.stripe.secret_key] - ask = "Secret key" - type = "string" - redact = true - help = "Indicate here the stripe secret key" - bind = ":/var/www/__APP__/settings.py" - - [main.stripe.prices] - ask = "Prices ID" - type = "tags" - help = """\ -Indicates here the prices ID of donation products you created in stripe interfaces. \ -Go on [Stripeproducts](https://dashboard.stripe.com/products)tocreatethosedonationproducts.\ -Fill it tag with 'FREQUENCY/CURRENCY/PRICE_ID' \ -FREQUENCY: 'one_time' or 'recuring' \ -CURRENCY: 'EUR' or 'USD' \ -PRICE_ID: ID from stripe interfaces starting with 'price_' \ -""" -pattern.error = "Please respect the format describe in help text for each price ID" -pattern.regexp = '^(one_time|recuring)/(EUR|USD)/price_.*$' diff --git a/scripts/install b/scripts/install index d29a529..a9a21b8 100755 --- a/scripts/install +++ b/scripts/install @@ -27,6 +27,8 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url="/" +client_max_body_size="50M" + admin=$YNH_APP_ARG_ADMIN email=$YNH_APP_ARG_EMAIL password=$YNH_APP_ARG_PASSWORD @@ -78,6 +80,8 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path_url --value=$path_url +ynh_app_setting_set --app=$app --key=client_max_body_size --value=$client_max_body_size + ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=email --value=$email ynh_app_setting_set --app=$app --key=password --value=$password diff --git a/scripts/restore b/scripts/restore index c23fd76..a93652b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -34,6 +34,8 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) path_url=$(ynh_app_setting_get --app=$app --key=path_url) +client_max_body_size=$(ynh_app_setting_get --app=$app --key=client_max_body_size) + db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) diff --git a/scripts/upgrade b/scripts/upgrade index 291f73f..3eb5678 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,6 +22,8 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) port=$(ynh_app_setting_get --app=$app --key=port) path_url=$(ynh_app_setting_get --app=$app --key=path_url) +client_max_body_size=$(ynh_app_setting_get --app=$app --key=client_max_body_size) + db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$(ynh_app_setting_get --app=$app --key=db_user) db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) @@ -67,6 +69,18 @@ ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_script_progression --message="Ensuring downward compatibility..." + +# Upgrade from <0.2.1~ynh4: +# If client_max_body_size doesn't exist, create it +if [ -z "$client_max_body_size" ]; then + client_max_body_size="50M" + ynh_app_setting_set --app=$app --key=client_max_body_size --value=$client_max_body_size +fi + #================================================= # CREATE DEDICATED USER #=================================================