[
  {
    "path": ".github/ISSUE_TEMPLATE.md",
    "content": "---\nname: Bug report\nabout: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.\n\n---\n\n**How to post a meaningful bug report**\n1. *Read this whole template first.*\n2. *Determine if you are on the right place:*\n   - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!*\n   - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*\n   - *When in doubt, post here and we will figure it out together.*\n3. *Delete the italic comments as you write over them below, and remove this guide.*\n--- \n\n### Describe the bug\n\n*A clear and concise description of what the bug is.*\n\n### Context\n\n- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*\n- YunoHost version: x.x.x\n- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*\n- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes*\n  - If yes, please explain:\n- Using, or trying to install package version/branch:\n- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*\n\n### Steps to reproduce\n\n- *If you performed a command from the CLI, the command itself is enough. For example:*\n    ```sh\n    sudo yunohost app install the_app\n    ```\n- *If you used the webadmin, please perform the equivalent command from the CLI first.*\n- *If the error occurs in your browser, explain what you did:*\n   1. *Go to '...'*\n   2. *Click on '...'*\n   3. *Scroll down to '...'*\n   4. *See error*\n\n### Expected behavior\n\n*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*\n\n### Logs\n\n*When an operation fails, YunoHost provides a simple way to share the logs.*\n- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*\n- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*\n\n*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*\n\n*If applicable and useful, add screenshots to help explain your problem.*\n"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "content": "## Problem\n\n- *Description of why you made this PR*\n\n## Solution\n\n- *And how do you fix that problem*\n\n## PR Status\n\n- [ ] Code finished and ready to be reviewed/tested\n- [ ] The fix/enhancement were manually tested (if applicable)\n\n## Automatic tests\n\nAutomatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting \"!testme\", \"!gogogadgetoci\" or \"By the power of systemd, I invoke The Great App CI to test this Pull Request!\". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization)\n"
  },
  {
    "path": ".gitignore",
    "content": "*~\n*.sw[op]\n.DS_Store\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU AFFERO GENERAL PUBLIC LICENSE\n                       Version 3, 19 November 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU Affero General Public License is a free, copyleft license for\nsoftware and other kinds of works, specifically designed to ensure\ncooperation with the community in the case of network server software.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nour General Public Licenses are intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  Developers that use our General Public Licenses protect your rights\nwith two steps: (1) assert copyright on the software, and (2) offer\nyou this License which gives you legal permission to copy, distribute\nand/or modify the software.\n\n  A secondary benefit of defending all users' freedom is that\nimprovements made in alternate versions of the program, if they\nreceive widespread use, become available for other developers to\nincorporate.  Many developers of free software are heartened and\nencouraged by the resulting cooperation.  However, in the case of\nsoftware used on network servers, this result may fail to come about.\nThe GNU General Public License permits making a modified version and\nletting the public access it on a server without ever releasing its\nsource code to the public.\n\n  The GNU Affero General Public License is designed specifically to\nensure that, in such cases, the modified source code becomes available\nto the community.  It requires the operator of a network server to\nprovide the source code of the modified version running there to the\nusers of that server.  Therefore, public use of a modified version, on\na publicly accessible server, gives the public access to the source\ncode of the modified version.\n\n  An older license, called the Affero General Public License and\npublished by Affero, was designed to accomplish similar goals.  This is\na different license, not a version of the Affero GPL, but Affero has\nreleased a new version of the Affero GPL which permits relicensing under\nthis license.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU Affero General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Remote Network Interaction; Use with the GNU General Public License.\n\n  Notwithstanding any other provision of this License, if you modify the\nProgram, your modified version must prominently offer all users\ninteracting with it remotely through a computer network (if your version\nsupports such interaction) an opportunity to receive the Corresponding\nSource of your version by providing access to the Corresponding Source\nfrom a network server at no charge, through some standard or customary\nmeans of facilitating copying of software.  This Corresponding Source\nshall include the Corresponding Source for any work covered by version 3\nof the GNU General Public License that is incorporated pursuant to the\nfollowing paragraph.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the work with which it is combined will remain governed by version\n3 of the GNU General Public License.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU Affero General Public License from time to time.  Such new versions\nwill be similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU Affero General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU Affero General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU Affero General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Affero General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Affero General Public License for more details.\n\n    You should have received a copy of the GNU Affero General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If your software can interact with users remotely through a computer\nnetwork, you should also make sure that it provides a way for users to\nget its source.  For example, if your program is a web application, its\ninterface could display a \"Source\" link that leads users to an archive\nof the code.  There are many ways you could offer source, and different\nsolutions will be better for different programs; see section 13 for the\nspecific requirements.\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU AGPL, see\n<http://www.gnu.org/licenses/>.\n"
  },
  {
    "path": "README.md",
    "content": "<!--\nN.B.: This README was automatically generated by <https://github.com/YunoHost/apps_tools/blob/main/readme_generator>\nIt shall NOT be edited by hand.\n-->\n\n<h1>\n  <img src=\"https://raw.githubusercontent.com/YunoHost/apps/main/logos/nextcloud.png\" width=\"32px\" alt=\"Logo of Nextcloud\">\n  Nextcloud, packaged for YunoHost\n</h1>\n\nOnline storage, file sharing platform and various other applications\n\n[![🌐 Official app website](https://img.shields.io/badge/Official_app_website-darkgreen?style=for-the-badge)](https://nextcloud.com)\n[![App Demo](https://img.shields.io/badge/App_Demo-blue?style=for-the-badge)](https://demo.nextcloud.com/)\n[![Version: 33.0.2~ynh1](https://img.shields.io/badge/Version-33.0.2~ynh1-rgb(18,138,11)?style=for-the-badge)](https://ci-apps.yunohost.org/ci/apps/nextcloud/)\n\n<div align=\"center\">\n<a href=\"https://apps.yunohost.org/app/nextcloud\"><img height=\"100px\" src=\"https://github.com/YunoHost/yunohost-artwork/raw/refs/heads/main/badges/neopossum-badges/badge_more_info_on_the_appstore.svg\"/></a>\n<a href=\"https://github.com/YunoHost-Apps/nextcloud_ynh/issues\"><img height=\"100px\" src=\"https://github.com/YunoHost/yunohost-artwork/raw/refs/heads/main/badges/neopossum-badges/badge_report_an_issue.svg\"/></a>\n</div>\n\n\n## Screenshots\n![Screenshot of Nextcloud](./doc/screenshots/screenshot.png)\n\n## 📦 Developer info\n\n[![Automatic tests level](https://apps.yunohost.org/badge/cilevel/nextcloud)](https://ci-apps.yunohost.org/ci/apps/nextcloud/)\n\n🛠️ Upstream Nextcloud repository: <https://github.com/nextcloud/server>\n\nPull request are welcome and should target the [`testing` branch](https://github.com/YunoHost-Apps/nextcloud_ynh/tree/testing).\n\nThe `testing` branch can be tested using:\n```\n# fresh install:\nsudo yunohost app install https://github.com/YunoHost-Apps/nextcloud_ynh/tree/testing\n\n# upgrade an existing install:\nsudo yunohost app upgrade nextcloud -u https://github.com/YunoHost-Apps/nextcloud_ynh/tree/testing\n```\n\n### 📚 App packaging documentation\n\nPlease see <https://doc.yunohost.org/packaging_apps> for more information."
  },
  {
    "path": "conf/config.json",
    "content": "{\n  \"system\": {\n    \"trashbin_retention_obligation\": \"auto, 30\",\n    \"versions_retention_obligation\": \"auto, 30\",\n    \"updatechecker\": false,\n    \"memcache.local\": \"\\\\OC\\\\Memcache\\\\APCu\",\n    \"integrity.check.disabled\": true,\n    \"filelocking.enabled\": true,\n    \"lost_password_link\": \"disabled\",\n    \"memcache.locking\": \"\\\\OC\\\\Memcache\\\\Redis\",\n    \"redis\": {\n      \"host\": \"localhost\",\n      \"port\": \"6379\",\n      \"timeout\": \"0.0\",\n      \"password\": \"\"\n     },\n    \"hashing_default_password\": true,\n    \"localstorage.allowsymlinks\": true,\n    \"simpleSignUpLink.shown\": false,\n    \"default_phone_region\": \"\",\n    \"maintenance_window_start\": 1,\n    \"mail_smtpmode\": \"smtp\",\n    \"mail_smtpport\": \"25\",\n    \"mail_smtpauth\": 1,\n    \"mail_smtpname\": \"__APP__\",\n    \"mail_smtppassword\": \"__MAIL_PWD__\",\n    \"mail_sendmailmode\": \"smtp\",\n    \"mail_from_address\": \"__APP__\",\n    \"mail_domain\": \"__DOMAIN__\",\n    \"mail_smtphost\": \"localhost\",\n    \"mail_smtpstreamoptions\": {\n      \"ssl\": {\n        \"allow_self_signed\": true,\n        \"verify_peer\": false,\n        \"verify_peer_name\": false\n      }\n    },\n    \"trusted_proxies\": [ \"127.0.0.1\", \"::1\" ]\n  },\n  \"apps\": {\n    \"user_ldap\": {\n      \"__LDAP_CONFIG_PREFIX__ldap_base\": \"dc=yunohost,dc=org\",\n      \"__LDAP_CONFIG_PREFIX__ldap_base_groups\": \"ou=groups,dc=yunohost,dc=org\",\n      \"__LDAP_CONFIG_PREFIX__ldap_base_users\": \"ou=users,dc=yunohost,dc=org\",\n      \"__LDAP_CONFIG_PREFIX__ldap_cache_ttl\": \"600\",\n      \"__LDAP_CONFIG_PREFIX__ldap_configuration_active\": \"1\",\n      \"__LDAP_CONFIG_PREFIX__ldap_display_name\": \"displayname\",\n      \"__LDAP_CONFIG_PREFIX__ldap_email_attr\": \"__LDAP_EMAIL_ATTR__\",\n      \"__LDAP_CONFIG_PREFIX__ldap_expert_username_attr\": \"uid\",\n      \"__LDAP_CONFIG_PREFIX__ldap_group_display_name\": \"cn\",\n      \"__LDAP_CONFIG_PREFIX__ldap_group_filter\": \"(&(objectclass=top)(memberUid=*))\",\n      \"__LDAP_CONFIG_PREFIX__ldap_group_filter_mode\": \"0\",\n      \"__LDAP_CONFIG_PREFIX__ldap_groupfilter_objectclass\": \"posixGroup\",\n      \"__LDAP_CONFIG_PREFIX__ldap_group_member_assoc_attribute\": \"memberUid\",\n      \"__LDAP_CONFIG_PREFIX__ldap_host\": \"localhost\",\n      \"__LDAP_CONFIG_PREFIX__ldap_login_filter\": \"(&(|(objectclass=posixAccount))(|(uid=%uid)(mail=%uid))(permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org))\",\n      \"__LDAP_CONFIG_PREFIX__ldap_login_filter_mode\": \"0\",\n      \"__LDAP_CONFIG_PREFIX__ldap_port\": \"389\",\n      \"__LDAP_CONFIG_PREFIX__ldap_quota_attr\": \"userquota\",\n      \"__LDAP_CONFIG_PREFIX__ldap_tls\": \"0\",\n      \"__LDAP_CONFIG_PREFIX__ldap_user_display_name\": \"cn\",\n      \"__LDAP_CONFIG_PREFIX__ldap_user_filter_mode\": \"0\",\n      \"__LDAP_CONFIG_PREFIX__ldap_userfilter_objectclass\": \"posixAccount\",\n      \"__LDAP_CONFIG_PREFIX__ldap_userlist_filter\": \"objectclass=posixAccount\"\n    }\n  }\n}\n"
  },
  {
    "path": "conf/config_install.json",
    "content": "{\n  \"system\": {\n    \"datadirectory\": \"__DATA_DIR__/data/\",\n    \"trusted_domains\": [\n      \"localhost\",\n      \"__DOMAIN__\"\n    ]\n  }\n}\n"
  },
  {
    "path": "conf/extra_php-fpm.conf",
    "content": "\n; Additional php.ini defines, specific to this pool of workers.\nenv[PATH] = $PATH\nenv[LANG] = $LANG\nenv[LC_ALL] = $LANG\nphp_value[default_charset] = UTF-8\n; OPcache is already activated by default\n; php_value[opcache.enable]=1\n; The following parameters are nevertheless recommended for Nextcloud\n; see here: https://docs.nextcloud.com/server/20/admin_manual/installation/server_tuning.html#enable-php-opcache\nphp_value[opcache.enable_cli]=1\nphp_value[opcache.interned_strings_buffer]=32\nphp_value[opcache.max_accelerated_files]=10000\nphp_value[opcache.memory_consumption]=128\nphp_value[opcache.save_comments]=1\nphp_value[opcache.revalidate_freq]=60\n; https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/big_file_upload_configuration.html#configuring-php\nphp_value[output_buffering]=0\n; https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/caching_configuration.html#id1\nphp_value[apc.enabled]=1\nphp_value[apc.enable_cli]=1\n"
  },
  {
    "path": "conf/f2b_filter.conf",
    "content": "[INCLUDES]\nbefore = common.conf\n[Definition]\n_groupsre = (?:(?:,?\\s*\"\\w+\":(?:\"[^\"]+\"|\\w+))*)\nfailregex = ^\\{%(_groupsre)s,?\\s*\"remoteAddr\":\"<HOST>\"%(_groupsre)s,?\\s*\"message\":\"Login failed:\n            ^\\{%(_groupsre)s,?\\s*\"remoteAddr\":\"<HOST>\"%(_groupsre)s,?\\s*\"message\":\"Two-factor challenge failed:\n            ^\\{%(_groupsre)s,?\\s*\"remoteAddr\":\"<HOST>\"%(_groupsre)s,?\\s*\"message\":\"Trusted domain error.\ndatepattern = ,?\\s*\"time\"\\s*:\\s*\"%%Y-%%m-%%d[T ]%%H:%%M:%%S(%%z)?\"\n"
  },
  {
    "path": "conf/f2b_jail.conf",
    "content": "[__APP__]\nenabled = true\nport = http,https\nfilter = __APP__\nlogpath = /var/log/__APP__/nextcloud.log\nmaxretry = 5\n"
  },
  {
    "path": "conf/nextcloud.cron",
    "content": "*/5  *  *  *  * __APP__ /usr/bin/php__PHP_VERSION__ --define apc.enable_cli=1 -f __INSTALL_DIR__/cron.php\n"
  },
  {
    "path": "conf/nginx.conf",
    "content": "# Set .mjs MIME types\n# Either include it in the default mime.types list\n# or include you can include that list explicitly and add the file extension\n# and include that list explicitly or add the file extension\n# only for Nextcloud like below:\ninclude mime.types;\ntypes {\n    text/javascript mjs;\n    application/wasm wasm;\n}\n\nlocation ^~ /.well-known {\n  # The following 6 rules are borrowed from `.htaccess`\n\n  # The following 2 rules are only needed for the user_webfinger app.\n  # Uncomment it if you're planning to use this app.\n  #rewrite ^/\\.well-known/host-meta\\.json  __PATH__/public.php?service=host-meta-json  last;\n  #rewrite ^/\\.well-known/host-meta        __PATH__/public.php?service=host-meta       last;\n\n  location = /.well-known/carddav     { return 301 __PATH__/remote.php/dav/; }\n  location = /.well-known/caldav      { return 301 __PATH__/remote.php/dav/; }\n\n  location = /.well-known/webfinger     { return 301 __PATH__/index.php$request_uri; }\n  location = /.well-known/nodeinfo      { return 301 __PATH__/index.php$request_uri; }\n\n  # Let Nextcloud's API for `/.well-known` URIs handle all other\n  # requests by passing them to the front-end controller.\n  return 301 __PATH__/index.php$request_uri;\n}\n\n#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;\nlocation ^~ __PATH__/ {\n\n  # Path to source\n  alias __INSTALL_DIR__/;\n\n  # set max upload size and increase upload timeout:\n  client_max_body_size 10G;\n  client_body_timeout 300s;\n  fastcgi_buffers 64 4K;\n\n  # Enable gzip but do not remove ETag headers\n  gzip on;\n  gzip_vary on;\n  gzip_comp_level 4;\n  gzip_min_length 256;\n  gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;\n  gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;\n\n  # Pagespeed is not supported by Nextcloud, so if your server is built\n  # with the `ngx_pagespeed` module, uncomment this line to disable it.\n  #pagespeed off;\n\n  # The settings allows you to optimize the HTTP2 bandwitdth.\n  # See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/\n  # for tunning hints\n  client_body_buffer_size 512k;\n\n  # HSTS settings\n  # WARNING: Only add the preload option once you read about\n  # the consequences in https://hstspreload.org/. This option\n  # will add the domain to a hardcoded list that is shipped\n  # in all major browsers and getting removed from this list\n  # could take several months.\n  #more_set_headers \"Strict-Transport-Security: max-age=15768000; includeSubDomains; preload;\";\n  \n  # HTTP response headers borrowed from Nextcloud `.htaccess`\n  more_set_headers \"Referrer-Policy: no-referrer\";\n  more_set_headers \"X-Content-Type-Options: nosniff\";\n  more_set_headers \"X-Frame-Options: SAMEORIGIN\";\n  more_set_headers \"X-Permitted-Cross-Domain-Policies: none\";\n  more_set_headers \"X-Robots-Tag: noindex, nofollow\";\n\n  # Remove X-Powered-By, which is an information leak\n  fastcgi_hide_header X-Powered-By;\n\n  # Specify how to handle directories -- specifying `/nextcloud/index.php$request_uri`\n  # here as the fallback means that Nginx always exhibits the desired behaviour\n  # when a client requests a path that corresponds to a directory that exists\n  # on the server. In particular, if that directory contains an index.php file,\n  # that file is correctly served; if it doesn't, then the request is passed to\n  # the front-end controller. This consistent behaviour means that we don't need\n  # to specify custom rules for certain paths (e.g. images and other assets,\n  # `/updater`, `/ocs-provider`), and thus\n  # `try_files $uri $uri/ /nextcloud/index.php$request_uri`\n  # always provides the desired behaviour.\n  index index.php index.html __PATH__/index.php$request_uri;\n\n  # Rule borrowed from `.htaccess` to handle Microsoft DAV clients\n  location = __PATH__/ {\n      if ( $http_user_agent ~ ^DavClnt ) {\n          return 302 __PATH__/remote.php/webdav/$is_args$args;\n      }\n  }\n\n  location = __PATH__/robots.txt {\n    allow all;\n    log_not_found off;\n    access_log off;\n  }\n  \n  # Rules borrowed from `.htaccess` to hide certain paths from clients\n  location ~ ^__PATH__/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/)    { return 404; }\n  location ~ ^__PATH__/(?:\\.|autotest|occ|issue|indie|db_|console)                  { return 404; }\n\n  # Ensure this block, which passes PHP files to the PHP process, is above the blocks\n  # which handle static assets (as seen below). If this block is not declared first,\n  # then Nginx will encounter an infinite rewriting loop when it prepends\n  # `/nextcloud/index.php` to the URI, resulting in a HTTP 500 error response.\n  location ~ \\.php(?:$|/) {\n    # Required for legacy support\n    rewrite ^__PATH__/(?!index|remote|public|cron|core\\/ajax\\/update|status|ocs\\/v[12]|updater\\/.+|ocs-provider\\/.+|.+\\/richdocumentscode(_arm64)?\\/proxy) __PATH__/index.php$request_uri;\n    set $path_info $fastcgi_path_info;\n    \n    try_files $fastcgi_script_name =404;\n    fastcgi_param modHeadersAvailable true;         # Avoid sending the security headers twice\n    fastcgi_param front_controller_active true;     # Enable pretty urls\n    fastcgi_param HTTP_ACCEPT_ENCODING \"\";          # Disable encoding of Nextcloud response to inject ynh scripts\n    fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock;\n    include fastcgi_params_with_auth;\n    \n    fastcgi_intercept_errors on;\n    fastcgi_request_buffering on; # Required as PHP-FPM does not support chunked transfer encoding and requires a valid ContentLength header.\n\n    fastcgi_read_timeout 600;\n    fastcgi_send_timeout 600;\n    fastcgi_connect_timeout 600;\n    proxy_connect_timeout 600;\n    proxy_send_timeout 600;\n    proxy_read_timeout 600;\n    send_timeout 600;\n  }\n\n  location ~ ^__PATH__/(?:updater|ocs-provider)(?:$|/) {\n       try_files $uri/ =404;\n       index index.php;\n  }\n\n  # Serve static files\n  location ~ \\.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac|mp4|webm)$ {\n    try_files $uri / __PATH__/index.php$request_uri;\n    # Adapted from https://github.com/nextcloud/documentation/blob/master/admin_manual/installation/nginx-root.conf.sample\n    # HTTP response headers borrowed from Nextcloud `.htaccess`\n    more_set_headers \"Cache-Control: public, max-age=15778463, immutable\";\n    more_set_headers \"Referrer-Policy: no-referrer\";\n    more_set_headers \"X-Content-Type-Options: nosniff\";\n    more_set_headers \"X-Frame-Options: SAMEORIGIN\";\n    more_set_headers \"X-Permitted-Cross-Domain-Policies: none\";\n    more_set_headers \"X-Robots-Tag: noindex, nofollow\";\n    access_log off;   # Optional: Don't log access to assets\n  }\n\n  location ~ \\.(otf|woff2?)$ {\n    try_files $uri / __PATH__/index.php$request_uri;\n    expires 7d;         # Cache-Control policy borrowed from `.htaccess`\n    access_log off;     # Optional: Don't log access to assets\n  }\n\n  # Rule borrowed from `.htaccess`\n  location __PATH__/remote {\n    return 301 __PATH__/remote.php$request_uri;\n  }\n\n  location ~ ^__PATH__/ {\n    if ($request_method ~ ^(PUT|DELETE|PATCH|PROPFIND|PROPPATCH)$) {\n        rewrite ^ __PATH__/index.php$request_uri last;\n    }\n    try_files $uri / __PATH__/index.php$request_uri;\n  }\n\n  include conf.d/__DOMAIN__.d/__APP__.d/*.conf;\n}\n"
  },
  {
    "path": "conf/notify_push.conf",
    "content": "location ^~ __PATH__/push/ {\n   proxy_pass http://127.0.0.1:__PORT__/;\n   include    proxy_params_no_auth;\n}"
  },
  {
    "path": "conf/systemd.service",
    "content": "[Unit]\nDescription=Push daemon for Nextcloud clients\nAfter=network.target nginx.service\nDocumentation = https://github.com/nextcloud/notify_push\n\n[Service]\nType=notify\nUser=__APP__\nGroup=__APP__\nEnvironment=PORT=__PORT__\nEnvironment=ALLOW_SELF_SIGNED=true\nRuntimeDirectory=__APP__\nExecStart=__INSTALL_DIR__/apps/notify_push/bin/__ARCH__/notify_push __INSTALL_DIR__/config/config.php\nRestart=always\nRestartSec=60\n\n# Sandboxing options to harden security\n# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html\nNoNewPrivileges=yes\nPrivateTmp=yes\nPrivateDevices=yes\nRestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK\nRestrictNamespaces=yes\nRestrictRealtime=yes\nDevicePolicy=closed\nProtectClock=yes\nProtectHostname=yes\nProtectProc=invisible\nProtectSystem=full\nProtectControlGroups=yes\nProtectKernelModules=yes\nProtectKernelTunables=yes\nLockPersonality=yes\nSystemCallArchitectures=native\nSystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap @cpu-emulation @privileged\n\n# Denying access to capabilities that should not be relevant for webapps\n# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html\nCapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD\nCapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE\nCapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT\nCapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK\nCapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM\nCapabilityBoundingSet=~CAP_SYS_TTY_CONFIG\nCapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE\nCapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW\nCapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG\n\n[Install]\nWantedBy = multi-user.target"
  },
  {
    "path": "conf/watcher.path",
    "content": "[Unit]\nDescription=Restart Push daemon for Nextcloud clients when it receives updates\nDocumentation=https://github.com/nextcloud/notify_push\nPartOf=__APP__-notify-push-watcher.service\n\n[Path]\nPathModified=/var/www/nextcloud/apps/notify_push/bin/__ARCH__/notify_push\nUnit=__APP__-notify-push-watcher.service\n\n[Install]\nWantedBy=multi-user.target"
  },
  {
    "path": "conf/watcher.service",
    "content": "[Unit]\nDescription=Restart Push daemon for Nextcloud clients when it receives updates\nDocumentation=https://github.com/nextcloud/notify_push\n#Requires=__APP__-notify-push.service\nAfter=__APP__-notify-push.service\nStartLimitIntervalSec=10\nStartLimitBurst=5\n\n[Service]\nType=oneshot\nExecStartPre=/usr/bin/chmod u+x __INSTALL_DIR__/apps/notify_push/bin/__ARCH__/notify_push\nExecStart=/usr/bin/systemctl restart __APP__-notify-push.service\n\n[Install]\nWantedBy=multi-user.target"
  },
  {
    "path": "config_panel.toml",
    "content": "version = \"1.0\"\n\n[main]\nname.en = \"Nextcloud configuration\"\nname.fr = \"Configuration de Nextcloud\"\n\n    [main.maintenance]\n    name = \"Maintenance\"\n\n        [main.maintenance.maintenance_mode]\n        ask.en = \"Enable maintenance mode\"\n        ask.fr = \"Activer le mode maintenance\"\n        type = \"boolean\"\n        default = false\n\n    [main.permissions]\n    name.en = \"Permissions\"\n    name.fr = \"Autorisations\"\n\n        [main.permissions.set_permissions_button]\n        ask.en = \"Reset permissions\"\n        ask.fr = \"Redéfinir les autorisations\"\n        type = \"button\"\n        style = \"success\"\n        help.en = \"This action sets permissions for all data. Beware, this action can take up to several hours if users have a lot of data.\"\n        help.fr = \"Cette action définit les autorisations pour toutes les données. Attention, cette action peut prendre jusqu'à plusieurs heures si les utilisateurs ont beaucoup de données.\"\n\n    [main.addressbook]\n    name.en = \"Address book configuration\"\n    name.fr = \"Configuration du carnet d'adresses\"\n\n        [main.addressbook.system_addressbook_exposed]\n        ask.en = \"Enable address book\"\n        ask.fr = \"Activer le carnet d’adresses\"\n        type = \"boolean\"\n        help.en = \"Should there be a system address book listing all users, accessible by all users?\"\n        help.fr = \"Devrait-il y avoir un carnet d’adresses système répertoriant tous les utilisateurs, accessible par tous les utilisateurs ?\"\n\n    [main.notify_push]\n    name.en = \"Notify Push configuration\"\n    name.fr = \"Configuration Notification Push\"\n\n        [main.notify_push.enable_notify_push]\n        ask.en = \"Enable Notify Push\"\n        ask.fr = \"Activer la Notification Push\"\n        type = \"boolean\"\n        help.en = \"<a href=https://github.com/nextcloud/notify_push#about target=_blank>Notify Push</a> is a mechanism  allowing more instantaneous notifications and reduce server load.\"\n        help.fr = \"<a href=https://github.com/nextcloud/notify_push#about target=_blank>Notify Push</a> est un mécanisme qui permet d'avoir des notifications plus rapides et de réduire la charge du serveur.\"\n\n    [main.forward_email]\n    name.en = \"Forward Email?\"\n    name.fr = \"E-mails de transfert?\"\n\n        [main.forward_email.enable_forward_email]\n        ask.en = \"Set YunoHost user's forward email instead of YunoHost user's main email?\"\n        ask.fr = \"Utiliser les e-mails de transfert des utilisateurs de YunoHost plutôt que les e-mails principaux ?\"\n        type = \"boolean\"\n        help.en = \"If all your users have set a forward email and aren't using YunoHost emails, you may choose to set their forward email as their Nextcloud email setting.\"\n        help.fr = \"Si tous vos utilisateurs ont paramétré un e-mail de transfert et n'utilise pas du tout les e-mails de leur compte YunoHost, vous pouvez paramétrer Nextcloud d'utiliser les e-mails de transfert.\"\n"
  },
  {
    "path": "doc/ADMIN.md",
    "content": "### Manually running Nextcloud commands\n\nYou can run Nextcloud commands from the command line by opening a Nextcloud \"shell\" and running `php occ` directly:\n\n```bash\nsudo yunohost app shell __APP__\n# You should then see you're in a shell with \"__APP__@yourmachine\"\nphp occ ...\n```\nAlternatively, you can run `sudo -u __APP__ php__PHP_VERSION__ --define apc.enable_cli=1 __INSTALL_DIR__/occ ...`\n\n### Promoting a user to admin\n\nIn some cases, your user may not be a Nextcloud admin and therefore cannot access the admin panels from Nextcloud.\n\nThis user can be added to the Nextcloud admin group with : \n\n```bash\nsudo yunohost app shell __APP__\n# And then\nphp occ group:adduser admin <username>\n```\n"
  },
  {
    "path": "doc/ADMIN_fr.md",
    "content": "### Exécuter manuellement des commandes Nextcloud\n\nVous pouvez lancer des commandes Nextcloud en ouvrant un \"shell\" Nextcloud et utiliser `php occ` directement:\n\n```bash\nsudo yunohost app shell __APP__\n# Vous devriez voir que vous êtes dans un shell \"__APP__@yourmachine\"\nphp occ ...\n```\n\nAutrement, vous pouvez exécuter `sudo -u __APP__ php__PHP_VERSION__ --define apc.enable_cli=1 __INSTALL_DIR__/occ ...`\n\n### Ajouter un compte aux admins de Nextcloud\n\nDans certains cas, votre compte n'est peut-être pas un admin de Nextcloud et ne peut donc pas accéder aux fonctionnalités admin.\n\nVous pouvez ajouter le comptes aux admins de Nextcloud avec:\n\n```bash\nsudo yunohost app shell __APP__\n# Puis\nphp occ group:adduser admin <username>\n```\n"
  },
  {
    "path": "doc/DESCRIPTION.md",
    "content": "Nextcloud lets you access and synchronize data, files, contacts and calendars between different devices (PCs or mobiles), or share them with other people (with or without accounts), and also offers advanced communication and collaborative working features. Nextcloud features its own application mechanism (see also [Nextcloud's app store](https://apps.nextcloud.com/)) for specific functionalities. \n\nIn the context of YunoHost, Nextcloud integrates with the SSO/User Portal (YunoHost accounts are automatically connected to Nextcloud).\n\nThe `/.well-known` address will be automatically configured for CalDAV and CardDAV synchronization if no other service such as Baïkal is already using it.\n\nThe YunoHost catalog has two collaborative office suites, [OnlyOffice](https://github.com/YunoHost-Apps/onlyoffice_ynh) and [Collabora](https://github.com/YunoHost-Apps/collabora_ynh), which can be integrated with Nextcloud."
  },
  {
    "path": "doc/DESCRIPTION_fr.md",
    "content": "Nextcloud permet de rendre accessible et de synchroniser ses données, fichiers, contacts, agendas entre différents appareils (ordinateurs ou mobiles), ou de les partager avec d'autres personnes (avec ou sans comptes), et propose également des fonctionnalités avancées de communication et de travail collaboratif. Nextcloud dispose de son propre mécanisme d'applications (voir aussi [le store d'apps de Nextcloud](https://apps.nextcloud.com/)) pour disposer des fonctionnalités spécifiques.\n\nDans le cadre de YunoHost, Nextcloud s'intègre avec le SSO/portail utilisateur (les comptes YunoHost sont automatiquements connectés à Nextcloud).\n\nL'adresse `/.well-known` sera automatiquement configuré pour la synchronisation CalDAV et CardDAV si aucun autre service tel que Baïkal ne l'utilise déjà.\n\nLe catalogue YunoHost dispose de deux suites bureautiques collaboratives, [OnlyOffice](https://github.com/YunoHost-Apps/onlyoffice_ynh) et [Collabora](https://github.com/YunoHost-Apps/collabora_ynh), qui peuvent être intégrées à Nextcloud.\n"
  },
  {
    "path": "doc/POST_UPGRADE.md",
    "content": "Note that if you've installed any third-party Nextcloud applications, they have probably been disabled. If so, you'll need to manually enable them again.\n"
  },
  {
    "path": "doc/POST_UPGRADE_fr.md",
    "content": "Notez que si vous avez installé des applications Nextcloud tierces, elles sont probablement désactivées et vous devrez les réactiver manuellement."
  },
  {
    "path": "doc/PRE_UPGRADE.d/MAJOR_RELEASE.md",
    "content": "If you are upgrading to a **new major version** of Nextcloud (e.g. 32, 33), **please make sure that your Nextcloud apps are up to date** from Nextcloud's administration panel beforehand.\n\nAdditionally, if you installed **specific Nextcloud apps**, we recommend **making sure that they are compatible with the new major version**.\nYunoHost will attempt to check this automatically at the very beginning of the upgrade, but a manual check doesn't hurt either. See https://apps.nextcloud.com/apps/<app_name>  \n\n\n* **Incompatible apps will cause the upgrade to fail.**\n* Also make sure the **sury repo signing key** is up to date (run `sudo apt update` and check the output. If needed, this thread may help to renew this key : <https://forum.yunohost.org/t/yarn-and-sury-apt-keys-issues/41617>\n"
  },
  {
    "path": "hooks/post_user_create",
    "content": "#!/bin/bash\n\nuser=\"$1\"\napp=\"$(basename $0 | cut -d- -f 2-)\" # Extract the app name from the script name, which is supposed to be something like \"50-app_id\"\n\nsetfacl --recursive --modify g:$app:rwX,d:g:$app:rwX /home/$user\n"
  },
  {
    "path": "hooks/post_user_delete",
    "content": "#!/bin/bash\n\nsource /usr/share/yunohost/helpers\n\nuser=\"$1\"\napp=\"$(basename $0 | cut -d- -f 2-)\" # Extract the app name from the script name, which is supposed to be something like \"50-app_id\"\ninstall_dir=$(ynh_app_setting_get --app=$app --key=install_dir)\nphp_version=$(ynh_app_setting_get --app=$app --key=php_version)\n\n# Define a function to execute commands with `occ`\nexec_occ() {\n  (cd \"$install_dir\" && sudo -u $app \\\n      php${php_version} --define apc.enable_cli=1 occ --no-interaction --no-ansi \"$@\")\n}\n\nexec_occ user:delete $user\n"
  },
  {
    "path": "manifest.toml",
    "content": "packaging_format = 2\n\nid = \"nextcloud\"\nname = \"Nextcloud\"\ndescription.en = \"Online storage, file sharing platform and various other applications\"\ndescription.fr = \"Stockage en ligne, plateforme de partage de fichiers et diverses autres applications\"\n\nversion = \"33.0.2~ynh1\"\n\nmaintainers = [\"kay0u\"]\n\n[upstream]\nlicense = \"AGPL-3.0\"\nwebsite = \"https://nextcloud.com\"\ndemo = \"https://demo.nextcloud.com/\"\nadmindoc = \"https://docs.nextcloud.com/server/stable/admin_manual/\"\nuserdoc = \"https://docs.nextcloud.com/server/latest/user_manual/en/\"\ncode = \"https://github.com/nextcloud/server\"\ncpe = \"cpe:2.3:a:nextcloud:nextcloud\"\n\n[integration]\nyunohost = \">= 12.1.38\"\nhelpers_version = \"2.1\"\narchitectures = [\"amd64\", \"arm64\", \"armhf\"]\nmulti_instance = true\n\nldap = true\nsso = true\n\ndisk = \"650M\"\nram.build = \"250M\"\nram.runtime = \"512M\"\n\n[install]\n    [install.domain]\n    type = \"domain\"\n\n    [install.path]\n    type = \"path\"\n    default = \"/nextcloud\"\n\n    [install.admin]\n    type = \"user\"\n\n    [install.init_main_permission]\n    help.en = \"You must activate 'Visitors' if you want to connect Nextcloud Desktop client to Nextcloud server. This can be changed later via the webadmin.\"\n    help.fr = \"Vous devez activer 'Visiteurs' si vous souhaitez connecter le client Nextcloud Desktop au serveur Nextcloud. Cela peut être modifié ultérieurement via l'administrateur Web.\"\n    type = \"group\"\n    default = \"visitors\"\n\n    [install.user_home]\n    ask.en = \"Add the users' home directory in Nextcloud?\"\n    ask.fr = \"Ajouter le dossier personnel des utilisateurs à Nextcloud ?\"\n    help.en = \"If enabled, each `/home/$user` directory will be added to their respective user's Nextcloud.\"\n    help.fr = \"Si activé, le dossier `/home/$user` de chaque compte lui sera ajouté dans Nextcloud.\"\n    type = \"boolean\"\n    default = false\n\n[resources]\n\n    [resources.sources]\n\n        [resources.sources.main]\n        url = 'https://download.nextcloud.com/server/releases/nextcloud-33.0.2.tar.bz2'\n        sha256 = '91257ab5002d5d09da8d09d80389983330351c5c00a7e3a25b177bcea81171cc'\n\n        [resources.sources.32]\n        url = 'https://download.nextcloud.com/server/releases/nextcloud-32.0.7.tar.bz2'\n        sha256 = '450b4f2b26c83be4d7b8682229a7d868e2802fd54ae8f3ee6367618995637a76'\n        prefetch = false\n        \n        [resources.sources.31]\n        url = 'https://download.nextcloud.com/server/releases/nextcloud-31.0.13.tar.bz2'\n        sha256 = '92df08369467e81c23d7fd997afb756eae44ce47eff0c85c5d4d27212ebe283e'\n        prefetch = false\n\n        [resources.sources.30]\n        url = 'https://download.nextcloud.com/server/releases/nextcloud-30.0.15.tar.bz2'\n        sha256 = 'f33552d3185e97ad1a5fe57a49fe2b55a361dc8e4f925fb12b592047d1f0e6a5'\n        prefetch = false\n\n        [resources.sources.29]\n        url = 'https://download.nextcloud.com/server/releases/nextcloud-29.0.16.tar.bz2'\n        sha256 = '499bf61ab19edcd4e542af86609243c5b4f440eb5bb06c2ba7da0c2faa525322'\n        prefetch = false\n\n        [resources.sources.28]\n        url = 'https://download.nextcloud.com/server/releases/nextcloud-28.0.14.tar.bz2'\n        sha256 = '4a937f1882486426c9703e59ec4b293f621be8d080b7f85016f629903c3af336'\n        prefetch = false\n\n        [resources.sources.27]\n        url = 'https://download.nextcloud.com/server/releases/nextcloud-27.1.11.tar.bz2'\n        sha256 = '4edd2570f4c83442f8f0f0616fb774ed2663b11cf9f6ea49e795ab43aeef9645'\n        prefetch = false\n\n        [resources.sources.26]\n        url = 'https://download.nextcloud.com/server/releases/nextcloud-26.0.13.tar.bz2'\n        sha256 = '0a362df7a1233348f99d1853fd7e79f0667b552c145dc45012fab54ac31c79ae'\n        prefetch = false\n\n        [resources.sources.25]\n        url = 'https://download.nextcloud.com/server/releases/nextcloud-25.0.13.tar.bz2'\n        sha256 = '387bac148a696244f1ec02698a082d408283a875b3de85eb9719dd4493eebe33'\n        prefetch = false\n\n        [resources.sources.24]\n        url = 'https://download.nextcloud.com/server/releases/nextcloud-24.0.12.tar.bz2'\n        sha256 = '2f093bdf7d34faf38d22f38a5e11f3aee32746ff4add3df17c790b9b36390836'\n        prefetch = false\n\n        [resources.sources.23]\n        url = 'https://download.nextcloud.com/server/releases/nextcloud-23.0.12.tar.bz2'\n        sha256 = 'ad3637fd987e9f1ed5bd5dbd177bdce1e39228e3daf95bc4a3c590d4b1522b1e'\n        prefetch = false\n\n    [resources.system_user]\n    allow_email = true\n\n    [resources.install_dir]\n    group = \"www-data:r-x\"\n\n    [resources.data_dir]\n    subdirs = [\"data\"]\n\n    [resources.permissions]\n    main.url = \"/\"\n\n    api.url = \"re:__DOMAIN__\\\\/.well-known\\\\/.*\"\n    api.auth_header = false\n    api.show_tile = false\n    api.protected= true\n    api.allowed = [\"visitors\", \"all_users\"]\n\n    [resources.ports]\n\n    [resources.apt]\n    packages = [\n        \"imagemagick\",\n        \"acl\",\n        \"tar\",\n        \"smbclient\",\n        \"at\",\n        \"mariadb-server\",\n        \"redis-server\",\n        \"php8.4-apcu\",\n        \"php8.4-bcmath\",\n        \"php8.4-bz2\",\n        \"php8.4-curl\",\n        \"php8.4-fpm\",\n        \"php8.4-gd\",\n        \"php8.4-gmp\",\n        \"php8.4-igbinary\",\n        \"php8.4-imagick\",\n        \"php8.4-imap\",\n        \"php8.4-intl\",\n        \"php8.4-ldap\",\n        \"php8.4-mbstring\",\n        \"php8.4-mysql\",\n        \"php8.4-redis\",\n        \"php8.4-sqlite3\",\n        \"php8.4-xml\",\n        \"php8.4-zip\",\n        \"php8.4-smbclient\",\n    ]\n\n    packages_from_raw_bash = \"\"\"\n        case $YNH_DEBIAN_VERSION in\n            bullseye)   echo libmagickcore-6.q16-6-extra ;;\n            bookworm)   echo libmagickcore-6.q16-6-extra ;;\n            trixie)     echo libmagickcore-7.q16-10-extra ;;\n        esac\n    \"\"\"\n\n    [resources.database]\n    type = \"mysql\"\n"
  },
  {
    "path": "patches/30/00-add-logout_url-conf.patch",
    "content": "diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php\nindex d4d6a17db79..f587f805683 100644\n--- a/core/Controller/LoginController.php\n+++ b/core/Controller/LoginController.php\n@@ -75,15 +75,21 @@ class LoginController extends Controller {\n \t#[FrontpageRoute(verb: 'GET', url: '/logout')]\n \tpublic function logout() {\n \t\t$loginToken = $this->request->getCookie('nc_token');\n+\t\t$uuidUser = $this->userSession->getUser()->getUID();\n+\t\t$isLdapUser = $this->config->getUserValue($uuidUser, 'user_ldap', 'uid');\n \t\tif (!is_null($loginToken)) {\n-\t\t\t$this->config->deleteUserValue($this->userSession->getUser()->getUID(), 'login_token', $loginToken);\n+\t\t\t$this->config->deleteUserValue($uuidUser, 'login_token', $loginToken);\n \t\t}\n \t\t$this->userSession->logout();\n \n-\t\t$response = new RedirectResponse($this->urlGenerator->linkToRouteAbsolute(\n+\t\t$redirectUrl = $this->urlGenerator->linkToRouteAbsolute(\n \t\t\t'core.login.showLoginForm',\n-\t\t\t['clear' => true] // this param the code in login.js may be removed when the \"Clear-Site-Data\" is working in the browsers\n-\t\t));\n+\t\t\t['clear' => true] // this param the code in login.js may be removed when the \"Clear-Site-Data\" is working in the browsers)\n+\t\t);\n+\t\tif (!is_null($isLdapUser)) {\n+\t\t\t$redirectUrl = $this->config->getSystemValue('logout_url', $redirectUrl);\n+\t\t}\n+\t\t$response = new RedirectResponse($redirectUrl);\n \n \t\t$this->session->set('clearingExecutionContexts', '1');\n \t\t$this->session->close();\n"
  },
  {
    "path": "patches/main/00-add-logout_url-conf.patch",
    "content": "diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php\nindex 1a105130..9a51f8d9 100644\n--- a/core/Controller/LoginController.php\n+++ b/core/Controller/LoginController.php\n@@ -80,15 +80,22 @@ class LoginController extends Controller {\n \tpublic function logout() {\n \t\t$loginToken = $this->request->getCookie('nc_token');\n \t\t$uid = $this->userSession->getUser()?->getUID();\n+\t\t$isLdapUser = $this->config->getUserValue($uid, 'user_ldap', 'uid');\n \t\tif ($loginToken !== null && $uid !== null) {\n \t\t\t$this->config->deleteUserValue($uid, 'login_token', $loginToken);\n \t\t}\n \t\t$this->userSession->logout();\n \n-\t\t$response = new RedirectResponse($this->urlGenerator->linkToRouteAbsolute(\n+\t\t$redirectUrl = $this->urlGenerator->linkToRouteAbsolute(\n \t\t\t'core.login.showLoginForm',\n \t\t\t['clear' => true] // this param the code in login.js may be removed when the \"Clear-Site-Data\" is working in the browsers\n-\t\t));\n+\t\t);\n+\n+\t\tif (!is_null($isLdapUser)) {\n+\t\t\t$redirectUrl = $this->config->getSystemValue('logout_url', $redirectUrl);\n+\t\t}\n+\n+\t\t$response = new RedirectResponse($redirectUrl);\n \n \t\t$this->session->set('clearingExecutionContexts', '1');\n \t\t$this->session->close();\n\n"
  },
  {
    "path": "scripts/_common.sh",
    "content": "#!/bin/bash\n\n#=================================================\n# COMMON VARIABLES AND CUSTOM HELPERS\n#=================================================\n\n# Define a function to execute commands with `occ`\nexec_occ() {\n  (cd \"$install_dir\" && ynh_exec_as_app \\\n      php${php_version} --define apc.enable_cli=1 occ --no-interaction --no-ansi \"$@\")\n}\n\nwait_nginx_reload() {\n    # NGINX may take some time to support the new configuration,\n    # wait for the Nextcloud configuration file to disappear from NGINX before checking the CalDAV/CardDAV URL.\n    timeout=30\n    for i in $(seq 1 $timeout); do\n        if ! ynh_hide_warnings nginx -T | grep --quiet \"# configuration file /etc/nginx/conf.d/$domain.d/$app.conf:\"; then\n            break\n        fi\n        sleep 1\n    done\n    # Wait untils NGINX has fully reloaded (avoid cURL fail with http2)\n\n    sleep 2\n}\n\n# Check if an URL is already handled\n# usage: is_url_handled --domain=DOMAIN --path=PATH_URI\nis_url_handled() {\n    # Declare an array to define the options of this helper.\n    local legacy_args=dp\n    declare -Ar args_array=( [d]=domain= [p]=path= )\n    local domain\n    local path\n    # Manage arguments with getopts\n    ynh_handle_getopts_args \"$@\"\n\n    # Try to get the URL with cURL, and keep the http code and an eventual redirection URL.\n    local curl_output=\"$(curl --insecure --silent --output /dev/null \\\n      --write-out '%{http_code};%{redirect_url}' https://127.0.0.1$path --header \"Host: $domain\" --resolve $domain:443:127.0.0.1)\"\n\n    # Cut the output and keep only the first part to keep the http code\n    local http_code=\"${curl_output%%;*}\"\n    # Do the same thing but keep the second part, the redirection URL\n    local redirection=\"${curl_output#*;}\"\n\n    # Return 1 if the URL isn't handled.\n    # Which means either cURL got a 404 (or the admin) or the SSO.\n    # A handled URL should redirect to a publicly accessible URL.\n    # Return 1 if the URL has returned 404\n    if [ \"$http_code\" = \"404\" ] || [[ $redirection =~ \"/yunohost/admin\" ]]; then\n        return 1\n    # Return 1 if the URL is redirected to the SSO\n    elif [[ $redirection =~ \"/yunohost/sso\" ]]; then\n        return 1\n    fi\n}\n"
  },
  {
    "path": "scripts/backup",
    "content": "#!/bin/bash\n\nsource ../settings/scripts/_common.sh\nsource /usr/share/yunohost/helpers\n\nynh_print_info \"Declaring files to be backed up...\"\n\n#=================================================\n# BACKUP THE APP MAIN DIR\n#=================================================\n\nynh_backup \"$install_dir\"\n\n#=================================================\n# BACKUP THE DATA DIRECTORY\n#=================================================\n\nynh_backup \"$data_dir\"\n\n#=================================================\n# BACKUP THE NGINX CONFIGURATION\n#=================================================\n\nynh_backup \"/etc/php/$php_version/fpm/pool.d/$app.conf\"\n\nynh_backup \"/etc/nginx/conf.d/$domain.d/$app.conf\"\nynh_backup \"/etc/nginx/conf.d/$domain.d/$app.d\"\n\nynh_backup \"/etc/logrotate.d/$app\"\n\nynh_backup \"/etc/fail2ban/jail.d/$app.conf\"\nynh_backup \"/etc/fail2ban/filter.d/$app.conf\"\n\n#=================================================\n# BACKUP VARIOUS FILES\n#=================================================\n\nynh_backup \"/etc/cron.d/$app\"\n\nynh_backup \"/var/log/$app\"\n\n#=================================================\n# BACKUP THE MYSQL DATABASE\n#=================================================\nynh_print_info \"Backing up the MySQL database...\"\n\nynh_mysql_dump_db > db.sql\n\n#=================================================\n# BACKUP THE NOTIFY_PUSH APP\n#=================================================\n\nif [ $enable_notify_push -eq 1 ]\nthen\n    ynh_backup \"/etc/systemd/system/${app}-notify-push.service\"\n    ynh_backup \"/etc/systemd/system/${app}-notify-push-watcher.service\"\n    ynh_backup \"/etc/systemd/system/${app}-notify-push-watcher.path\"\nfi\n\n#=================================================\n# END OF SCRIPT\n#=================================================\n\nynh_print_info \"Backup script completed for $app. (YunoHost will then actually copy those files to the archive).\"\n"
  },
  {
    "path": "scripts/change_url",
    "content": "#!/bin/bash\n\nsource _common.sh\nsource /usr/share/yunohost/helpers\n\n#=================================================\n# MODIFY URL IN NGINX CONF\n#=================================================\nynh_script_progression \"Updating NGINX web server configuration...\"\n\nif [ $change_domain -eq 1 ]\nthen\n    # Check if .well-known is available for this domain\n    if is_url_handled --domain=\"$new_domain\" --path=\"/.well-known/caldav\" || is_url_handled --domain=\"$new_domain\" --path=\"/.well-known/carddav\"\n    then\n        ynh_print_warn \"Another app already uses the domain $new_domain to serve a CalDAV/CardDAV feature. You may encounter issues when dealing with your calendar or address book.\"\n\n        # Remove lines about .well-known/carddav and caldav with sed.\n        sed --in-place --regexp-extended '/location = \\/\\.well\\-known\\/(caldav|carddav)/d' \"/etc/nginx/conf.d/$domain.d/$app.conf\"\n        ynh_store_file_checksum \"/etc/nginx/conf.d/$domain.d/$app.conf\"\n    fi\nfi\n\nynh_config_change_url_nginx\n\n#=================================================\n# SPECIFIC MODIFICATIONS\n#=================================================\nynh_script_progression \"Applying $app specific modifications...\"\n\nif [ $change_domain -eq 1 ]\nthen\n    # Change the trusted domain\n    exec_occ config:system:set trusted_domains 1 --value=$new_domain\n\n    # Change hostname for activity notifications\n    exec_occ config:system:set overwrite.cli.url --value=\"https://${new_domain}${new_path}\"\n\n    # Reload PHP-FPM, necessary for force Nextcloud to re-read config.php, cf opcache.revalidate_freq\n    ynh_systemctl --service=php${php_version}-fpm --action=reload\n\n    mv /etc/nginx/conf.d/$old_domain.d/$app.d /etc/nginx/conf.d/$new_domain.d/$app.d\nfi\n\n#=================================================\n# CONFIGURE NOTIFY_PUSH APP\n#=================================================\n\nif [ $enable_notify_push -eq 1 ]\nthen\n    ynh_config_add --template=\"notify_push.conf\" --destination=\"/etc/nginx/conf.d/$new_domain.d/$app.d/notify_push.conf\"\n\n    ynh_systemctl --service=nginx --action=reload\n\n    case $YNH_ARCH in\n        amd64) arch=\"x86_64\";;\n        arm64) arch=\"aarch64\";;\n        armel|armhf) arch=\"armv7\";;\n    esac\n\n    ynh_config_add --template=\"watcher.path\" --destination=\"/etc/systemd/system/${app}-notify-push-watcher.path\"\n    ynh_config_add_systemd --service=\"${app}-notify-push-watcher\" --template=\"watcher.service\"\n    systemctl enable --now ${app}-notify-push-watcher.path\n    ynh_config_add_systemd --service=\"${app}-notify-push\"\n\n    count=0\n    while ! exec_occ $install_dir/cron.php && [[ $count -lt 30 ]]\n    do\n        sleep 1\n        count=$((count + 1))\n    done\n\n    ynh_systemctl --service=\"${app}-notify-push\" --action=restart --log_path=\"systemd\" --wait_until=\"Push daemon for Nextcloud clients.\"\n\n    exec_occ config:app:set notify_push base_endpoint --value=https://$new_domain${new_path%/}/push\n\n    if ! exec_occ notify_push:self-test; then\n        ynh_print_warn \"The High Performance Backend service is still not working properly. Please log in with a user to your NextCloud instance, restart the High Performance Backend service with \\\"systemctl restart ${app}-notify-push.service\\\", and run \\\"sudo -u $app php${php_version} $install_dir/occ notify_push:self-test\\\" to verify that everything is green.\"\n    fi\nfi\n\n#=================================================\n# RELOAD NGINX\n#=================================================\nynh_script_progression \"Reloading NGINX web server...\"\n\n# Temporary fix for the API permission (workaround for https://github.com/YunoHost/issues/issues/2294 )\nynh_permission_url --permission=\"api\" --url=\"re:$new_domain\\/.well-known\\/.*\" --auth_header=\"false\" --clear_urls\n\nynh_systemctl --service=nginx --action=reload\n\n#=================================================\n# END OF SCRIPT\n#=================================================\n\nynh_script_progression \"Change of URL completed for $app\"\n"
  },
  {
    "path": "scripts/config",
    "content": "#!/bin/bash\n\nsource _common.sh\nsource /usr/share/yunohost/helpers\n\n#=================================================\n# RETRIEVE ARGUMENTS\n#=================================================\n\nphp_version=$(ynh_app_setting_get --key=php_version)\n\n#=================================================\n# SPECIFIC GETTERS FOR TOML SHORT KEY\n#=================================================\n\nget__maintenance_mode() {\n    # Maintenance mode status\n    maintenance_mode_status=\"$(cd \"$install_dir\" && exec_occ maintenance:mode 2> /dev/null)\"\n    if echo $maintenance_mode_status | grep -q \"disabled\"\n    then\n        echo \"0\"\n    elif echo $maintenance_mode_status | grep -q \"enabled\"\n    then\n        echo \"1\"\n    else\n        ynh_print_warn \"Unexpected output from maintenance status check command.\"\n        exit 0\n    fi\n}\n\nget__system_addressbook_exposed() {\n\techo $(exec_occ config:app:get dav system_addressbook_exposed)\n}\n\nget__enable_forward_email() {\n    ldapEmail=$(exec_occ config:app:get user_ldap \"${ldap_config_prefix:-}\"ldap_email_attr)\n    if [ \"$ldapEmail\" = \"maildrop\" ]\n    then\n        echo \"1\"\n    else\n        echo \"0\"\n    fi\n}\n\n#=================================================\n# SPECIFIC SETTERS FOR TOML SHORT KEYS\n#=================================================\n\nset__maintenance_mode() {\n    if [ $maintenance_mode -eq 0 ]; then\n        # If maintenance_mode was set to 0, disable maintenance mode\n        exec_occ maintenance:mode --off\n        ynh_print_info \"Maintenance mode disabled\"\n    elif [ $maintenance_mode -eq 1 ]; then\n        # If maintenance_mode was set to 1, enable maintenance mode\n        exec_occ maintenance:mode --on\n        ynh_print_info \"Maintenance mode enabled\"\n    fi\n    ynh_app_setting_set --key=maintenance_mode --value=\"$maintenance_mode\"\n}\n\nset__system_addressbook_exposed() {\n\texec_occ config:app:set dav system_addressbook_exposed --value=\"$system_addressbook_exposed\"\n\tynh_print_info \"System addressbook is exposed: $system_addressbook_exposed\"\n}\n\nset__enable_notify_push() {\n    if [ $enable_notify_push -eq 0 ]; then\n        nginx_extra_conf_dir=\"/etc/nginx/conf.d/$domain.d/$app.d\"\n        ynh_safe_rm \"$nginx_extra_conf_dir/notify_push.conf\"\n        ynh_systemctl --service=\"nginx\" --action=reload\n\n        # If notify_push is enabled, disable it\n        if exec_occ app:list | awk '/Enabled/{f=1;next} f' | grep -q -w notify_push; then\n            exec_occ app:disable notify_push\n        fi\n\n        ynh_config_remove_systemd \"${app}-notify-push\"\n        systemctl disable --now \"${app}-notify-push-watcher.path\"\n        ynh_safe_rm \"/etc/systemd/system/${app}-notify-push-watcher.path\"\n        ynh_config_remove_systemd \"${app}-notify-push-watcher\"\n\n        ynh_print_info \"Notify push disabled\"\n    elif [ $enable_notify_push -eq 1 ]; then\n        nginx_extra_conf_dir=\"/etc/nginx/conf.d/$domain.d/$app.d\"\n        mkdir -p \"$nginx_extra_conf_dir\"\n\n        ynh_config_add --template=\"notify_push.conf\" --destination=\"$nginx_extra_conf_dir/notify_push.conf\"\n\n        ynh_systemctl --service=\"nginx\" --action=reload\n\n        # If notify_push is disabled, reenable it\n        if exec_occ app:list | awk '/Disabled/{f=1;next} f' | grep -q -w notify_push; then\n            exec_occ app:enable notify_push\n        # If notify_push is not installed, install it\n        elif ! exec_occ app:list | awk '/Enabled/{f=1;next} /Disabled/{f=0} f' | grep -q -w notify_push; then\n            exec_occ app:install notify_push\n        fi\n        exec_occ config:app:set notify_push base_endpoint --value=https://$domain${path_url%/}/push\n\n        mkdir -p /var/run/$app/\n        chown $app: /var/run/$app/\n\n        case $YNH_ARCH in\n            amd64) arch=\"x86_64\";;\n            arm64) arch=\"aarch64\";;\n            armel|armhf) arch=\"armv7\";;\n        esac\n\n        ynh_config_add --template=\"watcher.path\" --destination=\"/etc/systemd/system/${app}-notify-push-watcher.path\"\n        ynh_config_add_systemd --service=\"${app}-notify-push-watcher\" --template=\"watcher.service\"\n        systemctl enable --now ${app}-notify-push-watcher.path\n        ynh_config_add_systemd --service=\"${app}-notify-push\"\n\n        count=0\n\n        while ! exec_occ $install_dir/cron.php && [[ $count -lt 30 ]]\n        do\n            sleep 1\n            count=$((count + 1))\n        done\n\n        ynh_systemctl --service=\"${app}-notify-push-watcher\" --action=restart\n        ynh_systemctl --service=\"${app}-notify-push\" --action=restart --log_path=\"systemd\" --wait_until=\"Push daemon for Nextcloud clients.\"\n\n        if ! exec_occ notify_push:self-test; then\n            ynh_print_warn \"The High Performance Backend service is still not working properly. Please log in with a user to your NextCloud instance, restart the High Performance Backend service with \\\"systemctl restart ${app}-notify-push.service\\\", and run \\\"sudo -u $app php${php_version} $install_dir/occ notify_push:self-test\\\" to verify that everything is green.\"\n        fi\n        ynh_print_info \"Notify push enabled\"\n    fi\n    ynh_app_setting_set --key=enable_notify_push --value=\"$enable_notify_push\"\n}\n\nset__enable_forward_email() {\n\n    if [ $enable_forward_email -eq 0 ]; then\n        exec_occ ldap:set-config \"${ldap_config_prefix:-}\" ldapEmailAttribute \"mail\"\n    elif [ $enable_forward_email -eq 1 ]; then\n        exec_occ ldap:set-config \"${ldap_config_prefix:-}\" ldapEmailAttribute \"maildrop\"\n    fi\n}\n\n#=================================================\n# SPECIFIC RUNNERS FOR TOML SHORT KEYS\n#=================================================\n\nfunction run__set_permissions_button() {\n    local data_dir=$(ynh_app_setting_get --key=data_dir)\n    ynh_print_info \"Set permissions, it may take some time...\"\n    chown -R $app:www-data \"$install_dir\"\n    chown -R $app: \"$data_dir\"\n    find $install_dir/ -type f -print0 | xargs -r0 chmod 0644\n    find $install_dir/ -type d -print0 | xargs -r0 chmod 0755\n    find $data_dir/data/ -type f -print0 | xargs -r0 chmod 0640\n    find $data_dir/data/ -type d -print0 | xargs -r0 chmod 0750\n    chmod 640 \"$install_dir/config/config.php\"\n    chmod 755 /home/yunohost.app\n    chmod 750 $install_dir\n}\n\n#=================================================\n\nynh_app_config_apply() {\n    _ynh_app_config_apply\n\n    ynh_config_add_phpfpm\n}\n\nynh_app_config_run $1\n"
  },
  {
    "path": "scripts/install",
    "content": "#!/bin/bash\n\nsource _common.sh\nsource /usr/share/yunohost/helpers\n\n#=================================================\n# INITIALIZE AND STORE SETTINGS\n#=================================================\n\nynh_app_setting_set_default --key=php_upload_max_filesize --value=10G\nynh_app_setting_set_default --key=php_memory_limit --value=512M\n\nynh_app_setting_set_default --key=enable_notify_push --value=0\n\nphpflags=\"--define apc.enable_cli=1\"\nynh_app_setting_set --key=phpflags --value=\"$phpflags\"\n\nldap_email_attr=\"mail\"\n\n#=================================================\n# CREATE A MYSQL DATABASE\n#=================================================\nynh_script_progression \"Migrate MySQL database to utf8...\"\n\nynh_mysql_db_shell <<< \"ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;\"\n\n#=================================================\n# DOWNLOAD, CHECK AND UNPACK SOURCE\n#=================================================\nynh_script_progression \"Setting up source files...\"\n\n# Download, check integrity, uncompress and patch the source from app.src\nynh_setup_source --dest_dir=\"$install_dir\"\n\n#=================================================\n# PHP-FPM CONFIGURATION\n#=================================================\nynh_script_progression \"Configuring PHP-FPM...\"\n\nynh_config_add_phpfpm\n\n#=================================================\n# NGINX CONFIGURATION\n#=================================================\nynh_script_progression \"Configuring NGINX web server...\"\n\n# Check if .well-known is available for this domain\nif is_url_handled --domain=\"$domain\" --path=\"/.well-known/caldav\" || is_url_handled --domain=\"$domain\" --path=\"/.well-known/carddav\"\nthen\n    ynh_print_warn \"Another app already uses the domain $domain to serve a CalDAV/CardDAV feature. You may encounter issues when dealing with your calendar or address book.\"\n\n    # Remove lines about .well-known/carddav and caldav with sed.\n    sed --in-place --regexp-extended '/location = \\/\\.well\\-known\\/(caldav|carddav)/d' \"../conf/nginx.conf\"\nfi\n\nnginx_extra_conf_dir=\"/etc/nginx/conf.d/$domain.d/$app.d\"\nmkdir -p \"$nginx_extra_conf_dir\"\n\nif [ $enable_notify_push -eq 1 ]\nthen\n    ynh_config_add --template=\"notify_push.conf\" --destination=\"$nginx_extra_conf_dir/notify_push.conf\"\nfi\n\nynh_config_add_nginx\n\n#=================================================\n# INSTALL NEXTCLOUD\n#=================================================\nynh_script_progression \"Installing $app...\"\n\n# Set write access for the following commands\nchown -R $app:www-data \"$install_dir\"\nchown -R $app: \"$data_dir\"\n\n# Define password in an intermediate var\n# The fact that it's called _password allows it to be\n# picked up by YunoHost's auto-redact mecanism\nadmin_password=\"$(ynh_string_random --length=6)\"\n\n# Install Nextcloud using a temporary admin user\nexec_occ maintenance:install \\\n    --database \"mysql\" --database-name $db_name \\\n    --database-user $db_user --database-pass \"$db_pwd\" \\\n    --admin-user \"admin\" --admin-pass \"$admin_password\" \\\n    --data-dir \"$data_dir/data\" \\\n    || ynh_die \"Unable to install $app\"\n\n#=================================================\n# CONFIGURE NEXTCLOUD\n#=================================================\nynh_script_progression \"Configuring $app...\"\n\n# Set the mysql.utf8mb4 config to true in config.php\nexec_occ config:system:set mysql.utf8mb4 --type=boolean --value=\"true\"\n\n# move the logs from the data_dir to the standard /var/log\nexec_occ config:system:set logfile --value=\"/var/log/$app/nextcloud.log\"\n\n# Ensure that UpdateNotification app is disabled\nexec_occ app:disable updatenotification\n\n# Enable LDAP plugin\nexec_occ app:enable user_ldap\nldap_config_prefix=$(exec_occ ldap:create-empty-config --only-print-prefix)\nynh_app_setting_set --key=ldap_config_prefix --value=\"$ldap_config_prefix\"\n\n# Load the installation config file in Nextcloud\nynh_config_add --template=\"config_install.json\" --destination=\"$install_dir/config_install.json\"\n\nexec_occ config:import \"$install_dir/config_install.json\"\n\n# Then remove the config file\nynh_safe_rm \"$install_dir/config_install.json\"\n\n# Load the additional config file (used also for upgrade)\nynh_config_add --template=\"config.json\" --destination=\"$install_dir/config.json\"\n\nexec_occ config:import \"$install_dir/config.json\"\n\n# Then remove the config file\nynh_safe_rm \"$install_dir/config.json\"\n\n#=================================================\n# CHECK THE LDAP CONFIG\n#=================================================\n\n# Check LDAP configuration to see if everything worked well\nexec_occ ldap:test-config \"$ldap_config_prefix\" || ynh_die \"An error occured during LDAP configuration\"\n\n#=================================================\n# MOUNT HOME FOLDERS AS EXTERNAL STORAGE\n#=================================================\n\n# Define a function to add an external storage\n# Create the external storage for the given folders and enable sharing\ncreate_external_storage() {\n  local mount_dir=\"$1\"\n  local mount_name=\"$2\"\n  local mount_id=`exec_occ files_external:create --output=json \\\n      \"$mount_name\" 'local' 'null::null' -c \"datadir=$mount_dir\" || true`\n  ! [[ $mount_id =~ ^[0-9]+$ ]] \\\n      && ynh_print_warn \"Unable to create external storage\" \\\n      || exec_occ files_external:option \"$mount_id\" enable_sharing true\n}\n\n# Enable External Storage and create local mount to home folder\nif [ $user_home -eq 1 ]\nthen\n    exec_occ app:enable files_external\n    create_external_storage \"/home/\\$user\" \"Home\"\n    # Iterate over users to extend their home folder permissions\n    for u in $(ynh_user_list); do\n        setfacl --recursive --modify g:$app:rwX,d:g:$app:rwX \"/home/$u\" || true\n    done\nfi\n\n#=================================================\n# ALLOW USERS TO DISCONNECT FROM NEXTCLOUD\n#=================================================\n\n# Add dynamic logout URL to the config\nurl_base64=\"$(echo -n \"https://$domain$path\" | base64)\"\nexec_occ config:system:get logout_url >/dev/null 2>&1 \\\n  || echo \"\n//-YunoHost-\n// set logout_url according to main domain\n\\$main_domain = exec('cat /etc/yunohost/current_host');\n\\$CONFIG['logout_url'] = 'https://'.\\$main_domain.'/yunohost/sso/?action=logout&r=${url_base64}';\n//-YunoHost-\n\" >> \"$install_dir/config/config.php\"\n\n#=================================================\n# CHANGE HOSTNAME FOR ACTIVITY NOTIFICATIONS\n#=================================================\n\nexec_occ config:system:set overwrite.cli.url --value=\"https://${domain}${path}\"\n\n#=================================================\n# REMOVE THE TEMPORARY ADMIN AND SET THE TRUE ONE\n#=================================================\n\n# Set the user as admin\nynh_mysql_db_shell <<< \"INSERT INTO oc_group_user VALUES ('admin','$admin');\"\n\n# And delete admin user\nexec_occ user:delete admin\n\n#=================================================\n# ENABLE OR DISABLE SYSTEM ADDRESS BOOK\n#=================================================\n\n# Disabled by default on install, can be enabled in config panel\nexec_occ config:app:set dav system_addressbook_exposed --value=\"0\"\n\n#=================================================\n# STORE THE CHECKSUM OF THE CONFIG FILE\n#=================================================\n\n# Calculate and store the config file checksum into the app settings\nynh_store_file_checksum \"$install_dir/config/config.php\"\n\n#=================================================\n# CONFIGURE NOTIFY_PUSH APP\n#=================================================\n\nif [ $enable_notify_push -eq 1 ]\nthen\n    exec_occ app:install notify_push\n    exec_occ config:app:set notify_push base_endpoint --value=https://$domain${path_url%/}/push\n\n    mkdir -p /var/run/$app/\n    chown $app: /var/run/$app/\n\n    case $YNH_ARCH in\n        amd64) arch=\"x86_64\";;\n        arm64) arch=\"aarch64\";;\n        armel|armhf) arch=\"armv7\";;\n    esac\n\n    ynh_config_add --template=\"watcher.path\" --destination=\"/etc/systemd/system/${app}-notify-push-watcher.path\"\n    ynh_config_add_systemd --service=\"${app}-notify-push-watcher\" --template=\"watcher.service\"\n    systemctl enable --now --quiet ${app}-notify-push-watcher.path\n    ynh_config_add_systemd --service=\"${app}-notify-push\"\nfi\n\n#=================================================\n# ADD A CRON JOB\n#=================================================\n\nynh_config_add --template=\"nextcloud.cron\" --destination=\"/etc/cron.d/$app\"\nchown root: \"/etc/cron.d/$app\"\nchmod 644 \"/etc/cron.d/$app\"\n\nexec_occ background:cron\n\n#=================================================\n# POST-INSTALL MAINTENANCE\n#=================================================\n\nexec_occ db:add-missing-indices\nexec_occ db:add-missing-columns\nexec_occ db:convert-filecache-bigint -n\n\n#=================================================\n# YUNOHOST MULTIMEDIA INTEGRATION\n#=================================================\nynh_script_progression \"Adding multimedia directories...\"\n\n# Build YunoHost multimedia directories\nynh_multimedia_build_main_dir\n\n# Mount the user directory in Nextcloud\nexec_occ app:enable files_external\ncreate_external_storage \"/home/yunohost.multimedia/\\$user\" \"Multimedia\"\ncreate_external_storage \"/home/yunohost.multimedia/share\" \"Shared multimedia\"\n\n# Allow nextcloud to write into these directories\nynh_multimedia_addaccess $app\n\n#=================================================\n# SECURE FILES AND DIRECTORIES\n#=================================================\n\n# Fix app ownerships & permissions\nchown -R $app:www-data \"$install_dir\"\nchown -R $app: \"$data_dir\"\nfind $install_dir/ -type f -print0 | xargs -r0 chmod 0644\nfind $install_dir/ -type d -print0 | xargs -r0 chmod 0755\nfind $data_dir/data/ -type f -print0 | xargs -r0 chmod 0640\nfind $data_dir/data/ -type d -print0 | xargs -r0 chmod 0750\nchmod 600 \"$install_dir/config/config.php\"\nchmod 755 /home/yunohost.app\nchmod 750 $install_dir\n\n#=================================================\n# SETUP LOGROTATE\n#=================================================\nynh_script_progression \"Configuring log rotation...\"\n\nynh_config_add_logrotate\n\n#=================================================\n# SETUP FAIL2BAN\n#=================================================\nynh_script_progression \"Configuring Fail2Ban...\"\n\n# Create a dedicated Fail2Ban config\nynh_config_add_fail2ban --logpath=\"/var/log/$app/nextcloud.log\"\n\n#=================================================\n# CHECK IF NOTIFY_PUSH WORKS\n#=================================================\n\nif [ $enable_notify_push -eq 1 ]\nthen\n    count=0\n    while ! exec_occ $install_dir/cron.php && [[ $count -lt 30 ]]\n    do\n        sleep 1\n        count=$((count + 1))\n    done\n\n    ynh_systemctl --service=\"${app}-notify-push-watcher\" --action=restart\n    ynh_systemctl --service=\"${app}-notify-push\" --action=restart --log_path=\"systemd\" --wait_until=\"Push daemon for Nextcloud clients.\"\n\n    if ! exec_occ notify_push:self-test; then\n        ynh_print_warn \"The Notify Push service is still not working properly. Please log in with a user to your NextCloud instance, restart the Notify Push service with \\\"systemctl restart ${app}-notify-push.service\\\", and run \\\"ynh_exec_as_app php${php_version} $install_dir/occ notify_push:self-test\\\" to verify that everything is green.\"\n    fi\nfi\n\n#=================================================\n# END OF SCRIPT\n#=================================================\n\nynh_script_progression \"Installation of $app completed\"\n"
  },
  {
    "path": "scripts/remove",
    "content": "#!/bin/bash\n\nsource _common.sh\nsource /usr/share/yunohost/helpers\n\n#=================================================\n# REMOVE SYSTEM CONFIGURATIONS\n#=================================================\nynh_script_progression \"Removing system configurations related to $app...\"\n\nynh_config_remove_fail2ban\n\nynh_config_remove_logrotate\n\nynh_config_remove_nginx\nynh_safe_rm \"/etc/nginx/conf.d/$domain.d/$app.d\"\n\nynh_config_remove_phpfpm\n\n# Remove notify push\nif [ $enable_notify_push -eq 1 ]; then\n  ynh_config_remove_systemd \"${app}-notify-push\"\n  systemctl disable --now --quiet ${app}-notify-push-watcher.path\n  ynh_safe_rm \"/etc/systemd/system/${app}-notify-push-watcher.path\"\n  ynh_config_remove_systemd \"${app}-notify-push-watcher\"\nfi\n\n# Remove a cron file\n# TODO: Ensure that cron job is not running (How !?)\nynh_safe_rm \"/etc/cron.d/$app\"\n\n# Cleaning ACL in home directories\nfor path in /home/*; do\n  # Clean ACL in every directories in /home, except those which start with 'yunohost.'\n  [[ ! $path == /home/yunohost.* ]] \\\n    && setfacl --recursive --remove g:$app,d:g:$app -- \"$path\" 2>&1\ndone\n\n#=================================================\n# END OF SCRIPT\n#=================================================\n\nynh_script_progression \"Removal of $app completed\"\n"
  },
  {
    "path": "scripts/restore",
    "content": "#!/bin/bash\n\nsource ../settings/scripts/_common.sh\nsource /usr/share/yunohost/helpers\n\n#=================================================\n# RESTORE THE APP MAIN DIR\n#=================================================\nynh_script_progression \"Restoring the app main directory...\"\n\nynh_restore \"$install_dir\"\n\n#=================================================\n# RESTORE THE DATA DIRECTORY\n#=================================================\nynh_script_progression \"Restoring data directory...\"\n\nynh_restore \"$data_dir\"\n\n#=================================================\n# RESTORE THE MYSQL DATABASE\n#=================================================\nynh_script_progression \"Restoring the MySQL database...\"\n\nynh_mysql_db_shell < ./db.sql\n\n#=================================================\n# RESTORE SYSTEM CONFIGURATIONS\n#=================================================\nynh_script_progression \"Restoring system configurations related to $app...\"\n\nynh_restore \"/etc/php/$php_version/fpm/pool.d/$app.conf\"\n\nynh_config_add_phpfpm\n\nynh_restore \"/etc/nginx/conf.d/$domain.d/$app.conf\"\nynh_restore \"/etc/nginx/conf.d/$domain.d/$app.d\"\n\n# Check if .well-known is available for this domain\nif is_url_handled --domain=\"$domain\" --path=\"/.well-known/caldav\" || is_url_handled --domain=\"$domain\" --path=\"/.well-known/carddav\"\nthen\n    ynh_print_warn \"Another app already uses the domain $domain to serve a CalDAV/CardDAV feature. You may encounter issues when dealing with your calendar or address book.\"\n\n    # Remove lines about .well-known/CardDAV and CalDAV with sed.\n    sed --in-place --regexp-extended '/location = \\/\\.well\\-known\\/(caldav|carddav)/d' \"/etc/nginx/conf.d/$domain.d/$app.conf\"\nfi\n\n#=================================================\n# RESTORE VARIOUS FILES\n#=================================================\n\nynh_restore \"/etc/cron.d/$app\"\n\nynh_restore \"/var/log/$app\"\n\nynh_restore \"/etc/logrotate.d/$app\"\n\n#=================================================\n# RESTORE USER RIGHTS\n#=================================================\n\n# Fix app ownerships & permissions\nchown -R $app:www-data \"$install_dir\"\nchown -R $app: \"$data_dir\"\nfind $install_dir/ -type f -print0 | xargs -r0 chmod 0644\nfind $install_dir/ -type d -print0 | xargs -r0 chmod 0755\nfind $data_dir/data/ -type f -print0 | xargs -r0 chmod 0640\nfind $data_dir/data/ -type d -print0 | xargs -r0 chmod 0750\nchmod 600 \"$install_dir/config/config.php\"\nchmod 755 /home/yunohost.app\nchmod 750 $install_dir\n\n# Iterate over users to extend their home folder permissions - for the external\n# storage plugin usage - and create relevant Nextcloud directories\nfor u in $(ynh_user_list); do\n    setfacl --recursive --modify g:$app:rwX,d:g:$app:rwX \"/home/$u\" || true\ndone\n\n#=================================================\n# YUNOHOST MULTIMEDIA INTEGRATION\n#=================================================\nynh_script_progression \"Adding multimedia directories...\"\n\n# Build YunoHost multimedia directories\nynh_multimedia_build_main_dir\n# Allow nextcloud to write into these directories\nynh_multimedia_addaccess $app\n\n#=================================================\n# RESTORE THE FAIL2BAN CONFIGURATION\n#=================================================\nynh_script_progression \"Restoring the Fail2Ban configuration...\"\n\nynh_restore \"/etc/fail2ban/jail.d/$app.conf\"\nynh_restore \"/etc/fail2ban/filter.d/$app.conf\"\n\n# Make sure a log file exists (mostly for CI tests)\nlogfile=\"/var/log/$app/nextcloud.log\"\nif [ ! -f \"$logfile\" ]; then\n\ttouch \"$logfile\"\n\tchown \"$app:\" \"$logfile\"\nfi\n\nynh_systemctl --action=restart --service=fail2ban\n\n#=================================================\n# RESTORE THE NOTIFY_PUSH APP\n#=================================================\n\nif [ $enable_notify_push -eq 1 ]\nthen\n    ynh_restore \"/etc/systemd/system/${app}-notify-push.service\"\n    ynh_restore \"/etc/systemd/system/${app}-notify-push-watcher.service\"\n    ynh_restore \"/etc/systemd/system/${app}-notify-push-watcher.path\"\n\n    systemctl enable --now \"${app}-notify-push-watcher.service\" --quiet\n    systemctl enable --now \"${app}-notify-push-watcher.path\" --quiet\n    systemctl enable --now \"${app}-notify-push.service\" --quiet\nfi\n\n#=================================================\n# RELOAD NGINX\n#=================================================\nynh_script_progression \"Reloading NGINX web server...\"\n\nynh_systemctl --service=nginx --action=reload\n\n#=================================================\n# CHECK IF NOTIFY_PUSH WORKS\n#=================================================\n\nif [ $enable_notify_push -eq 1 ]\nthen\n    count=0\n    while ! exec_occ $install_dir/cron.php && [[ $count -lt 30 ]]\n    do\n        sleep 1\n        count=$((count + 1))\n    done\n\n    ynh_systemctl --service=\"${app}-notify-push-watcher\" --action=restart\n    ynh_systemctl --service=\"${app}-notify-push\" --action=restart --log_path=\"systemd\" --wait_until=\"Push daemon for Nextcloud clients.\"\n\n    if ! exec_occ notify_push:self-test; then\n        ynh_print_warn \"The Notify Push service is still not working properly. Please log in with a user to your NextCloud instance, restart the Notify Push service with \\\"systemctl restart ${app}-notify-push.service\\\", and run \\\"ynh_exec_as_app php${php_version} $install_dir/occ notify_push:self-test\\\" to verify that everything is green.\"\n    fi\nfi\n\n#=================================================\n# END OF SCRIPT\n#=================================================\n\nynh_script_progression \"Restoration completed for $app\"\n"
  },
  {
    "path": "scripts/upgrade",
    "content": "#!/bin/bash\n\nsource _common.sh\nsource /usr/share/yunohost/helpers\n\n#=================================================\n# ENSURE DOWNWARD COMPATIBILITY\n#=================================================\nynh_script_progression \"Ensuring downward compatibility...\"\n\nynh_app_setting_set_default --key=php_upload_max_filesize --value=10G\nynh_app_setting_set_default --key=php_memory_limit --value=512M\n\nynh_app_setting_set_default --key=enable_notify_push --value=0\n\n# Remove the option backup_core_only if it's in the settings.yml file\nynh_app_setting_delete --key=backup_core_only\n\nphpflags=\"--define apc.enable_cli=1\"\nynh_app_setting_set --key=phpflags --value=\"$phpflags\"\n\nif ynh_app_upgrading_from_version_before 22.2~ynh1\nthen\n    ynh_die \"Upgrading from Nextcloud < 22.2 is not supported anymore. You should first upgrade to 22.2 using: yunohost app upgrade nextcloud -u https://github.com/YunoHost-Apps/nextcloud_ynh/tree/41f5f902e7c7cd3c30a6793020562ba98b9bf3e9\"\nfi\n\n#=================================================\n# MAKE SEQUENTIAL UPGRADES FROM EACH MAJOR\n# VERSION TO THE NEXT ONE\n#=================================================\n\nfilter_boring_occ_warnings() {\n    # Filter stupid and boring messages such as the progress bar looking like:\n    # 3/3 [============================] 100% Starting ...\n    # and being pretty much useless, as well as the annoying warning about \"only a limited number of commands\" etc...\n\n    sed -E 's@\\s*([0-9]+\\/[0-9]+\\s+\\[(-|>|=)+\\]\\s+[0-9]+%|\\s*Starting ...|Nextcloud or one of the apps require upgrade - only a limited number of commands are available|You may use your browser or the occ upgrade command to do the upgrade)@@g'\n}\n\n# Define a function to execute commands with `occ`\nexec_occ() {\n    # Backward compatibility to upgrade from older versions\n    if [ $current_major_version -ge 33 ]\n    then\n        NEXTCLOUD_PHP_VERSION=\"8.4\"\n    elif [ $current_major_version -ge 30 ]\n    then\n        NEXTCLOUD_PHP_VERSION=\"8.3\"\n    elif [ $current_major_version -ge 26 ]\n    then\n        NEXTCLOUD_PHP_VERSION=\"8.2\"\n    elif [ $current_major_version -ge 24 ]\n    then\n        NEXTCLOUD_PHP_VERSION=\"8.1\"\n    else\n        NEXTCLOUD_PHP_VERSION=\"7.4\"\n    fi\n\n    # NB: be super careful when designing this part of the code, because calling ynh_apt_install_dependencies\n    # will do magic regarding php configuration and $php_version when the php version of the dependencies changes ...\n    php_version=$(ynh_app_setting_get --key=php_version)\n    if [[ \"$NEXTCLOUD_PHP_VERSION\" != \"$php_version\" ]]; then\n        local pkg_dependencies=\"$(dpkg-query --show --showformat='${Depends}' ${app//_/-}-ynh-deps)\"\n        pkg_dependencies=\"${pkg_dependencies//$php_version/$NEXTCLOUD_PHP_VERSION}\"\n        # Packaging v1 ~legacy : ynh_apt_install_dependencies is designed to be called several times\n        # but the second time it will *append* the list of dependencies rather than replace the existing dependencies\n        # resulting in a crash when parsing what's the php version the app uses, hence we need to force the full-replacement\n        YNH_INSTALL_APP_DEPENDENCIES_REPLACE=true\n        ynh_apt_install_dependencies \"$pkg_dependencies\"\n    fi\n\n(cd \"$install_dir\" && ynh_exec_as_app \\\n    php$NEXTCLOUD_PHP_VERSION --define apc.enable_cli=1 occ --no-interaction --no-ansi \"$@\") 2> >(filter_boring_occ_warnings >&2)\n}\n\n# Define a function to add an external storage\n# Create the external storage for the given folders and enable sharing\ncreate_external_storage() {\n    local mount_dir=\"$1\"\n    local mount_name=\"$2\"\n    local mount_id=$(exec_occ files_external:create --output=json \\\n        \"$mount_name\" 'local' 'null::null' -c \"datadir=$mount_dir\" || true)\n    ! [[ $mount_id =~ ^[0-9]+$ ]] \\\n        && ynh_print_warn \"Unable to create external storage\" \\\n        || exec_occ files_external:option \"$mount_id\" enable_sharing true\n}\n\nfunction list_installed_apps_not_compatible_with_future_version()\n{\n    local nextcloud_destination_version=\"$1\"\n    local nextcloud_current_version=\"$(grep OC_VersionString \"$install_dir/version.php\" | cut -d\\' -f2)\"\n    local installed_apps=$(mktemp)\n    local core_apps_in_current_version=$(mktemp)\n    local nextcloud_destination_appcatalog=$(mktemp)\n\n    # Run a first \"dummy\" command just to make sure we have the appropriate php dependencies installed,\n    # otherwise this creates funky stuff when tweaking the apt deps because the next command is piped into jq ...\n    exec_occ -V >/dev/null\n    # List installed apps\n    exec_occ app:list --output json | jq -r \".enabled | keys[]\" | sort > $installed_apps\n    # Fetch Nextcloud list of core apps from their github repo for the current version\n    curl -s https://raw.githubusercontent.com/nextcloud/server/v$nextcloud_current_version/core/shipped.json | jq -r '.shippedApps[]' | sort > $core_apps_in_current_version\n    # Fetch Nextcloud app catalog (doesnt contain core app) for the future version\n    curl -s https://apps.nextcloud.com/api/v1/platform/$nextcloud_destination_version.0.0/apps.json | jq -r '.[] | .id' | sort > $nextcloud_destination_appcatalog\n\n    # Compute set complement, cf https://catonmat.net/set-operations-in-unix-shell\n    # We want to list the installed apps which are neither core apps nor in the destination catalog\n    comm -23 <(comm -23 $installed_apps $core_apps_in_current_version) $nextcloud_destination_appcatalog\n}\n\ncurrent_version=$(grep OC_VersionString \"$install_dir/version.php\" | cut -d\\' -f2)\ncurrent_major_version=${current_version%%.*}\n\nlast_version=$(ynh_read_manifest \"resources.sources.main.url\" | grep -Eo '[0-9]+\\.[0-9]+\\.[0-9]+')\nlast_major_version=${last_version%%.*}\n\nif [[ \"$last_major_version\" != \"$current_major_version\" ]]\nthen\n    installed_apps_not_compatible_with_future_version=\"$(list_installed_apps_not_compatible_with_future_version $last_major_version)\"\n    if [[ -n \"$installed_apps_not_compatible_with_future_version\" ]]\n    then\n        ynh_die \"The following apps are not (yet?) compatible with Nextcloud $last_major_version. You should make sure to upgrade the app, or disable it, or wait for it to become compatible before running this upgrade : $installed_apps_not_compatible_with_future_version\"\n    fi\nfi\n\n# Keep the attribute choose for ldapEmailAttribute\nldapEmail=$(exec_occ config:app:get user_ldap \"${ldap_config_prefix:-}\"ldap_email_attr)\nif [ \"$ldapEmail\" = \"maildrop\" ]\nthen\n    ldap_email_attr=\"maildrop\"\nelse\n    ldap_email_attr=\"mail\"\nfi\n\n# Before NCv32, Yunohost was not using any prefix for the LDAP config.\n# This is now mandatory so we need to create a new config with a prefix.\nif [ \"${ldap_config_prefix:-}\" = \"\" ]\nthen\n    ldap_config_prefix=$(exec_occ ldap:create-empty-config --only-print-prefix)\n    ynh_app_setting_set --key=ldap_config_prefix --value=\"$ldap_config_prefix\"\nfi\n\n#=================================================\n# UPGRADE NEXTCLOUD\n#=================================================\nynh_script_progression \"Upgrading $app...\"\n\n# Set write access for the following commands\nchown -R $app:www-data \"$install_dir\"\n# Print the current version number of Nextcloud\nexec_occ -V\n\nif [ \"$(exec_occ config:system:get mysql.utf8mb4)\" != \"true\" ]; then\n    db_pwd=$(ynh_app_setting_get --key=db_pwd)\n    # Change your databases character set and collation\n    ynh_mysql_db_shell <<< \"ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;\"\n    # Set the mysql.utf8mb4 config to true in config.php\n    exec_occ config:system:set mysql.utf8mb4 --type boolean --value=\"true\"\n    exec_occ maintenance:repair\nfi\n\n# Upgrade may fail if this app is enabled\n# Take all apps enabled, and check if mail is one of them\n# Then temporary disable the mail app\nmail_app_must_be_reactived=0\n\nif exec_occ app:list | awk '/Enabled/{f=1;next} /Disabled/{f=0} f' | grep -q -w mail; then\n    exec_occ app:disable mail\n    mail_app_must_be_reactived=1\nfi\n\n# Avoid to downgrade Nextcloud, if channel has changed from stable to oldstable.\nif [[ \"$current_major_version\" -le \"$last_major_version\" ]]; then\n\n    # While the current version is not the last version, do an upgrade\n    while [ \"$last_version\" != \"$current_version\" ]\n    do\n\n        next_major_version=\"$(( $current_major_version + 1 ))\"\n        source_id=\"$next_major_version\"\n        if [[ \"$next_major_version\" -ge \"$last_major_version\" ]]; then\n            ynh_print_info \"Upgrading to Nextcloud $last_version\"\n            source_id=\"main\"\n        else\n            ynh_print_info \"Upgrading to Nextcloud $next_major_version\"\n        fi\n\n        # Create a temporary directory\n        tmpdir=\"${install_dir}__tmp_upgrade\"\n\n        ynh_setup_source --dest_dir=\"$tmpdir\" --source_id=\"$source_id\"\n\n        # Backup the config file in the temp dir\n        cp -a \"$install_dir/config/config.php\" \"$tmpdir/config/config.php\"\n\n        # Enable maintenance mode\n        exec_occ maintenance:mode --on\n\n        # Backup 3rd party applications from the current Nextcloud\n        # But do not overwrite if there is any upgrade\n        # (apps directory already exists in Nextcloud archive)\n        (\n        cd $install_dir/apps\n        for nc_app_dir in */\n        do\n        if [ ! -d \"$tmpdir/apps/$nc_app_dir\" ]\n        then\n            cp -a \"$nc_app_dir\" \"$tmpdir/apps/$nc_app_dir\"\n        fi\n        done\n        )\n\n        # Replace the old Nextcloud by the new one\n        ynh_safe_rm \"$install_dir\"\n        mv \"$tmpdir\" \"$install_dir\"\n\n        # Get the new current version number\n        current_version=$(grep OC_VersionString \"$install_dir/version.php\" | cut -d\\' -f2)\n        current_major_version=${current_version%%.*}\n\n        # Set write access for the following commands\n        chown -R $app:www-data \"$install_dir\"\n        # Upgrade Nextcloud (SUCCESS = 0, UP_TO_DATE = 3)\n        exec_occ maintenance:mode --off\n        exec_occ upgrade || [ $? -eq 3 ] || ynh_die \"Unable to upgrade $app\"\n\n        # Print the current version number of Nextcloud\n        exec_occ -V\n    done\nfi\nexec_occ db:add-missing-indices -n\nexec_occ db:add-missing-columns -n\nexec_occ db:add-missing-primary-keys -n\nexec_occ db:convert-filecache-bigint -n\n\n#=================================================\n# CONFIGURE NEXTCLOUD\n#=================================================\nynh_script_progression \"Reconfiguring $app...\"\n\n# Verify the checksum and backup the file if it's different\nynh_backup_if_checksum_is_different \"$install_dir/config/config.php\"\n\nnc_conf=\"${install_dir}/config.json\"\nynh_config_add --template=\"config.json\" --destination=\"$nc_conf\"\n\n# Reneable the mail app\nif [ $mail_app_must_be_reactived -eq 1 ]; then\n    exec_occ app:enable mail\nfi\n\n# Ensure that UpdateNotification app is disabled\nexec_occ app:disable updatenotification\n\n# Enable LDAP plugin\nexec_occ app:enable user_ldap\n\n# Update all installed apps\nexec_occ app:update --all\n\n# move the logs from the data_dir to the standard /var/log\n# it would be better in the ENSURE DOWNWARD COMPATIBILITY section\n# but it must be after the exec_occ() definition, so it's here\nif [ -f \"$data_dir/data/nextcloud.log\" ]; then\n    mkdir -p \"/var/log/$app\"\n    chmod 750 \"/var/log/$app\"\n    mv \"$data_dir\"/data/nextcloud.log* \"/var/log/$app\"\n    # adapt the nextcloud config\n    exec_occ config:system:set logfile --value=\"/var/log/$app/nextcloud.log\"\nfi\n\n# Load the config file in nextcloud\nexec_occ config:import \"$nc_conf\"\n\n# Then remove the config file\nynh_safe_rm \"$nc_conf\"\n\n# Occasionally new mimetypes are added to better handle certain file types.\n# Migrating the mimetypes take a long time on larger instances\n# so this is not done automatically during upgrades.\nexec_occ maintenance:repair --include-expensive\n\n#=================================================\n# ALLOW USERS TO DISCONNECT FROM NEXTCLOUD\n#=================================================\n\n# Add dynamic logout URL to the config\nurl_base64=\"$(echo -n \"https://$domain$path\" | base64)\"\nold_logout_url=\"https://$(cat /etc/yunohost/current_host)/yunohost/sso/?action=logout\"\ncurrent_logout_url=\"$(exec_occ config:system:get logout_url 2> /dev/null || echo '')\"\nif [[ \"$current_logout_url\" == \"${old_logout_url}\" ]] || [[ \"$current_logout_url\" == \"\" ]]\nthen\n    echo \"\n//-YunoHost-\n// set logout_url according to main domain\n\\$main_domain = file_get_contents('/etc/yunohost/current_host');\n\\$CONFIG['logout_url'] = 'https://'.\\$main_domain.'/yunohost/sso/?action=logout&r=${url_base64}';\n//-YunoHost-\n    \" >> \"$install_dir/config/config.php\"\nfi\n\n#=================================================\n# CHANGE HOSTNAME FOR ACTIVITY NOTIFICATIONS\n#=================================================\n\nexec_occ config:system:set overwrite.cli.url --value=\"https://${domain}${path}\"\n\n#=================================================\n# MOUNT HOME FOLDERS AS EXTERNAL STORAGE\n#=================================================\n\n# Enable External Storage and create local mount to home folder as needed\nif [ $user_home -eq 1 ]; then\n    exec_occ app:enable files_external\n    exec_occ files_external:list --output=json \\\n    | grep -q '\"storage\":\"\\\\\\\\OC\\\\\\\\Files\\\\\\\\Storage\\\\\\\\Local\"' \\\n    || create_external_storage \"/home/\\$user\" \"Home\"\n    # Iterate over users to extend their home folder permissions\n    for u in $(ynh_user_list); do\n    setfacl --modify g:$app:rwx \"/home/$u\" || true\n    done\nfi\n\n#=================================================\n# STORE THE CHECKSUM OF THE CONFIG FILE\n#=================================================\n\n# Calculate and store the config file checksum into the app settings\nynh_store_file_checksum \"${install_dir}/config/config.php\"\n\n#=================================================\n# REGEN PERMISSIONS\n#=================================================\nynh_script_progression \"Reapplying file permissions...\"\n\n# Fix app ownerships & permissions\nchown -R $app:www-data \"$install_dir\"\nfind $install_dir/ -type f -print0 | xargs -r0 chmod 0644\nfind $install_dir/ -type d -print0 | xargs -r0 chmod 0755\nfind \"$install_dir/apps/\"*/{bin,bin-ext} -type d -print0 2>/dev/null | xargs -r0 chmod -R u+x\nchmod 600 \"$install_dir/config/config.php\"\nchmod 755 /home/yunohost.app\nchmod 750 $install_dir\n\n#=================================================\n# REGEN SYSTEM CONFIGURATIONS\n#=================================================\nynh_script_progression \"Regenerating system configurations for $app...\"\n\n#-------------------------------------------------\n# PHP-FPM\n#-------------------------------------------------\n\nynh_config_add_phpfpm\n\n#-------------------------------------------------\n# NGINX\n#-------------------------------------------------\n\n# Delete current NGINX configuration to be able to check if .well-known is already served.\nynh_backup_if_checksum_is_different \"/etc/nginx/conf.d/$domain.d/$app.conf\"\nynh_config_remove_nginx\nynh_app_setting_delete --key=\"checksum__etc_nginx_conf.d_$domain.d_$app.conf\"\n\n# Wait untils NGINX has fully reloaded\nynh_systemctl --service=nginx --action=reload --wait_until=\"Reloaded\" --log_path=\"systemd\"\n\nwait_nginx_reload\n\n# Check if .well-known is available for this domain\nif is_url_handled --domain=\"$domain\" --path=\"/.well-known/caldav\" || is_url_handled --domain=\"$domain\" --path=\"/.well-known/carddav\"\nthen\n    ynh_print_warn \"Another app already uses the domain $domain to serve a CalDAV/CardDAV feature. You may encounter issues when dealing with your calendar or address book.\"\n\n    # Remove lines about .well-known/carddav and caldav with sed.\n    sed --in-place --regexp-extended '/location = \\/\\.well\\-known\\/(caldav|carddav)/d' \"../conf/nginx.conf\"\nfi\n\n# Create a dedicated NGINX config\nnginx_extra_conf_dir=\"/etc/nginx/conf.d/$domain.d/$app.d\"\nmkdir -p \"$nginx_extra_conf_dir\"\n\nif [ $enable_notify_push -eq 1 ]\nthen\n    ynh_config_add --template=\"notify_push.conf\" --destination=\"$nginx_extra_conf_dir/notify_push.conf\"\nfi\n\n# Create a dedicated NGINX config\nynh_config_add_nginx\n\n#=================================================\n# CONFIGURE NOTIFY_PUSH APP\n#=================================================\n\nif [ $enable_notify_push -eq 1 ]\nthen\n    # If notify_push is disabled, reenable it\n    if exec_occ app:list | awk '/Disabled/{f=1;next} f' | grep -q -w notify_push; then\n        exec_occ app:enable notify_push\n    # If notify_push is not installed, install it\n    elif ! exec_occ app:list | awk '/Enabled/{f=1;next} /Disabled/{f=0} f' | grep -q -w notify_push; then\n        exec_occ app:install notify_push\n    fi\n    exec_occ config:app:set notify_push base_endpoint --value=https://$domain${path_url%/}/push\n\n    mkdir -p /var/run/$app/\n    chown $app: /var/run/$app/\n\n    case $YNH_ARCH in\n        amd64) arch=\"x86_64\";;\n        arm64) arch=\"aarch64\";;\n        armel|armhf) arch=\"armv7\";;\n    esac\n\n    ynh_config_add --template=\"watcher.path\" --destination=\"/etc/systemd/system/${app}-notify-push-watcher.path\"\n    ynh_config_add_systemd --service=\"${app}-notify-push-watcher\" --template=\"watcher.service\"\n    systemctl enable --now --quiet ${app}-notify-push-watcher.path\n    ynh_config_add_systemd --service=\"${app}-notify-push\"\nfi\n\n#=================================================\n# CRON JOB\n#=================================================\n\nynh_config_add --template=\"nextcloud.cron\" --destination=\"/etc/cron.d/$app\"\nchown root: \"/etc/cron.d/$app\"\nchmod 644 \"/etc/cron.d/$app\"\n\nexec_occ background:cron\n\n#=================================================\n# LOGROTATE\n#=================================================\nynh_script_progression \"Configuring log rotation...\"\n\nynh_config_add_logrotate\n\n#=================================================\n# FAIL2BAN\n#=================================================\nynh_script_progression \"Configuring Fail2Ban...\"\n\n# Create a dedicated Fail2Ban config\nynh_config_add_fail2ban --logpath=\"/var/log/$app/nextcloud.log\"\n\n#=================================================\n# CHECK IF NOTIFY_PUSH WORKS\n#=================================================\n\nif [ $enable_notify_push -eq 1 ]\nthen\n    count=0\n    while ! exec_occ $install_dir/cron.php && [[ $count -lt 30 ]]\n    do\n        sleep 1\n        count=$((count + 1))\n    done\n\n    ynh_systemctl --service=\"${app}-notify-push-watcher\" --action=restart\n    ynh_systemctl --service=\"${app}-notify-push\" --action=restart --log_path=\"systemd\" --wait_until=\"Push daemon for Nextcloud clients.\"\n\n    if ! exec_occ notify_push:self-test; then\n        ynh_print_warn \"The Notify Push service is still not working properly. Please log in with a user to your NextCloud instance, restart the Notify Push service with \\\"systemctl restart ${app}-notify-push.service\\\", and run \\\"ynh_exec_as_app php${php_version} $install_dir/occ notify_push:self-test\\\" to verify that everything is green.\"\n    fi\nfi\n\n#=================================================\n# END OF SCRIPT\n#=================================================\n\nynh_script_progression \"Upgrade of $app completed\"\n"
  },
  {
    "path": "tests.toml",
    "content": "test_format = 1.0\n\n[default]\n\n    args.enable_notify_push = \"0\"\n\n    # -------------------------------\n    # Commits to test upgrade from\n    # -------------------------------\n\n    test_upgrade_from.5bbe70c6.name = \"Upgrade from 30.0.8\"\n    test_upgrade_from.446e9775.name = \"Upgrade from 31.0.7\"\n    test_upgrade_from.05f2feff.name = \"Upgrade from 32.0.3\"\n\n    [default.curl_tests]\n    #home.path = \"/\"\n    home.expect_title = \"Login - Nextcloud\"\n    home.auto_test_assets = true\n\n    #dash.path = \"/\"\n    dash.logged_on_sso = true\n    dash.expect_title = \"Dashboard - Nextcloud\"\n\n    admin.path = \"/settings/admin\"\n    admin.logged_on_sso = true\n    admin.expect_title = \"Administration settings - Nextcloud\"\n\n    asset.path = \"/core/img/logo/logo.svg\"\n\n    file.path = \"/remote.php/dav/files/__USER__/Readme.md\"\n    file.logged_on_sso = true\n    file.expect_content = \"# Welcome to Nextcloud!\"\n\n    caldav.base_url = \"https://__DOMAIN__\"\n    caldav.path = \"/.well-known/caldav\"\n    caldav.logged_on_sso = true\n    caldav.expect_content = \"This is the WebDAV interface.\"\n\n[notify_push_test]\n    args.enable_notify_push = \"1\"\n    test_upgrade_from.05f2feff.name = \"Upgrade from 32.0.3\"\n    test_upgrade_from.05f2feff.args.system_addressbook_exposed = \"yes\"\n"
  }
]