Full Code of YunoHost-Apps/nextcloud_ynh for AI

master 07a7581d3adc cached
38 files
121.1 KB
30.5k tokens
1 requests
Download .txt
Repository: YunoHost-Apps/nextcloud_ynh
Branch: master
Commit: 07a7581d3adc
Files: 38
Total size: 121.1 KB

Directory structure:
gitextract_5zm6mp9i/

├── .github/
│   ├── ISSUE_TEMPLATE.md
│   └── PULL_REQUEST_TEMPLATE.md
├── .gitignore
├── LICENSE
├── README.md
├── conf/
│   ├── config.json
│   ├── config_install.json
│   ├── extra_php-fpm.conf
│   ├── f2b_filter.conf
│   ├── f2b_jail.conf
│   ├── nextcloud.cron
│   ├── nginx.conf
│   ├── notify_push.conf
│   ├── systemd.service
│   ├── watcher.path
│   └── watcher.service
├── config_panel.toml
├── doc/
│   ├── ADMIN.md
│   ├── ADMIN_fr.md
│   ├── DESCRIPTION.md
│   ├── DESCRIPTION_fr.md
│   ├── POST_UPGRADE.md
│   ├── POST_UPGRADE_fr.md
│   └── PRE_UPGRADE.d/
│       └── MAJOR_RELEASE.md
├── hooks/
│   ├── post_user_create
│   └── post_user_delete
├── manifest.toml
├── patches/
│   ├── 30/
│   │   └── 00-add-logout_url-conf.patch
│   └── main/
│       └── 00-add-logout_url-conf.patch
├── scripts/
│   ├── _common.sh
│   ├── backup
│   ├── change_url
│   ├── config
│   ├── install
│   ├── remove
│   ├── restore
│   └── upgrade
└── tests.toml

================================================
FILE CONTENTS
================================================

================================================
FILE: .github/ISSUE_TEMPLATE.md
================================================
---
name: Bug report
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.

---

**How to post a meaningful bug report**
1. *Read this whole template first.*
2. *Determine if you are on the right place:*
   - *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!*
   - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
   - *When in doubt, post here and we will figure it out together.*
3. *Delete the italic comments as you write over them below, and remove this guide.*
--- 

### Describe the bug

*A clear and concise description of what the bug is.*

### Context

- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
- YunoHost version: x.x.x
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes*
  - If yes, please explain:
- Using, or trying to install package version/branch:
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*

### Steps to reproduce

- *If you performed a command from the CLI, the command itself is enough. For example:*
    ```sh
    sudo yunohost app install the_app
    ```
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
- *If the error occurs in your browser, explain what you did:*
   1. *Go to '...'*
   2. *Click on '...'*
   3. *Scroll down to '...'*
   4. *See error*

### Expected behavior

*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.*

### Logs

*When an operation fails, YunoHost provides a simple way to share the logs.*
- *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.*
- *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`.*

*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...)*

*If applicable and useful, add screenshots to help explain your problem.*


================================================
FILE: .github/PULL_REQUEST_TEMPLATE.md
================================================
## Problem

- *Description of why you made this PR*

## Solution

- *And how do you fix that problem*

## PR Status

- [ ] Code finished and ready to be reviewed/tested
- [ ] The fix/enhancement were manually tested (if applicable)

## Automatic tests

Automatic 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)


================================================
FILE: .gitignore
================================================
*~
*.sw[op]
.DS_Store


================================================
FILE: LICENSE
================================================
                    GNU AFFERO GENERAL PUBLIC LICENSE
                       Version 3, 19 November 2007

 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.

  The licenses for most software and other practical works are designed
to take away your freedom to share and change the works.  By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.

  Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.

  A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate.  Many developers of free software are heartened and
encouraged by the resulting cooperation.  However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.

  The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community.  It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server.  Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.

  An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals.  This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.

  The precise terms and conditions for copying, distribution and
modification follow.

                       TERMS AND CONDITIONS

  0. Definitions.

  "This License" refers to version 3 of the GNU Affero General Public License.

  "Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.

  "The Program" refers to any copyrightable work licensed under this
License.  Each licensee is addressed as "you".  "Licensees" and
"recipients" may be individuals or organizations.

  To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy.  The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.

  A "covered work" means either the unmodified Program or a work based
on the Program.

  To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy.  Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.

  To "convey" a work means any kind of propagation that enables other
parties to make or receive copies.  Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.

  An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License.  If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.

  1. Source Code.

  The "source code" for a work means the preferred form of the work
for making modifications to it.  "Object code" means any non-source
form of a work.

  A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.

  The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form.  A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.

  The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities.  However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work.  For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.

  The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.

  The Corresponding Source for a work in source code form is that
same work.

  2. Basic Permissions.

  All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met.  This License explicitly affirms your unlimited
permission to run the unmodified Program.  The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work.  This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.

  You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force.  You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright.  Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.

  Conveying under any other circumstances is permitted solely under
the conditions stated below.  Sublicensing is not allowed; section 10
makes it unnecessary.

  3. Protecting Users' Legal Rights From Anti-Circumvention Law.

  No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.

  When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.

  4. Conveying Verbatim Copies.

  You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.

  You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.

  5. Conveying Modified Source Versions.

  You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:

    a) The work must carry prominent notices stating that you modified
    it, and giving a relevant date.

    b) The work must carry prominent notices stating that it is
    released under this License and any conditions added under section
    7.  This requirement modifies the requirement in section 4 to
    "keep intact all notices".

    c) You must license the entire work, as a whole, under this
    License to anyone who comes into possession of a copy.  This
    License will therefore apply, along with any applicable section 7
    additional terms, to the whole of the work, and all its parts,
    regardless of how they are packaged.  This License gives no
    permission to license the work in any other way, but it does not
    invalidate such permission if you have separately received it.

    d) If the work has interactive user interfaces, each must display
    Appropriate Legal Notices; however, if the Program has interactive
    interfaces that do not display Appropriate Legal Notices, your
    work need not make them do so.

  A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit.  Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.

  6. Conveying Non-Source Forms.

  You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:

    a) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by the
    Corresponding Source fixed on a durable physical medium
    customarily used for software interchange.

    b) Convey the object code in, or embodied in, a physical product
    (including a physical distribution medium), accompanied by a
    written offer, valid for at least three years and valid for as
    long as you offer spare parts or customer support for that product
    model, to give anyone who possesses the object code either (1) a
    copy of the Corresponding Source for all the software in the
    product that is covered by this License, on a durable physical
    medium customarily used for software interchange, for a price no
    more than your reasonable cost of physically performing this
    conveying of source, or (2) access to copy the
    Corresponding Source from a network server at no charge.

    c) Convey individual copies of the object code with a copy of the
    written offer to provide the Corresponding Source.  This
    alternative is allowed only occasionally and noncommercially, and
    only if you received the object code with such an offer, in accord
    with subsection 6b.

    d) Convey the object code by offering access from a designated
    place (gratis or for a charge), and offer equivalent access to the
    Corresponding Source in the same way through the same place at no
    further charge.  You need not require recipients to copy the
    Corresponding Source along with the object code.  If the place to
    copy the object code is a network server, the Corresponding Source
    may be on a different server (operated by you or a third party)
    that supports equivalent copying facilities, provided you maintain
    clear directions next to the object code saying where to find the
    Corresponding Source.  Regardless of what server hosts the
    Corresponding Source, you remain obligated to ensure that it is
    available for as long as needed to satisfy these requirements.

    e) Convey the object code using peer-to-peer transmission, provided
    you inform other peers where the object code and Corresponding
    Source of the work are being offered to the general public at no
    charge under subsection 6d.

  A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.

  A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling.  In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage.  For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product.  A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.

  "Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source.  The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.

  If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information.  But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).

  The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed.  Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.

  Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.

  7. Additional Terms.

  "Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law.  If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.

  When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it.  (Additional permissions may be written to require their own
removal in certain cases when you modify the work.)  You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.

  Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:

    a) Disclaiming warranty or limiting liability differently from the
    terms of sections 15 and 16 of this License; or

    b) Requiring preservation of specified reasonable legal notices or
    author attributions in that material or in the Appropriate Legal
    Notices displayed by works containing it; or

    c) Prohibiting misrepresentation of the origin of that material, or
    requiring that modified versions of such material be marked in
    reasonable ways as different from the original version; or

    d) Limiting the use for publicity purposes of names of licensors or
    authors of the material; or

    e) Declining to grant rights under trademark law for use of some
    trade names, trademarks, or service marks; or

    f) Requiring indemnification of licensors and authors of that
    material by anyone who conveys the material (or modified versions of
    it) with contractual assumptions of liability to the recipient, for
    any liability that these contractual assumptions directly impose on
    those licensors and authors.

  All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10.  If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term.  If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.

  If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.

  Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.

  8. Termination.

  You may not propagate or modify a covered work except as expressly
provided under this License.  Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).

  However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.

  Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.

  Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License.  If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.

  9. Acceptance Not Required for Having Copies.

  You are not required to accept this License in order to receive or
run a copy of the Program.  Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance.  However,
nothing other than this License grants you permission to propagate or
modify any covered work.  These actions infringe copyright if you do
not accept this License.  Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.

  10. Automatic Licensing of Downstream Recipients.

  Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License.  You are not responsible
for enforcing compliance by third parties with this License.

  An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations.  If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.

  You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License.  For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.

  11. Patents.

  A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based.  The
work thus licensed is called the contributor's "contributor version".

  A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version.  For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.

  Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.

  In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement).  To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.

  If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients.  "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.

  If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.

  A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License.  You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.

  Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.

  12. No Surrender of Others' Freedom.

  If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all.  For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.

  13. Remote Network Interaction; Use with the GNU General Public License.

  Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software.  This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.

  Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work.  The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.

  14. Revised Versions of this License.

  The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time.  Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

  Each version is given a distinguishing version number.  If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation.  If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.

  If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.

  Later license versions may give you additional or different
permissions.  However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.

  15. Disclaimer of Warranty.

  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

  16. Limitation of Liability.

  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.

  17. Interpretation of Sections 15 and 16.

  If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

  If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source.  For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code.  There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.

  You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.


================================================
FILE: README.md
================================================
<!--
N.B.: This README was automatically generated by <https://github.com/YunoHost/apps_tools/blob/main/readme_generator>
It shall NOT be edited by hand.
-->

<h1>
  <img src="https://raw.githubusercontent.com/YunoHost/apps/main/logos/nextcloud.png" width="32px" alt="Logo of Nextcloud">
  Nextcloud, packaged for YunoHost
</h1>

Online storage, file sharing platform and various other applications

[![🌐 Official app website](https://img.shields.io/badge/Official_app_website-darkgreen?style=for-the-badge)](https://nextcloud.com)
[![App Demo](https://img.shields.io/badge/App_Demo-blue?style=for-the-badge)](https://demo.nextcloud.com/)
[![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/)

<div align="center">
<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>
<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>
</div>


## Screenshots
![Screenshot of Nextcloud](./doc/screenshots/screenshot.png)

## 📦 Developer info

[![Automatic tests level](https://apps.yunohost.org/badge/cilevel/nextcloud)](https://ci-apps.yunohost.org/ci/apps/nextcloud/)

🛠️ Upstream Nextcloud repository: <https://github.com/nextcloud/server>

Pull request are welcome and should target the [`testing` branch](https://github.com/YunoHost-Apps/nextcloud_ynh/tree/testing).

The `testing` branch can be tested using:
```
# fresh install:
sudo yunohost app install https://github.com/YunoHost-Apps/nextcloud_ynh/tree/testing

