From 3d7b8a54ecfd05cdeebc1a73719b59230d0e4206 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Thu, 17 Mar 2022 21:03:11 +0100 Subject: [PATCH 01/30] create config file --- config_panel.toml | 293 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 293 insertions(+) create mode 100644 config_panel.toml diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..ea34ec9 --- /dev/null +++ b/config_panel.toml @@ -0,0 +1,293 @@ + +## 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" + +################################################################################ +#### 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 = "" + +############################################################################ +#### ABOUT SECTIONS +############################################################################ + +## 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] + +## (optional) Defining a proper title for sections is not mandatory +## and depends on the exact rendering you're aiming for the CLI / webadmin +name = "" + +## (optional) This help properties is a short help displayed on the same line +## than the section title, meant to provide additional details +# help = "" + +## (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 = [] + +## (optional) By default all questions are optionals, but you can specify a +## default behaviour for question in the section + +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 + +######################################################################## +#### ABOUT QUESTIONS +######################################################################## + +## A section is compound of one or several questions. + +## --------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------- + +## 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 + +[main.customization.project_name] + +## (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" + +## (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 + +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, +## question IDs should almost **always** correspond to an app setting +## initialized / reused during install/upgrade. +## 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_.*$' From da5467a96d4816a6610ab4e83055fbff337c9822 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 26 Mar 2022 00:21:52 +0100 Subject: [PATCH 02/30] added config panel --- conf/nginx.conf | 2 +- config_panel.toml | 428 ++++++++++++++++++---------------------------- scripts/install | 4 + scripts/restore | 2 + scripts/upgrade | 14 ++ 5 files changed, 186 insertions(+), 264 deletions(-) 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 #================================================= From 709eb9054a95d9e85ec0643c1db3ac25f1388e6d Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 26 Mar 2022 00:43:51 +0100 Subject: [PATCH 03/30] added all configuration parameters --- conf/config.yaml | 20 +++++++++--------- scripts/install | 26 +++++++++++++++++++++++ scripts/restore | 14 +++++++++++- scripts/upgrade | 55 ++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 102 insertions(+), 13 deletions(-) diff --git a/conf/config.yaml b/conf/config.yaml index 8de7d54..c0a42bc 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -188,22 +188,22 @@ accounts-reason-required: __REGISTRATION_REASON__ # Int. Maximum allowed image upload size in bytes. # Examples: [2097152, 10485760] # Default: 2097152 -- aka 2MB -media-image-max-size: 2097152 +media-image-max-size: __MEDIA_IMAGE_MAX_SIZE__ # Int. Maximum allowed video upload size in bytes. # Examples: [2097152, 10485760] # Default: 10485760 -- aka 10MB -media-video-max-size: 10485760 +media-video-max-size: __MEDIA_VIDEO_MAX_SIZE__ # Int. Minimum amount of characters required as an image or video description. # Examples: [500, 1000, 1500] # Default: 0 (not required) -media-description-min-chars: 0 +media-description-min-chars: __MEDIA_DESCRIPTION_MIN_CHARS__ # Int. Maximum amount of characters permitted in an image or video description. # Examples: [500, 1000, 1500] # Default: 500 -media-description-max-chars: 500 +media-description-max-chars: __MEDIA_DESCRIPTION_MAX_CHARS__ # Int. Number of days to cache media from remote instances before they are removed from the cache. # A job will run every day at midnight to clean up any remote media older than the given amount of days. @@ -214,7 +214,7 @@ media-description-max-chars: 500 # If this is set to 0, then media from remote instances will be cached indefinitely. # Examples: [30, 60, 7, 0] # Default: 30 -media-remote-cache-days: 30 +media-remote-cache-days: __MEDIA_REMOTE_CACHE_DAYS__ ########################## ##### STORAGE CONFIG ##### @@ -245,31 +245,31 @@ storage-local-base-path: "__DATADIR__" # Note that going way higher than the default might break federation. # Examples: [140, 500, 5000] # Default: 5000 -statuses-max-chars: 5000 +statuses-max-chars: __STATUSES_MAX_CHARS__ # Int. Maximum amount of characters allowed in the CW/subject header of a status. # Note that going way higher than the default might break federation. # Examples: [100, 200] # Default: 100 -statuses-cw-max-chars: 100 +statuses-cw-max-chars: __STATUSES_CW_MAX_CHARS__ # Int. Maximum amount of options to permit when creating a new poll. # Note that going way higher than the default might break federation. # Examples: [4, 6, 10] # Default: 6 -statuses-poll-max-options: 6 +statuses-poll-max-options: __STATUSES_POLL_MAX_OPTIONS__ # Int. Maximum amount of characters to permit per poll option when creating a new poll. # Note that going way higher than the default might break federation. # Examples: [50, 100, 150] # Default: 50 -statuses-poll-option-max-chars: 50 +statuses-poll-option-max-chars: __STATUSES_POLL_OPTION_MAX_OPTIONS__ # Int. Maximum amount of media files that can be attached to a new status. # Note that going way higher than the default might break federation. # Examples: [4, 6, 10] # Default: 6 -statuses-media-max-files: 6 +statuses-media-max-files: __STATUSES_MEDIA_MAX_FILES__ ############################## ##### LETSENCRYPT CONFIG ##### diff --git a/scripts/install b/scripts/install index a9a21b8..c601a92 100755 --- a/scripts/install +++ b/scripts/install @@ -33,10 +33,24 @@ admin=$YNH_APP_ARG_ADMIN email=$YNH_APP_ARG_EMAIL password=$YNH_APP_ARG_PASSWORD +# Config stuff: + registration_open=$YNH_APP_ARG_REGISTRATION_OPEN registration_approval=$YNH_APP_ARG_REGISTRATION_APPROVAL registration_reason=$YNH_APP_ARG_REGISTRATION_REASON +media-image-max-size="2097152" +media-video-max-size="10485760" +media-description-min-chars="0" +media-description-max-chars="500" +media-remote-cache-days="30" + +statuses-max-chars="5000" +statuses-cw-max-chars="100" +statuses-poll-max-options="6" +statuses-poll-option-max-chars="50" +statuses-media-max-files="6" + ### If it's a multi-instance app, meaning it can be installed several times independently ### The id of the app as stated in the manifest is available as $YNH_APP_ID ### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2"...) @@ -90,6 +104,18 @@ ynh_app_setting_set --app=$app --key=registration_open --value=$registration_ope ynh_app_setting_set --app=$app --key=registration_approval --value=$registration_approval ynh_app_setting_set --app=$app --key=registration_reason --value=$registration_reason +ynh_app_setting_set --app=$app --key=media_image_max_size --value=$media_image_max_size +ynh_app_setting_set --app=$app --key=media_video_max_size --value=$media_video_max_size +ynh_app_setting_set --app=$app --key=media_description_min_chars --value=$media_description_min_chars +ynh_app_setting_set --app=$app --key=media_description_max_chars --value=$media_description_max_chars +ynh_app_setting_set --app=$app --key=media_remote_cache_days --value=$media_remote_cache_days + +ynh_app_setting_set --app=$app --key=statuses_max_chars --value=$statuses_max_chars +ynh_app_setting_set --app=$app --key=statuses_cw_max_chars --value=$statuses_cw_max_chars +ynh_app_setting_set --app=$app --key=statuses_poll_max_options --value=$statuses_poll_max_options +ynh_app_setting_set --app=$app --key=statuses_poll_option_max_chars --value=$statuses_poll_option_max_chars +ynh_app_setting_set --app=$app --key=statuses_media_max_files --value=$statuses_media_max_files + #================================================= # STANDARD MODIFICATIONS #================================================= diff --git a/scripts/restore b/scripts/restore index a93652b..ed15ecd 100755 --- a/scripts/restore +++ b/scripts/restore @@ -40,11 +40,23 @@ 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) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) + registration_open=$(ynh_app_setting_get --app=$app --key=registration_open) registration_approval=$(ynh_app_setting_get --app=$app --key=registration_approval) registration_reason=$(ynh_app_setting_get --app=$app --key=registration_reason) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +media_image_max_size=$(ynh_app_setting_get --app=$app --key=media_image_max_size) +media_video_max_size=$(ynh_app_setting_get --app=$app --key=media_video_max_size) +media_description_min_chars=$(ynh_app_setting_get --app=$app --key=media_description_min_chars) +media_description_max_chars=$(ynh_app_setting_get --app=$app --key=media_description_max_chars) +media_remote_cache_days=$(ynh_app_setting_get --app=$app --key=media_remote_cache_days) + +statuses_max_chars=$(ynh_app_setting_get --app=$app --key=statuses_max_chars) +statuses_cw_max_chars=$(ynh_app_setting_get --app=$app --key=statuses_cw_max_chars) +statuses_poll_max_options=$(ynh_app_setting_get --app=$app --key=statuses_poll_max_options) +statuses_poll_option_max_chars=$(ynh_app_setting_get --app=$app --key=statuses_poll_option_max_chars) +statuses_media_max_files=$(ynh_app_setting_get --app=$app --key=statuses_media_max_files) #================================================= # CHECK IF THE APP CAN BE RESTORED diff --git a/scripts/upgrade b/scripts/upgrade index 3eb5678..ffa5d3e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -28,11 +28,23 @@ 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) +datadir=$(ynh_app_setting_get --app=$app --key=datadir) + registration_open=$(ynh_app_setting_get --app=$app --key=registration_open) registration_approval=$(ynh_app_setting_get --app=$app --key=registration_approval) registration_reason=$(ynh_app_setting_get --app=$app --key=registration_reason) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) +media_image_max_size=$(ynh_app_setting_get --app=$app --key=media_image_max_size) +media_video_max_size=$(ynh_app_setting_get --app=$app --key=media_video_max_size) +media_description_min_chars=$(ynh_app_setting_get --app=$app --key=media_description_min_chars) +media_description_max_chars=$(ynh_app_setting_get --app=$app --key=media_description_max_chars) +media_remote_cache_days=$(ynh_app_setting_get --app=$app --key=media_remote_cache_days) + +statuses_max_chars=$(ynh_app_setting_get --app=$app --key=statuses_max_chars) +statuses_cw_max_chars=$(ynh_app_setting_get --app=$app --key=statuses_cw_max_chars) +statuses_poll_max_options=$(ynh_app_setting_get --app=$app --key=statuses_poll_max_options) +statuses_poll_option_max_chars=$(ynh_app_setting_get --app=$app --key=statuses_poll_option_max_chars) +statuses_media_max_files=$(ynh_app_setting_get --app=$app --key=statuses_media_max_files) #================================================= # CHECK VERSION @@ -75,11 +87,50 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app 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 +if [ -z "$client_max_body_size" ]; then + media-image-max-size="2097152" + ynh_app_setting_set --app=$app --key=media_image_max_size --value=$media_image_max_size +fi +if [ -z "$client_max_body_size" ]; then + media-video-max-size="10485760" + ynh_app_setting_set --app=$app --key=media_video_max_size --value=$media_video_max_size +fi +if [ -z "$client_max_body_size" ]; then + media-description-min-chars="0" + ynh_app_setting_set --app=$app --key=media_description_min_chars --value=$media_description_min_chars +fi +if [ -z "$client_max_body_size" ]; then + media-description-max-chars="500" + ynh_app_setting_set --app=$app --key=media_description_max_chars --value=$media_description_max_chars +fi +if [ -z "$client_max_body_size" ]; then + media-remote-cache-days="30" + ynh_app_setting_set --app=$app --key=media_remote_cache_days --value=$media_remote_cache_days +fi +if [ -z "$client_max_body_size" ]; then + statuses-max-chars="5000" + ynh_app_setting_set --app=$app --key=statuses_max_chars --value=$statuses_max_chars +fi +if [ -z "$client_max_body_size" ]; then + statuses-cw-max-chars="100" + ynh_app_setting_set --app=$app --key=statuses_cw_max_chars --value=$statuses_cw_max_chars +fi +if [ -z "$client_max_body_size" ]; then + statuses-poll-max-options="6" + ynh_app_setting_set --app=$app --key=statuses_poll_max_options --value=$statuses_poll_max_options +fi +if [ -z "$client_max_body_size" ]; then + statuses-poll-option-max-chars="50" + ynh_app_setting_set --app=$app --key=statuses_poll_option_max_chars --value=$statuses_poll_option_max_chars +fi +if [ -z "$client_max_body_size" ]; then + statuses-media-max-files="6" + ynh_app_setting_set --app=$app --key=statuses_media_max_files --value=$statuses_media_max_files +fi #================================================= # CREATE DEDICATED USER From 8f51eab15b46159a7f8b436365e50fca0801dfa5 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 26 Mar 2022 00:50:48 +0100 Subject: [PATCH 04/30] scripts cleaning --- scripts/install | 108 +----------------------------------------------- scripts/upgrade | 13 ------ 2 files changed, 1 insertion(+), 120 deletions(-) diff --git a/scripts/install b/scripts/install index c601a92..ef63abb 100755 --- a/scripts/install +++ b/scripts/install @@ -51,37 +51,17 @@ statuses-poll-max-options="6" statuses-poll-option-max-chars="50" statuses-media-max-files="6" -### If it's a multi-instance app, meaning it can be installed several times independently -### The id of the app as stated in the manifest is available as $YNH_APP_ID -### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2"...) -### The app instance name is available as $YNH_APP_INSTANCE_NAME -### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample -### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2 -### - ynhexample__{N} for the subsequent installations, with N=3,4... -### The app instance name is probably what interests you most, since this is -### guaranteed to be unique. This is a good unique identifier to define installation path, -### db names... app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -### About --weight and --time -### ynh_script_progression will show to your final users the progression of each scripts. -### In order to do that, --weight will represent the relative time of execution compared to the other steps in the script. -### is a packager option, it will show you the execution time since the previous call. -### This option should be removed before releasing your app. -### Use the execution time, given by --time, to estimate the weight of a step. -### A common way to do it is to set a weight equal to the execution time in second +1. -### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call. + ynh_script_progression --message="Validating installation parameters..." --weight=1 -### If the app uses NGINX as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". -### If the app provides an internal web server (or uses another application server such as uWSGI), the final path should be "/opt/yunohost/$app" final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" -# Register (book) web path ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= @@ -123,9 +103,6 @@ ynh_app_setting_set --app=$app --key=statuses_media_max_files --value=$statuses_ #================================================= ynh_script_progression --message="Finding an available port..." --weight=1 -### Use these lines if you have to open a port for the application -### `ynh_find_port` will find the first available port starting from the given port. - # Find an available port port=$(ynh_find_port --port=8095) ynh_app_setting_set --app=$app --key=port --value=$port @@ -135,9 +112,6 @@ ynh_app_setting_set --app=$app --key=port --value=$port #================================================= ynh_script_progression --message="Installing dependencies..." --weight=5 -### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. -### Those deb packages will be installed as dependencies of this package. - ynh_install_app_dependencies $pkg_dependencies #================================================= @@ -166,10 +140,6 @@ ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -### `ynh_setup_source` is used to install an app from a zip or tar.gz file, -### downloaded from an upstream source, like a git repository. -### `ynh_setup_source` use the file conf/app.src - architecture=$YNH_ARCH # Download, check integrity, uncompress and patch the source from app.src @@ -204,10 +174,6 @@ ynh_add_nginx_config #================================================= ynh_script_progression --message="Creating a data directory..." --weight=1 -### Use these lines if you need to create a directory to store "persistent files" for the application. -### Usually this directory is used to store uploaded files or any file that won't be updated during -### an upgrade and that won't be deleted during app removal - datadir=/home/yunohost.app/$app ynh_app_setting_set --app=$app --key=datadir --value=$datadir @@ -228,18 +194,6 @@ chown -R $app:www-data "$datadir" #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -### You can add specific configuration files. -### -### Typically, put your template conf file in ../conf/your_config_file -### The template may contain strings such as __FOO__ or __FOO_BAR__, -### which will automatically be replaced by the values of $foo and $foo_bar -### -### ynh_add_config will also keep track of the config file's checksum, -### which later during upgrade may allow to automatically backup the config file -### if it's found that the file was manually modified -### -### Check the documentation of `ynh_add_config` for more info. - ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml" # FIXME: this should be handled by the core in the future @@ -248,47 +202,14 @@ ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml" chmod 400 "$final_path/config.yaml" chown $app:$app "$final_path/config.yaml" -### For more complex cases where you want to replace stuff using regexes, -### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) -### When doing so, you also need to manually call ynh_store_file_checksum -### -### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/some_config_file" -### ynh_store_file_checksum --file="$final_path/some_config_file" - #================================================= # SETUP SYSTEMD #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=1 -### `ynh_systemd_config` is used to configure a systemd script for an app. -### It can be used for apps that use sysvinit (with adaptation) or systemd. -### Have a look at the app to be sure this app needs a systemd script. -### `ynh_systemd_config` will use the file conf/systemd.service - # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# SETUP APPLICATION WITH CURL -#================================================= - -### Use these lines only if the app installation needs to be finalized through -### web forms. We generally don't want to ask the final user, -### so we're going to use curl to automatically fill the fields and submit the -### forms. - -# Set the app as temporarily public for curl call -ynh_script_progression --message="Configuring SSOwat..." --weight=1 -# Making the app public for curl -ynh_permission_update --permission="main" --add="visitors" - -# Installation with curl -ynh_script_progression --message="Finalizing installation..." --weight=1 -ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3" - -# Remove the public access -ynh_permission_update --permission="main" --remove="visitors" - #================================================= # GENERIC FINALIZATION #================================================= @@ -296,9 +217,6 @@ ynh_permission_update --permission="main" --remove="visitors" #================================================= ynh_script_progression --message="Configuring log rotation..." --weight=1 -### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app. -### Use this helper only if there is effectively a log file for this app. - # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -307,28 +225,8 @@ ynh_use_logrotate #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -### `yunohost service add` integrates a service in YunoHost. It then gets -### displayed in the admin interface and through the others `yunohost service` commands. -### (N.B.: this line only makes sense if the app adds a service to the system!) - yunohost service add $app --description="Gotosocial server" --log="/var/log/$app/$app.log" -### Additional options starting with 3.8: -### -### --needs_exposed_ports "$port" a list of ports that needs to be publicly exposed -### which will then be checked by YunoHost's diagnosis system -### (N.B. DO NOT USE THIS is the port is only internal!!!) -### -### --test_status "some command" a custom command to check the status of the service -### (only relevant if 'systemctl status' doesn't do a good job) -### -### --test_conf "some command" some command similar to "nginx -t" that validates the conf of the service -### -### Re-calling 'yunohost service add' during the upgrade script is the right way -### to proceed if you later realize that you need to enable some flags that -### weren't enabled on old installs (be careful it'll override the existing -### service though so you should re-provide all relevant flags when doing so) - #================================================= # CREATE ADMIN USER #================================================= @@ -345,9 +243,6 @@ ynh_script_progression --message="Creating gotosocial admin user..." --weight=1 #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -### `ynh_systemd_action` is used to start a systemd service for an app. -### Only needed if you have configure a systemd service - # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" @@ -357,7 +252,6 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap ynh_script_progression --message="Configuring permissions..." --weight=1 # Everyone can access the app. -# The "main" permission is automatically created before the install script. ynh_permission_update --permission="main" --add="visitors" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index ffa5d3e..52ba2f9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -179,12 +179,6 @@ ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies -#================================================= -# SPECIFIC UPGRADE -#================================================= -# ... -#================================================= - #================================================= # UPDATE A CONFIG FILE #================================================= @@ -203,13 +197,6 @@ ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml" chmod 400 "$final_path/config.yaml" chown $app:$app "$final_path/config.yaml" -### For more complex cases where you want to replace stuff using regexes, -### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) -### When doing so, you also need to manually call ynh_store_file_checksum -### -### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/some_config_file" -### ynh_store_file_checksum --file="$final_path/some_config_file" - #================================================= # SETUP SYSTEMD #================================================= From 131ebd9fd7cfb575a97e380d20cabb89a72d2ffb Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 26 Mar 2022 00:52:16 +0100 Subject: [PATCH 05/30] cleaning --- scripts/install | 6 ------ 1 file changed, 6 deletions(-) diff --git a/scripts/install b/scripts/install index ef63abb..bb515e0 100755 --- a/scripts/install +++ b/scripts/install @@ -163,12 +163,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SPECIFIC SETUP -#================================================= -# -#================================================= - #================================================= # CREATE DATA DIRECTORY #================================================= From 79212dac6b3839733fc629fa833109f740b072c9 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 26 Mar 2022 00:56:26 +0100 Subject: [PATCH 06/30] temp fix for https://github.com/YunoHost/yunohost/pull/1449 --- config_panel.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config_panel.toml b/config_panel.toml index f8cf80b..b089793 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -1,4 +1,7 @@ +# temp fix for https://github.com/YunoHost/yunohost/pull/1449 +final_path = "/var/www/$app" + version = "1.0" [gotosocial] From 596091a21805c93e1e2f492a871b384c56201969 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 26 Mar 2022 01:21:10 +0100 Subject: [PATCH 07/30] translations --- config_panel.toml | 91 +++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 43 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index b089793..decd877 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -14,157 +14,170 @@ name.fr = "Configuration de GoToSocial" help.en = "" help.fr = "" +#################### #### ACCOUNTS CONFIG +#################### [gotosocial.accounts] -name.en = "Account config" +name.en = "Accounts configuration" name.fr = "Configuration des inscriptions" help.en = "Config pertaining to creation and maintenance of accounts on the server, as well as defaults for new accounts." -help.fr = "" +help.fr = "Configuration relative à la création et à la maintenance des comptes sur le serveur, ainsi que les valeurs par défaut pour les nouveaux comptes." [gotosocial.accounts.registration-open] ask.en = "Open registrations?" -ask.fr = "" +ask.fr = "Inscriptions ouvertes ?" 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 = "" +help.fr = "Voulez-vous que les gens puissent simplement envoyer des demandes d'inscription, ou voulez-vous qu'iels doivent être invité-e-s ?" type = "boolean" [gotosocial.accounts.approval-required] ask.en = "Approval required?" -ask.fr = "" +ask.fr = "Validation requise ?" 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 = "" +help.fr = "Les demandes d'inscription doivent-elles être approuvées par un-e administrateur-ice/modérateur-ice avant qu'un compte puisse se connecter/utiliser le serveur ?" type = "boolean" [gotosocial.accounts.reason-required] ask.en = "Reason required?" -ask.fr = "" +ask.fr = "Motif requis ?" 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 = "" +help.fr = "Les demandes d'inscription doivent-elles être motivées (par exemple, par une explication de la raison pour laquelle la personne souhaite rejoindre l'instance) ?" type = "boolean" +################# #### MEDIA CONFIG +################# [gotosocial.media] name.en = "Media config" name.fr = "Configuration des médias" help.en = "Config pertaining to user media uploads (videos, image, image descriptions)." -help.fr = "" +help.fr = "Configuration relative aux médias téléchargés par les utilisateurs (vidéos, images, descriptions d'images)." [gotosocial.media.image-max-size] ask.en = "Maximum allowed image upload size in bytes." -ask.fr = "" +ask.fr = "Taille maximale autorisée pour le téléchargement d'images, en octets." bind = "media-image-max-size:__FINALPATH__/config.yaml" default = "2097152" help.en = "Default: 2097152 -- aka 2MB" -help.fr = "" +help.fr = "Valeur par défaut : 2097152 (soit 2 Mo)" type = "number" [gotosocial.media.video-max-size] ask.en = "Maximum allowed video upload size in bytes." -ask.fr = "" +ask.fr = "Taille maximale autorisée pour le téléchargement de vidéos, en octets." bind = "media-video-max-size:__FINALPATH__/config.yaml" default = "10485760" help.en = "Default: 10485760 -- aka 10MB" -help.fr = "" +help.fr = "Valeur par défaut : 10485760 (soit 10 Mo)" type = "number" [gotosocial.media.description-min-chars] ask.en = "Minimum amount of characters required as an image or video description." -ask.fr = "" +ask.fr = "Nombre minimum de caractères requis pour la description d'une image ou d'une vidéo." bind = "media-description-min-chars:__FINALPATH__/config.yaml" default = "0" help.en = "Default: 0 (not required)" -help.fr = "" +help.fr = "Valeur par défaut : 0 (non obligatoire)" type = "number" [gotosocial.media.description-max-chars] ask.en = "Maximum amount of characters permitted in an image or video description." -ask.fr = "" +ask.fr = "Nombre maximum de caractères requis pour la description d'une image ou d'une vidéo." bind = "media-description-max-chars:__FINALPATH__/config.yaml" default = "500" -help.en = "Default: 500." -help.fr = "" +help.en = "Default: 500" +help.fr = "Valeur par défaut : 500" 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 = "" +ask.fr = "Nombre de jours de mise en cache des médias des instances distantes avant qu'ils ne soient retirés du cache." bind = "media-remote-cache-days:__FINALPATH__/config.yaml" default = "30" help.en = """\ -Default: 30.\ +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 = "" +help.fr = """\ +Valeur par défaut : 30\ +Une tâche est exécutée tous les soirs à minuit pour nettoyer les médias distants datant de plus d'un certain nombre de jours.\ +Lorsque le média distant est supprimé du cache, il est supprimé du stockage mais les entrées de la base de données pour le média sont conservées afin qu'il puisse être récupéré si un utilisateur le demande.\ +Si la valeur 0 est attribuée à ce paramètre, les médias des instances distantes sont mis en cache indéfiniment.\ +""" 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 = "" +help.fr = "Configuration relative à la création de statuts/posts, et aux limites autorisées." [gotosocial.statuses.max-chars] ask.en = "Maximum amount of characters permitted for a new status." -ask.fr = "" +ask.fr = "Nombre maximal de caractères autorisés pour un nouveau statut." 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 = "" +help.fr = "Valeur par défaut : 5000. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." type = "number" [gotosocial.statuses.cw-max-chars] ask.en = "Maximum amount of characters allowed in the CW/subject header of a status." -ask.fr = "" +ask.fr = "Nombre maximum de caractères autorisés dans l'en-tête CW/sujet d'un statut." 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 = "" +help.fr = "Valeur par défaut : 100. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." type = "number" [gotosocial.statuses.poll-max-options] ask.en = "Maximum amount of options to permit when creating a new poll." -ask.fr = "" +ask.fr = "Nombre maximum d'options autorisées lors de la création d'un nouveau sondage." 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 = "" +help.fr = "Valeur par défaut : 6. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." 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 = "" +ask.fr = "Nombre maximal de caractères autorisés par option de sondage lors de la création d'un nouveau sondage." 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 = "" +help.fr = "Valeur par défaut : 50. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." type = "number" [gotosocial.statuses.media-max-files] ask.en = "Maximum amount of media files that can be attached to a new status." -ask.fr = "" +ask.fr = "Quantité maximale de fichiers multimédias qui peuvent être joints à un nouveau statut." 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 = "" +help.fr = "Valeur par défaut : 6. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." type = "number" +################ ### NGINX CONFIG +################ [nginx] @@ -178,21 +191,13 @@ name.en = "nginx configuration" name.fr = "Configuration de nginx" help.en = "Config pertaining to the Web server." -help.fr = "" +help.fr = "Configuration relative au serveur Web." [nginx.config.max-client_max_body_size] ask.en = "Sets the maximum allowed size of uploaded files." -ask.fr = "" +ask.fr = "Définit la taille maximale autorisée des fichiers téléchargés." bind = "client_max_body_size:/etc/nginx/conf.d/__DOMAIN__/__APP__.conf" default = "50M" help.en = "Default: 50M." -help.fr = "" +help.fr = "Valeur par défaut : 50M" type = "string" - -## --------------------------------------------------------------------- -## IMPORTANT: with the exception of bind=null questions, -## question IDs should almost **always** correspond to an app setting -## initialized / reused during install/upgrade. -## Not doing so may result in inconsistencies between the config panel mechanism -## and the use of ynh_add_config -## --------------------------------------------------------------------- From 4181acc3f96bd02f8404c693289e0110d4883244 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 26 Mar 2022 03:12:20 +0100 Subject: [PATCH 08/30] fix nginx config path --- config_panel.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_panel.toml b/config_panel.toml index decd877..6a6e427 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -196,7 +196,7 @@ help.fr = "Configuration relative au serveur Web." [nginx.config.max-client_max_body_size] ask.en = "Sets the maximum allowed size of uploaded files." ask.fr = "Définit la taille maximale autorisée des fichiers téléchargés." -bind = "client_max_body_size:/etc/nginx/conf.d/__DOMAIN__/__APP__.conf" +bind = "client_max_body_size:/etc/nginx/conf.d/__DOMAIN__.d/__APP__.conf" default = "50M" help.en = "Default: 50M." help.fr = "Valeur par défaut : 50M" From f4dba67a0f6533cb0601a15683c2b32d07ccaaa0 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 26 Mar 2022 03:15:15 +0100 Subject: [PATCH 09/30] added helps --- config_panel.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index 6a6e427..5c201f3 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -11,8 +11,8 @@ services = ["__APP__"] name.en = "GoToSocial configuration panel" name.fr = "Configuration de GoToSocial" -help.en = "" -help.fr = "" +help.en = "Here you can easily configure some things about your GoToSocial instance." +help.fr = "Ici vous pouvez configurer facilement certaines choses à propos de votre instance GoToSocial." #################### #### ACCOUNTS CONFIG From 561a377e65d0c1f0be1b17e0f8c517476a009b05 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 26 Mar 2022 03:39:36 +0100 Subject: [PATCH 10/30] improved updating with new parameters --- scripts/upgrade | 45 ++++++++++++++------------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index ed9beea..bf2e954 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -87,48 +87,31 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app ynh_script_progression --message="Ensuring downward compatibility..." # Upgrade from <0.2.1~ynh4: -if [ -z "$client_max_body_size" ]; then +if ynh_compare_current_package_version --comparison lt --version 0.2.1~ynh4 +then + # declaration of new parameters client_max_body_size="50M" - ynh_app_setting_set --app=$app --key=client_max_body_size --value=$client_max_body_size -fi -if [ -z "$client_max_body_size" ]; then media-image-max-size="2097152" - ynh_app_setting_set --app=$app --key=media_image_max_size --value=$media_image_max_size -fi -if [ -z "$client_max_body_size" ]; then media-video-max-size="10485760" - ynh_app_setting_set --app=$app --key=media_video_max_size --value=$media_video_max_size -fi -if [ -z "$client_max_body_size" ]; then media-description-min-chars="0" - ynh_app_setting_set --app=$app --key=media_description_min_chars --value=$media_description_min_chars -fi -if [ -z "$client_max_body_size" ]; then media-description-max-chars="500" - ynh_app_setting_set --app=$app --key=media_description_max_chars --value=$media_description_max_chars -fi -if [ -z "$client_max_body_size" ]; then media-remote-cache-days="30" - ynh_app_setting_set --app=$app --key=media_remote_cache_days --value=$media_remote_cache_days -fi -if [ -z "$client_max_body_size" ]; then statuses-max-chars="5000" - ynh_app_setting_set --app=$app --key=statuses_max_chars --value=$statuses_max_chars -fi -if [ -z "$client_max_body_size" ]; then statuses-cw-max-chars="100" - ynh_app_setting_set --app=$app --key=statuses_cw_max_chars --value=$statuses_cw_max_chars -fi -if [ -z "$client_max_body_size" ]; then statuses-poll-max-options="6" - ynh_app_setting_set --app=$app --key=statuses_poll_max_options --value=$statuses_poll_max_options -fi -if [ -z "$client_max_body_size" ]; then statuses-poll-option-max-chars="50" - ynh_app_setting_set --app=$app --key=statuses_poll_option_max_chars --value=$statuses_poll_option_max_chars -fi -if [ -z "$client_max_body_size" ]; then statuses-media-max-files="6" + # registration of new parameters + ynh_app_setting_set --app=$app --key=client_max_body_size --value=$client_max_body_size + ynh_app_setting_set --app=$app --key=media_image_max_size --value=$media_image_max_size + ynh_app_setting_set --app=$app --key=media_video_max_size --value=$media_video_max_size + ynh_app_setting_set --app=$app --key=media_description_min_chars --value=$media_description_min_chars + ynh_app_setting_set --app=$app --key=media_description_max_chars --value=$media_description_max_chars + ynh_app_setting_set --app=$app --key=media_remote_cache_days --value=$media_remote_cache_days + ynh_app_setting_set --app=$app --key=statuses_max_chars --value=$statuses_max_chars + ynh_app_setting_set --app=$app --key=statuses_cw_max_chars --value=$statuses_cw_max_chars + ynh_app_setting_set --app=$app --key=statuses_poll_max_options --value=$statuses_poll_max_options + ynh_app_setting_set --app=$app --key=statuses_poll_option_max_chars --value=$statuses_poll_option_max_chars ynh_app_setting_set --app=$app --key=statuses_media_max_files --value=$statuses_media_max_files fi From 0de668e65bbf5d4857a84c1a0cb83457b43ba130 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 26 Mar 2022 04:56:16 +0100 Subject: [PATCH 11/30] added convert_bool function to fix bools in the config file & vars fix --- scripts/_common.sh | 5 ++ scripts/install | 160 ++++++++++++++++++++++----------------------- scripts/upgrade | 28 +++++--- 3 files changed, 103 insertions(+), 90 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index d5c690b..6d394d9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -31,6 +31,11 @@ detect_arch(){ echo $architecture } +# custom function to change bash bool 0/1 to false/true +convert_bool(){ + $1 && echo "true" || echo "false" +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index d566915..e6d72ba 100755 --- a/scripts/install +++ b/scripts/install @@ -35,21 +35,21 @@ password=$YNH_APP_ARG_PASSWORD # Config stuff: -registration_open=$YNH_APP_ARG_REGISTRATION_OPEN -registration_approval=$YNH_APP_ARG_REGISTRATION_APPROVAL -registration_reason=$YNH_APP_ARG_REGISTRATION_REASON +registration_open=$(convert_bool $YNH_APP_ARG_REGISTRATION_OPEN) +registration_approval=$(convert_bool $YNH_APP_ARG_REGISTRATION_APPROVAL) +registration_reason=$(convert_bool $YNH_APP_ARG_REGISTRATION_REASON) -media-image-max-size="2097152" -media-video-max-size="10485760" -media-description-min-chars="0" -media-description-max-chars="500" -media-remote-cache-days="30" +media_image_max_size="2097152" +media_video_max_size="10485760" +media_description_min_chars="0" +media_description_max_chars="500" +media_remote_cache_days="30" -statuses-max-chars="5000" -statuses-cw-max-chars="100" -statuses-poll-max-options="6" -statuses-poll-option-max-chars="50" -statuses-media-max-files="6" +statuses_max_chars="5000" +statuses_cw_max_chars="100" +statuses_poll_max_options="6" +statuses_poll_option_max_chars="50" +statuses_media_max_files="6" app=$YNH_APP_INSTANCE_NAME @@ -57,88 +57,88 @@ app=$YNH_APP_INSTANCE_NAME # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 +ynh_script_progression __message="Validating installation parameters..." __weight=1 final_path=/var/www/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" +test ! _e "$final_path" || ynh_die __message="This path already contains a folder" -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url +ynh_webpath_register __app=$app __domain=$domain __path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 +ynh_script_progression __message="Storing installation settings..." __weight=1 -ynh_app_setting_set --app=$app --key=final_path --value=$final_path +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=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=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 +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 -ynh_app_setting_set --app=$app --key=registration_open --value=$registration_open -ynh_app_setting_set --app=$app --key=registration_approval --value=$registration_approval -ynh_app_setting_set --app=$app --key=registration_reason --value=$registration_reason +ynh_app_setting_set __app=$app __key=registration_open __value=$registration_open +ynh_app_setting_set __app=$app __key=registration_approval __value=$registration_approval +ynh_app_setting_set __app=$app __key=registration_reason __value=$registration_reason -ynh_app_setting_set --app=$app --key=media_image_max_size --value=$media_image_max_size -ynh_app_setting_set --app=$app --key=media_video_max_size --value=$media_video_max_size -ynh_app_setting_set --app=$app --key=media_description_min_chars --value=$media_description_min_chars -ynh_app_setting_set --app=$app --key=media_description_max_chars --value=$media_description_max_chars -ynh_app_setting_set --app=$app --key=media_remote_cache_days --value=$media_remote_cache_days +ynh_app_setting_set __app=$app __key=media_image_max_size __value=$media_image_max_size +ynh_app_setting_set __app=$app __key=media_video_max_size __value=$media_video_max_size +ynh_app_setting_set __app=$app __key=media_description_min_chars __value=$media_description_min_chars +ynh_app_setting_set __app=$app __key=media_description_max_chars __value=$media_description_max_chars +ynh_app_setting_set __app=$app __key=media_remote_cache_days __value=$media_remote_cache_days -ynh_app_setting_set --app=$app --key=statuses_max_chars --value=$statuses_max_chars -ynh_app_setting_set --app=$app --key=statuses_cw_max_chars --value=$statuses_cw_max_chars -ynh_app_setting_set --app=$app --key=statuses_poll_max_options --value=$statuses_poll_max_options -ynh_app_setting_set --app=$app --key=statuses_poll_option_max_chars --value=$statuses_poll_option_max_chars -ynh_app_setting_set --app=$app --key=statuses_media_max_files --value=$statuses_media_max_files +ynh_app_setting_set __app=$app __key=statuses_max_chars __value=$statuses_max_chars +ynh_app_setting_set __app=$app __key=statuses_cw_max_chars __value=$statuses_cw_max_chars +ynh_app_setting_set __app=$app __key=statuses_poll_max_options __value=$statuses_poll_max_options +ynh_app_setting_set __app=$app __key=statuses_poll_option_max_chars __value=$statuses_poll_option_max_chars +ynh_app_setting_set __app=$app __key=statuses_media_max_files __value=$statuses_media_max_files #================================================= # STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 +ynh_script_progression __message="Finding an available port..." __weight=1 # Find an available port -port=$(ynh_find_port --port=8095) -ynh_app_setting_set --app=$app --key=port --value=$port +port=$(ynh_find_port __port=8095) +ynh_app_setting_set __app=$app __key=port __value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=5 +ynh_script_progression __message="Installing dependencies..." __weight=5 ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 +ynh_script_progression __message="Configuring system user..." __weight=1 # Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" +ynh_system_user_create __username=$app __home_dir="$final_path" #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." --weight=5 +ynh_script_progression __message="Creating a PostgreSQL database..." __weight=5 -db_name=$(ynh_sanitize_dbid --db_name=$app) +db_name=$(ynh_sanitize_dbid __db_name=$app) db_user=$db_name -db_pwd=$(ynh_string_random --length=30) -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd +db_pwd=$(ynh_string_random __length=30) +ynh_app_setting_set __app=$app __key=db_name __value=$db_name +ynh_app_setting_set __app=$app __key=db_pwd __value=$db_pwd ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_psql_setup_db __db_user=$db_user __db_name=$db_name __db_pwd=$db_pwd #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression __message="Setting up source files..." __weight=1 ### `ynh_setup_source` is used to install an app from a zip or tar.gz file, ### downloaded from an upstream source, like a git repository. @@ -148,22 +148,22 @@ ynh_script_progression --message="Setting up source files..." --weight=1 architecture=$(detect_arch) # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" --source_id=$architecture +ynh_setup_source __dest_dir="$final_path" __source_id=$architecture # FIXME: this should be managed by the core in the future # Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www-data) can access +# such that the appropriate users (e.g. maybe www_data) can access # files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - +# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder _ # this will be treated as a security issue. chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod _R o_rwx "$final_path" +chown _R $app:www_data "$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=1 +ynh_script_progression __message="Configuring NGINX web server..." __weight=1 # Create a dedicated NGINX config ynh_add_nginx_config @@ -171,29 +171,29 @@ ynh_add_nginx_config #================================================= # CREATE DATA DIRECTORY #================================================= -ynh_script_progression --message="Creating a data directory..." --weight=1 +ynh_script_progression __message="Creating a data directory..." __weight=1 datadir=/home/yunohost.app/$app -ynh_app_setting_set --app=$app --key=datadir --value=$datadir +ynh_app_setting_set __app=$app __key=datadir __value=$datadir -mkdir -p $datadir +mkdir _p $datadir # FIXME: this should be managed by the core in the future # Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www-data) can access +# such that the appropriate users (e.g. maybe www_data) can access # files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - +# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder _ # this will be treated as a security issue. chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" +chmod _R o_rwx "$datadir" +chown _R $app:www_data "$datadir" #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression __message="Adding a configuration file..." __weight=1 -ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml" +ynh_add_config __template="config.yaml" __destination="$final_path/config.yaml" # FIXME: this should be handled by the core in the future # You may need to use chmod 600 instead of 400, @@ -204,7 +204,7 @@ chown $app:$app "$final_path/config.yaml" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 +ynh_script_progression __message="Configuring a systemd service..." __weight=1 # Create a dedicated systemd config ynh_add_systemd_config @@ -214,7 +214,7 @@ ynh_add_systemd_config #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 +ynh_script_progression __message="Configuring log rotation..." __weight=1 # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -222,46 +222,46 @@ ynh_use_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression __message="Integrating service in YunoHost..." __weight=1 -yunohost service add $app --description="Gotosocial server" --log="/var/log/$app/$app.log" +yunohost service add $app __description="Gotosocial server" __log="/var/log/$app/$app.log" #================================================= # CREATE ADMIN USER #================================================= -ynh_script_progression --message="Creating gotosocial admin user..." --weight=1 +ynh_script_progression __message="Creating gotosocial admin user..." __weight=1 -"$final_path"/gotosocial --config-path "$final_path/config.yaml" admin account create --username "$admin" --email "$email" --password "$password" +"$final_path"/gotosocial __config_path "$final_path/config.yaml" admin account create __username "$admin" __email "$email" __password "$password" -"$final_path"/gotosocial --config-path "$final_path/config.yaml" admin account confirm --username "$admin" +"$final_path"/gotosocial __config_path "$final_path/config.yaml" admin account confirm __username "$admin" -"$final_path"/gotosocial --config-path "$final_path/config.yaml" admin account promote --username "$admin" +"$final_path"/gotosocial __config_path "$final_path/config.yaml" admin account promote __username "$admin" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression __message="Starting a systemd service..." __weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action __service_name=$app __action="start" __log_path="/var/log/$app/$app.log" #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 +ynh_script_progression __message="Configuring permissions..." __weight=1 # Everyone can access the app. -ynh_permission_update --permission="main" --add="visitors" +ynh_permission_update __permission="main" __add="visitors" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression __message="Reloading NGINX web server..." __weight=1 -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action __service_name=nginx __action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression __message="Installation of $app completed" __last diff --git a/scripts/upgrade b/scripts/upgrade index bf2e954..d4c260b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -91,16 +91,20 @@ if ynh_compare_current_package_version --comparison lt --version 0.2.1~ynh4 then # declaration of new parameters client_max_body_size="50M" - media-image-max-size="2097152" - media-video-max-size="10485760" - media-description-min-chars="0" - media-description-max-chars="500" - media-remote-cache-days="30" - statuses-max-chars="5000" - statuses-cw-max-chars="100" - statuses-poll-max-options="6" - statuses-poll-option-max-chars="50" - statuses-media-max-files="6" + media_image_max_size="2097152" + media_video_max_size="10485760" + media_description_min_chars="0" + media_description_max_chars="500" + media_remote_cache_days="30" + statuses_max_chars="5000" + statuses_cw_max_chars="100" + statuses_poll_max_options="6" + statuses_poll_option_max_chars="50" + statuses_media_max_files="6" + # conversionof old parameters + registration_open=$(convert_bool "$registration_open") + registration_approval=$(convert_bool "$registration_approval") + registration_reason=$(convert_bool "$registration_reason") # registration of new parameters ynh_app_setting_set --app=$app --key=client_max_body_size --value=$client_max_body_size ynh_app_setting_set --app=$app --key=media_image_max_size --value=$media_image_max_size @@ -113,6 +117,10 @@ then ynh_app_setting_set --app=$app --key=statuses_poll_max_options --value=$statuses_poll_max_options ynh_app_setting_set --app=$app --key=statuses_poll_option_max_chars --value=$statuses_poll_option_max_chars ynh_app_setting_set --app=$app --key=statuses_media_max_files --value=$statuses_media_max_files + # registration of converted parameters + ynh_app_setting_set --app=$app --key=statuses_media_max_files --value=$registration_open + ynh_app_setting_set --app=$app --key=statuses_media_max_files --value=$registration_approval + ynh_app_setting_set --app=$app --key=statuses_media_max_files --value=$registration_reason fi #================================================= From e7693f729f0b39b1d11e6836c4d9fddcec375809 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 26 Mar 2022 04:58:48 +0100 Subject: [PATCH 12/30] fix convert_bool sigh --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 6d394d9..53f06a4 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -33,7 +33,7 @@ detect_arch(){ # custom function to change bash bool 0/1 to false/true convert_bool(){ - $1 && echo "true" || echo "false" + (($1)) && echo "true" || echo "false" } #================================================= From b7487729bf79b30bed7439370a907a33a3cf0dbd Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 26 Mar 2022 05:35:44 +0100 Subject: [PATCH 13/30] $1 double quoted --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 53f06a4..4452969 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -33,7 +33,7 @@ detect_arch(){ # custom function to change bash bool 0/1 to false/true convert_bool(){ - (($1)) && echo "true" || echo "false" + (("$1")) && echo "true" || echo "false" } #================================================= From 0e8dc7116ad5179f0c93edc8169b4edeef4ed4be Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sat, 26 Mar 2022 17:44:50 +0100 Subject: [PATCH 14/30] sigh... fix all "-" which have been replaced by a "_" --- scripts/install | 130 ++++++++++++++++++++++++------------------------ 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/scripts/install b/scripts/install index e6d72ba..7aaa801 100755 --- a/scripts/install +++ b/scripts/install @@ -57,88 +57,88 @@ app=$YNH_APP_INSTANCE_NAME # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression __message="Validating installation parameters..." __weight=1 +ynh_script_progression --message="Validating installation parameters..." --weight=1 final_path=/var/www/$app -test ! _e "$final_path" || ynh_die __message="This path already contains a folder" +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" -ynh_webpath_register __app=$app __domain=$domain __path_url=$path_url +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression __message="Storing installation settings..." __weight=1 +ynh_script_progression --message="Storing installation settings..." --weight=1 -ynh_app_setting_set __app=$app __key=final_path __value=$final_path +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=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=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 +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 -ynh_app_setting_set __app=$app __key=registration_open __value=$registration_open -ynh_app_setting_set __app=$app __key=registration_approval __value=$registration_approval -ynh_app_setting_set __app=$app __key=registration_reason __value=$registration_reason +ynh_app_setting_set --app=$app --key=registration_open --value=$registration_open +ynh_app_setting_set --app=$app --key=registration_approval --value=$registration_approval +ynh_app_setting_set --app=$app --key=registration_reason --value=$registration_reason -ynh_app_setting_set __app=$app __key=media_image_max_size __value=$media_image_max_size -ynh_app_setting_set __app=$app __key=media_video_max_size __value=$media_video_max_size -ynh_app_setting_set __app=$app __key=media_description_min_chars __value=$media_description_min_chars -ynh_app_setting_set __app=$app __key=media_description_max_chars __value=$media_description_max_chars -ynh_app_setting_set __app=$app __key=media_remote_cache_days __value=$media_remote_cache_days +ynh_app_setting_set --app=$app --key=media_image_max_size --value=$media_image_max_size +ynh_app_setting_set --app=$app --key=media_video_max_size --value=$media_video_max_size +ynh_app_setting_set --app=$app --key=media_description_min_chars --value=$media_description_min_chars +ynh_app_setting_set --app=$app --key=media_description_max_chars --value=$media_description_max_chars +ynh_app_setting_set --app=$app --key=media_remote_cache_days --value=$media_remote_cache_days -ynh_app_setting_set __app=$app __key=statuses_max_chars __value=$statuses_max_chars -ynh_app_setting_set __app=$app __key=statuses_cw_max_chars __value=$statuses_cw_max_chars -ynh_app_setting_set __app=$app __key=statuses_poll_max_options __value=$statuses_poll_max_options -ynh_app_setting_set __app=$app __key=statuses_poll_option_max_chars __value=$statuses_poll_option_max_chars -ynh_app_setting_set __app=$app __key=statuses_media_max_files __value=$statuses_media_max_files +ynh_app_setting_set --app=$app --key=statuses_max_chars --value=$statuses_max_chars +ynh_app_setting_set --app=$app --key=statuses_cw_max_chars --value=$statuses_cw_max_chars +ynh_app_setting_set --app=$app --key=statuses_poll_max_options --value=$statuses_poll_max_options +ynh_app_setting_set --app=$app --key=statuses_poll_option_max_chars --value=$statuses_poll_option_max_chars +ynh_app_setting_set --app=$app --key=statuses_media_max_files --value=$statuses_media_max_files #================================================= # STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression __message="Finding an available port..." __weight=1 +ynh_script_progression --message="Finding an available port..." --weight=1 # Find an available port -port=$(ynh_find_port __port=8095) -ynh_app_setting_set __app=$app __key=port __value=$port +port=$(ynh_find_port --port=8095) +ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression __message="Installing dependencies..." __weight=5 +ynh_script_progression --message="Installing dependencies..." --weight=5 ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression __message="Configuring system user..." __weight=1 +ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user -ynh_system_user_create __username=$app __home_dir="$final_path" +ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression __message="Creating a PostgreSQL database..." __weight=5 +ynh_script_progression --message="Creating a PostgreSQL database..." --weight=5 -db_name=$(ynh_sanitize_dbid __db_name=$app) +db_name=$(ynh_sanitize_dbid --db_name=$app) db_user=$db_name -db_pwd=$(ynh_string_random __length=30) -ynh_app_setting_set __app=$app __key=db_name __value=$db_name -ynh_app_setting_set __app=$app __key=db_pwd __value=$db_pwd +db_pwd=$(ynh_string_random --length=30) +ynh_app_setting_set --app=$app --key=db_name --value=$db_name +ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd ynh_psql_test_if_first_run -ynh_psql_setup_db __db_user=$db_user __db_name=$db_name __db_pwd=$db_pwd +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression __message="Setting up source files..." __weight=1 +ynh_script_progression --message="Setting up source files..." --weight=1 ### `ynh_setup_source` is used to install an app from a zip or tar.gz file, ### downloaded from an upstream source, like a git repository. @@ -148,7 +148,7 @@ ynh_script_progression __message="Setting up source files..." __weight=1 architecture=$(detect_arch) # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source __dest_dir="$final_path" __source_id=$architecture +ynh_setup_source --dest_dir="$final_path" --source_id=$architecture # FIXME: this should be managed by the core in the future # Here, as a packager, you may have to tweak the ownerhsip/permissions @@ -157,13 +157,13 @@ ynh_setup_source __dest_dir="$final_path" __source_id=$architecture # But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder _ # this will be treated as a security issue. chmod 750 "$final_path" -chmod _R o_rwx "$final_path" -chown _R $app:www_data "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www_data "$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression __message="Configuring NGINX web server..." __weight=1 +ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config @@ -171,29 +171,29 @@ ynh_add_nginx_config #================================================= # CREATE DATA DIRECTORY #================================================= -ynh_script_progression __message="Creating a data directory..." __weight=1 +ynh_script_progression --message="Creating a data directory..." --weight=1 datadir=/home/yunohost.app/$app -ynh_app_setting_set __app=$app __key=datadir __value=$datadir +ynh_app_setting_set --app=$app --key=datadir --value=$datadir -mkdir _p $datadir +mkdir -p $datadir # FIXME: this should be managed by the core in the future # Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www_data) can access +# such that the appropriate users (e.g. maybe www-data) can access # files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder _ +# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - # this will be treated as a security issue. chmod 750 "$datadir" -chmod _R o_rwx "$datadir" -chown _R $app:www_data "$datadir" +chmod -R o-rwx "$datadir" +chown -R $app:www_data "$datadir" #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression __message="Adding a configuration file..." __weight=1 +ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config __template="config.yaml" __destination="$final_path/config.yaml" +ynh_add_config --template="config.yaml" --destination="$final_path/config.yaml" # FIXME: this should be handled by the core in the future # You may need to use chmod 600 instead of 400, @@ -204,7 +204,7 @@ chown $app:$app "$final_path/config.yaml" #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression __message="Configuring a systemd service..." __weight=1 +ynh_script_progression --message="Configuring a systemd service..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config @@ -214,7 +214,7 @@ ynh_add_systemd_config #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression __message="Configuring log rotation..." __weight=1 +ynh_script_progression --message="Configuring log rotation..." --weight=1 # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -222,46 +222,46 @@ ynh_use_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression __message="Integrating service in YunoHost..." __weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app __description="Gotosocial server" __log="/var/log/$app/$app.log" +yunohost service add $app --description="Gotosocial server" --log="/var/log/$app/$app.log" #================================================= # CREATE ADMIN USER #================================================= -ynh_script_progression __message="Creating gotosocial admin user..." __weight=1 +ynh_script_progression --message="Creating gotosocial admin user..." --weight=1 -"$final_path"/gotosocial __config_path "$final_path/config.yaml" admin account create __username "$admin" __email "$email" __password "$password" +"$final_path"/gotosocial --config-path "$final_path/config.yaml" admin account create --username "$admin" --email "$email" --password "$password" -"$final_path"/gotosocial __config_path "$final_path/config.yaml" admin account confirm __username "$admin" +"$final_path"/gotosocial --config-path "$final_path/config.yaml" admin account confirm --_username "$admin" -"$final_path"/gotosocial __config_path "$final_path/config.yaml" admin account promote __username "$admin" +"$final_path"/gotosocial --config-path "$final_path/config.yaml" admin account promote --username "$admin" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression __message="Starting a systemd service..." __weight=1 +ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action __service_name=$app __action="start" __log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression __message="Configuring permissions..." __weight=1 +ynh_script_progression --message="Configuring permissions..." --weight=1 # Everyone can access the app. -ynh_permission_update __permission="main" __add="visitors" +ynh_permission_update --permission="main" --add="visitors" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression __message="Reloading NGINX web server..." __weight=1 +ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action __service_name=nginx __action=reload +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_script_progression __message="Installation of $app completed" __last +ynh_script_progression --message="Installation of $app completed" --last From 37c70c78acda7479521f30de241f45d48ce4b6b7 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 27 Mar 2022 18:14:04 +0200 Subject: [PATCH 15/30] fix www-data --- scripts/install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 7aaa801..3941319 100755 --- a/scripts/install +++ b/scripts/install @@ -152,13 +152,13 @@ ynh_setup_source --dest_dir="$final_path" --source_id=$architecture # FIXME: this should be managed by the core in the future # Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www_data) can access +# such that the appropriate users (e.g. maybe www-data) can access # files in some cases. # But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder _ # this will be treated as a security issue. chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:www_data "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION @@ -186,7 +186,7 @@ mkdir -p $datadir # this will be treated as a security issue. chmod 750 "$datadir" chmod -R o-rwx "$datadir" -chown -R $app:www_data "$datadir" +chown -R $app:www-data "$datadir" #================================================= # ADD A CONFIGURATION From 8f9bb50523240d66a1121abfe19043373bf82731 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 27 Mar 2022 18:20:13 +0200 Subject: [PATCH 16/30] fix var name --- conf/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/config.yaml b/conf/config.yaml index b0ecef6..9cde08d 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -263,7 +263,7 @@ statuses-poll-max-options: __STATUSES_POLL_MAX_OPTIONS__ # Note that going way higher than the default might break federation. # Examples: [50, 100, 150] # Default: 50 -statuses-poll-option-max-chars: __STATUSES_POLL_OPTION_MAX_OPTIONS__ +statuses-poll-option-max-chars: __STATUSES_POLL_OPTION_MAX_CHARS__ # Int. Maximum amount of media files that can be attached to a new status. # Note that going way higher than the default might break federation. From 0d98cb44f22cceaf317ded49757befb96b4f356c Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 27 Mar 2022 18:24:28 +0200 Subject: [PATCH 17/30] typo --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 3941319..c90a01a 100755 --- a/scripts/install +++ b/scripts/install @@ -233,7 +233,7 @@ ynh_script_progression --message="Creating gotosocial admin user..." --weight=1 "$final_path"/gotosocial --config-path "$final_path/config.yaml" admin account create --username "$admin" --email "$email" --password "$password" -"$final_path"/gotosocial --config-path "$final_path/config.yaml" admin account confirm --_username "$admin" +"$final_path"/gotosocial --config-path "$final_path/config.yaml" admin account confirm --username "$admin" "$final_path"/gotosocial --config-path "$final_path/config.yaml" admin account promote --username "$admin" From 34b1f1f2b1208743123477ef1fb87414f3dbdb4c Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 27 Mar 2022 18:39:46 +0200 Subject: [PATCH 18/30] small move of variable declaration for consistency of arrangement --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index c90a01a..3563d04 100755 --- a/scripts/install +++ b/scripts/install @@ -24,6 +24,8 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= +app=$YNH_APP_INSTANCE_NAME + domain=$YNH_APP_ARG_DOMAIN path_url="/" @@ -51,8 +53,6 @@ statuses_poll_max_options="6" statuses_poll_option_max_chars="50" statuses_media_max_files="6" -app=$YNH_APP_INSTANCE_NAME - #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= From 91b5b10ca70cc076c9e3df936bbaa4eea554490d Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 27 Mar 2022 19:38:33 +0200 Subject: [PATCH 19/30] test without final_path trick --- config_panel.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index 5c201f3..5a409a2 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -1,7 +1,3 @@ - -# temp fix for https://github.com/YunoHost/yunohost/pull/1449 -final_path = "/var/www/$app" - version = "1.0" [gotosocial] From c2be0a11fa3c8500d655eab48f038f00d157f519 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 27 Mar 2022 21:05:27 +0200 Subject: [PATCH 20/30] renamed all questions id for config consistencies reasons --- config_panel.toml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index 5a409a2..3322fcf 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -22,7 +22,7 @@ name.fr = "Configuration des inscriptions" help.en = "Config pertaining to creation and maintenance of accounts on the server, as well as defaults for new accounts." help.fr = "Configuration relative à la création et à la maintenance des comptes sur le serveur, ainsi que les valeurs par défaut pour les nouveaux comptes." -[gotosocial.accounts.registration-open] +[gotosocial.accounts.accounts-registration-open] ask.en = "Open registrations?" ask.fr = "Inscriptions ouvertes ?" bind = "accounts-registration-open:__FINALPATH__/config.yaml" @@ -31,7 +31,7 @@ help.en = "Do we want people to be able to just submit sign up requests, or do w help.fr = "Voulez-vous que les gens puissent simplement envoyer des demandes d'inscription, ou voulez-vous qu'iels doivent être invité-e-s ?" type = "boolean" -[gotosocial.accounts.approval-required] +[gotosocial.accounts.accounts-approval-required] ask.en = "Approval required?" ask.fr = "Validation requise ?" bind = "accounts-approval-required:__FINALPATH__/config.yaml" @@ -40,7 +40,7 @@ help.en = "Do sign up requests require approval from an admin/moderator before a help.fr = "Les demandes d'inscription doivent-elles être approuvées par un-e administrateur-ice/modérateur-ice avant qu'un compte puisse se connecter/utiliser le serveur ?" type = "boolean" -[gotosocial.accounts.reason-required] +[gotosocial.accounts.accounts-reason-required] ask.en = "Reason required?" ask.fr = "Motif requis ?" bind = "accounts-reason-required:__FINALPATH__/config.yaml" @@ -60,7 +60,7 @@ name.fr = "Configuration des médias" help.en = "Config pertaining to user media uploads (videos, image, image descriptions)." help.fr = "Configuration relative aux médias téléchargés par les utilisateurs (vidéos, images, descriptions d'images)." -[gotosocial.media.image-max-size] +[gotosocial.media.media-image-max-size] ask.en = "Maximum allowed image upload size in bytes." ask.fr = "Taille maximale autorisée pour le téléchargement d'images, en octets." bind = "media-image-max-size:__FINALPATH__/config.yaml" @@ -69,7 +69,7 @@ help.en = "Default: 2097152 -- aka 2MB" help.fr = "Valeur par défaut : 2097152 (soit 2 Mo)" type = "number" -[gotosocial.media.video-max-size] +[gotosocial.media.media-video-max-size] ask.en = "Maximum allowed video upload size in bytes." ask.fr = "Taille maximale autorisée pour le téléchargement de vidéos, en octets." bind = "media-video-max-size:__FINALPATH__/config.yaml" @@ -78,7 +78,7 @@ help.en = "Default: 10485760 -- aka 10MB" help.fr = "Valeur par défaut : 10485760 (soit 10 Mo)" type = "number" -[gotosocial.media.description-min-chars] +[gotosocial.media.media-description-min-chars] ask.en = "Minimum amount of characters required as an image or video description." ask.fr = "Nombre minimum de caractères requis pour la description d'une image ou d'une vidéo." bind = "media-description-min-chars:__FINALPATH__/config.yaml" @@ -87,7 +87,7 @@ help.en = "Default: 0 (not required)" help.fr = "Valeur par défaut : 0 (non obligatoire)" type = "number" -[gotosocial.media.description-max-chars] +[gotosocial.media.media-description-max-chars] ask.en = "Maximum amount of characters permitted in an image or video description." ask.fr = "Nombre maximum de caractères requis pour la description d'une image ou d'une vidéo." bind = "media-description-max-chars:__FINALPATH__/config.yaml" @@ -96,7 +96,7 @@ help.en = "Default: 500" help.fr = "Valeur par défaut : 500" type = "number" -[gotosocial.media.remote-cache-days] +[gotosocial.media.media-remote-cache-days] ask.en = "Number of days to cache media from remote instances before they are removed from the cache." ask.fr = "Nombre de jours de mise en cache des médias des instances distantes avant qu'ils ne soient retirés du cache." bind = "media-remote-cache-days:__FINALPATH__/config.yaml" @@ -126,7 +126,7 @@ name.fr = "Configuration des status" help.en = "Config pertaining to the creation of statuses/posts, and permitted limits." help.fr = "Configuration relative à la création de statuts/posts, et aux limites autorisées." -[gotosocial.statuses.max-chars] +[gotosocial.statuses.statuses-max-chars] ask.en = "Maximum amount of characters permitted for a new status." ask.fr = "Nombre maximal de caractères autorisés pour un nouveau statut." bind = "statuses-max-chars:__FINALPATH__/config.yaml" @@ -135,7 +135,7 @@ help.en = "Default: 5000. Note that going way higher than the default might brea help.fr = "Valeur par défaut : 5000. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." type = "number" -[gotosocial.statuses.cw-max-chars] +[gotosocial.statuses.statuses-cw-max-chars] ask.en = "Maximum amount of characters allowed in the CW/subject header of a status." ask.fr = "Nombre maximum de caractères autorisés dans l'en-tête CW/sujet d'un statut." bind = "statuses-cw-max-chars:__FINALPATH__/config.yaml" @@ -144,7 +144,7 @@ help.en = "Default: 100. Note that going way higher than the default might break help.fr = "Valeur par défaut : 100. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." type = "number" -[gotosocial.statuses.poll-max-options] +[gotosocial.statuses.statuses-poll-max-options] ask.en = "Maximum amount of options to permit when creating a new poll." ask.fr = "Nombre maximum d'options autorisées lors de la création d'un nouveau sondage." bind = "statuses-poll-max-options:__FINALPATH__/config.yaml" @@ -153,7 +153,7 @@ help.en = "Default: 6. Note that going way higher than the default might break f help.fr = "Valeur par défaut : 6. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." type = "number" -[gotosocial.statuses.poll-option-max-chars] +[gotosocial.statuses.statuses-poll-option-max-chars] ask.en = "Maximum amount of characters to permit per poll option when creating a new poll." ask.fr = "Nombre maximal de caractères autorisés par option de sondage lors de la création d'un nouveau sondage." bind = "statuses-poll-option-max-chars:__FINALPATH__/config.yaml" @@ -162,7 +162,7 @@ help.en = "Default: 50. Note that going way higher than the default might break help.fr = "Valeur par défaut : 50. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." type = "number" -[gotosocial.statuses.media-max-files] +[gotosocial.statuses.statuses-media-max-files] ask.en = "Maximum amount of media files that can be attached to a new status." ask.fr = "Quantité maximale de fichiers multimédias qui peuvent être joints à un nouveau statut." bind = "statuses-media-max-files:__FINALPATH__/config.yaml" @@ -189,7 +189,7 @@ name.fr = "Configuration de nginx" help.en = "Config pertaining to the Web server." help.fr = "Configuration relative au serveur Web." -[nginx.config.max-client_max_body_size] +[nginx.config.client_max_body_size] ask.en = "Sets the maximum allowed size of uploaded files." ask.fr = "Définit la taille maximale autorisée des fichiers téléchargés." bind = "client_max_body_size:/etc/nginx/conf.d/__DOMAIN__.d/__APP__.conf" From 340adf129588c3f0790cf6a15bc4364a7e12a26a Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 27 Mar 2022 21:32:40 +0200 Subject: [PATCH 21/30] nginx section removed --- config_panel.toml | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index 3322fcf..6c7e5d8 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -170,30 +170,3 @@ default = "6" help.en = "Default: 6. Note that going way higher than the default might break federation." help.fr = "Valeur par défaut : 6. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." 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 = "Configuration relative au serveur Web." - -[nginx.config.client_max_body_size] -ask.en = "Sets the maximum allowed size of uploaded files." -ask.fr = "Définit la taille maximale autorisée des fichiers téléchargés." -bind = "client_max_body_size:/etc/nginx/conf.d/__DOMAIN__.d/__APP__.conf" -default = "50M" -help.en = "Default: 50M." -help.fr = "Valeur par défaut : 50M" -type = "string" From acc850a6cbe7f70ae523c54bd8d6b59072ebf36a Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 27 Mar 2022 21:48:30 +0200 Subject: [PATCH 22/30] fix var names (_ in place of -) --- config_panel.toml | 64 ++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index 6c7e5d8..5444158 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -4,11 +4,9 @@ version = "1.0" services = ["__APP__"] -name.en = "GoToSocial configuration panel" -name.fr = "Configuration de GoToSocial" +name = "GoToSocial configuration panel" -help.en = "Here you can easily configure some things about your GoToSocial instance." -help.fr = "Ici vous pouvez configurer facilement certaines choses à propos de votre instance GoToSocial." +help = "Here you can easily configure some things about your GoToSocial instance." #################### #### ACCOUNTS CONFIG @@ -16,34 +14,32 @@ help.fr = "Ici vous pouvez configurer facilement certaines choses à propos de v [gotosocial.accounts] -name.en = "Accounts configuration" -name.fr = "Configuration des inscriptions" +name = "Accounts configuration" -help.en = "Config pertaining to creation and maintenance of accounts on the server, as well as defaults for new accounts." -help.fr = "Configuration relative à la création et à la maintenance des comptes sur le serveur, ainsi que les valeurs par défaut pour les nouveaux comptes." +help = "Config pertaining to creation and maintenance of accounts on the server, as well as defaults for new accounts." -[gotosocial.accounts.accounts-registration-open] +[gotosocial.accounts.accounts_registration_open] ask.en = "Open registrations?" ask.fr = "Inscriptions ouvertes ?" -bind = "accounts-registration-open:__FINALPATH__/config.yaml" +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 = "Voulez-vous que les gens puissent simplement envoyer des demandes d'inscription, ou voulez-vous qu'iels doivent être invité-e-s ?" type = "boolean" -[gotosocial.accounts.accounts-approval-required] +[gotosocial.accounts.accounts_approval_required] ask.en = "Approval required?" ask.fr = "Validation requise ?" -bind = "accounts-approval-required:__FINALPATH__/config.yaml" +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 = "Les demandes d'inscription doivent-elles être approuvées par un-e administrateur-ice/modérateur-ice avant qu'un compte puisse se connecter/utiliser le serveur ?" type = "boolean" -[gotosocial.accounts.accounts-reason-required] +[gotosocial.accounts.accounts_reason_required] ask.en = "Reason required?" ask.fr = "Motif requis ?" -bind = "accounts-reason-required:__FINALPATH__/config.yaml" +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 = "Les demandes d'inscription doivent-elles être motivées (par exemple, par une explication de la raison pour laquelle la personne souhaite rejoindre l'instance) ?" @@ -60,46 +56,46 @@ name.fr = "Configuration des médias" help.en = "Config pertaining to user media uploads (videos, image, image descriptions)." help.fr = "Configuration relative aux médias téléchargés par les utilisateurs (vidéos, images, descriptions d'images)." -[gotosocial.media.media-image-max-size] +[gotosocial.media.media_image_max_size] ask.en = "Maximum allowed image upload size in bytes." ask.fr = "Taille maximale autorisée pour le téléchargement d'images, en octets." -bind = "media-image-max-size:__FINALPATH__/config.yaml" +bind = "media_image_max_size:__FINALPATH__/config.yaml" default = "2097152" help.en = "Default: 2097152 -- aka 2MB" help.fr = "Valeur par défaut : 2097152 (soit 2 Mo)" type = "number" -[gotosocial.media.media-video-max-size] +[gotosocial.media.media_video_max_size] ask.en = "Maximum allowed video upload size in bytes." ask.fr = "Taille maximale autorisée pour le téléchargement de vidéos, en octets." -bind = "media-video-max-size:__FINALPATH__/config.yaml" +bind = "media_video_max_size:__FINALPATH__/config.yaml" default = "10485760" help.en = "Default: 10485760 -- aka 10MB" help.fr = "Valeur par défaut : 10485760 (soit 10 Mo)" type = "number" -[gotosocial.media.media-description-min-chars] +[gotosocial.media.media_description_min_chars] ask.en = "Minimum amount of characters required as an image or video description." ask.fr = "Nombre minimum de caractères requis pour la description d'une image ou d'une vidéo." -bind = "media-description-min-chars:__FINALPATH__/config.yaml" +bind = "media_description_min_chars:__FINALPATH__/config.yaml" default = "0" help.en = "Default: 0 (not required)" help.fr = "Valeur par défaut : 0 (non obligatoire)" type = "number" -[gotosocial.media.media-description-max-chars] +[gotosocial.media.media_description_max_chars] ask.en = "Maximum amount of characters permitted in an image or video description." ask.fr = "Nombre maximum de caractères requis pour la description d'une image ou d'une vidéo." -bind = "media-description-max-chars:__FINALPATH__/config.yaml" +bind = "media_description_max_chars:__FINALPATH__/config.yaml" default = "500" help.en = "Default: 500" help.fr = "Valeur par défaut : 500" type = "number" -[gotosocial.media.media-remote-cache-days] +[gotosocial.media.media_remote_cache_days] ask.en = "Number of days to cache media from remote instances before they are removed from the cache." ask.fr = "Nombre de jours de mise en cache des médias des instances distantes avant qu'ils ne soient retirés du cache." -bind = "media-remote-cache-days:__FINALPATH__/config.yaml" +bind = "media_remote_cache_days:__FINALPATH__/config.yaml" default = "30" help.en = """\ Default: 30\ @@ -126,46 +122,46 @@ name.fr = "Configuration des status" help.en = "Config pertaining to the creation of statuses/posts, and permitted limits." help.fr = "Configuration relative à la création de statuts/posts, et aux limites autorisées." -[gotosocial.statuses.statuses-max-chars] +[gotosocial.statuses.statuses_max_chars] ask.en = "Maximum amount of characters permitted for a new status." ask.fr = "Nombre maximal de caractères autorisés pour un nouveau statut." -bind = "statuses-max-chars:__FINALPATH__/config.yaml" +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 = "Valeur par défaut : 5000. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." type = "number" -[gotosocial.statuses.statuses-cw-max-chars] +[gotosocial.statuses.statuses_cw_max_chars] ask.en = "Maximum amount of characters allowed in the CW/subject header of a status." ask.fr = "Nombre maximum de caractères autorisés dans l'en-tête CW/sujet d'un statut." -bind = "statuses-cw-max-chars:__FINALPATH__/config.yaml" +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 = "Valeur par défaut : 100. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." type = "number" -[gotosocial.statuses.statuses-poll-max-options] +[gotosocial.statuses.statuses_poll_max_options] ask.en = "Maximum amount of options to permit when creating a new poll." ask.fr = "Nombre maximum d'options autorisées lors de la création d'un nouveau sondage." -bind = "statuses-poll-max-options:__FINALPATH__/config.yaml" +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 = "Valeur par défaut : 6. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." type = "number" -[gotosocial.statuses.statuses-poll-option-max-chars] +[gotosocial.statuses.statuses_poll_option_max_chars] ask.en = "Maximum amount of characters to permit per poll option when creating a new poll." ask.fr = "Nombre maximal de caractères autorisés par option de sondage lors de la création d'un nouveau sondage." -bind = "statuses-poll-option-max-chars:__FINALPATH__/config.yaml" +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 = "Valeur par défaut : 50. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." type = "number" -[gotosocial.statuses.statuses-media-max-files] +[gotosocial.statuses.statuses_media_max_files] ask.en = "Maximum amount of media files that can be attached to a new status." ask.fr = "Quantité maximale de fichiers multimédias qui peuvent être joints à un nouveau statut." -bind = "statuses-media-max-files:__FINALPATH__/config.yaml" +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 = "Valeur par défaut : 6. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." From b4055747804f56c74da1cd639d2c86a28f533a93 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 27 Mar 2022 21:50:53 +0200 Subject: [PATCH 23/30] re putting final_path trick --- config_panel.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config_panel.toml b/config_panel.toml index 5444158..d3f6271 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -1,3 +1,6 @@ +# temp fix for https://github.com/YunoHost/yunohost/pull/1449 +final_path = "/var/www/$app" + version = "1.0" [gotosocial] From 9f7560b9a2b2a89ff3e797b6b80d0a3a090cb984 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 27 Mar 2022 21:54:27 +0200 Subject: [PATCH 24/30] correction of an overcorrection --- config_panel.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index d3f6271..d2f875b 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -21,7 +21,7 @@ name = "Accounts configuration" help = "Config pertaining to creation and maintenance of accounts on the server, as well as defaults for new accounts." -[gotosocial.accounts.accounts_registration_open] +[gotosocial.accounts.registration_open] ask.en = "Open registrations?" ask.fr = "Inscriptions ouvertes ?" bind = "accounts_registration_open:__FINALPATH__/config.yaml" @@ -30,7 +30,7 @@ help.en = "Do we want people to be able to just submit sign up requests, or do w help.fr = "Voulez-vous que les gens puissent simplement envoyer des demandes d'inscription, ou voulez-vous qu'iels doivent être invité-e-s ?" type = "boolean" -[gotosocial.accounts.accounts_approval_required] +[gotosocial.accounts.approval_required] ask.en = "Approval required?" ask.fr = "Validation requise ?" bind = "accounts_approval_required:__FINALPATH__/config.yaml" @@ -39,7 +39,7 @@ help.en = "Do sign up requests require approval from an admin/moderator before a help.fr = "Les demandes d'inscription doivent-elles être approuvées par un-e administrateur-ice/modérateur-ice avant qu'un compte puisse se connecter/utiliser le serveur ?" type = "boolean" -[gotosocial.accounts.accounts_reason_required] +[gotosocial.accounts.reason_required] ask.en = "Reason required?" ask.fr = "Motif requis ?" bind = "accounts_reason_required:__FINALPATH__/config.yaml" From bc06848f54ce7ffbdf474a9321f255a22b73b5c0 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 27 Mar 2022 21:58:43 +0200 Subject: [PATCH 25/30] typo --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index d4c260b..1ddf2d5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -101,7 +101,7 @@ then statuses_poll_max_options="6" statuses_poll_option_max_chars="50" statuses_media_max_files="6" - # conversionof old parameters + # conversion of old parameters registration_open=$(convert_bool "$registration_open") registration_approval=$(convert_bool "$registration_approval") registration_reason=$(convert_bool "$registration_reason") From 2f0e29bb5b28f87a992c4e0057ab64aad9d0c98f Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 27 Mar 2022 22:24:20 +0200 Subject: [PATCH 26/30] sigh test without final_path trick --- config_panel.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_panel.toml b/config_panel.toml index d2f875b..01a46af 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -1,5 +1,5 @@ # temp fix for https://github.com/YunoHost/yunohost/pull/1449 -final_path = "/var/www/$app" +# final_path = "/var/www/$app" version = "1.0" From 826b7a4f0e3dcf6f9be58c43e81961391218230d Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 27 Mar 2022 22:31:32 +0200 Subject: [PATCH 27/30] fix binds --- config_panel.toml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index 01a46af..eda45c9 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -1,5 +1,5 @@ # temp fix for https://github.com/YunoHost/yunohost/pull/1449 -# final_path = "/var/www/$app" +final_path = "/var/www/$app" version = "1.0" @@ -24,7 +24,7 @@ help = "Config pertaining to creation and maintenance of accounts on the server, [gotosocial.accounts.registration_open] ask.en = "Open registrations?" ask.fr = "Inscriptions ouvertes ?" -bind = "accounts_registration_open:__FINALPATH__/config.yaml" +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 = "Voulez-vous que les gens puissent simplement envoyer des demandes d'inscription, ou voulez-vous qu'iels doivent être invité-e-s ?" @@ -33,7 +33,7 @@ type = "boolean" [gotosocial.accounts.approval_required] ask.en = "Approval required?" ask.fr = "Validation requise ?" -bind = "accounts_approval_required:__FINALPATH__/config.yaml" +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 = "Les demandes d'inscription doivent-elles être approuvées par un-e administrateur-ice/modérateur-ice avant qu'un compte puisse se connecter/utiliser le serveur ?" @@ -42,7 +42,7 @@ type = "boolean" [gotosocial.accounts.reason_required] ask.en = "Reason required?" ask.fr = "Motif requis ?" -bind = "accounts_reason_required:__FINALPATH__/config.yaml" +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 = "Les demandes d'inscription doivent-elles être motivées (par exemple, par une explication de la raison pour laquelle la personne souhaite rejoindre l'instance) ?" @@ -62,7 +62,7 @@ help.fr = "Configuration relative aux médias téléchargés par les utilisateur [gotosocial.media.media_image_max_size] ask.en = "Maximum allowed image upload size in bytes." ask.fr = "Taille maximale autorisée pour le téléchargement d'images, en octets." -bind = "media_image_max_size:__FINALPATH__/config.yaml" +bind = "media-image-max-size:__FINALPATH__/config.yaml" default = "2097152" help.en = "Default: 2097152 -- aka 2MB" help.fr = "Valeur par défaut : 2097152 (soit 2 Mo)" @@ -71,7 +71,7 @@ type = "number" [gotosocial.media.media_video_max_size] ask.en = "Maximum allowed video upload size in bytes." ask.fr = "Taille maximale autorisée pour le téléchargement de vidéos, en octets." -bind = "media_video_max_size:__FINALPATH__/config.yaml" +bind = "media-video-max-size:__FINALPATH__/config.yaml" default = "10485760" help.en = "Default: 10485760 -- aka 10MB" help.fr = "Valeur par défaut : 10485760 (soit 10 Mo)" @@ -80,7 +80,7 @@ type = "number" [gotosocial.media.media_description_min_chars] ask.en = "Minimum amount of characters required as an image or video description." ask.fr = "Nombre minimum de caractères requis pour la description d'une image ou d'une vidéo." -bind = "media_description_min_chars:__FINALPATH__/config.yaml" +bind = "media-description-min-chars:__FINALPATH__/config.yaml" default = "0" help.en = "Default: 0 (not required)" help.fr = "Valeur par défaut : 0 (non obligatoire)" @@ -89,7 +89,7 @@ type = "number" [gotosocial.media.media_description_max_chars] ask.en = "Maximum amount of characters permitted in an image or video description." ask.fr = "Nombre maximum de caractères requis pour la description d'une image ou d'une vidéo." -bind = "media_description_max_chars:__FINALPATH__/config.yaml" +bind = "media-description-max-chars:__FINALPATH__/config.yaml" default = "500" help.en = "Default: 500" help.fr = "Valeur par défaut : 500" @@ -98,7 +98,7 @@ type = "number" [gotosocial.media.media_remote_cache_days] ask.en = "Number of days to cache media from remote instances before they are removed from the cache." ask.fr = "Nombre de jours de mise en cache des médias des instances distantes avant qu'ils ne soient retirés du cache." -bind = "media_remote_cache_days:__FINALPATH__/config.yaml" +bind = "media-remote-cache-days:__FINALPATH__/config.yaml" default = "30" help.en = """\ Default: 30\ @@ -128,7 +128,7 @@ help.fr = "Configuration relative à la création de statuts/posts, et aux limit [gotosocial.statuses.statuses_max_chars] ask.en = "Maximum amount of characters permitted for a new status." ask.fr = "Nombre maximal de caractères autorisés pour un nouveau statut." -bind = "statuses_max_chars:__FINALPATH__/config.yaml" +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 = "Valeur par défaut : 5000. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." @@ -137,7 +137,7 @@ type = "number" [gotosocial.statuses.statuses_cw_max_chars] ask.en = "Maximum amount of characters allowed in the CW/subject header of a status." ask.fr = "Nombre maximum de caractères autorisés dans l'en-tête CW/sujet d'un statut." -bind = "statuses_cw_max_chars:__FINALPATH__/config.yaml" +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 = "Valeur par défaut : 100. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." @@ -146,7 +146,7 @@ type = "number" [gotosocial.statuses.statuses_poll_max_options] ask.en = "Maximum amount of options to permit when creating a new poll." ask.fr = "Nombre maximum d'options autorisées lors de la création d'un nouveau sondage." -bind = "statuses_poll_max_options:__FINALPATH__/config.yaml" +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 = "Valeur par défaut : 6. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." @@ -155,7 +155,7 @@ type = "number" [gotosocial.statuses.statuses_poll_option_max_chars] ask.en = "Maximum amount of characters to permit per poll option when creating a new poll." ask.fr = "Nombre maximal de caractères autorisés par option de sondage lors de la création d'un nouveau sondage." -bind = "statuses_poll_option_max_chars:__FINALPATH__/config.yaml" +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 = "Valeur par défaut : 50. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." @@ -164,7 +164,7 @@ type = "number" [gotosocial.statuses.statuses_media_max_files] ask.en = "Maximum amount of media files that can be attached to a new status." ask.fr = "Quantité maximale de fichiers multimédias qui peuvent être joints à un nouveau statut." -bind = "statuses_media_max_files:__FINALPATH__/config.yaml" +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 = "Valeur par défaut : 6. Notez que si vous dépassez la valeur par défaut, vous risquez de compromettre la fédération." From d1fd7cf8f60bdd63b8c08e70b8eb92479ee40bef Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 27 Mar 2022 22:36:46 +0200 Subject: [PATCH 28/30] final_path trick doesn't work, waiting for core fix --- config_panel.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index eda45c9..bbf7245 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -1,6 +1,3 @@ -# temp fix for https://github.com/YunoHost/yunohost/pull/1449 -final_path = "/var/www/$app" - version = "1.0" [gotosocial] From eac9c5d4ea8e1c2f82d2050715de52d87288d103 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 27 Mar 2022 22:37:46 +0200 Subject: [PATCH 29/30] name and help doesn't support localization --- config_panel.toml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index bbf7245..4f3619a 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -50,11 +50,9 @@ type = "boolean" ################# [gotosocial.media] -name.en = "Media config" -name.fr = "Configuration des médias" +name = "Media config" -help.en = "Config pertaining to user media uploads (videos, image, image descriptions)." -help.fr = "Configuration relative aux médias téléchargés par les utilisateurs (vidéos, images, descriptions d'images)." +help = "Config pertaining to user media uploads (videos, image, image descriptions)." [gotosocial.media.media_image_max_size] ask.en = "Maximum allowed image upload size in bytes." @@ -116,11 +114,9 @@ type = "number" ################### [gotosocial.statuses] -name.en = "Status config" -name.fr = "Configuration des status" +name = "Status config" -help.en = "Config pertaining to the creation of statuses/posts, and permitted limits." -help.fr = "Configuration relative à la création de statuts/posts, et aux limites autorisées." +help = "Config pertaining to the creation of statuses/posts, and permitted limits." [gotosocial.statuses.statuses_max_chars] ask.en = "Maximum amount of characters permitted for a new status." From 837743990cb3975701f2a6d60a4cb7c21aca8cb2 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Sun, 27 Mar 2022 22:46:21 +0200 Subject: [PATCH 30/30] edited client_max_body_size from 50M to 100M --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 3563d04..cd7f545 100755 --- a/scripts/install +++ b/scripts/install @@ -29,7 +29,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN path_url="/" -client_max_body_size="50M" +client_max_body_size="100M" admin=$YNH_APP_ARG_ADMIN email=$YNH_APP_ARG_EMAIL diff --git a/scripts/upgrade b/scripts/upgrade index 1ddf2d5..fd800cb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -90,7 +90,7 @@ ynh_script_progression --message="Ensuring downward compatibility..." if ynh_compare_current_package_version --comparison lt --version 0.2.1~ynh4 then # declaration of new parameters - client_max_body_size="50M" + client_max_body_size="100M" media_image_max_size="2097152" media_video_max_size="10485760" media_description_min_chars="0"