diff --git a/LICENSE b/LICENSE index 7d1e40b..5c304d1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,201 @@ -File containing the license of your package. +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ -More information here: -https://yunohost.org/packaging_apps_guidelines#yep-1-3 + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 464c85a..ecfcb66 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ It shall NOT be edited by hand. # Matrix IRC Bridge for YunoHost [![Integration level](https://dash.yunohost.org/integration/matrix-appservice-irc.svg)](https://dash.yunohost.org/appci/app/matrix-appservice-irc) ![Working status](https://ci-apps.yunohost.org/ci/badges/matrix-appservice-irc.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/matrix-appservice-irc.maintain.svg) + [![Install Matrix IRC Bridge with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=matrix-appservice-irc) *[Lire ce readme en français.](./README_fr.md)* @@ -28,16 +29,8 @@ It is highly configurable and is currently used on the matrix.org homeserver to **Shipped version:** 0.36.0~ynh1 -## Disclaimers / important information - -WARNING: This bridge requires additional configuration in the configuration file. - -* You need a local Matrix-synapse server (Yunohost app available) -* No connection to the Yunohost LDAP - ## Documentation and resources -* Official app website: * Official user documentation: * Official admin documentation: * Upstream app code repository: diff --git a/README_fr.md b/README_fr.md index 49223ab..d59b20c 100644 --- a/README_fr.md +++ b/README_fr.md @@ -6,6 +6,7 @@ It shall NOT be edited by hand. # Matrix IRC Bridge pour YunoHost [![Niveau d’intégration](https://dash.yunohost.org/integration/matrix-appservice-irc.svg)](https://dash.yunohost.org/appci/app/matrix-appservice-irc) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/matrix-appservice-irc.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/matrix-appservice-irc.maintain.svg) + [![Installer Matrix IRC Bridge avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=matrix-appservice-irc) *[Read this readme in english.](./README.md)* @@ -28,16 +29,8 @@ Elle est hautement configurable, et est actuellement uilisée sur matrix.org pou **Version incluse :** 0.36.0~ynh1 -## Avertissements / informations importantes - -ATTENTION : Cette passerelle requiert une configuration supplémentaire dans son fichier de configuration. - -* Vous avez besoin d'un serveur local Matrix-Synapse (appli Yunohost disponible) -* Aucune connection au LDAP de Yunohost - ## Documentations et ressources -* Site officiel de l’app : * Documentation officielle utilisateur : * Documentation officielle de l’admin : * Dépôt de code officiel de l’app : diff --git a/check_process b/check_process deleted file mode 100644 index fefa192..0000000 --- a/check_process +++ /dev/null @@ -1,34 +0,0 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-check_process-file - -# Move this file from check_process.default to check_process when you have filled it. - -;; Test complet - ; Manifest - domain="domain.tld" - path="/path" - admin="john" - language="fr" - is_public=1 - password="1Strong-Password" - port="666" - ; Checks - pkg_linter=1 - setup_sub_dir=1 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - upgrade=1 from_commit=CommitHash - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=CommitHash - name=Name and date of the commit. - manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666& diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index 4fdc1e5..0000000 --- a/conf/app.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/matrix-org/matrix-appservice-irc/archive/refs/tags/0.36.0.tar.gz -SOURCE_SUM=95f2f5288d2347121e399dff1136e854932db5b3a8ff61a1a7cf5c9fd2729988 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/config.yaml b/conf/config.yaml index c8a4dcd..2586b71 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -1,4 +1,4 @@ -# GENERATED BY YUNOHOST FROM UPSTREAM VERSION 0.32.1 +# GENERATED BY YUNOHOST FROM UPSTREAM VERSION 1.0.1 # Configuration specific to AS registration. Unless other marked, all fields # are *REQUIRED*. @@ -38,7 +38,7 @@ homeserver: # Which port should the appservice bind to. Can be overriden by the one provided in the # command line! Optional. - # bindPort: 9999 + # bindPort: 8090 # Use this option to force the appservice to listen on another hostname for transactions. # This is NOT your synapse hostname. E.g. use 127.0.0.1 to only listen locally. Optional. @@ -334,8 +334,8 @@ ircService: # The display name to use for created matrix clients. This should have # $NICK somewhere in it if it is specified. Can also use $SERVER to # insert the IRC domain. - # Optional. Default: "$NICK (IRC)". Example: "Alice (IRC)" - displayName: "$NICK (IRC)" + # Optional. Default: "$NICK". Example: "Alice" + displayName: "$NICK" # Number of tries a client can attempt to join a room before the request # is discarded. You can also use -1 to never retry or 0 to never give up. # Optional. Default: -1 @@ -373,6 +373,16 @@ ircService: # Older kernels will need IP_FREEBIND, which requires an LD_PRELOAD with the library # https://github.com/matrix-org/freebindfree as Node does not expose setsockopt. # prefix: "2001:0db8:85a3::" # modify appropriately + + # Optional. Define blocks of IPv6 addresses for different homeservers + # which can be used to restrict users of those homeservers to a given + # IP. These blocks should be considered immutable once set, as changing + # the startFrom value will NOT adjust existing IP addresses. + # Changing the startFrom value to a lower value may conflict with existing clients. + # Multiple homeservers may NOT share blocks. + blocks: + - homeserver: another-server.org + startFrom: '10:0000' # # The maximum amount of time in seconds that the client can exist # without sending another message before being disconnected. Use 0 to @@ -461,7 +471,6 @@ ircService: # Configuration for logging. Optional. Default: console debug level logging # only. - # This key CANNOT be hot-reloaded logging: # Level to log on console/logfile. One of error|warn|info|debug level: "warn" @@ -480,7 +489,7 @@ ircService: # This key CANNOT be hot-reloaded metrics: # Whether to actually enable the metric endpoint. Default: false - enabled: true + enabled: false # Which port to listen on (omit to listen on the bindPort) port: 7001 # Which hostname to listen on (omit to listen on 127.0.0.1), requires port to be set @@ -512,15 +521,15 @@ ircService: port: 11100 # Configuration for the provisioning API. - # - # GET /_matrix/provision/link - # GET /_matrix/provision/unlink - # GET /_matrix/provision/listlinks - # # This key CANNOT be hot-reloaded provisioning: # True to enable the provisioning HTTP endpoint. Default: false. enabled: false + # Whether to enable hosting the setup widget page. Default: false. + widget: true + # A secure secret token for making provisioner requests. Default: the appservice hs_token. + secret: $generateMe + # The number of seconds to wait before giving up on getting a response from # an IRC channel operator. If the channel operator does not respond within the # allotted time period, the provisioning request will fail. @@ -540,11 +549,46 @@ ircService: # These users will deny a room from being bridged. - "@.*:badguys.com" - # Watch the file for changes, and apply the rules. Default: false - enableReload: true # Number of channels allowed to be bridged roomLimit: 50 + # Endpoint prefix for provisoning requests. Default: "/_matrix/provision" + # apiPrefix: "/_matrix/provision" + # Whether to apply rate limiting to the provisioning API. Default: true. + # ratelimit: true + + # Run a separate HTTP listener for provisioning requests. + http: + # The port to listen on. + port: 7700 + # The host to listen on. Optional. By default this is 0.0.0.0 + # host: 0.0.0.0 + + # When users request a token from the bridge to make provisioning + # requests, disallow any requests that resolve a Matrix server_name included in these ranges. + # This list should include any internal IPs that the bridge should never lookup. + # By default, the below list is used. + # openIdDisallowedIpRanges: + # - '127.0.0.0/8' + # - '10.0.0.0/8' + # - '172.16.0.0/12' + # - '192.168.0.0/16' + # - '100.64.0.0/10' + # - '192.0.0.0/24' + # - '169.254.0.0/16' + # - '192.88.99.0/24' + # - '198.18.0.0/15' + # - '192.0.2.0/24' + # - '198.51.100.0/24' + # - '203.0.113.0/24' + # - '224.0.0.0/4' + # - '::1/128' + # - 'fe80::/10' + # - 'fc00::/7' + # - '2001:db8::/32' + # - 'ff00::/8' + # - 'fec0::/10' + # WARNING: The bridge needs to send plaintext passwords to the IRC server, it cannot # send a password hash. As a result, passwords (NOT hashes) are stored encrypted in # the database. @@ -575,6 +619,7 @@ ircService: # Maximum number of montly active users, beyond which the bridge gets blocked (both ways) # RMAUlimit: 100 + # Optional. # userActivity: # The "grace period" before we start counting users as active # minUserActiveDays: 1 @@ -623,6 +668,13 @@ ircService: # the configuration in the config file. # allowUnconnectedMatrixUsers: true + # Options for hooking into Matrix moderation policy lists + banLists: + # A list of rooms containing "m.policy.rule.*" events which can be used + # to identify banned users, rooms and servers. + rooms: + - "#matrix-org-coc-bl:matrix.org" + # Options here are generally only applicable to large-scale bridges and may have # consequences greater than other options in this configuration file. advanced: @@ -655,3 +707,11 @@ database: # For postgres, it must start with postgres:// # For NeDB, it must start with nedb://. The path is relative to the project directory. connectionString: "postgres://__DB_NAME__:__DB_PWD__@localhost:5432/__DB_NAME__" + +# Enable running IRC connections out of a secondary process. +# See https://matrix-org.github.io/matrix-appservice-irc/latest/connection_pooling.html for more information +# connectionPool: +# # The Redis URI to connect to +# redisUrl: redis://user:password@host:port/dbnum +# # Should the connections persist after the bridge successfully shuts down? +# persistConnectionsOnShutdown: true diff --git a/conf/systemd.service b/conf/systemd.service index ae4fdef..d165476 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,9 +6,9 @@ After=matrix-synapse.target Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ +WorkingDirectory=__INSTALL_DIR__/ Environment="__YNH_NODE_LOAD_PATH__" -ExecStart=__FINALPATH__/bin/matrix-appservice-irc -c __FINALPATH__/config.yaml +ExecStart=__INSTALL_DIR__/bin/matrix-appservice-irc -c __INSTALL_DIR__/config.yaml StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit diff --git a/config_panel.toml.example b/config_panel.toml.example deleted file mode 100644 index c6bccd8..0000000 --- a/config_panel.toml.example +++ /dev/null @@ -1,295 +0,0 @@ - -## 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 = "Main configuration" -# name.fr = "Configuration principale" - -## (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.regexp = '^\w{3,30}$' - pattern.error = "The name should be at least 3 chars and less than 30 chars. Alphanumeric chars are accepted" - - ## Note: visible and optional properties are also available for questions - - - [main.customization.contact_url] - ask = "Contact url" - type = "url" - example = "mailto: contact@example.org" - help = "mailto: accepted" - pattern.regexp = '^mailto:[^@]+@[^@]+|https://$' - pattern.error = "Should be https or mailto:" - bind = ":/var/www/__APP__/settings.py" - - [main.customization.logo] - ask = "Logo" - type = "file" - accept = ".png" - help = "Fill with an already resized logo" - bind = "__FINALPATH__/img/logo.png" - - [main.customization.favicon] - ask = "Favicon" - type = "file" - accept = ".png" - help = "Fill with an already sized favicon" - bind = "__FINALPATH__/img/favicon.png" - - - [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 [Stripe products](https://dashboard.stripe.com/products) to create those donation products. \ - 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.regexp = '^(one_time|recuring)/(EUR|USD)/price_.*$' - pattern.error = "Please respect the format describe in help text for each price ID" diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index f5c8a36..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,4 +0,0 @@ -WARNING: This bridge requires additional configuration in the configuration file. - -* You need a local Matrix-synapse server (Yunohost app available) -* No connection to the Yunohost LDAP diff --git a/doc/DISCLAIMER_fr.md b/doc/DISCLAIMER_fr.md deleted file mode 100644 index d635111..0000000 --- a/doc/DISCLAIMER_fr.md +++ /dev/null @@ -1,4 +0,0 @@ -ATTENTION : Cette passerelle requiert une configuration supplémentaire dans son fichier de configuration. - -* Vous avez besoin d'un serveur local Matrix-Synapse (appli Yunohost disponible) -* Aucune connection au LDAP de Yunohost diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..2c657a3 --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1,79 @@ +### Bridge configuration + +The bridge needs to be configure after installation. + +Please edit the file `__INSTALL_DIR__/config.yaml` to add IRC servers, then run `sudo systemctl restart __APP__.service`. + +This file's documentation is here: . + +Here's a simple IRC server configuration: + +```yaml + irc.example.com: + name: "MyServer" + port: 6697 + ssl: true + + # A map for conversion of IRC user modes to Matrix power levels. This enables bridging + # of IRC ops to Matrix power levels only, it does not enable the reverse. If a user has + # been given multiple modes, the one that maps to the highest power level will be used. + modePowerMap: + o: 50 + v: 1 + + botConfig: + enabled: true + nick: "MatrixBot" + username: "matrixbot" + joinChannelsIfNoUsers: false + + privateMessages: + enabled: true + federate: true + + dynamicChannels: + enabled: true + createAlias: true + published: true + federate: true + aliasTemplate: "#irc_$CHANNEL" + + # What should the join_rule be for the new Matrix room? If 'public', + # anyone can join the room. If 'invite', only users with an invite can + # join the room. Note that if an IRC channel has +k or +i set on it, + # join_rules will be set to 'invite' until these modes are removed. + # Default: "public". + joinRule: public + # A list of user IDs which the AS bot will send invites to in response + # to a !join. Only applies if joinRule is 'invite'. Default: [] + # whitelist: + # - "@foo:example.com" + # - "@bar:example.com" + # + # Prevent the given list of channels from being mapped under any + # circumstances. + # exclude: ["#foo", "#bar"] + + # excludedUsers: + # - regex: "@.*:evilcorp.com" + # kickReason: "We don't like Evilcorp" + + matrixClients: + userTemplate: "@irc_$NICK" + displayName: "$NICK" + joinAttempts: -1 + + ircClients: + nickTemplate: "$DISPLAY[m]" + allowNickChanges: true + maxClients: 30 + + # The number of lines to allow being sent by the IRC client that has received + # a large block of text to send from matrix. If the number of lines that would + # be sent is > lineLimit, the text will instead be uploaded to matrix and the + # resulting URI is treated as a file. As such, a link will be sent to the IRC + # side instead of potentially spamming IRC and getting the IRC client kicked. + # Default: 3. + lineLimit: 10 + +``` diff --git a/doc/POST_INSTALL_fr.md b/doc/POST_INSTALL_fr.md new file mode 100644 index 0000000..36eeac1 --- /dev/null +++ b/doc/POST_INSTALL_fr.md @@ -0,0 +1,79 @@ +### Configuration de la passerelle + +La passerelle nécessite d'être configurée après installation. + +Veuillez éditer le fichier `__INSTALL_DIR__/config.yaml` pour rajouter des serveurs IRC, puis exécutez `sudo systemctl restart __APP__.service`. + +Vous pouvez vous référer à pour les détails concernant ce fichier. + +Voici une configuration simple de serveur IRC: + +```yaml + irc.example.com: + name: "MyServer" + port: 6697 + ssl: true + + # A map for conversion of IRC user modes to Matrix power levels. This enables bridging + # of IRC ops to Matrix power levels only, it does not enable the reverse. If a user has + # been given multiple modes, the one that maps to the highest power level will be used. + modePowerMap: + o: 50 + v: 1 + + botConfig: + enabled: true + nick: "MatrixBot" + username: "matrixbot" + joinChannelsIfNoUsers: false + + privateMessages: + enabled: true + federate: true + + dynamicChannels: + enabled: true + createAlias: true + published: true + federate: true + aliasTemplate: "#irc_$CHANNEL" + + # What should the join_rule be for the new Matrix room? If 'public', + # anyone can join the room. If 'invite', only users with an invite can + # join the room. Note that if an IRC channel has +k or +i set on it, + # join_rules will be set to 'invite' until these modes are removed. + # Default: "public". + joinRule: public + # A list of user IDs which the AS bot will send invites to in response + # to a !join. Only applies if joinRule is 'invite'. Default: [] + # whitelist: + # - "@foo:example.com" + # - "@bar:example.com" + # + # Prevent the given list of channels from being mapped under any + # circumstances. + # exclude: ["#foo", "#bar"] + + # excludedUsers: + # - regex: "@.*:evilcorp.com" + # kickReason: "We don't like Evilcorp" + + matrixClients: + userTemplate: "@irc_$NICK" + displayName: "$NICK" + joinAttempts: -1 + + ircClients: + nickTemplate: "$DISPLAY[m]" + allowNickChanges: true + maxClients: 30 + + # The number of lines to allow being sent by the IRC client that has received + # a large block of text to send from matrix. If the number of lines that would + # be sent is > lineLimit, the text will instead be uploaded to matrix and the + # resulting URI is treated as a file. As such, a link will be sent to the IRC + # side instead of potentially spamming IRC and getting the IRC client kicked. + # Default: 3. + lineLimit: 10 + +``` diff --git a/doc/PRE_INSTALL.md b/doc/PRE_INSTALL.md new file mode 100644 index 0000000..fd3558c --- /dev/null +++ b/doc/PRE_INSTALL.md @@ -0,0 +1,3 @@ +This app requires the Matrix server Synapse to be installed first in Yunohost. + +Also, you will have to configure the bridge into its configuration file. diff --git a/doc/PRE_INSTALL_fr.md b/doc/PRE_INSTALL_fr.md new file mode 100644 index 0000000..87ceaaa --- /dev/null +++ b/doc/PRE_INSTALL_fr.md @@ -0,0 +1,3 @@ +Cette application nécessite d'installer d'abord le serveur Matrix Synapse dans Yunohost. + +Vous aurez aussi besoin de configurer la passerelle dans son fichier de configuration diff --git a/manifest.json b/manifest.json deleted file mode 100644 index a20785e..0000000 --- a/manifest.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "name": "Matrix IRC Bridge", - "id": "matrix-appservice-irc", - "packaging_format": 1, - "description": { - "en": "Matrix bridge for IRC", - "fr": "Passerelle Matrix pour IRC" - }, - "version": "0.36.0~ynh1", - "url": "https://github.com/matrix-org/matrix-appservice-irc", - "upstream": { - "license": "free", - "website": "https://github.com/matrix-org/matrix-appservice-irc", - "admindoc": "https://matrix-org.github.io/matrix-appservice-irc/latest/bridge_setup", - "userdoc": "https://matrix-org.github.io/matrix-appservice-irc/latest/usage", - "code": "https://github.com/matrix-org/matrix-appservice-irc" - }, - "license": "free", - "maintainer": { - "name": "Salamandar", - "email": "felix@piedallu.me" - }, - "requirements": { - "yunohost": ">= 4.3.0" - }, - "multi_instance": true, - "services": [ - "postgresql" - ], - "arguments": { - "install" : [ - { - "name": "synapsenumber", - "type": "string", - "ask": { - "en": "Choose the local Synapse instance number to communicate with matrix-appservice-irc.", - "fr": "Choisissez le numéro de l'instance Synapse qui doit communiquer avec matrix-appservice-irc." - }, - "example": "2 (for instance synapse__2)", - "help": { - "en": "If you installed Synapse only once time, then leave default value 1.", - "fr": "Si vous n'avez installé qu'une fois Synapse, gardez la valeur par défaut 1." - }, - "default": "1" - }, - { - "name": "botname", - "type": "string", - "ask": { - "en": "Choose a local Synapse user name for the irc bot", - "fr": "Choisissez un nom d'utilisateur Synapse local pour le robot irc" - }, - "example": "ircmatrixbot", - "help": { - "en": "A system user will be created. Invite @ircmatrixbot:localsynapse.servername from an authorized Matrix account to start bridging. Give the Matrix server_name, not the full domain/URL.", - "fr": "Un utilisateur système sera créé. Inviter @ircmatrixbot:localsynapse.servername depuis un compte Matrix autorisé pour démarrer une passerelle. Donner le nom du serveur Matrix, pas le domaine/URL complet." - }, - "default": "ircmatrixbot" - }, - { - "name": "botadmin", - "type": "string", - "ask": { - "en": "Choose the Matrix account administrator of the irc bridge", - "fr": "Choisissez le compte Matrix administrateur de la passerelle irc" - }, - "example": "@johndoe:localsynapse.servername or @johndoe:matrix.org", - "help": { - "en": "The irc bridge administrator does not need to be a local Synapse account.", - "fr": "Le compte administrateur de la passerelle irc peut ne pas être un compte local Synapse." - }, - "default": "Your main Matrix account" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..68f0158 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,112 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "matrix-appservice-irc" +name = "Matrix IRC Bridge" +description.en = "Matrix bridge for IRC" +description.fr = "Passerelle Matrix pour IRC" + +version = "0.36.0~ynh1" + +maintainers = ["Salamandar"] + +[upstream] +license = "Apache-2.0" +code = "https://github.com/matrix-org/matrix-appservice-irc" +admindoc = "https://matrix-org.github.io/matrix-appservice-irc/latest/bridge_setup" +userdoc = "https://matrix-org.github.io/matrix-appservice-irc/latest/usage" + +[integration] +yunohost = ">= 11.1" +architectures = "all" +multi_instance = true +ldap = false +sso = false +disk = "100M" +ram.build = "256M" +ram.runtime = "1024M" + +[install] + [install.synapse_instance] + ask.en = "Choose the local Synapse instance to communicate with matrix-appservice-irc." + ask.fr = "Choisissez l'instance Synapse qui doit communiquer avec matrix-appservice-irc." + type = "app" + # pattern.regexp = "synapse(__)*[0-9]*" + # pattern.error = "Invalid app selected. Please select a Synapse instance." + help.en = "Usually the Synapse instances contain a number after it is installed more than one time. E.g. synapse__1 will be the second instance." + help.fr = "En général, les instances de Synapse contiennent un numéro après avoir été installées plus d'une fois. Par exemple, synapse__1 sera la deuxième instance." + default = "synapse" + + [install.botname] + ask.en = "Choose a local Synapse user name for the irc bot" + ask.fr = "Choisissez un nom d'utilisateur Synapse local pour le robot irc" + help.en = "A system user will be created. Invite @ircmatrixbot:localsynapse.servername from an authorized Matrix account to start bridging. Give the Matrix server_name, not the full domain/URL." + help.fr = "Un utilisateur système sera créé. Inviter @ircmatrixbot:localsynapse.servername depuis un compte Matrix autorisé pour démarrer une passerelle. Donner le nom du serveur Matrix, pas le domaine/URL complet." + type = "string" + example = "ircmatrixbot" + default = "ircmatrixbot" + + [install.bot_synapse_adm] + ask.en = "Give the IRC bot administrator rights to the Synapse instance?" + ask.fr = "Donner au robot IRC des droits administrateur à l'instance Synapse ?" + type = "boolean" + help.en = "If true, the bot can group IRC chats in a Matrix space.Not required if you set up Synapse so that non-admins are authorized to create communities." + help.fr = "Si true, le robot groupera les conversations IRC dans une communauté Matrix.Pas nécessaire si vous avez réglé Synapse pour qu'il autorise les non-admin à créer des communautés." + default = true + + [install.botadmin] + ask.en = "Choose the Matrix account administrator of the IRC bot" + ask.fr = "Choisissez le compte Matrix administrateur du robot IRC" + type = "string" + example = "@johndoe:localsynapse.servername or @johndoe:matrix.org" + help.en = "The administrator does not need to be a local Synapse account. Valid formats are @johndoe:localsynapse.servername or @johndoe:matrix.org" + help.fr = "L'administrateur peut ne pas être un compte local Synapse. Les formats valables sont @johndoe:localsynapse.servername or @johndoe:matrix.org" + + [install.botusers] + ask.en = "Choose Matrix user(s) authorized to bridge with the IRC bot." + ask.fr = "Choisissez le/les compte(s) Matrix autorisés à utiliser la passerelle IRC." + type = "string" + example = "@johndoe:server.name or server.name or *" + [install.botusers.help] + en = """ + A remote or local user (@johndoe:server.name),the local server (server.name), a remote server (matrix.org), or all remote/local servers (*) can be authorized. + Give the Matrix server_name, not the full domain/URL. + It is also possible to specify multiple values by separating them with comma. Example: @johndoe:server.name,domain.tld,matrix.org""" + fr = """ + Un compte local ou distant (@johndoe:server.name), le serveur local (server.name), un serveur distant (matrix.org), ou tous les serveurs remote/local (*). + Donner le nom du serveur Matrix, pas le domaine/URL complet. + Il est également possible de spécifier plusieurs valeurs en les séparant par une virgule. Exemple : @johndoe:server.name,domain.tld,matrix.org""" + + +[resources] + [resources.sources.main] + url = "https://github.com/matrix-org/matrix-appservice-irc/archive/refs/tags/1.0.1.tar.gz" + sha256 = "ac58ca1e7ed1a496b0ec69cd7079f67c2e3ad5007f24bdacd63fc992cc442ce3" + autoupdate.strategy = "latest_github_release" + autoupdate.asset = "*.tar.gz" + + [resources.system_user] + home = "/opt/yunohost/__APP__" + + [resources.install_dir] + dir = "/opt/yunohost/__APP__" + + [resources.permissions] + main.allowed = "all_users" + main.auth_header = false + + [resources.ports] + main.default = 8095 + + [resources.apt] + packages = [ + "postgresql", + ] + + extras.yarn.repo = "deb https://dl.yarnpkg.com/debian/ stable main" + extras.yarn.key = "https://dl.yarnpkg.com/debian/pubkey.gpg" + extras.yarn.packages = "yarn" + + [resources.database] + type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 00c09fa..1f5dfa4 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,15 +4,38 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -pkg_dependencies="postgresql" - -nodejs_version=14 +nodejs_version=18 #================================================= # PERSONAL HELPERS #================================================= +__ynh_register_synapse_app_service() { + "$install_dir/bin/matrix-appservice-irc" -r \ + -c "$install_dir/config.yaml" \ + -u "http://127.0.0.1:$port" \ + -f "$install_dir/appservice-registration-irc.yaml" + + # This appservice needs it to be duplicated… + cp "$install_dir/appservice-registration-irc.yaml" \ + "/etc/matrix-$synapse_instance/app-service/$app.yaml" + + "/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh" \ + || ynh_die --message="Synapse can't restart with the appservice configuration" + + ynh_store_file_checksum --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" + ynh_store_file_checksum --file="$install_dir/appservice-registration-irc.yaml" +} + +# TODO: +__ynh_register_dendrite_app_service() { + : +} + +__ynh_register_matrix_app_service() { + __ynh_register_synapse_app_service +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index af32bd7..251bb1b 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,27 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -40,7 +19,7 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # SPECIFIC BACKUP @@ -61,8 +40,6 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= ynh_print_info --message="Backing up the PostgreSQL database..." -### (However, things like MySQL dumps *do* take some time to run, though the -### copy of the generated dump to the archive still happens later) ynh_psql_dump_db --database="$db_name" > db.sql #================================================= diff --git a/scripts/change_url b/scripts/change_url deleted file mode 100644 index 322641b..0000000 --- a/scripts/change_url +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/bash - -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= - -source _common.sh -source /usr/share/yunohost/helpers - -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH - -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -# Add settings here as needed by your application -#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) - -#================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. - ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -change_domain=0 -if [ "$old_domain" != "$new_domain" ] -then - change_domain=1 -fi - -change_path=0 -if [ "$old_path" != "$new_path" ] -then - change_path=1 -fi - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 - -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" - -#================================================= -# MODIFY URL IN NGINX CONF -#================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 - -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the path in the NGINX config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original NGINX config file if modified - ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" - # Create a dedicated NGINX config - ynh_add_nginx_config -fi - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= - -#================================================= -# GENERIC FINALISATION -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 - -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload - -#================================================= -# END OF SCRIPT -#================================================= - -ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index f2ebff9..22ccba4 100755 --- a/scripts/install +++ b/scripts/install @@ -9,50 +9,20 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -synapsenumber=$YNH_APP_ARG_SYNAPSENUMBER -botname=$YNH_APP_ARG_BOTNAME -botadmin=$YNH_APP_ARG_BOTADMIN -app=$YNH_APP_INSTANCE_NAME - -if [ "$synapsenumber" == "1" ]; then - synapse_instance="synapse" -else - synapse_instance="synapse__$synapsenumber" -fi - -domain=$(ynh_app_setting_get --app "$synapse_instance" --key domain) +# Retrieve some values from selected Synapse instance and store them server_name=$(ynh_app_setting_get --app "$synapse_instance" --key server_name) - -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 - -final_path=/opt/yunohost/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" -ynh_app_setting_set --app=$app --key=final_path --value=$final_path +domain=$(ynh_app_setting_get --app "$synapse_instance" --key domain) +ynh_app_setting_set --app="$app" --key=server_name --value="$server_name" +ynh_app_setting_set --app="$app" --key=domain --value="$domain" +synapse_db_name="matrix_$synapse_instance" #================================================= # STORE SETTINGS FROM MANIFEST #================================================= ynh_script_progression --message="Storing installation settings..." --weight=1 -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=server_name --value=$server_name ynh_app_setting_set --app=$app --key=botname --value=$botname ynh_app_setting_set --app=$app --key=synapse_instance --value=$synapse_instance -ynh_app_setting_set --app=$app --key=botadmin --value=$botadmin #================================================= # SET CONSTANTS @@ -60,95 +30,53 @@ ynh_app_setting_set --app=$app --key=botadmin --value=$botadmin enable_relaybot=true bot_synapse_db_user="@$botname:$server_name" -synapse_db_name="matrix_$synapse_instance" - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 - -# Find an available port for communication between the local synapse instance (home server) and the bridge app service. -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=1 +ynh_script_progression --message="Installing NodeJS..." --weight=1 -ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$nodejs_version - ynh_use_nodejs -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" - -#================================================= -# CREATE A POSTGRESQL DATABASE -#================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." --weight=2 - -db_name=$(ynh_sanitize_dbid --db_name=$app) -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -db_pwd=$(ynh_string_random --length=30) -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_name --db_name=$db_name --db_pwd=$db_pwd - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files and building the app..." --weight=3 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$final_path" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" - -pushd "$final_path" >/dev/null || ynh_die - ynh_exec_as $app $ynh_node_load_PATH $ynh_npm i -popd >/dev/null || ynh_die +ynh_setup_source --dest_dir="$install_dir" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app:$app" "$install_dir" +( + cd "$install_dir" + ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" i +) +#================================================= +# SPECIFIC SETUP #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml" -ynh_store_file_checksum --file="$final_path/config.yaml" -chmod 400 "$final_path/config.yaml" -chown $app:$app "$final_path/config.yaml" +ynh_add_config --template="../conf/config.yaml" --destination="$install_dir/config.yaml" + +chmod 400 "$install_dir/config.yaml" +chown "$app:$app" "$install_dir/config.yaml" # Generate the password encryption key -openssl genpkey -out $final_path/passkey.pem -outform PEM -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -chmod 400 "$final_path/passkey.pem" -chown $app:$app "$final_path/passkey.pem" +openssl genpkey -out "$install_dir/passkey.pem" -outform PEM -algorithm RSA -pkeyopt rsa_keygen_bits:2048 +chmod 400 "$install_dir/passkey.pem" +chown "$app:$app" "$install_dir/passkey.pem" #================================================= # REGISTER SYNAPSE APP-SERVICE #================================================= +ynh_script_progression --message="Registering Synapse app-service" --weight=1 -$final_path/bin/matrix-appservice-irc -r \ - -c $final_path/config.yaml \ - -u "http://localhost:$port" \ - -f $final_path/appservice-registration-irc.yaml - -ynh_store_file_checksum --file=$final_path/appservice-registration-irc.yaml - -# This appservice needs it to be duplicated… -cp $final_path/appservice-registration-irc.yaml /etc/matrix-$synapse_instance/app-service/$app.yaml - -/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \ - || ynh_die "Synapse can't restart with the appservice configuration" +__ynh_register_matrix_app_service #================================================= # SETUP SYSTEMD @@ -166,17 +94,17 @@ ynh_add_systemd_config ynh_script_progression --message="Configuring log rotation..." --weight=1 # Use logrotate to manage application logfile(s) -ynh_use_logrotate --specific_user $app/$app +ynh_use_logrotate --logfile "/var/log/$app/$app.log" --nonappend --specific_user "$app/$app" chmod -R 600 "/var/log/$app" chmod 700 "/var/log/$app" -chown -R $app:$app /var/log/$app +chown -R "$app:$app" "/var/log/$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="$app daemon for bridging IRC and Matrix." --log="/var/log/$app/$app.log" +yunohost service add $app --description="$app daemon for bridging IRC and Matrix messages." --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE @@ -184,10 +112,10 @@ yunohost service add $app --description="$app daemon for bridging IRC and Matrix 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" --line_match="Error: No IRC servers specified." +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" --line_match="Error: No IRC servers specified." ynh_print_warn "The bridge is successfully configured but non working yet!" -ynh_print_warn "You need to edit the file $final_path/config.yaml to add IRC networks." +ynh_print_warn "You need to edit the file $install_dir/config.yaml to add IRC networks." #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index 7dd68fc..3f5340a 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,17 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) - #================================================= # STANDARD REMOVE #================================================= @@ -29,14 +18,14 @@ synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null then - ynh_script_progression --message="Removing $app service integration..." --time --weight=1 + ynh_script_progression --message="Removing $app service integration..." --weight=1 yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --time --weight=1 +ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 # Remove the dedicated systemd config ynh_remove_systemd_config @@ -44,34 +33,16 @@ ynh_remove_systemd_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Removing logrotate configuration..." --time --weight=1 +ynh_script_progression --message="Removing logrotate configuration..." --weight=1 # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE THE POSTGRESQL DATABASE -#================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." --time --weight=1 - -# Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$db_name --db_name=$db_name - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing app main directory..." --time --weight=1 - -# Remove the app directory securely -ynh_secure_remove --file="$final_path" - #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --time --weight=1 +ynh_script_progression --message="Removing dependencies..." --weight=1 -# Remove metapackage and its dependencies -ynh_remove_app_dependencies ynh_remove_nodejs #================================================= @@ -81,26 +52,15 @@ ynh_remove_nodejs #================================================= ynh_script_progression --message="Removing synapse app service..." --weight=6 +# Remove a directory securely ynh_secure_remove --file="/etc/matrix-$synapse_instance/app-service/$app.yaml" - -/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \ - || ynh_die "Synapse can't restart with the appservice configuration" +"/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh" || ynh_die --message="Synapse can't restart with the appservice configuration" # Remove the log files ynh_secure_remove --file="/var/log/$app" -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." --time --weight=1 - -# Delete a system user -ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --time --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 9df704e..c3bf14c 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,126 +10,76 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= +server_name=$(ynh_app_setting_get --app=$app --key=server_name) -ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 - -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" +synapse_db_name="matrix_$synapse_instance" +bot_synapse_db_user="@$botname:$server_name" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 +ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R 750 "$install_dir" +chown -R "$app:$app" "$install_dir" #================================================= # SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies - #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --time --weight=1 +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_name --db_name=$db_name --db_pwd=$db_pwd -ynh_psql_connect_as --user=$db_name --password=$db_pwd --database=$db_name < ./db.sql +ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" #================================================= -# RESTORE VARIOUS FILES +# REGISTER SYNAPSE APP-SERVICE #================================================= -ynh_script_progression --message="Restoring various files..." --time --weight=1 +ynh_script_progression --message="Registering Synapse app-service" --weight=1 -ynh_restore_file --origin_path="/etc/cron.d/$app" +__ynh_register_matrix_app_service -ynh_restore_file --origin_path="/etc/$app/" +chmod 400 "$install_dir/config.yaml" +chown "$app:$app" "$install_dir/config.yaml" #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1 +ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 ynh_restore_file --origin_path="/etc/systemd/system/$app.service" -systemctl enable $app.service --quiet +systemctl enable "$app.service" --quiet #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --time --weight=1 +ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 ynh_restore_file --origin_path="/etc/logrotate.d/$app" +mkdir --parents "/var/log/$app" +chmod -R 600 "/var/log/$app" +chmod 700 "/var/log/$app" +chown -R "$app:$app" "/var/log/$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --time --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="$app daemon for bridging IRC and Matrix messages." --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX AND PHP-FPM -#================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --time --weight=1 - -ynh_systemd_action --service_name=php$phpversion-fpm --action=reload -ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --time --last +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade index 19f9f70..be9c23f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,43 +9,12 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -server_name=$(ynh_app_setting_get --app=$app --key=server_name) -port=$(ynh_app_setting_get --app=$app --key=port) -botname=$(ynh_app_setting_get --app=$app --key=botname) -synapse_instance=$(ynh_app_setting_get --app=$app --key=synapse_instance) -botadmin=$(ynh_app_setting_get --app=$app --key=botadmin) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) - #================================================= # CHECK VERSION #================================================= upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -60,14 +29,6 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -77,21 +38,19 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$install_dir" fi -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:www-data "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R "$app:www-data" "$install_dir" #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 +ynh_script_progression --message="Installing NodeJS..." --weight=1 -ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$nodejs_version - ynh_use_nodejs #================================================= @@ -101,9 +60,10 @@ ynh_use_nodejs #================================================= ynh_script_progression --message="Upgrading the app..." --weight=1 -pushd "$final_path" >/dev/null || ynh_die - ynh_exec_as $app $ynh_node_load_PATH $ynh_npm i -popd >/dev/null || ynh_die +( + cd "$install_dir" + ynh_exec_as "$app" "$ynh_node_load_PATH" "$ynh_npm" i +) #================================================= # UPDATE A CONFIG FILE @@ -111,42 +71,31 @@ popd >/dev/null || ynh_die ynh_script_progression --message="Updating a configuration file..." --weight=1 configured_servers=$(python3 -c "import yaml -with open('$final_path/config.yaml') as c: c = yaml.load(c, Loader=yaml.SafeLoader) +with open('$install_dir/config.yaml') as c: c = yaml.load(c, Loader=yaml.SafeLoader) print(yaml.dump(c['ircService']['servers']))") ### Same as during install -ynh_add_config --template="../conf/config.yaml" --destination="$final_path/config.yaml" +ynh_add_config --template="../conf/config.yaml" --destination="$install_dir/config.yaml" # Try to recover the previously configured IRC servers. python3 -c "import yaml -with open('$final_path/config.yaml') as c: c = yaml.load(c, Loader=yaml.SafeLoader) +with open('$install_dir/config.yaml') as c: c = yaml.load(c, Loader=yaml.SafeLoader) servers = yaml.safe_load('''$configured_servers''') c['ircService']['servers'] = servers -print(yaml.dump(c))" > $final_path/config.yaml.temp -mv $final_path/config.yaml.temp $final_path/config.yaml +print(yaml.dump(c))" > $install_dir/config.yaml.temp +mv $install_dir/config.yaml.temp $install_dir/config.yaml -chmod 400 "$final_path/config.yaml" -chown $app:$app "$final_path/config.yaml" +chmod 400 "$install_dir/config.yaml" +chown $app:$app "$install_dir/config.yaml" #================================================= # REGISTER SYNAPSE APP-SERVICE #================================================= -ynh_backup_if_checksum_is_different --file=$final_path/appservice-registration-irc.yaml +ynh_backup_if_checksum_is_different --file=$install_dir/appservice-registration-irc.yaml -$final_path/bin/matrix-appservice-irc -r \ - -c $final_path/config.yaml \ - -u "http://localhost:$port" \ - -f $final_path/appservice-registration-irc.yaml - -ynh_store_file_checksum --file=$final_path/appservice-registration-irc.yaml - -# This appservice needs it to be duplicated… -cp $final_path/appservice-registration-irc.yaml /etc/matrix-$synapse_instance/app-service/$app.yaml - -/opt/yunohost/matrix-$synapse_instance/update_synapse_for_appservice.sh \ - || ynh_die "Synapse can't restart with the appservice configuration" +__ynh_register_matrix_app_service #================================================= # SETUP SYSTEMD @@ -171,7 +120,7 @@ ynh_use_logrotate --non-append --specific_user $app/$app #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" +yunohost service add $app --description="$app daemon for bridging IRC and Matrix messages." --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..60b04fd --- /dev/null +++ b/tests.toml @@ -0,0 +1,54 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + +test_format = 1.0 + +[default] + + # ------------ + # Tests to run + # ------------ + + # For special usecases, sometimes you need to setup other things on the machine + # prior to installing the app (such as installing another app) + # (Remove this key entirely if not needed) + preinstall = """ + sudo yunohost tools update apps + sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh \ + -a "domain=$domain&server_name=$server_name&is_free_registration=$is_free_registration&jitsi_server=$jitsi_server" --force + """ + + # ------------------------------- + # Default args to use for install + # ------------------------------- + + # By default, the CI will automagically fill the 'standard' args + # such as domain, path, admin, is_public and password with relevant values + # and also install args with a "default" provided in the manifest.. + # It should only make sense to declare custom args here for args with no default values + + args.botadmin = "@johndoe:server.name" + args.botusers = "server.name" + + # ------------------------------- + # Commits to test upgrade from + # ------------------------------- + + # test_upgrade_from.1d57a3b.name = "Upgrade from 0.7.2" # After config panel was implemented + # test_upgrade_from.ede12ed.name = "Upgrade from 0.8.0" + + +# # This is an additional test suite +# [multiple_botusers] + +# preinstall = """ +# sudo yunohost tools update apps +# sudo yunohost app install https://github.com/YunoHost-Apps/synapse_ynh \ +# -a "domain=$domain&server_name=$server_name&is_free_registration=$is_free_registration&jitsi_server=$jitsi_server" --force +# """ + +# # On additional tests suites, you can decide to run only specific tests + +# only = ["install.subdir"] + +# args.botadmin = "@johndoe:server.name" +# args.botusers = "@john:server.name,@jdoe:server.name,@janedoe:server.name"