# upgrade an existing install:
sudo yunohost app upgrade nextcloud -u https://github.com/YunoHost-Apps/nextcloud_ynh/tree/testing
```

### 📚 App packaging documentation

Please see <https://doc.yunohost.org/packaging_apps> for more information.

================================================
FILE: conf/config.json
================================================
{
  "system": {
    "trashbin_retention_obligation": "auto, 30",
    "versions_retention_obligation": "auto, 30",
    "updatechecker": false,
    "memcache.local": "\\OC\\Memcache\\APCu",
    "integrity.check.disabled": true,
    "filelocking.enabled": true,
    "lost_password_link": "disabled",
    "memcache.locking": "\\OC\\Memcache\\Redis",
    "redis": {
      "host": "localhost",
      "port": "6379",
      "timeout": "0.0",
      "password": ""
     },
    "hashing_default_password": true,
    "localstorage.allowsymlinks": true,
    "simpleSignUpLink.shown": false,
    "default_phone_region": "",
    "maintenance_window_start": 1,
    "mail_smtpmode": "smtp",
    "mail_smtpport": "25",
    "mail_smtpauth": 1,
    "mail_smtpname": "__APP__",
    "mail_smtppassword": "__MAIL_PWD__",
    "mail_sendmailmode": "smtp",
    "mail_from_address": "__APP__",
    "mail_domain": "__DOMAIN__",
    "mail_smtphost": "localhost",
    "mail_smtpstreamoptions": {
      "ssl": {
        "allow_self_signed": true,
        "verify_peer": false,
        "verify_peer_name": false
      }
    },
    "trusted_proxies": [ "127.0.0.1", "::1" ]
  },
  "apps": {
    "user_ldap": {
      "__LDAP_CONFIG_PREFIX__ldap_base": "dc=yunohost,dc=org",
      "__LDAP_CONFIG_PREFIX__ldap_base_groups": "ou=groups,dc=yunohost,dc=org",
      "__LDAP_CONFIG_PREFIX__ldap_base_users": "ou=users,dc=yunohost,dc=org",
      "__LDAP_CONFIG_PREFIX__ldap_cache_ttl": "600",
      "__LDAP_CONFIG_PREFIX__ldap_configuration_active": "1",
      "__LDAP_CONFIG_PREFIX__ldap_display_name": "displayname",
      "__LDAP_CONFIG_PREFIX__ldap_email_attr": "__LDAP_EMAIL_ATTR__",
      "__LDAP_CONFIG_PREFIX__ldap_expert_username_attr": "uid",
      "__LDAP_CONFIG_PREFIX__ldap_group_display_name": "cn",
      "__LDAP_CONFIG_PREFIX__ldap_group_filter": "(&(objectclass=top)(memberUid=*))",
      "__LDAP_CONFIG_PREFIX__ldap_group_filter_mode": "0",
      "__LDAP_CONFIG_PREFIX__ldap_groupfilter_objectclass": "posixGroup",
      "__LDAP_CONFIG_PREFIX__ldap_group_member_assoc_attribute": "memberUid",
      "__LDAP_CONFIG_PREFIX__ldap_host": "localhost",
      "__LDAP_CONFIG_PREFIX__ldap_login_filter": "(&(|(objectclass=posixAccount))(|(uid=%uid)(mail=%uid))(permission=cn=__APP__.main,ou=permission,dc=yunohost,dc=org))",
      "__LDAP_CONFIG_PREFIX__ldap_login_filter_mode": "0",
      "__LDAP_CONFIG_PREFIX__ldap_port": "389",
      "__LDAP_CONFIG_PREFIX__ldap_quota_attr": "userquota",
      "__LDAP_CONFIG_PREFIX__ldap_tls": "0",
      "__LDAP_CONFIG_PREFIX__ldap_user_display_name": "cn",
      "__LDAP_CONFIG_PREFIX__ldap_user_filter_mode": "0",
      "__LDAP_CONFIG_PREFIX__ldap_userfilter_objectclass": "posixAccount",
      "__LDAP_CONFIG_PREFIX__ldap_userlist_filter": "objectclass=posixAccount"
    }
  }
}


================================================
FILE: conf/config_install.json
================================================
{
  "system": {
    "datadirectory": "__DATA_DIR__/data/",
    "trusted_domains": [
      "localhost",
      "__DOMAIN__"
    ]
  }
}


================================================
FILE: conf/extra_php-fpm.conf
================================================

; Additional php.ini defines, specific to this pool of workers.
env[PATH] = $PATH
env[LANG] = $LANG
env[LC_ALL] = $LANG
php_value[default_charset] = UTF-8
; OPcache is already activated by default
; php_value[opcache.enable]=1
; The following parameters are nevertheless recommended for Nextcloud
; see here: https://docs.nextcloud.com/server/20/admin_manual/installation/server_tuning.html#enable-php-opcache
php_value[opcache.enable_cli]=1
php_value[opcache.interned_strings_buffer]=32
php_value[opcache.max_accelerated_files]=10000
php_value[opcache.memory_consumption]=128
php_value[opcache.save_comments]=1
php_value[opcache.revalidate_freq]=60
; https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/big_file_upload_configuration.html#configuring-php
php_value[output_buffering]=0
; https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/caching_configuration.html#id1
php_value[apc.enabled]=1
php_value[apc.enable_cli]=1


================================================
FILE: conf/f2b_filter.conf
================================================
[INCLUDES]
before = common.conf
[Definition]
_groupsre = (?:(?:,?\s*"\w+":(?:"[^"]+"|\w+))*)
failregex = ^\{%(_groupsre)s,?\s*"remoteAddr":"<HOST>"%(_groupsre)s,?\s*"message":"Login failed:
            ^\{%(_groupsre)s,?\s*"remoteAddr":"<HOST>"%(_groupsre)s,?\s*"message":"Two-factor challenge failed:
            ^\{%(_groupsre)s,?\s*"remoteAddr":"<HOST>"%(_groupsre)s,?\s*"message":"Trusted domain error.
datepattern = ,?\s*"time"\s*:\s*"%%Y-%%m-%%d[T ]%%H:%%M:%%S(%%z)?"


================================================
FILE: conf/f2b_jail.conf
================================================
[__APP__]
enabled = true
port = http,https
filter = __APP__
logpath = /var/log/__APP__/nextcloud.log
maxretry = 5


================================================
FILE: conf/nextcloud.cron
================================================
*/5  *  *  *  * __APP__ /usr/bin/php__PHP_VERSION__ --define apc.enable_cli=1 -f __INSTALL_DIR__/cron.php


================================================
FILE: conf/nginx.conf
================================================
# Set .mjs MIME types
# Either include it in the default mime.types list
# or include you can include that list explicitly and add the file extension
# and include that list explicitly or add the file extension
# only for Nextcloud like below:
include mime.types;
types {
    text/javascript mjs;
    application/wasm wasm;
}

location ^~ /.well-known {
  # The following 6 rules are borrowed from `.htaccess`

  # The following 2 rules are only needed for the user_webfinger app.
  # Uncomment it if you're planning to use this app.
  #rewrite ^/\.well-known/host-meta\.json  __PATH__/public.php?service=host-meta-json  last;
  #rewrite ^/\.well-known/host-meta        __PATH__/public.php?service=host-meta       last;

  location = /.well-known/carddav     { return 301 __PATH__/remote.php/dav/; }
  location = /.well-known/caldav      { return 301 __PATH__/remote.php/dav/; }

  location = /.well-known/webfinger     { return 301 __PATH__/index.php$request_uri; }
  location = /.well-known/nodeinfo      { return 301 __PATH__/index.php$request_uri; }

  # Let Nextcloud's API for `/.well-known` URIs handle all other
  # requests by passing them to the front-end controller.
  return 301 __PATH__/index.php$request_uri;
}

#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location ^~ __PATH__/ {

  # Path to source
  alias __INSTALL_DIR__/;

  # set max upload size and increase upload timeout:
  client_max_body_size 10G;
  client_body_timeout 300s;
  fastcgi_buffers 64 4K;

  # Enable gzip but do not remove ETag headers
  gzip on;
  gzip_vary on;
  gzip_comp_level 4;
  gzip_min_length 256;
  gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
  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;

  # Pagespeed is not supported by Nextcloud, so if your server is built
  # with the `ngx_pagespeed` module, uncomment this line to disable it.
  #pagespeed off;

  # The settings allows you to optimize the HTTP2 bandwitdth.
  # See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/
  # for tunning hints
  client_body_buffer_size 512k;

  # HSTS settings
  # WARNING: Only add the preload option once you read about
  # the consequences in https://hstspreload.org/. This option
  # will add the domain to a hardcoded list that is shipped
  # in all major browsers and getting removed from this list
  # could take several months.
  #more_set_headers "Strict-Transport-Security: max-age=15768000; includeSubDomains; preload;";
  
  # HTTP response headers borrowed from Nextcloud `.htaccess`
  more_set_headers "Referrer-Policy: no-referrer";
  more_set_headers "X-Content-Type-Options: nosniff";
  more_set_headers "X-Frame-Options: SAMEORIGIN";
  more_set_headers "X-Permitted-Cross-Domain-Policies: none";
  more_set_headers "X-Robots-Tag: noindex, nofollow";

  # Remove X-Powered-By, which is an information leak
  fastcgi_hide_header X-Powered-By;

  # Specify how to handle directories -- specifying `/nextcloud/index.php$request_uri`
  # here as the fallback means that Nginx always exhibits the desired behaviour
  # when a client requests a path that corresponds to a directory that exists
  # on the server. In particular, if that directory contains an index.php file,
  # that file is correctly served; if it doesn't, then the request is passed to
  # the front-end controller. This consistent behaviour means that we don't need
  # to specify custom rules for certain paths (e.g. images and other assets,
  # `/updater`, `/ocs-provider`), and thus
  # `try_files $uri $uri/ /nextcloud/index.php$request_uri`
  # always provides the desired behaviour.
  index index.php index.html __PATH__/index.php$request_uri;

  # Rule borrowed from `.htaccess` to handle Microsoft DAV clients
  location = __PATH__/ {
      if ( $http_user_agent ~ ^DavClnt ) {
          return 302 __PATH__/remote.php/webdav/$is_args$args;
      }
  }

  location = __PATH__/robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  }
  
  # Rules borrowed from `.htaccess` to hide certain paths from clients
  location ~ ^__PATH__/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/)    { return 404; }
  location ~ ^__PATH__/(?:\.|autotest|occ|issue|indie|db_|console)                  { return 404; }

  # Ensure this block, which passes PHP files to the PHP process, is above the blocks
  # which handle static assets (as seen below). If this block is not declared first,
  # then Nginx will encounter an infinite rewriting loop when it prepends
  # `/nextcloud/index.php` to the URI, resulting in a HTTP 500 error response.
  location ~ \.php(?:$|/) {
    # Required for legacy support
    rewrite ^__PATH__/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) __PATH__/index.php$request_uri;
    set $path_info $fastcgi_path_info;
    
    try_files $fastcgi_script_name =404;
    fastcgi_param modHeadersAvailable true;         # Avoid sending the security headers twice
    fastcgi_param front_controller_active true;     # Enable pretty urls
    fastcgi_param HTTP_ACCEPT_ENCODING "";          # Disable encoding of Nextcloud response to inject ynh scripts
    fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock;
    include fastcgi_params_with_auth;
    
    fastcgi_intercept_errors on;
    fastcgi_request_buffering on; # Required as PHP-FPM does not support chunked transfer encoding and requires a valid ContentLength header.

    fastcgi_read_timeout 600;
    fastcgi_send_timeout 600;
    fastcgi_connect_timeout 600;
    proxy_connect_timeout 600;
    proxy_send_timeout 600;
    proxy_read_timeout 600;
    send_timeout 600;
  }

  location ~ ^__PATH__/(?:updater|ocs-provider)(?:$|/) {
       try_files $uri/ =404;
       index index.php;
  }

  # Serve static files
  location ~ \.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac|mp4|webm)$ {
    try_files $uri / __PATH__/index.php$request_uri;
    # Adapted from https://github.com/nextcloud/documentation/blob/master/admin_manual/installation/nginx-root.conf.sample
    # HTTP response headers borrowed from Nextcloud `.htaccess`
    more_set_headers "Cache-Control: public, max-age=15778463, immutable";
    more_set_headers "Referrer-Policy: no-referrer";
    more_set_headers "X-Content-Type-Options: nosniff";
    more_set_headers "X-Frame-Options: SAMEORIGIN";
    more_set_headers "X-Permitted-Cross-Domain-Policies: none";
    more_set_headers "X-Robots-Tag: noindex, nofollow";
    access_log off;   # Optional: Don't log access to assets
  }

  location ~ \.(otf|woff2?)$ {
    try_files $uri / __PATH__/index.php$request_uri;
    expires 7d;         # Cache-Control policy borrowed from `.htaccess`
    access_log off;     # Optional: Don't log access to assets
  }

  # Rule borrowed from `.htaccess`
  location __PATH__/remote {
    return 301 __PATH__/remote.php$request_uri;
  }

  location ~ ^__PATH__/ {
    if ($request_method ~ ^(PUT|DELETE|PATCH|PROPFIND|PROPPATCH)$) {
        rewrite ^ __PATH__/index.php$request_uri last;
    }
    try_files $uri / __PATH__/index.php$request_uri;
  }

  include conf.d/__DOMAIN__.d/__APP__.d/*.conf;
}


================================================
FILE: conf/notify_push.conf
================================================
location ^~ __PATH__/push/ {
   proxy_pass http://127.0.0.1:__PORT__/;
   include    proxy_params_no_auth;
}

================================================
FILE: conf/systemd.service
================================================
[Unit]
Description=Push daemon for Nextcloud clients
After=network.target nginx.service
Documentation = https://github.com/nextcloud/notify_push

[Service]
Type=notify
User=__APP__
Group=__APP__
Environment=PORT=__PORT__
Environment=ALLOW_SELF_SIGNED=true
RuntimeDirectory=__APP__
ExecStart=__INSTALL_DIR__/apps/notify_push/bin/__ARCH__/notify_push __INSTALL_DIR__/config/config.php
Restart=always
RestartSec=60

# Sandboxing options to harden security
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
RestrictNamespaces=yes
RestrictRealtime=yes
DevicePolicy=closed
ProtectClock=yes
ProtectHostname=yes
ProtectProc=invisible
ProtectSystem=full
ProtectControlGroups=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
LockPersonality=yes
SystemCallArchitectures=native
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap @cpu-emulation @privileged

# Denying access to capabilities that should not be relevant for webapps
# Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG

[Install]
WantedBy = multi-user.target

================================================
FILE: conf/watcher.path
================================================
[Unit]
Description=Restart Push daemon for Nextcloud clients when it receives updates
Documentation=https://github.com/nextcloud/notify_push
PartOf=__APP__-notify-push-watcher.service

[Path]
PathModified=/var/www/nextcloud/apps/notify_push/bin/__ARCH__/notify_push
Unit=__APP__-notify-push-watcher.service

[Install]
WantedBy=multi-user.target

================================================
FILE: conf/watcher.service
================================================
[Unit]
Description=Restart Push daemon for Nextcloud clients when it receives updates
Documentation=https://github.com/nextcloud/notify_push
#Requires=__APP__-notify-push.service
After=__APP__-notify-push.service
StartLimitIntervalSec=10
StartLimitBurst=5

[Service]
Type=oneshot
ExecStartPre=/usr/bin/chmod u+x __INSTALL_DIR__/apps/notify_push/bin/__ARCH__/notify_push
ExecStart=/usr/bin/systemctl restart __APP__-notify-push.service

[Install]
WantedBy=multi-user.target

================================================
FILE: config_panel.toml
================================================
version = "1.0"

[main]
name.en = "Nextcloud configuration"
name.fr = "Configuration de Nextcloud"

    [main.maintenance]
    name = "Maintenance"

        [main.maintenance.maintenance_mode]
        ask.en = "Enable maintenance mode"
        ask.fr = "Activer le mode maintenance"
        type = "boolean"
        default = false

    [main.permissions]
    name.en = "Permissions"
    name.fr = "Autorisations"

        [main.permissions.set_permissions_button]
        ask.en = "Reset permissions"
        ask.fr = "Redéfinir les autorisations"
        type = "button"
        style = "success"
        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."
        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."

    [main.addressbook]
    name.en = "Address book configuration"
    name.fr = "Configuration du carnet d'adresses"

        [main.addressbook.system_addressbook_exposed]
        ask.en = "Enable address book"
        ask.fr = "Activer le carnet d’adresses"
        type = "boolean"
        help.en = "Should there be a system address book listing all users, accessible by all users?"
        help.fr = "Devrait-il y avoir un carnet d’adresses système répertoriant tous les utilisateurs, accessible par tous les utilisateurs ?"

    [main.notify_push]
    name.en = "Notify Push configuration"
    name.fr = "Configuration Notification Push"

        [main.notify_push.enable_notify_push]
        ask.en = "Enable Notify Push"
        ask.fr = "Activer la Notification Push"
        type = "boolean"
        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."
        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."

    [main.forward_email]
    name.en = "Forward Email?"
    name.fr = "E-mails de transfert?"

        [main.forward_email.enable_forward_email]
        ask.en = "Set YunoHost user's forward email instead of YunoHost user's main email?"
        ask.fr = "Utiliser les e-mails de transfert des utilisateurs de YunoHost plutôt que les e-mails principaux ?"
        type = "boolean"
        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."
        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."


================================================
FILE: doc/ADMIN.md
================================================
### Manually running Nextcloud commands

You can run Nextcloud commands from the command line by opening a Nextcloud "shell" and running `php occ` directly:

```bash
sudo yunohost app shell __APP__
# You should then see you're in a shell with "__APP__@yourmachine"
php occ ...
```
Alternatively, you can run `sudo -u __APP__ php__PHP_VERSION__ --define apc.enable_cli=1 __INSTALL_DIR__/occ ...`

### Promoting a user to admin

In some cases, your user may not be a Nextcloud admin and therefore cannot access the admin panels from Nextcloud.

This user can be added to the Nextcloud admin group with : 

```bash
sudo yunohost app shell __APP__
# And then
php occ group:adduser admin <username>
```


================================================
FILE: doc/ADMIN_fr.md
================================================
### Exécuter manuellement des commandes Nextcloud

Vous pouvez lancer des commandes Nextcloud en ouvrant un "shell" Nextcloud et utiliser `php occ` directement:

```bash
sudo yunohost app shell __APP__
# Vous devriez voir que vous êtes dans un shell "__APP__@yourmachine"
php occ ...
```

Autrement, vous pouvez exécuter `sudo -u __APP__ php__PHP_VERSION__ --define apc.enable_cli=1 __INSTALL_DIR__/occ ...`

### Ajouter un compte aux admins de Nextcloud

Dans certains cas, votre compte n'est peut-être pas un admin de Nextcloud et ne peut donc pas accéder aux fonctionnalités admin.

Vous pouvez ajouter le comptes aux admins de Nextcloud avec:

```bash
sudo yunohost app shell __APP__
# Puis
php occ group:adduser admin <username>
```


================================================
FILE: doc/DESCRIPTION.md
================================================
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. 

In the context of YunoHost, Nextcloud integrates with the SSO/User Portal (YunoHost accounts are automatically connected to Nextcloud).

The `/.well-known` address will be automatically configured for CalDAV and CardDAV synchronization if no other service such as Baïkal is already using it.

The 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.

================================================
FILE: doc/DESCRIPTION_fr.md
================================================
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.

Dans le cadre de YunoHost, Nextcloud s'intègre avec le SSO/portail utilisateur (les comptes YunoHost sont automatiquements connectés à Nextcloud).

L'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à.

Le 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.


================================================
FILE: doc/POST_UPGRADE.md
================================================
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.


================================================
FILE: doc/POST_UPGRADE_fr.md
================================================
Notez que si vous avez installé des applications Nextcloud tierces, elles sont probablement désactivées et vous devrez les réactiver manuellement.

================================================
FILE: doc/PRE_UPGRADE.d/MAJOR_RELEASE.md
================================================
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.

Additionally, if you installed **specific Nextcloud apps**, we recommend **making sure that they are compatible with the new major version**.
YunoHost 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>  


* **Incompatible apps will cause the upgrade to fail.**
* 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>


================================================
FILE: hooks/post_user_create
================================================
#!/bin/bash

user="$1"
app="$(basename $0 | cut -d- -f 2-)" # Extract the app name from the script name, which is supposed to be something like "50-app_id"

setfacl --recursive --modify g:$app:rwX,d:g:$app:rwX /home/$user


================================================
FILE: hooks/post_user_delete
================================================
#!/bin/bash

source /usr/share/yunohost/helpers

user="$1"
app="$(basename $0 | cut -d- -f 2-)" # Extract the app name from the script name, which is supposed to be something like "50-app_id"
install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
php_version=$(ynh_app_setting_get --app=$app --key=php_version)

# Define a function to execute commands with `occ`
exec_occ() {
  (cd "$install_dir" && sudo -u $app \
      php${php_version} --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@")
}

exec_occ user:delete $user


================================================
FILE: manifest.toml
================================================
packaging_format = 2

id = "nextcloud"
name = "Nextcloud"
description.en = "Online storage, file sharing platform and various other applications"
description.fr = "Stockage en ligne, plateforme de partage de fichiers et diverses autres applications"

version = "33.0.2~ynh1"

maintainers = ["kay0u"]

[upstream]
license = "AGPL-3.0"
website = "https://nextcloud.com"
demo = "https://demo.nextcloud.com/"
admindoc = "https://docs.nextcloud.com/server/stable/admin_manual/"
userdoc = "https://docs.nextcloud.com/server/latest/user_manual/en/"
code = "https://github.com/nextcloud/server"
cpe = "cpe:2.3:a:nextcloud:nextcloud"

[integration]
yunohost = ">= 12.1.38"
helpers_version = "2.1"
architectures = ["amd64", "arm64", "armhf"]
multi_instance = true

ldap = true
sso = true

disk = "650M"
ram.build = "250M"
ram.runtime = "512M"

[install]
    [install.domain]
    type = "domain"

    [install.path]
    type = "path"
    default = "/nextcloud"

    [install.admin]
    type = "user"

    [install.init_main_permission]
    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."
    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."
    type = "group"
    default = "visitors"

    [install.user_home]
    ask.en = "Add the users' home directory in Nextcloud?"
    ask.fr = "Ajouter le dossier personnel des utilisateurs à Nextcloud ?"
    help.en = "If enabled, each `/home/$user` directory will be added to their respective user's Nextcloud."
    help.fr = "Si activé, le dossier `/home/$user` de chaque compte lui sera ajouté dans Nextcloud."
    type = "boolean"
    default = false

[resources]

    [resources.sources]

        [resources.sources.main]
        url = 'https://download.nextcloud.com/server/releases/nextcloud-33.0.2.tar.bz2'
        sha256 = '91257ab5002d5d09da8d09d80389983330351c5c00a7e3a25b177bcea81171cc'

        [resources.sources.32]
        url = 'https://download.nextcloud.com/server/releases/nextcloud-32.0.7.tar.bz2'
        sha256 = '450b4f2b26c83be4d7b8682229a7d868e2802fd54ae8f3ee6367618995637a76'
        prefetch = false
        
        [resources.sources.31]
        url = 'https://download.nextcloud.com/server/releases/nextcloud-31.0.13.tar.bz2'
        sha256 = '92df08369467e81c23d7fd997afb756eae44ce47eff0c85c5d4d27212ebe283e'
        prefetch = false

        [resources.sources.30]
        url = 'https://download.nextcloud.com/server/releases/nextcloud-30.0.15.tar.bz2'
        sha256 = 'f33552d3185e97ad1a5fe57a49fe2b55a361dc8e4f925fb12b592047d1f0e6a5'
        prefetch = false

        [resources.sources.29]
        url = 'https://download.nextcloud.com/server/releases/nextcloud-29.0.16.tar.bz2'
        sha256 = '499bf61ab19edcd4e542af86609243c5b4f440eb5bb06c2ba7da0c2faa525322'
        prefetch = false

        [resources.sources.28]
        url = 'https://download.nextcloud.com/server/releases/nextcloud-28.0.14.tar.bz2'
        sha256 = '4a937f1882486426c9703e59ec4b293f621be8d080b7f85016f629903c3af336'
        prefetch = false

        [resources.sources.27]
        url = 'https://download.nextcloud.com/server/releases/nextcloud-27.1.11.tar.bz2'
        sha256 = '4edd2570f4c83442f8f0f0616fb774ed2663b11cf9f6ea49e795ab43aeef9645'
        prefetch = false

        [resources.sources.26]
        url = 'https://download.nextcloud.com/server/releases/nextcloud-26.0.13.tar.bz2'
        sha256 = '0a362df7a1233348f99d1853fd7e79f0667b552c145dc45012fab54ac31c79ae'
        prefetch = false

        [resources.sources.25]
        url = 'https://download.nextcloud.com/server/releases/nextcloud-25.0.13.tar.bz2'
        sha256 = '387bac148a696244f1ec02698a082d408283a875b3de85eb9719dd4493eebe33'
        prefetch = false

        [resources.sources.24]
        url = 'https://download.nextcloud.com/server/releases/nextcloud-24.0.12.tar.bz2'
        sha256 = '2f093bdf7d34faf38d22f38a5e11f3aee32746ff4add3df17c790b9b36390836'
        prefetch = false

        [resources.sources.23]
        url = 'https://download.nextcloud.com/server/releases/nextcloud-23.0.12.tar.bz2'
        sha256 = 'ad3637fd987e9f1ed5bd5dbd177bdce1e39228e3daf95bc4a3c590d4b1522b1e'
        prefetch = false

    [resources.system_user]
    allow_email = true

    [resources.install_dir]
    group = "www-data:r-x"

    [resources.data_dir]
    subdirs = ["data"]

    [resources.permissions]
    main.url = "/"

    api.url = "re:__DOMAIN__\\/.well-known\\/.*"
    api.auth_header = false
    api.show_tile = false
    api.protected= true
    api.allowed = ["visitors", "all_users"]

    [resources.ports]

    [resources.apt]
    packages = [
        "imagemagick",
        "acl",
        "tar",
        "smbclient",
        "at",
        "mariadb-server",
        "redis-server",
        "php8.4-apcu",
        "php8.4-bcmath",
        "php8.4-bz2",
        "php8.4-curl",
        "php8.4-fpm",
        "php8.4-gd",
        "php8.4-gmp",
        "php8.4-igbinary",
        "php8.4-imagick",
        "php8.4-imap",
        "php8.4-intl",
        "php8.4-ldap",
        "php8.4-mbstring",
        "php8.4-mysql",
        "php8.4-redis",
        "php8.4-sqlite3",
        "php8.4-xml",
        "php8.4-zip",
        "php8.4-smbclient",
    ]

    packages_from_raw_bash = """
        case $YNH_DEBIAN_VERSION in
            bullseye)   echo libmagickcore-6.q16-6-extra ;;
            bookworm)   echo libmagickcore-6.q16-6-extra ;;
            trixie)     echo libmagickcore-7.q16-10-extra ;;
        esac
    """

    [resources.database]
    type = "mysql"


================================================
FILE: patches/30/00-add-logout_url-conf.patch
================================================
diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php
index d4d6a17db79..f587f805683 100644
--- a/core/Controller/LoginController.php
+++ b/core/Controller/LoginController.php
@@ -75,15 +75,21 @@ class LoginController extends Controller {
 	#[FrontpageRoute(verb: 'GET', url: '/logout')]
 	public function logout() {
 		$loginToken = $this->request->getCookie('nc_token');
+		$uuidUser = $this->userSession->getUser()->getUID();
+		$isLdapUser = $this->config->getUserValue($uuidUser, 'user_ldap', 'uid');
 		if (!is_null($loginToken)) {
-			$this->config->deleteUserValue($this->userSession->getUser()->getUID(), 'login_token', $loginToken);
+			$this->config->deleteUserValue($uuidUser, 'login_token', $loginToken);
 		}
 		$this->userSession->logout();
 
-		$response = new RedirectResponse($this->urlGenerator->linkToRouteAbsolute(
+		$redirectUrl = $this->urlGenerator->linkToRouteAbsolute(
 			'core.login.showLoginForm',
-			['clear' => true] // this param the code in login.js may be removed when the "Clear-Site-Data" is working in the browsers
-		));
+			['clear' => true] // this param the code in login.js may be removed when the "Clear-Site-Data" is working in the browsers)
+		);
+		if (!is_null($isLdapUser)) {
+			$redirectUrl = $this->config->getSystemValue('logout_url', $redirectUrl);
+		}
+		$response = new RedirectResponse($redirectUrl);
 
 		$this->session->set('clearingExecutionContexts', '1');
 		$this->session->close();


================================================
FILE: patches/main/00-add-logout_url-conf.patch
================================================
diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php
index 1a105130..9a51f8d9 100644
--- a/core/Controller/LoginController.php
+++ b/core/Controller/LoginController.php
@@ -80,15 +80,22 @@ class LoginController extends Controller {
 	public function logout() {
 		$loginToken = $this->request->getCookie('nc_token');
 		$uid = $this->userSession->getUser()?->getUID();
+		$isLdapUser = $this->config->getUserValue($uid, 'user_ldap', 'uid');
 		if ($loginToken !== null && $uid !== null) {
 			$this->config->deleteUserValue($uid, 'login_token', $loginToken);
 		}
 		$this->userSession->logout();
 
-		$response = new RedirectResponse($this->urlGenerator->linkToRouteAbsolute(
+		$redirectUrl = $this->urlGenerator->linkToRouteAbsolute(
 			'core.login.showLoginForm',
 			['clear' => true] // this param the code in login.js may be removed when the "Clear-Site-Data" is working in the browsers
-		));
+		);
+
+		if (!is_null($isLdapUser)) {
+			$redirectUrl = $this->config->getSystemValue('logout_url', $redirectUrl);
+		}
+
+		$response = new RedirectResponse($redirectUrl);
 
 		$this->session->set('clearingExecutionContexts', '1');
 		$this->session->close();



================================================
FILE: scripts/_common.sh
================================================
#!/bin/bash

#=================================================
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================

# Define a function to execute commands with `occ`
exec_occ() {
  (cd "$install_dir" && ynh_exec_as_app \
      php${php_version} --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@")
}

wait_nginx_reload() {
    # NGINX may take some time to support the new configuration,
    # wait for the Nextcloud configuration file to disappear from NGINX before checking the CalDAV/CardDAV URL.
    timeout=30
    for i in $(seq 1 $timeout); do
        if ! ynh_hide_warnings nginx -T | grep --quiet "# configuration file /etc/nginx/conf.d/$domain.d/$app.conf:"; then
            break
        fi
        sleep 1
    done
    # Wait untils NGINX has fully reloaded (avoid cURL fail with http2)

    sleep 2
}

# Check if an URL is already handled
# usage: is_url_handled --domain=DOMAIN --path=PATH_URI
is_url_handled() {
    # Declare an array to define the options of this helper.
    local legacy_args=dp
    declare -Ar args_array=( [d]=domain= [p]=path= )
    local domain
    local path
    # Manage arguments with getopts
    ynh_handle_getopts_args "$@"

    # Try to get the URL with cURL, and keep the http code and an eventual redirection URL.
    local curl_output="$(curl --insecure --silent --output /dev/null \
      --write-out '%{http_code};%{redirect_url}' https://127.0.0.1$path --header "Host: $domain" --resolve $domain:443:127.0.0.1)"

    # Cut the output and keep only the first part to keep the http code
    local http_code="${curl_output%%;*}"
    # Do the same thing but keep the second part, the redirection URL
    local redirection="${curl_output#*;}"

    # Return 1 if the URL isn't handled.
    # Which means either cURL got a 404 (or the admin) or the SSO.
    # A handled URL should redirect to a publicly accessible URL.
    # Return 1 if the URL has returned 404
    if [ "$http_code" = "404" ] || [[ $redirection =~ "/yunohost/admin" ]]; then
        return 1
    # Return 1 if the URL is redirected to the SSO
    elif [[ $redirection =~ "/yunohost/sso" ]]; then
        return 1
    fi
}


================================================
FILE: scripts/backup
================================================
#!/bin/bash

source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers

ynh_print_info "Declaring files to be backed up..."

#=================================================
# BACKUP THE APP MAIN DIR
#=================================================

ynh_backup "$install_dir"

#=================================================
# BACKUP THE DATA DIRECTORY
#=================================================

ynh_backup "$data_dir"

#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================

ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf"

ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.d"

ynh_backup "/etc/logrotate.d/$app"

ynh_backup "/etc/fail2ban/jail.d/$app.conf"
ynh_backup "/etc/fail2ban/filter.d/$app.conf"

#=================================================
# BACKUP VARIOUS FILES
#=================================================

ynh_backup "/etc/cron.d/$app"

ynh_backup "/var/log/$app"

#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info "Backing up the MySQL database..."

ynh_mysql_dump_db > db.sql

#=================================================
# BACKUP THE NOTIFY_PUSH APP
#=================================================

if [ $enable_notify_push -eq 1 ]
then
    ynh_backup "/etc/systemd/system/${app}-notify-push.service"
    ynh_backup "/etc/systemd/system/${app}-notify-push-watcher.service"
    ynh_backup "/etc/systemd/system/${app}-notify-push-watcher.path"
fi

#=================================================
# END OF SCRIPT
#=================================================

ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."


================================================
FILE: scripts/change_url
================================================
#!/bin/bash

source _common.sh
source /usr/share/yunohost/helpers

#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression "Updating NGINX web server configuration..."

if [ $change_domain -eq 1 ]
then
    # Check if .well-known is available for this domain
    if is_url_handled --domain="$new_domain" --path="/.well-known/caldav" || is_url_handled --domain="$new_domain" --path="/.well-known/carddav"
    then
        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."

        # Remove lines about .well-known/carddav and caldav with sed.
        sed --in-place --regexp-extended '/location = \/\.well\-known\/(caldav|carddav)/d' "/etc/nginx/conf.d/$domain.d/$app.conf"
        ynh_store_file_checksum "/etc/nginx/conf.d/$domain.d/$app.conf"
    fi
fi

ynh_config_change_url_nginx

#=================================================
# SPECIFIC MODIFICATIONS
#=================================================
ynh_script_progression "Applying $app specific modifications..."

if [ $change_domain -eq 1 ]
then
    # Change the trusted domain
    exec_occ config:system:set trusted_domains 1 --value=$new_domain

    # Change hostname for activity notifications
    exec_occ config:system:set overwrite.cli.url --value="https://${new_domain}${new_path}"

    # Reload PHP-FPM, necessary for force Nextcloud to re-read config.php, cf opcache.revalidate_freq
    ynh_systemctl --service=php${php_version}-fpm --action=reload

    mv /etc/nginx/conf.d/$old_domain.d/$app.d /etc/nginx/conf.d/$new_domain.d/$app.d
fi

#=================================================
# CONFIGURE NOTIFY_PUSH APP
#=================================================

if [ $enable_notify_push -eq 1 ]
then
    ynh_config_add --template="notify_push.conf" --destination="/etc/nginx/conf.d/$new_domain.d/$app.d/notify_push.conf"

    ynh_systemctl --service=nginx --action=reload

    case $YNH_ARCH in
        amd64) arch="x86_64";;
        arm64) arch="aarch64";;
        armel|armhf) arch="armv7";;
    esac

    ynh_config_add --template="watcher.path" --destination="/etc/systemd/system/${app}-notify-push-watcher.path"
    ynh_config_add_systemd --service="${app}-notify-push-watcher" --template="watcher.service"
    systemctl enable --now ${app}-notify-push-watcher.path
    ynh_config_add_systemd --service="${app}-notify-push"

    count=0
    while ! exec_occ $install_dir/cron.php && [[ $count -lt 30 ]]
    do
        sleep 1
        count=$((count + 1))
    done

    ynh_systemctl --service="${app}-notify-push" --action=restart --log_path="systemd" --wait_until="Push daemon for Nextcloud clients."

    exec_occ config:app:set notify_push base_endpoint --value=https://$new_domain${new_path%/}/push

    if ! exec_occ notify_push:self-test; then
        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."
    fi
fi

#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression "Reloading NGINX web server..."

# Temporary fix for the API permission (workaround for https://github.com/YunoHost/issues/issues/2294 )
ynh_permission_url --permission="api" --url="re:$new_domain\/.well-known\/.*" --auth_header="false" --clear_urls

ynh_systemctl --service=nginx --action=reload

#=================================================
# END OF SCRIPT
#=================================================

ynh_script_progression "Change of URL completed for $app"


================================================
FILE: scripts/config
================================================
#!/bin/bash

source _common.sh
source /usr/share/yunohost/helpers

#=================================================
# RETRIEVE ARGUMENTS
#=================================================

php_version=$(ynh_app_setting_get --key=php_version)

#=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY
#=================================================

get__maintenance_mode() {
    # Maintenance mode status
    maintenance_mode_status="$(cd "$install_dir" && exec_occ maintenance:mode 2> /dev/null)"
    if echo $maintenance_mode_status | grep -q "disabled"
    then
        echo "0"
    elif echo $maintenance_mode_status | grep -q "enabled"
    then
        echo "1"
    else
        ynh_print_warn "Unexpected output from maintenance status check command."
        exit 0
    fi
}

get__system_addressbook_exposed() {
	echo $(exec_occ config:app:get dav system_addressbook_exposed)
}

get__enable_forward_email() {
    ldapEmail=$(exec_occ config:app:get user_ldap "${ldap_config_prefix:-}"ldap_email_attr)
    if [ "$ldapEmail" = "maildrop" ]
    then
        echo "1"
    else
        echo "0"
    fi
}

#=================================================
# SPECIFIC SETTERS FOR TOML SHORT KEYS
#=================================================

set__maintenance_mode() {
    if [ $maintenance_mode -eq 0 ]; then
        # If maintenance_mode was set to 0, disable maintenance mode
        exec_occ maintenance:mode --off
        ynh_print_info "Maintenance mode disabled"
    elif [ $maintenance_mode -eq 1 ]; then
        # If maintenance_mode was set to 1, enable maintenance mode
        exec_occ maintenance:mode --on
        ynh_print_info "Maintenance mode enabled"
    fi
    ynh_app_setting_set --key=maintenance_mode --value="$maintenance_mode"
}

set__system_addressbook_exposed() {
	exec_occ config:app:set dav system_addressbook_exposed --value="$system_addressbook_exposed"
	ynh_print_info "System addressbook is exposed: $system_addressbook_exposed"
}

set__enable_notify_push() {
    if [ $enable_notify_push -eq 0 ]; then
        nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
        ynh_safe_rm "$nginx_extra_conf_dir/notify_push.conf"
        ynh_systemctl --service="nginx" --action=reload

        # If notify_push is enabled, disable it
        if exec_occ app:list | awk '/Enabled/{f=1;next} f' | grep -q -w notify_push; then
            exec_occ app:disable notify_push
        fi

        ynh_config_remove_systemd "${app}-notify-push"
        systemctl disable --now "${app}-notify-push-watcher.path"
        ynh_safe_rm "/etc/systemd/system/${app}-notify-push-watcher.path"
        ynh_config_remove_systemd "${app}-notify-push-watcher"

        ynh_print_info "Notify push disabled"
    elif [ $enable_notify_push -eq 1 ]; then
        nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
        mkdir -p "$nginx_extra_conf_dir"

        ynh_config_add --template="notify_push.conf" --destination="$nginx_extra_conf_dir/notify_push.conf"

        ynh_systemctl --service="nginx" --action=reload

        # If notify_push is disabled, reenable it
        if exec_occ app:list | awk '/Disabled/{f=1;next} f' | grep -q -w notify_push; then
            exec_occ app:enable notify_push
        # If notify_push is not installed, install it
        elif ! exec_occ app:list | awk '/Enabled/{f=1;next} /Disabled/{f=0} f' | grep -q -w notify_push; then
            exec_occ app:install notify_push
        fi
        exec_occ config:app:set notify_push base_endpoint --value=https://$domain${path_url%/}/push

        mkdir -p /var/run/$app/
        chown $app: /var/run/$app/

        case $YNH_ARCH in
            amd64) arch="x86_64";;
            arm64) arch="aarch64";;
            armel|armhf) arch="armv7";;
        esac

        ynh_config_add --template="watcher.path" --destination="/etc/systemd/system/${app}-notify-push-watcher.path"
        ynh_config_add_systemd --service="${app}-notify-push-watcher" --template="watcher.service"
        systemctl enable --now ${app}-notify-push-watcher.path
        ynh_config_add_systemd --service="${app}-notify-push"

        count=0

        while ! exec_occ $install_dir/cron.php && [[ $count -lt 30 ]]
        do
            sleep 1
            count=$((count + 1))
        done

        ynh_systemctl --service="${app}-notify-push-watcher" --action=restart
        ynh_systemctl --service="${app}-notify-push" --action=restart --log_path="systemd" --wait_until="Push daemon for Nextcloud clients."

        if ! exec_occ notify_push:self-test; then
            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."
        fi
        ynh_print_info "Notify push enabled"
    fi
    ynh_app_setting_set --key=enable_notify_push --value="$enable_notify_push"
}

set__enable_forward_email() {

    if [ $enable_forward_email -eq 0 ]; then
        exec_occ ldap:set-config "${ldap_config_prefix:-}" ldapEmailAttribute "mail"
    elif [ $enable_forward_email -eq 1 ]; then
        exec_occ ldap:set-config "${ldap_config_prefix:-}" ldapEmailAttribute "maildrop"
    fi
}

#=================================================
# SPECIFIC RUNNERS FOR TOML SHORT KEYS
#=================================================

function run__set_permissions_button() {
    local data_dir=$(ynh_app_setting_get --key=data_dir)
    ynh_print_info "Set permissions, it may take some time..."
    chown -R $app:www-data "$install_dir"
    chown -R $app: "$data_dir"
    find $install_dir/ -type f -print0 | xargs -r0 chmod 0644
    find $install_dir/ -type d -print0 | xargs -r0 chmod 0755
    find $data_dir/data/ -type f -print0 | xargs -r0 chmod 0640
    find $data_dir/data/ -type d -print0 | xargs -r0 chmod 0750
    chmod 640 "$install_dir/config/config.php"
    chmod 755 /home/yunohost.app
    chmod 750 $install_dir
}

#=================================================

ynh_app_config_apply() {
    _ynh_app_config_apply

    ynh_config_add_phpfpm
}

ynh_app_config_run $1


================================================
FILE: scripts/install
================================================
#!/bin/bash

source _common.sh
source /usr/share/yunohost/helpers

#=================================================
# INITIALIZE AND STORE SETTINGS
#=================================================

ynh_app_setting_set_default --key=php_upload_max_filesize --value=10G
ynh_app_setting_set_default --key=php_memory_limit --value=512M

ynh_app_setting_set_default --key=enable_notify_push --value=0

phpflags="--define apc.enable_cli=1"
ynh_app_setting_set --key=phpflags --value="$phpflags"

ldap_email_attr="mail"

#=================================================
# CREATE A MYSQL DATABASE
#=================================================
ynh_script_progression "Migrate MySQL database to utf8..."

ynh_mysql_db_shell <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"

#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression "Setting up source files..."

# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"

#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression "Configuring PHP-FPM..."

ynh_config_add_phpfpm

#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression "Configuring NGINX web server..."

# Check if .well-known is available for this domain
if is_url_handled --domain="$domain" --path="/.well-known/caldav" || is_url_handled --domain="$domain" --path="/.well-known/carddav"
then
    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."

    # Remove lines about .well-known/carddav and caldav with sed.
    sed --in-place --regexp-extended '/location = \/\.well\-known\/(caldav|carddav)/d' "../conf/nginx.conf"
fi

nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
mkdir -p "$nginx_extra_conf_dir"

if [ $enable_notify_push -eq 1 ]
then
    ynh_config_add --template="notify_push.conf" --destination="$nginx_extra_conf_dir/notify_push.conf"
fi

ynh_config_add_nginx

#=================================================
# INSTALL NEXTCLOUD
#=================================================
ynh_script_progression "Installing $app..."

# Set write access for the following commands
chown -R $app:www-data "$install_dir"
chown -R $app: "$data_dir"

# Define password in an intermediate var
# The fact that it's called _password allows it to be
# picked up by YunoHost's auto-redact mecanism
admin_password="$(ynh_string_random --length=6)"

# Install Nextcloud using a temporary admin user
exec_occ maintenance:install \
    --database "mysql" --database-name $db_name \
    --database-user $db_user --database-pass "$db_pwd" \
    --admin-user "admin" --admin-pass "$admin_password" \
    --data-dir "$data_dir/data" \
    || ynh_die "Unable to install $app"

#=================================================
# CONFIGURE NEXTCLOUD
#=================================================
ynh_script_progression "Configuring $app..."

# Set the mysql.utf8mb4 config to true in config.php
exec_occ config:system:set mysql.utf8mb4 --type=boolean --value="true"

# move the logs from the data_dir to the standard /var/log
exec_occ config:system:set logfile --value="/var/log/$app/nextcloud.log"

# Ensure that UpdateNotification app is disabled
exec_occ app:disable updatenotification

# Enable LDAP plugin
exec_occ app:enable user_ldap
ldap_config_prefix=$(exec_occ ldap:create-empty-config --only-print-prefix)
ynh_app_setting_set --key=ldap_config_prefix --value="$ldap_config_prefix"

# Load the installation config file in Nextcloud
ynh_config_add --template="config_install.json" --destination="$install_dir/config_install.json"

exec_occ config:import "$install_dir/config_install.json"

# Then remove the config file
ynh_safe_rm "$install_dir/config_install.json"

# Load the additional config file (used also for upgrade)
ynh_config_add --template="config.json" --destination="$install_dir/config.json"

exec_occ config:import "$install_dir/config.json"

# Then remove the config file
ynh_safe_rm "$install_dir/config.json"

#=================================================
# CHECK THE LDAP CONFIG
#=================================================

# Check LDAP configuration to see if everything worked well
exec_occ ldap:test-config "$ldap_config_prefix" || ynh_die "An error occured during LDAP configuration"

#=================================================
# MOUNT HOME FOLDERS AS EXTERNAL STORAGE
#=================================================

# Define a function to add an external storage
# Create the external storage for the given folders and enable sharing
create_external_storage() {
  local mount_dir="$1"
  local mount_name="$2"
  local mount_id=`exec_occ files_external:create --output=json \
      "$mount_name" 'local' 'null::null' -c "datadir=$mount_dir" || true`
  ! [[ $mount_id =~ ^[0-9]+$ ]] \
      && ynh_print_warn "Unable to create external storage" \
      || exec_occ files_external:option "$mount_id" enable_sharing true
}

# Enable External Storage and create local mount to home folder
if [ $user_home -eq 1 ]
then
    exec_occ app:enable files_external
    create_external_storage "/home/\$user" "Home"
    # Iterate over users to extend their home folder permissions
    for u in $(ynh_user_list); do
        setfacl --recursive --modify g:$app:rwX,d:g:$app:rwX "/home/$u" || true
    done
fi

#=================================================
# ALLOW USERS TO DISCONNECT FROM NEXTCLOUD
#=================================================

# Add dynamic logout URL to the config
url_base64="$(echo -n "https://$domain$path" | base64)"
exec_occ config:system:get logout_url >/dev/null 2>&1 \
  || echo "
//-YunoHost-
// set logout_url according to main domain
\$main_domain = exec('cat /etc/yunohost/current_host');
\$CONFIG['logout_url'] = 'https://'.\$main_domain.'/yunohost/sso/?action=logout&r=${url_base64}';
//-YunoHost-
" >> "$install_dir/config/config.php"

#=================================================
# CHANGE HOSTNAME FOR ACTIVITY NOTIFICATIONS
#=================================================

exec_occ config:system:set overwrite.cli.url --value="https://${domain}${path}"

#=================================================
# REMOVE THE TEMPORARY ADMIN AND SET THE TRUE ONE
#=================================================

# Set the user as admin
ynh_mysql_db_shell <<< "INSERT INTO oc_group_user VALUES ('admin','$admin');"

# And delete admin user
exec_occ user:delete admin

#=================================================
# ENABLE OR DISABLE SYSTEM ADDRESS BOOK
#=================================================

# Disabled by default on install, can be enabled in config panel
exec_occ config:app:set dav system_addressbook_exposed --value="0"

#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================

# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$install_dir/config/config.php"

#=================================================
# CONFIGURE NOTIFY_PUSH APP
#=================================================

if [ $enable_notify_push -eq 1 ]
then
    exec_occ app:install notify_push
    exec_occ config:app:set notify_push base_endpoint --value=https://$domain${path_url%/}/push

    mkdir -p /var/run/$app/
    chown $app: /var/run/$app/

    case $YNH_ARCH in
        amd64) arch="x86_64";;
        arm64) arch="aarch64";;
        armel|armhf) arch="armv7";;
    esac

    ynh_config_add --template="watcher.path" --destination="/etc/systemd/system/${app}-notify-push-watcher.path"
    ynh_config_add_systemd --service="${app}-notify-push-watcher" --template="watcher.service"
    systemctl enable --now --quiet ${app}-notify-push-watcher.path
    ynh_config_add_systemd --service="${app}-notify-push"
fi

#=================================================
# ADD A CRON JOB
#=================================================

ynh_config_add --template="nextcloud.cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"

exec_occ background:cron

#=================================================
# POST-INSTALL MAINTENANCE
#=================================================

exec_occ db:add-missing-indices
exec_occ db:add-missing-columns
exec_occ db:convert-filecache-bigint -n

#=================================================
# YUNOHOST MULTIMEDIA INTEGRATION
#=================================================
ynh_script_progression "Adding multimedia directories..."

# Build YunoHost multimedia directories
ynh_multimedia_build_main_dir

# Mount the user directory in Nextcloud
exec_occ app:enable files_external
create_external_storage "/home/yunohost.multimedia/\$user" "Multimedia"
create_external_storage "/home/yunohost.multimedia/share" "Shared multimedia"

# Allow nextcloud to write into these directories
ynh_multimedia_addaccess $app

#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================

# Fix app ownerships & permissions
chown -R $app:www-data "$install_dir"
chown -R $app: "$data_dir"
find $install_dir/ -type f -print0 | xargs -r0 chmod 0644
find $install_dir/ -type d -print0 | xargs -r0 chmod 0755
find $data_dir/data/ -type f -print0 | xargs -r0 chmod 0640
find $data_dir/data/ -type d -print0 | xargs -r0 chmod 0750
chmod 600 "$install_dir/config/config.php"
chmod 755 /home/yunohost.app
chmod 750 $install_dir

#=================================================
# SETUP LOGROTATE
#=================================================
ynh_script_progression "Configuring log rotation..."

ynh_config_add_logrotate

#=================================================
# SETUP FAIL2BAN
#=================================================
ynh_script_progression "Configuring Fail2Ban..."

# Create a dedicated Fail2Ban config
ynh_config_add_fail2ban --logpath="/var/log/$app/nextcloud.log"

#=================================================
# CHECK IF NOTIFY_PUSH WORKS
#=================================================

if [ $enable_notify_push -eq 1 ]
then
    count=0
    while ! exec_occ $install_dir/cron.php && [[ $count -lt 30 ]]
    do
        sleep 1
        count=$((count + 1))
    done

    ynh_systemctl --service="${app}-notify-push-watcher" --action=restart
    ynh_systemctl --service="${app}-notify-push" --action=restart --log_path="systemd" --wait_until="Push daemon for Nextcloud clients."

    if ! exec_occ notify_push:self-test; then
        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."
    fi
fi

#=================================================
# END OF SCRIPT
#=================================================

ynh_script_progression "Installation of $app completed"


================================================
FILE: scripts/remove
================================================
#!/bin/bash

source _common.sh
source /usr/share/yunohost/helpers

#=================================================
# REMOVE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression "Removing system configurations related to $app..."

ynh_config_remove_fail2ban

ynh_config_remove_logrotate

ynh_config_remove_nginx
ynh_safe_rm "/etc/nginx/conf.d/$domain.d/$app.d"

ynh_config_remove_phpfpm

# Remove notify push
if [ $enable_notify_push -eq 1 ]; then
  ynh_config_remove_systemd "${app}-notify-push"
  systemctl disable --now --quiet ${app}-notify-push-watcher.path
  ynh_safe_rm "/etc/systemd/system/${app}-notify-push-watcher.path"
  ynh_config_remove_systemd "${app}-notify-push-watcher"
fi

# Remove a cron file
# TODO: Ensure that cron job is not running (How !?)
ynh_safe_rm "/etc/cron.d/$app"

# Cleaning ACL in home directories
for path in /home/*; do
  # Clean ACL in every directories in /home, except those which start with 'yunohost.'
  [[ ! $path == /home/yunohost.* ]] \
    && setfacl --recursive --remove g:$app,d:g:$app -- "$path" 2>&1
done

#=================================================
# END OF SCRIPT
#=================================================

ynh_script_progression "Removal of $app completed"


================================================
FILE: scripts/restore
================================================
#!/bin/bash

source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers

#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression "Restoring the app main directory..."

ynh_restore "$install_dir"

#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression "Restoring data directory..."

ynh_restore "$data_dir"

#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression "Restoring the MySQL database..."

ynh_mysql_db_shell < ./db.sql

#=================================================
# RESTORE SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression "Restoring system configurations related to $app..."

ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf"

ynh_config_add_phpfpm

ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.d"

# Check if .well-known is available for this domain
if is_url_handled --domain="$domain" --path="/.well-known/caldav" || is_url_handled --domain="$domain" --path="/.well-known/carddav"
then
    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."

    # Remove lines about .well-known/CardDAV and CalDAV with sed.
    sed --in-place --regexp-extended '/location = \/\.well\-known\/(caldav|carddav)/d' "/etc/nginx/conf.d/$domain.d/$app.conf"
fi

#=================================================
# RESTORE VARIOUS FILES
#=================================================

ynh_restore "/etc/cron.d/$app"

ynh_restore "/var/log/$app"

ynh_restore "/etc/logrotate.d/$app"

#=================================================
# RESTORE USER RIGHTS
#=================================================

# Fix app ownerships & permissions
chown -R $app:www-data "$install_dir"
chown -R $app: "$data_dir"
find $install_dir/ -type f -print0 | xargs -r0 chmod 0644
find $install_dir/ -type d -print0 | xargs -r0 chmod 0755
find $data_dir/data/ -type f -print0 | xargs -r0 chmod 0640
find $data_dir/data/ -type d -print0 | xargs -r0 chmod 0750
chmod 600 "$install_dir/config/config.php"
chmod 755 /home/yunohost.app
chmod 750 $install_dir

# Iterate over users to extend their home folder permissions - for the external
# storage plugin usage - and create relevant Nextcloud directories
for u in $(ynh_user_list); do
    setfacl --recursive --modify g:$app:rwX,d:g:$app:rwX "/home/$u" || true
done

#=================================================
# YUNOHOST MULTIMEDIA INTEGRATION
#=================================================
ynh_script_progression "Adding multimedia directories..."

# Build YunoHost multimedia directories
ynh_multimedia_build_main_dir
# Allow nextcloud to write into these directories
ynh_multimedia_addaccess $app

#=================================================
# RESTORE THE FAIL2BAN CONFIGURATION
#=================================================
ynh_script_progression "Restoring the Fail2Ban configuration..."

ynh_restore "/etc/fail2ban/jail.d/$app.conf"
ynh_restore "/etc/fail2ban/filter.d/$app.conf"

# Make sure a log file exists (mostly for CI tests)
logfile="/var/log/$app/nextcloud.log"
if [ ! -f "$logfile" ]; then
	touch "$logfile"
	chown "$app:" "$logfile"
fi

ynh_systemctl --action=restart --service=fail2ban

#=================================================
# RESTORE THE NOTIFY_PUSH APP
#=================================================

if [ $enable_notify_push -eq 1 ]
then
    ynh_restore "/etc/systemd/system/${app}-notify-push.service"
    ynh_restore "/etc/systemd/system/${app}-notify-push-watcher.service"
    ynh_restore "/etc/systemd/system/${app}-notify-push-watcher.path"

    systemctl enable --now "${app}-notify-push-watcher.service" --quiet
    systemctl enable --now "${app}-notify-push-watcher.path" --quiet
    systemctl enable --now "${app}-notify-push.service" --quiet
fi

#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression "Reloading NGINX web server..."

ynh_systemctl --service=nginx --action=reload

#=================================================
# CHECK IF NOTIFY_PUSH WORKS
#=================================================

if [ $enable_notify_push -eq 1 ]
then
    count=0
    while ! exec_occ $install_dir/cron.php && [[ $count -lt 30 ]]
    do
        sleep 1
        count=$((count + 1))
    done

    ynh_systemctl --service="${app}-notify-push-watcher" --action=restart
    ynh_systemctl --service="${app}-notify-push" --action=restart --log_path="systemd" --wait_until="Push daemon for Nextcloud clients."

    if ! exec_occ notify_push:self-test; then
        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."
    fi
fi

#=================================================
# END OF SCRIPT
#=================================================

ynh_script_progression "Restoration completed for $app"


================================================
FILE: scripts/upgrade
================================================
#!/bin/bash

source _common.sh
source /usr/share/yunohost/helpers

#=================================================
# ENSURE DOWNWARD COMPATIBILITY
#=================================================
ynh_script_progression "Ensuring downward compatibility..."

ynh_app_setting_set_default --key=php_upload_max_filesize --value=10G
ynh_app_setting_set_default --key=php_memory_limit --value=512M

ynh_app_setting_set_default --key=enable_notify_push --value=0

# Remove the option backup_core_only if it's in the settings.yml file
ynh_app_setting_delete --key=backup_core_only

phpflags="--define apc.enable_cli=1"
ynh_app_setting_set --key=phpflags --value="$phpflags"

if ynh_app_upgrading_from_version_before 22.2~ynh1
then
    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"
fi

#=================================================
# MAKE SEQUENTIAL UPGRADES FROM EACH MAJOR
# VERSION TO THE NEXT ONE
#=================================================

filter_boring_occ_warnings() {
    # Filter stupid and boring messages such as the progress bar looking like:
    # 3/3 [============================] 100% Starting ...
    # and being pretty much useless, as well as the annoying warning about "only a limited number of commands" etc...

    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'
}

# Define a function to execute commands with `occ`
exec_occ() {
    # Backward compatibility to upgrade from older versions
    if [ $current_major_version -ge 33 ]
    then
        NEXTCLOUD_PHP_VERSION="8.4"
    elif [ $current_major_version -ge 30 ]
    then
        NEXTCLOUD_PHP_VERSION="8.3"
    elif [ $current_major_version -ge 26 ]
    then
        NEXTCLOUD_PHP_VERSION="8.2"
    elif [ $current_major_version -ge 24 ]
    then
        NEXTCLOUD_PHP_VERSION="8.1"
    else
        NEXTCLOUD_PHP_VERSION="7.4"
    fi

    # NB: be super careful when designing this part of the code, because calling ynh_apt_install_dependencies
    # will do magic regarding php configuration and $php_version when the php version of the dependencies changes ...
    php_version=$(ynh_app_setting_get --key=php_version)
    if [[ "$NEXTCLOUD_PHP_VERSION" != "$php_version" ]]; then
        local pkg_dependencies="$(dpkg-query --show --showformat='${Depends}' ${app//_/-}-ynh-deps)"
        pkg_dependencies="${pkg_dependencies//$php_version/$NEXTCLOUD_PHP_VERSION}"
        # Packaging v1 ~legacy : ynh_apt_install_dependencies is designed to be called several times
        # but the second time it will *append* the list of dependencies rather than replace the existing dependencies
        # resulting in a crash when parsing what's the php version the app uses, hence we need to force the full-replacement
        YNH_INSTALL_APP_DEPENDENCIES_REPLACE=true
        ynh_apt_install_dependencies "$pkg_dependencies"
    fi

(cd "$install_dir" && ynh_exec_as_app \
    php$NEXTCLOUD_PHP_VERSION --define apc.enable_cli=1 occ --no-interaction --no-ansi "$@") 2> >(filter_boring_occ_warnings >&2)
}

# Define a function to add an external storage
# Create the external storage for the given folders and enable sharing
create_external_storage() {
    local mount_dir="$1"
    local mount_name="$2"
    local mount_id=$(exec_occ files_external:create --output=json \
        "$mount_name" 'local' 'null::null' -c "datadir=$mount_dir" || true)
    ! [[ $mount_id =~ ^[0-9]+$ ]] \
        && ynh_print_warn "Unable to create external storage" \
        || exec_occ files_external:option "$mount_id" enable_sharing true
}

function list_installed_apps_not_compatible_with_future_version()
{
    local nextcloud_destination_version="$1"
    local nextcloud_current_version="$(grep OC_VersionString "$install_dir/version.php" | cut -d\' -f2)"
    local installed_apps=$(mktemp)
    local core_apps_in_current_version=$(mktemp)
    local nextcloud_destination_appcatalog=$(mktemp)

    # Run a first "dummy" command just to make sure we have the appropriate php dependencies installed,
    # otherwise this creates funky stuff when tweaking the apt deps because the next command is piped into jq ...
    exec_occ -V >/dev/null
    # List installed apps
    exec_occ app:list --output json | jq -r ".enabled | keys[]" | sort > $installed_apps
    # Fetch Nextcloud list of core apps from their github repo for the current version
    curl -s https://raw.githubusercontent.com/nextcloud/server/v$nextcloud_current_version/core/shipped.json | jq -r '.shippedApps[]' | sort > $core_apps_in_current_version
    # Fetch Nextcloud app catalog (doesnt contain core app) for the future version
    curl -s https://apps.nextcloud.com/api/v1/platform/$nextcloud_destination_version.0.0/apps.json | jq -r '.[] | .id' | sort > $nextcloud_destination_appcatalog

    # Compute set complement, cf https://catonmat.net/set-operations-in-unix-shell
    # We want to list the installed apps which are neither core apps nor in the destination catalog
    comm -23 <(comm -23 $installed_apps $core_apps_in_current_version) $nextcloud_destination_appcatalog
}

current_version=$(grep OC_VersionString "$install_dir/version.php" | cut -d\' -f2)
current_major_version=${current_version%%.*}

last_version=$(ynh_read_manifest "resources.sources.main.url" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
last_major_version=${last_version%%.*}

if [[ "$last_major_version" != "$current_major_version" ]]
then
    installed_apps_not_compatible_with_future_version="$(list_installed_apps_not_compatible_with_future_version $last_major_version)"
    if [[ -n "$installed_apps_not_compatible_with_future_version" ]]
    then
        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"
    fi
fi

# Keep the attribute choose for ldapEmailAttribute
ldapEmail=$(exec_occ config:app:get user_ldap "${ldap_config_prefix:-}"ldap_email_attr)
if [ "$ldapEmail" = "maildrop" ]
then
    ldap_email_attr="maildrop"
else
    ldap_email_attr="mail"
fi

# Before NCv32, Yunohost was not using any prefix for the LDAP config.
# This is now mandatory so we need to create a new config with a prefix.
if [ "${ldap_config_prefix:-}" = "" ]
then
    ldap_config_prefix=$(exec_occ ldap:create-empty-config --only-print-prefix)
    ynh_app_setting_set --key=ldap_config_prefix --value="$ldap_config_prefix"
fi

#=================================================
# UPGRADE NEXTCLOUD
#=================================================
ynh_script_progression "Upgrading $app..."

# Set write access for the following commands
chown -R $app:www-data "$install_dir"
# Print the current version number of Nextcloud
exec_occ -V

if [ "$(exec_occ config:system:get mysql.utf8mb4)" != "true" ]; then
    db_pwd=$(ynh_app_setting_get --key=db_pwd)
    # Change your databases character set and collation
    ynh_mysql_db_shell <<< "ALTER DATABASE $db_name CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
    # Set the mysql.utf8mb4 config to true in config.php
    exec_occ config:system:set mysql.utf8mb4 --type boolean --value="true"
    exec_occ maintenance:repair
fi

# Upgrade may fail if this app is enabled
# Take all apps enabled, and check if mail is one of them
# Then temporary disable the mail app
mail_app_must_be_reactived=0

if exec_occ app:list | awk '/Enabled/{f=1;next} /Disabled/{f=0} f' | grep -q -w mail; then
    exec_occ app:disable mail
    mail_app_must_be_reactived=1
fi

# Avoid to downgrade Nextcloud, if channel has changed from stable to oldstable.
if [[ "$current_major_version" -le "$last_major_version" ]]; then

    # While the current version is not the last version, do an upgrade
    while [ "$last_version" != "$current_version" ]
    do

        next_major_version="$(( $current_major_version + 1 ))"
        source_id="$next_major_version"
        if [[ "$next_major_version" -ge "$last_major_version" ]]; then
            ynh_print_info "Upgrading to Nextcloud $last_version"
            source_id="main"
        else
            ynh_print_info "Upgrading to Nextcloud $next_major_version"
        fi

        # Create a temporary directory
        tmpdir="${install_dir}__tmp_upgrade"

        ynh_setup_source --dest_dir="$tmpdir" --source_id="$source_id"

        # Backup the config file in the temp dir
        cp -a "$install_dir/config/config.php" "$tmpdir/config/config.php"

        # Enable maintenance mode
        exec_occ maintenance:mode --on

        # Backup 3rd party applications from the current Nextcloud
        # But do not overwrite if there is any upgrade
        # (apps directory already exists in Nextcloud archive)
        (
        cd $install_dir/apps
        for nc_app_dir in */
        do
        if [ ! -d "$tmpdir/apps/$nc_app_dir" ]
        then
            cp -a "$nc_app_dir" "$tmpdir/apps/$nc_app_dir"
        fi
        done
        )

        # Replace the old Nextcloud by the new one
        ynh_safe_rm "$install_dir"
        mv "$tmpdir" "$install_dir"

        # Get the new current version number
        current_version=$(grep OC_VersionString "$install_dir/version.php" | cut -d\' -f2)
        current_major_version=${current_version%%.*}

        # Set write access for the following commands
        chown -R $app:www-data "$install_dir"
        # Upgrade Nextcloud (SUCCESS = 0, UP_TO_DATE = 3)
        exec_occ maintenance:mode --off
        exec_occ upgrade || [ $? -eq 3 ] || ynh_die "Unable to upgrade $app"

        # Print the current version number of Nextcloud
        exec_occ -V
    done
fi
exec_occ db:add-missing-indices -n
exec_occ db:add-missing-columns -n
exec_occ db:add-missing-primary-keys -n
exec_occ db:convert-filecache-bigint -n

#=================================================
# CONFIGURE NEXTCLOUD
#=================================================
ynh_script_progression "Reconfiguring $app..."

# Verify the checksum and backup the file if it's different
ynh_backup_if_checksum_is_different "$install_dir/config/config.php"

nc_conf="${install_dir}/config.json"
ynh_config_add --template="config.json" --destination="$nc_conf"

# Reneable the mail app
if [ $mail_app_must_be_reactived -eq 1 ]; then
    exec_occ app:enable mail
fi

# Ensure that UpdateNotification app is disabled
exec_occ app:disable updatenotification

# Enable LDAP plugin
exec_occ app:enable user_ldap

# Update all installed apps
exec_occ app:update --all

# move the logs from the data_dir to the standard /var/log
# it would be better in the ENSURE DOWNWARD COMPATIBILITY section
# but it must be after the exec_occ() definition, so it's here
if [ -f "$data_dir/data/nextcloud.log" ]; then
    mkdir -p "/var/log/$app"
    chmod 750 "/var/log/$app"
    mv "$data_dir"/data/nextcloud.log* "/var/log/$app"
    # adapt the nextcloud config
    exec_occ config:system:set logfile --value="/var/log/$app/nextcloud.log"
fi

# Load the config file in nextcloud
exec_occ config:import "$nc_conf"

# Then remove the config file
ynh_safe_rm "$nc_conf"

# Occasionally new mimetypes are added to better handle certain file types.
# Migrating the mimetypes take a long time on larger instances
# so this is not done automatically during upgrades.
exec_occ maintenance:repair --include-expensive

#=================================================
# ALLOW USERS TO DISCONNECT FROM NEXTCLOUD
#=================================================

# Add dynamic logout URL to the config
url_base64="$(echo -n "https://$domain$path" | base64)"
old_logout_url="https://$(cat /etc/yunohost/current_host)/yunohost/sso/?action=logout"
current_logout_url="$(exec_occ config:system:get logout_url 2> /dev/null || echo '')"
if [[ "$current_logout_url" == "${old_logout_url}" ]] || [[ "$current_logout_url" == "" ]]
then
    echo "
//-YunoHost-
// set logout_url according to main domain
\$main_domain = file_get_contents('/etc/yunohost/current_host');
\$CONFIG['logout_url'] = 'https://'.\$main_domain.'/yunohost/sso/?action=logout&r=${url_base64}';
//-YunoHost-
    " >> "$install_dir/config/config.php"
fi

#=================================================
# CHANGE HOSTNAME FOR ACTIVITY NOTIFICATIONS
#=================================================

exec_occ config:system:set overwrite.cli.url --value="https://${domain}${path}"

#=================================================
# MOUNT HOME FOLDERS AS EXTERNAL STORAGE
#=================================================

# Enable External Storage and create local mount to home folder as needed
if [ $user_home -eq 1 ]; then
    exec_occ app:enable files_external
    exec_occ files_external:list --output=json \
    | grep -q '"storage":"\\\\OC\\\\Files\\\\Storage\\\\Local"' \
    || create_external_storage "/home/\$user" "Home"
    # Iterate over users to extend their home folder permissions
    for u in $(ynh_user_list); do
    setfacl --modify g:$app:rwx "/home/$u" || true
    done
fi

#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================

# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "${install_dir}/config/config.php"

#=================================================
# REGEN PERMISSIONS
#=================================================
ynh_script_progression "Reapplying file permissions..."

# Fix app ownerships & permissions
chown -R $app:www-data "$install_dir"
find $install_dir/ -type f -print0 | xargs -r0 chmod 0644
find $install_dir/ -type d -print0 | xargs -r0 chmod 0755
find "$install_dir/apps/"*/{bin,bin-ext} -type d -print0 2>/dev/null | xargs -r0 chmod -R u+x
chmod 600 "$install_dir/config/config.php"
chmod 755 /home/yunohost.app
chmod 750 $install_dir

#=================================================
# REGEN SYSTEM CONFIGURATIONS
#=================================================
ynh_script_progression "Regenerating system configurations for $app..."

#-------------------------------------------------
# PHP-FPM
#-------------------------------------------------

ynh_config_add_phpfpm

#-------------------------------------------------
# NGINX
#-------------------------------------------------

# Delete current NGINX configuration to be able to check if .well-known is already served.
ynh_backup_if_checksum_is_different "/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_config_remove_nginx
ynh_app_setting_delete --key="checksum__etc_nginx_conf.d_$domain.d_$app.conf"

# Wait untils NGINX has fully reloaded
ynh_systemctl --service=nginx --action=reload --wait_until="Reloaded" --log_path="systemd"

wait_nginx_reload

# Check if .well-known is available for this domain
if is_url_handled --domain="$domain" --path="/.well-known/caldav" || is_url_handled --domain="$domain" --path="/.well-known/carddav"
then
    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."

    # Remove lines about .well-known/carddav and caldav with sed.
    sed --in-place --regexp-extended '/location = \/\.well\-known\/(caldav|carddav)/d' "../conf/nginx.conf"
fi

# Create a dedicated NGINX config
nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d"
mkdir -p "$nginx_extra_conf_dir"

if [ $enable_notify_push -eq 1 ]
then
    ynh_config_add --template="notify_push.conf" --destination="$nginx_extra_conf_dir/notify_push.conf"
fi

# Create a dedicated NGINX config
ynh_config_add_nginx

#=================================================
# CONFIGURE NOTIFY_PUSH APP
#=================================================

if [ $enable_notify_push -eq 1 ]
then
    # If notify_push is disabled, reenable it
    if exec_occ app:list | awk '/Disabled/{f=1;next} f' | grep -q -w notify_push; then
        exec_occ app:enable notify_push
    # If notify_push is not installed, install it
    elif ! exec_occ app:list | awk '/Enabled/{f=1;next} /Disabled/{f=0} f' | grep -q -w notify_push; then
        exec_occ app:install notify_push
    fi
    exec_occ config:app:set notify_push base_endpoint --value=https://$domain${path_url%/}/push

    mkdir -p /var/run/$app/
    chown $app: /var/run/$app/

    case $YNH_ARCH in
        amd64) arch="x86_64";;
        arm64) arch="aarch64";;
        armel|armhf) arch="armv7";;
    esac

    ynh_config_add --template="watcher.path" --destination="/etc/systemd/system/${app}-notify-push-watcher.path"
    ynh_config_add_systemd --service="${app}-notify-push-watcher" --template="watcher.service"
    systemctl enable --now --quiet ${app}-notify-push-watcher.path
    ynh_config_add_systemd --service="${app}-notify-push"
fi

#=================================================
# CRON JOB
#=================================================

ynh_config_add --template="nextcloud.cron" --destination="/etc/cron.d/$app"
chown root: "/etc/cron.d/$app"
chmod 644 "/etc/cron.d/$app"

exec_occ background:cron

#=================================================
# LOGROTATE
#=================================================
ynh_script_progression "Configuring log rotation..."

ynh_config_add_logrotate

#=================================================
# FAIL2BAN
#=================================================
ynh_script_progression "Configuring Fail2Ban..."

# Create a dedicated Fail2Ban config
ynh_config_add_fail2ban --logpath="/var/log/$app/nextcloud.log"

#=================================================
# CHECK IF NOTIFY_PUSH WORKS
#=================================================

if [ $enable_notify_push -eq 1 ]
then
    count=0
    while ! exec_occ $install_dir/cron.php && [[ $count -lt 30 ]]
    do
        sleep 1
        count=$((count + 1))
    done

    ynh_systemctl --service="${app}-notify-push-watcher" --action=restart
    ynh_systemctl --service="${app}-notify-push" --action=restart --log_path="systemd" --wait_until="Push daemon for Nextcloud clients."

    if ! exec_occ notify_push:self-test; then
        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."
    fi
fi

#=================================================
# END OF SCRIPT
#=================================================

ynh_script_progression "Upgrade of $app completed"


================================================
FILE: tests.toml
================================================
test_format = 1.0

[default]

    args.enable_notify_push = "0"

    # -------------------------------
    # Commits to test upgrade from
    # -------------------------------

    test_upgrade_from.5bbe70c6.name = "Upgrade from 30.0.8"
    test_upgrade_from.446e9775.name = "Upgrade from 31.0.7"
    test_upgrade_from.05f2feff.name = "Upgrade from 32.0.3"

    [default.curl_tests]
    #home.path = "/"
    home.expect_title = "Login - Nextcloud"
    home.auto_test_assets = true

    #dash.path = "/"
    dash.logged_on_sso = true
    dash.expect_title = "Dashboard - Nextcloud"

    admin.path = "/settings/admin"
    admin.logged_on_sso = true
    admin.expect_title = "Administration settings - Nextcloud"

    asset.path = "/core/img/logo/logo.svg"

    file.path = "/remote.php/dav/files/__USER__/Readme.md"
    file.logged_on_sso = true
    file.expect_content = "# Welcome to Nextcloud!"

    caldav.base_url = "https://__DOMAIN__"
    caldav.path = "/.well-known/caldav"
    caldav.logged_on_sso = true
    caldav.expect_content = "This is the WebDAV interface."

[notify_push_test]
    args.enable_notify_push = "1"
    test_upgrade_from.05f2feff.name = "Upgrade from 32.0.3"
    test_upgrade_from.05f2feff.args.system_addressbook_exposed = "yes"
Download .txt
gitextract_5zm6mp9i/

├── .github/
│   ├── ISSUE_TEMPLATE.md
│   └── PULL_REQUEST_TEMPLATE.md
├── .gitignore
├── LICENSE
├── README.md
├── conf/
│   ├── config.json
│   ├── config_install.json
│   ├── extra_php-fpm.conf
│   ├── f2b_filter.conf
│   ├── f2b_jail.conf
│   ├── nextcloud.cron
│   ├── nginx.conf
│   ├── notify_push.conf
│   ├── systemd.service
│   ├── watcher.path
│   └── watcher.service
├── config_panel.toml
├── doc/
│   ├── ADMIN.md
│   ├── ADMIN_fr.md
│   ├── DESCRIPTION.md
│   ├── DESCRIPTION_fr.md
│   ├── POST_UPGRADE.md
│   ├── POST_UPGRADE_fr.md
│   └── PRE_UPGRADE.d/
│       └── MAJOR_RELEASE.md
├── hooks/
│   ├── post_user_create
│   └── post_user_delete
├── manifest.toml
├── patches/
│   ├── 30/
│   │   └── 00-add-logout_url-conf.patch
│   └── main/
│       └── 00-add-logout_url-conf.patch
├── scripts/
│   ├── _common.sh
│   ├── backup
│   ├── change_url
│   ├── config
│   ├── install
│   ├── remove
│   ├── restore
│   └── upgrade
└── tests.toml
Condensed preview — 38 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (131K chars).
[
  {
    "path": ".github/ISSUE_TEMPLATE.md",
    "chars": 2785,
    "preview": "---\nname: Bug report\nabout: When creating a bug report, please use the following template to provide all the relevant in"
  },
  {
    "path": ".github/PULL_REQUEST_TEMPLATE.md",
    "chars": 558,
    "preview": "## 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- ["
  },
  {
    "path": ".gitignore",
    "chars": 22,
    "preview": "*~\n*.sw[op]\n.DS_Store\n"
  },
  {
    "path": "LICENSE",
    "chars": 34520,
    "preview": "                    GNU AFFERO GENERAL PUBLIC LICENSE\n                       Version 3, 19 November 2007\n\n Copyright (C)"
  },
  {
    "path": "README.md",
    "chars": 2070,
    "preview": "<!--\nN.B.: This README was automatically generated by <https://github.com/YunoHost/apps_tools/blob/main/readme_generator"
  },
  {
    "path": "conf/config.json",
    "chars": 2789,
    "preview": "{\n  \"system\": {\n    \"trashbin_retention_obligation\": \"auto, 30\",\n    \"versions_retention_obligation\": \"auto, 30\",\n    \"u"
  },
  {
    "path": "conf/config_install.json",
    "chars": 134,
    "preview": "{\n  \"system\": {\n    \"datadirectory\": \"__DATA_DIR__/data/\",\n    \"trusted_domains\": [\n      \"localhost\",\n      \"__DOMAIN__"
  },
  {
    "path": "conf/extra_php-fpm.conf",
    "chars": 969,
    "preview": "\n; Additional php.ini defines, specific to this pool of workers.\nenv[PATH] = $PATH\nenv[LANG] = $LANG\nenv[LC_ALL] = $LANG"
  },
  {
    "path": "conf/f2b_filter.conf",
    "chars": 474,
    "preview": "[INCLUDES]\nbefore = common.conf\n[Definition]\n_groupsre = (?:(?:,?\\s*\"\\w+\":(?:\"[^\"]+\"|\\w+))*)\nfailregex = ^\\{%(_groupsre)"
  },
  {
    "path": "conf/f2b_jail.conf",
    "chars": 114,
    "preview": "[__APP__]\nenabled = true\nport = http,https\nfilter = __APP__\nlogpath = /var/log/__APP__/nextcloud.log\nmaxretry = 5\n"
  },
  {
    "path": "conf/nextcloud.cron",
    "chars": 106,
    "preview": "*/5  *  *  *  * __APP__ /usr/bin/php__PHP_VERSION__ --define apc.enable_cli=1 -f __INSTALL_DIR__/cron.php\n"
  },
  {
    "path": "conf/nginx.conf",
    "chars": 7630,
    "preview": "# Set .mjs MIME types\n# Either include it in the default mime.types list\n# or include you can include that list explicit"
  },
  {
    "path": "conf/notify_push.conf",
    "chars": 108,
    "preview": "location ^~ __PATH__/push/ {\n   proxy_pass http://127.0.0.1:__PORT__/;\n   include    proxy_params_no_auth;\n}"
  },
  {
    "path": "conf/systemd.service",
    "chars": 1757,
    "preview": "[Unit]\nDescription=Push daemon for Nextcloud clients\nAfter=network.target nginx.service\nDocumentation = https://github.c"
  },
  {
    "path": "conf/watcher.path",
    "chars": 344,
    "preview": "[Unit]\nDescription=Restart Push daemon for Nextcloud clients when it receives updates\nDocumentation=https://github.com/n"
  },
  {
    "path": "conf/watcher.service",
    "chars": 472,
    "preview": "[Unit]\nDescription=Restart Push daemon for Nextcloud clients when it receives updates\nDocumentation=https://github.com/n"
  },
  {
    "path": "config_panel.toml",
    "chars": 2896,
    "preview": "version = \"1.0\"\n\n[main]\nname.en = \"Nextcloud configuration\"\nname.fr = \"Configuration de Nextcloud\"\n\n    [main.maintenanc"
  },
  {
    "path": "doc/ADMIN.md",
    "chars": 698,
    "preview": "### Manually running Nextcloud commands\n\nYou can run Nextcloud commands from the command line by opening a Nextcloud \"sh"
  },
  {
    "path": "doc/ADMIN_fr.md",
    "chars": 738,
    "preview": "### Exécuter manuellement des commandes Nextcloud\n\nVous pouvez lancer des commandes Nextcloud en ouvrant un \"shell\" Next"
  },
  {
    "path": "doc/DESCRIPTION.md",
    "chars": 919,
    "preview": "Nextcloud lets you access and synchronize data, files, contacts and calendars between different devices (PCs or mobiles)"
  },
  {
    "path": "doc/DESCRIPTION_fr.md",
    "chars": 1035,
    "preview": "Nextcloud permet de rendre accessible et de synchroniser ses données, fichiers, contacts, agendas entre différents appar"
  },
  {
    "path": "doc/POST_UPGRADE.md",
    "chars": 154,
    "preview": "Note that if you've installed any third-party Nextcloud applications, they have probably been disabled. If so, you'll ne"
  },
  {
    "path": "doc/POST_UPGRADE_fr.md",
    "chars": 146,
    "preview": "Notez que si vous avez installé des applications Nextcloud tierces, elles sont probablement désactivées et vous devrez l"
  },
  {
    "path": "doc/PRE_UPGRADE.d/MAJOR_RELEASE.md",
    "chars": 790,
    "preview": "If you are upgrading to a **new major version** of Nextcloud (e.g. 32, 33), **please make sure that your Nextcloud apps "
  },
  {
    "path": "hooks/post_user_create",
    "chars": 222,
    "preview": "#!/bin/bash\n\nuser=\"$1\"\napp=\"$(basename $0 | cut -d- -f 2-)\" # Extract the app name from the script name, which is suppos"
  },
  {
    "path": "hooks/post_user_delete",
    "chars": 541,
    "preview": "#!/bin/bash\n\nsource /usr/share/yunohost/helpers\n\nuser=\"$1\"\napp=\"$(basename $0 | cut -d- -f 2-)\" # Extract the app name f"
  },
  {
    "path": "manifest.toml",
    "chars": 5728,
    "preview": "packaging_format = 2\n\nid = \"nextcloud\"\nname = \"Nextcloud\"\ndescription.en = \"Online storage, file sharing platform and va"
  },
  {
    "path": "patches/30/00-add-logout_url-conf.patch",
    "chars": 1481,
    "preview": "diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php\nindex d4d6a17db79..f587f805683 10"
  },
  {
    "path": "patches/main/00-add-logout_url-conf.patch",
    "chars": 1201,
    "preview": "diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php\nindex 1a105130..9a51f8d9 100644\n-"
  },
  {
    "path": "scripts/_common.sh",
    "chars": 2183,
    "preview": "#!/bin/bash\n\n#=================================================\n# COMMON VARIABLES AND CUSTOM HELPERS\n#================="
  },
  {
    "path": "scripts/backup",
    "chars": 1877,
    "preview": "#!/bin/bash\n\nsource ../settings/scripts/_common.sh\nsource /usr/share/yunohost/helpers\n\nynh_print_info \"Declaring files t"
  },
  {
    "path": "scripts/change_url",
    "chars": 3947,
    "preview": "#!/bin/bash\n\nsource _common.sh\nsource /usr/share/yunohost/helpers\n\n#=================================================\n# "
  },
  {
    "path": "scripts/config",
    "chars": 6298,
    "preview": "#!/bin/bash\n\nsource _common.sh\nsource /usr/share/yunohost/helpers\n\n#=================================================\n# "
  },
  {
    "path": "scripts/install",
    "chars": 11377,
    "preview": "#!/bin/bash\n\nsource _common.sh\nsource /usr/share/yunohost/helpers\n\n#=================================================\n# "
  },
  {
    "path": "scripts/remove",
    "chars": 1271,
    "preview": "#!/bin/bash\n\nsource _common.sh\nsource /usr/share/yunohost/helpers\n\n#=================================================\n# "
  },
  {
    "path": "scripts/restore",
    "chars": 5500,
    "preview": "#!/bin/bash\n\nsource ../settings/scripts/_common.sh\nsource /usr/share/yunohost/helpers\n\n#================================"
  },
  {
    "path": "scripts/upgrade",
    "chars": 18900,
    "preview": "#!/bin/bash\n\nsource _common.sh\nsource /usr/share/yunohost/helpers\n\n#=================================================\n# "
  },
  {
    "path": "tests.toml",
    "chars": 1258,
    "preview": "test_format = 1.0\n\n[default]\n\n    args.enable_notify_push = \"0\"\n\n    # -------------------------------\n    # Commits to "
  }
]

About this extraction

This page contains the full source code of the YunoHost-Apps/nextcloud_ynh GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 38 files (121.1 KB), approximately 30.5k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!