1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/diaspora_ynh.git synced 2024-09-03 18:26:13 +02:00

Merge pull request #2 from autra/fixes

This commit is contained in:
Augustin Trancart 2020-04-25 18:42:33 +02:00 committed by GitHub
commit b01c695cb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 2392 additions and 1499 deletions

View file

@ -1,7 +1,7 @@
test:
script:
- apt-get update
- apt-get install python pip
- apt-get install -y python3 git
- git clone https://github.com/YunoHost/package_linter
- python package_linter/package_linter.py .
- python3 package_linter/package_linter.py .

661
LICENSE Normal file
View file

@ -0,0 +1,661 @@
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/>.

View file

@ -1,26 +0,0 @@
.container{style: "padding-top: 5%;"}
.hero-unit
%h2 diaspora*
%hr/
%p
%b Vous êtes sur le point de changer Internet en utilisant un réseau social anonyme et distribué.
%br
%b Rejoignez-nous et récupérez votre liberté, votre vie privée et vos données avec YunoHost et diaspora* !
%p
= link_to "Créer un compte ! »", new_user_registration_path, class: "btn btn-primary btn-large"
.row
.span4
%h2 diaspora*
%p Découvrez l'ambition du projet pour créer un réseau social universel où vous gardez le contrôle.
%p
%a.btn{:href => "https://diasporafoundation.org/"} Fondation Diaspora »
.span4
%h2 Auto-hébergez-vous
%p Le site (pod) sur lequel vous êtes est propulsé par YunoHost. Une distribution simple basée sur des outils libres pour créer votre propre "cloud" !
%p
%a.btn{:href => "https://yunohost.org/"} YunoHost »
.span4
%h2 Créez votre "Pod"
%p A l'aide de Yunohost et de son application diaspora*, hébergez simplement votre "pod".
%p
%a.btn{:href => "https://github.com/aymhce/diaspora_ynh"} Application diaspora* pour YunoHost »

View file

@ -1,6 +0,0 @@
SOURCE_URL=https://github.com/diaspora/diaspora/archive/v0.6.7.0.zip
SOURCE_SUM=8bed8a84a336d51a7983636eab9670d85fdd1fc5
SOURCE_SUM_PRG=sha256
SOURCE_FORMAT=zip
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=

View file

@ -1,27 +1,28 @@
postgresql: &postgresql
adapter: postgresql
host: "localhost"
port: 5432
username: "{{ app }}"
password: "{{ db_pass }}"
encoding: unicode
mysql: &mysql
adapter: mysql2
host: "localhost"
port: 3306
username: "DBUSERTOCHANGE"
password: "DBPASSTOCHANGE"
username: "root"
password: ""
# socket: /tmp/mysql.sock
charset: utf8mb4
encoding: utf8mb4
collation: utf8mb4_bin
postgres: &postgres
adapter: postgresql
host: localhost
port: 5432
username: postgres
password:
encoding: unicode
# Comment the the mysql line and uncomment the postgres line
# if you want to use postgres
# Comment the postgresql line and uncomment the mysql line
# if you want to use mysql
common: &common
# Choose one of the following
<<: *mysql
#<<: *postgres
<<: *postgresql
#<<: *mysql
# Should match environment.sidekiq.concurrency
#pool: 25
@ -31,10 +32,9 @@ common: &common
##################################################
# Normally you don't need to touch anything here
# ynh note: we actually do :-) how about having different database name for
# different instances on the same postgres cluster?
postgres_travis: &postgres_travis
adapter: postgresql
username: postgres
combined: &combined
<<: *common
development:
@ -42,10 +42,10 @@ development:
database: diaspora_development
production:
<<: *combined
database: diaspora_production
database: {{ app }}
test:
<<: *combined
database: "diaspora_test"
database: diaspora_test
integration1:
<<: *combined
database: diaspora_integration1

View file

@ -1,8 +1,7 @@
[Unit]
Description=Diaspora social network
Wants=redis.service mysqld.service
After=redis.service mysqld.service
StopWhenUnneeded=true
Description=Diaspora social network (instance {{ app}})
Wants=redis.service postgresql.service
After=redis.service postgresql.service
[Install]
WantedBy=multi-user.target

1
conf/diaspora.tmpfiles.d Normal file
View file

@ -0,0 +1 @@
d /run/{{ app }} 0755 {{ app }} {{ app }} - -

View file

@ -21,7 +21,7 @@
## - Specify lists/arrays as comma-separated values
##
## - For example, on Heroku:
## heroku config:set SERVICES_FACEBOOK_APP_ID=yourappid SERVICES_FACEBOOK_SECRET=yourappsecret
## heroku config:set SERVICES_TWITTER_KEY=yourkey SERVICES_TWITTER_SECRET=yoursecret
configuration: ## Section
@ -36,13 +36,13 @@ configuration: ## Section
## However changing http to https is okay and has no consequences.
## If you do change the URL, you will have to start again as the URL
## will be hardcoded into the database.
url: "FULLURLTOCHANGE"
url: "https://{{ domain }}{{ path_url }}"
## Set the bundle of certificate authorities (CA) certificates.
## This is specific to your operating system.
## Examples (uncomment the relevant one or add your own):
## For Debian, Ubuntu, Archlinux, Gentoo (package ca-certificates):
#certificate_authorities: '/etc/ssl/certs/ca-certificates.crt'
certificate_authorities: '/etc/ssl/certs/ca-certificates.crt'
## For CentOS, Fedora:
#certificate_authorities: '/etc/pki/tls/certs/ca-bundle.crt'
@ -82,7 +82,7 @@ configuration: ## Section
## Number of times a job is retried (default=10).
## There's an exponential effect to this: if you set this too high you
## might get too many jobs building up in the queue.
## Set it to false to disable it completely.
## Set it to 0 to disable it completely.
#retry: 10
## Lines of backtrace that are stored on failure (default=15).
@ -175,19 +175,20 @@ configuration: ## Section
## Where the appserver should listen to (default=unix:tmp/diaspora.sock)
#listen: 'unix:tmp/diaspora.sock'
#listen: 'unix:/run/diaspora/diaspora.sock'
listen: '127.0.0.1:3986'
#listen: '127.0.0.1:3000'
listen: unix:/run/{{ app }}/diaspora.sock
## Set the path for the PID file of the unicorn master process (default=tmp/pids/web.pid)
#pid: 'tmp/pids/web.pid'
pid: '/run/{{ app }}/diaspora.pid'
## Rails environment (default='development').
## The environment in which the server should be started by default.
## Change this to 'production' if you wish to run a production environment.
#rails_environment: 'development'
rails_environment: 'production'
## Write unicorn stderr and stdout log.
#stderr_log: '/usr/local/app/diaspora/log/unicorn-stderr.log'
#stdout_log: '/usr/local/app/diaspora/log/unicorn-stdout.log'
stderr_log: 'log/unicorn-stderr.log'
stdout_log: 'log/unicorn-stdout.log'
## Number of Unicorn worker processes (default=2).
## Increase this if you have many users.
@ -208,68 +209,6 @@ configuration: ## Section
## increase environment.sidekiq.concurrency instead!
#sidekiq_workers: 1
## Diaspora has an internal XMPP web-client. If you want to enable the chat
## functionality or want to use a custom XMPP server, then you should edit
## the following configuration.
chat: ## Section
## Enable the chat service and all its components.
##
## Please make sure that you followed the Installation-Instructions first:
## https://wiki.diasporafoundation.org/Integration/Chat#Installation.2FUpdate
#enabled: true
## Custom XMPP server configuration goes here.
server: ## Section
## Use the configuration bridge to prosody (default=true).
## In case you want to run your own server or want to configure
## prosody on your own, you should disable it.
#enabled: false
## Set the directory in which to look for virtual hosts TLS certificates.
#certs: 'config/certs'
## XEP-0124 BOSH requests
## The easiest way of avoiding certificate and mixed-content issues
## is to use a proxy, e.g.:
##
## Apache: https://wiki.diasporafoundation.org/Integration/Chat#Apache2
## Nginx: https://wiki.diasporafoundation.org/Integration/Chat#Nginx
##
## If you configured your proxy correctly,
## you should set the proxy option to 'true'
bosh: ## Section
## If you'd like to use a proxy, you should set the proxy
## option to true, otherwise jsxc always tries to
## connect directly to the port specified below.
#proxy: true
## Configure the protocol used to access the BOSH endpoint
#proto: http
## Configure the address that prosody should listen on.
#address: '0.0.0.0'
## Configure the BOSH port.
#port: 5280
## Configure the bind endpoint.
#bind: '/http-bind'
## Specify log behaviour here.
log: ## Section
## Log file location.
#info: 'log/prosody.log'
## Error log file location.
#error: 'log/prosody.err'
## The debug level logs all XML sent and received by the server.
#debug: false
## Displays the location of a post in a map. Per default we are using the map
## tiles of the Heidelberg University (http://giscience.uni-hd.de).
## You also have the possibility to use the map tiles of https://www.mapbox.com
@ -300,21 +239,16 @@ configuration: ## Section
## Piwik Tracking (disabled by default).
## Provide a site ID and the host piwik is running on to enable
## tracking through Piwik.
# TODO ? Check implications...
piwik: ## Section
#enable: true
#host: 'stats.example.org'
#site_id: 1
## Mixpanel event tracking (disabled by default).
#mixpanel_uid:
## Chartbeat tracking (disabled by default).
#chartbeat_uid:
## Statistics
## Your pod will report its name, software version and whether
## or not registrations are open via /statistics.json.
## or not registrations are open via /statistics and NodeInfo.
## Uncomment the options below to enable more statistics.
statistics: ## Section
@ -367,7 +301,8 @@ configuration: ## Section
## Set this to false to prevent people from signing up to your pod
## without an invitation. Note that this needs to be set to true
## (or commented out) to enable the first registration (you).
#enable_registrations: true
# TODO ynh settings
enable_registrations: false
## Auto-follow on sign-up (default=true)
## Users will automatically follow a specified account on creation.
@ -461,6 +396,11 @@ configuration: ## Section
## of your Sidekiq workers.
#typhoeus_concurrency: 20
## Maximum number of parallel user data export jobs (default=1)
## Be careful, exports of big/old profiles can use a lot of memory, running
## many of them in parallel can be a problem for small servers.
#export_concurrency: 1
## Captcha settings
captcha: ## Section
@ -537,7 +477,7 @@ configuration: ## Section
## Source code URL
## URL to the source code your pod is currently running.
## If not set your pod will provide a downloadable archive.
#source_url: 'https://example.org/username/diaspora'
source_url: 'https://github.com/diaspora/diaspora'
## Changelog URL
## URL to the changelog of the diaspora-version your pod is currently running.
@ -567,14 +507,15 @@ configuration: ## Section
## party domains from services that are included in diaspora*, like OEmbed
## scripts, so you can safely activate it by setting `report_only` to false. If
## you customized diaspora* (edited templates or added own JS), additional work
## may be required. You can test the policy with the "report_uri". Our default CSP
## may be required. You can test the policy with the `report_uri`. Our default CSP
## does not work with Google analytics or Piwik, because they inject JS code that
## is blocked by CSP.
csp:
## Report-Only header (default=true)
## By default diaspora* adds only a "Content-Security-Policy-Report-Only" header. If you set
## this to false, the "Content-Security-Policy" header is added instead.
#report_only: false
## Report-Only header (default=false)
## By default diaspora* adds a "Content-Security-Policy" header. If you set
## this to true, the "Content-Security-Policy-Report-Only" header is added instead.
#report_only: true
## CSP report URI (default=)
## You can set an URI here, where the user agent reports violations as JSON document via a POST request.
@ -583,20 +524,6 @@ configuration: ## Section
## Posting from Diaspora to external services (all are disabled by default).
services: ## Section
## OAuth credentials for Facebook
facebook: ## Section
#enable: true
#app_id: 'abcdef'
#secret: 'change_me'
## This setting is required to define whether the Facebook app has permissions to post
## false == No permissions (default)
## true == Permissions for all users to post. App MUST have 'publish_actions' approved by Facebook!
## "username" == Set to local username to allow a single user to cross-post. The person who has created
## the Facebook app will always be able to cross-post, even without 'publish_actions'.
#authorized: false
## OAuth credentials for Twitter
twitter: ## Section
@ -623,14 +550,14 @@ configuration: ## Section
mail: ## Section
## First you need to enable it.
#enable: true
enable: true
## Sender address used in mail sent by Diaspora.
#sender_address: 'no-reply@example.org'
sender_address: 'no-reply@{{ domain }}'
## This selects which mailer should be used. Use 'smtp' for a smtp
## connection or 'sendmail' to use the sendmail binary.
#method: 'smtp'
method: 'sendmail'
## Ignore if method isn't 'smtp'.
smtp: ## Section
@ -667,7 +594,7 @@ configuration: ## Section
sendmail: ## Section
## The path to the sendmail binary (default='/usr/sbin/sendmail')
#location: '/usr/sbin/sendmail'
location: '/usr/sbin/sendmail'
## Use exim and sendmail (default=false)
#exim_fix: false
@ -679,10 +606,10 @@ configuration: ## Section
## This doesn't make the user an admin but is used when a generic
## admin contact is needed, much like the postmaster role in mail
## systems. Set only the username, NOT the full ID.
#account: "podmaster"
account: "{{ admin }}"
## E-mail address to contact the administrator.
#podmin_email: 'podmin@example.org'
podmin_email: '{{ admin_email }}'
## Settings related to relays
relay: ## Section
@ -695,13 +622,13 @@ configuration: ## Section
outbound: ## Section
## Enable this setting to send out public posts from this pod to a relay
#send: false
send: true
## Change default remote relay url used for sending out here
#url: 'https://relay.iliketoast.net/receive/public'
inbound: ## Section
## Enable this to receive public posts from relays
#subscribe: false
subscribe: true
## Scope is either 'all' or 'tags' (default).
## - 'all', means this pod wants to receive all public posts from a relay
@ -710,7 +637,7 @@ configuration: ## Section
## If scope is 'tags', should we include tags that users on this pod follow?
## These are added in addition to 'pod_tags', if set.
#include_user_tags: false
include_user_tags: true
## If scope is 'tags', a comma separated list of tags here can be set.
## For example "linux,diaspora", to receive posts related to these tags
@ -725,4 +652,3 @@ production: ## Section
development: ## Section
environment: ## Section
#redis: 'redis://production.example.org:6379'

View file

@ -1,17 +0,0 @@
[Unit]
Description=Diaspora social network (application server)
PartOf=diaspora.target
StopWhenUnneeded=true
[Service]
User=diaspora
WorkingDirectory=/var/www/diaspora
Environment=RAILS_ENV=production
ExecStart=/var/www/diaspora/.rvm/scripts/extras/chruby.sh 2.2 -- bin/bundle exec puma -b unix:///var/run/diaspora/diaspora.sock -e $RAILS_ENV
Restart=always
CPUAccounting=true
MemoryAccounting=true
BlockIOAccounting=true
[Install]
WantedBy=diaspora.target

View file

@ -0,0 +1,13 @@
[Unit]
Description=Diaspora social network (sidekiq - instance {{ app }})
PartOf={{ app }}.target
[Service]
User={{ app }}
Environment=RAILS_ENV=production
WorkingDirectory={{ final_path }}/diaspora
ExecStart=/bin/bash -lc "bin/bundle exec sidekiq"
Restart=always
[Install]
WantedBy={{ app }}.target

15
conf/diaspora_web.service Normal file
View file

@ -0,0 +1,15 @@
[Unit]
Description=Diaspora social network (unicorn - instance {{ app }})
PartOf={{ app }}.target
[Service]
User={{ app }}
Environment=RAILS_ENV=production
WorkingDirectory={{ final_path }}/diaspora
PIDFile=/run/{{ app }}/diaspora.pid
ExecStart=/bin/bash -lc "bin/bundle exec unicorn -c config/unicorn.rb -E production"
ExecReload=/bin/kill -USR2 $MAINPID
Restart=always
[Install]
WantedBy={{ app }}.target

View file

@ -1,18 +0,0 @@
[Unit]
Description=Diaspora social network (worker %i)
PartOf=diaspora.target
StopWhenUnneeded=true
[Service]
User=diaspora
WorkingDirectory=/var/www/diaspora
Environment=RAILS_ENV=production
ExecStart=/var/www/diaspora/.rvm/scripts/extras/chruby.sh 2.2 -- bin/bundle exec sidekiq
Restart=always
CPUAccounting=true
MemoryAccounting=true
BlockIOAccounting=true
[Install]
WantedBy=diaspora.target
DefaultInstance=worker1

View file

@ -1,224 +0,0 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: diaspora_ynh
# Required-Start: $remote_fs $syslog mysql redis-server
# Required-Stop: $remote_fs $syslog mysql redis-server
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Diaspora application server
# Description: Start / stop the Diaspora app server
### END INIT INFO
# Author: FABIAN Tamas Laszlo <giganetom@gmail.com>
# Updated: Pirate Praveen <praveen@debian.org>
# Updated: aymhce <aymhce@gmail.com>
# PATH should only include /usr/* if it runs after the mountnfs.sh script
# Note: /usr/local/bin for foreman gem
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
DESC="Diaspora application server"
NAME=diaspora
DIASPORA_HOME="/var/www/diaspora"
STARTSCRIPT="./script/server"
LOGFILE=$DIASPORA_HOME/log/startscript.log
SCRIPTNAME=$0
USER=diaspora
STARTUP_TIMEOUT=100
. /lib/init/vars.sh
. /lib/lsb/init-functions
check_unicorn() {
pgrep -f "unicorn_rails master"
}
check_sidekiq() {
pgrep -f "sidekiq 3"
}
check_foreman() {
pgrep -f "foreman-runner"
}
check_foreman_start() {
pgrep -f "foreman start"
}
check_script_server() {
pgrep -f "script/server"
}
do_start()
{
if ! touch $LOGFILE; then
log_failure_msg "Could not touch logfile"
return 2
fi
if ! chown $USER $LOGFILE; then
log_failure_msg "Could not chown logfile"
return 2
fi
if check_unicorn && check_sidekiq; then
log_warning_msg "Diaspora is already running"
return 1
fi
if check_foreman || check_foreman_start || check_script_server; then
log_warning_msg "Diaspora is starting"
return 1
fi
export SERVERNAME=localhost
export ENVIRONMENT_URL=http://localhost
export RAILS_ENV=production
export DB=mysql
cd $DIASPORA_HOME
sudo su - $USER -c " . ~/.bashrc && cd $DIASPORA_HOME && $STARTSCRIPT >> $LOGFILE 2>&1 " &
if [ $? -gt 0 ]
then
log_failure_msg "Could not run start script"
return 2
else
log_success_msg "Starting diaspora server..."
return 0
fi
[ "$VERBOSE" != no ] && log_action_msg "Waiting for Diaspora processes... "
c=0
while ! check_unicorn > /dev/null || ! check_sidekiq > /dev/null; do
if [ $c -gt $STARTUP_TIMEOUT ]; then
log_failure_msg "Timeout waiting for Diaspora processes"
return 2
fi
c=`expr $c + 1`
sleep 1
[ "$VERBOSE" != no ] && echo -n "."
done
[ "$VERBOSE" != no ] && log_action_end_msg 0
}
do_stop()
{
for i in `check_unicorn`; do
[ "$VERBOSE" != no ] && log_action_msg "Killing unicorn master with PID $i"
kill -TERM $i
[ "$VERBOSE" != no ] && log_action_end_msg $?
done
for i in `check_sidekiq`; do
[ "$VERBOSE" != no ] && log_action_msg "Killing sidekiq with PID $i"
kill -TERM $i
[ "$VERBOSE" != no ] && log_action_end_msg $?
done
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
*) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
log_daemon_msg 'Checking for running Diaspora processes'
if ! check_unicorn
then
log_action_msg "unicorn not found"
unicorn_running=false
else
for i in `check_unicorn`; do
log_action_msg "Found unicorn master with PID $i"
unicorn_running=true
done
fi
if ! check_foreman
then
log_action_msg "foreman not found"
foreman_running=false
else
for i in `check_foreman`; do
log_action_msg "Found foreman with pid $i"
foreman_running=true
done
fi
if ! check_sidekiq
then
log_action_msg "sidekiq is not found"
sidekiq_running=false
else
for i in `check_sidekiq`; do
log_action_msg "Found sidekiq with PID $i"
sidekiq_running=true
done
fi
if $foreman_running && ! $unicorn_running; then
log_action_msg "Diaspora is starting, check after some time..."
log_end_msg 0
return 0
fi
if $unicorn_running && $sidekiq_running; then
log_action_msg "Diaspora health is OK"
log_end_msg 0
else
if $unicorn_running; then
log_failure_msg "Unicorn is RUNNING, but sidekiq is DOWN!"
log_end_msg 1
return 1
fi
if $sidekiq_running; then
log_failure_msg "Sidekiq is RUNNING, but unicorn is DOWN!"
log_end_msg 1
return 1
fi
log_daemon_msg "All Diaspora processes are DOWN"
log_end_msg 0
fi
;;
restart|force-reload)
[ "$VERBOSE" != no ] && log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
ret=$?
sleep 5
case "$ret" in
0|1)
do_start
case "$?" in
0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
1) [ "$VERBOSE" != no ] && log_failure_msg "old process is still running" && log_end_msg 1 ;;
*) [ "$VERBOSE" != no ] && log_failure_msg "failed to start" && log_end_msg 1 ;;
esac
;;
*)
[ "$VERBOSE" != no ] && log_failure_msg "failed to stop"
[ "$VERBOSE" != no ] && log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:

1129
conf/mpapis@gmail.com.pgp Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,22 +1,33 @@
# Proxy if requested file not found
try_files $uri @diaspora;
root ROOTOCHANGE/public;
location __PATH__ {
root __FINALPATH__/diaspora/public;
location @diaspora {
# Configure maximum picture size
# Note that Diaspora has a client side check set at 4M
client_max_body_size 5M;
client_body_buffer_size 256K;
# Proxy if requested file not found
try_files $uri @diaspora;
location __PATH__/assets/ {
expires max;
add_header Cache-Control public;
}
# Include SSOWAT user panel.
# TODO check that
include conf.d/yunohost_panel.conf.inc;
}
location @diaspora {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://diaspora_server;
proxy_pass http://unix:/run/__NAME__/diaspora.sock;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}

View file

@ -1,5 +0,0 @@
upstream diaspora_server {
server 127.0.0.1:3986;
}

View file

@ -0,0 +1,132 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFglzSYBEADfGIe+NZMt2ymkKz6QvgG7Kwu54s5E/rikRNRKviysO7O3NWC8
P6FQ80kf4s1OhMF+//xnQTXiqFyjCFqftbEM2ApK9YHTUoVFF8I6Ed3uRxP9H3fO
dkn3nkvWjSUNo35DkBpGtV6XcMRqHbjG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ToDdydSnuEhSC3rlyJ9Du724UsKBBoH/LiRp4yMv6Y7b4lH4orONriEjjb1X3Ln3
Dcp83Zho3ANvhjWz2lL4XRzCLnUdYwV56872vH3AeSAvjfgbf5oYlLhXgMUXsNF/
2YBn1UOcqwKgmOGl8capSPz2+q/sGjYLIMQ6pA5XKHrI8FjdON2AYxrSRb8RBBAW
hFvJNrAwzAqorolYtNkAfXgU0kayY9SXElQBsNnU/9EcW6/eqfZPWzHgTRXV6yvC
OAygYHVwad62iQMzFGSamQYcinnwZccRuRNRCYHzIjB9tCOMe2qa5pjPeYMTk8vK
9yrYeRzBeQFMQXQgRZV8GcN8E/qBBc85qGZWRw8XeXpqBo08teH81jnjbbw+uZrl
ItFD89SDex93x3lKKaBo31AAqmYx5hOEG4q2cOh33kB9WOozqLf0UjUQOyBpN+Cu
/PK2WJKMqBfFjpef34eIMVOzhxp/oQ4xVQD+H27ExayutgIvExrFBeRU1RxhwRAW
fiC0aDWzK4QuWnmZG1oSv7hLIMChvUM39Oo/Jz1BYTVfCRWMQZeX/ncaZCSBM/MM
iWTuv7mXY0bNG+s=
=SF+D
-----END PGP PUBLIC KEY BLOCK-----

View file

@ -7,20 +7,19 @@
"en": "Distributed social networking service",
"fr": "Service de réseau social distribué"
},
"license": "free",
"version": "1.0",
"license": "AGPL-3.0",
"version": "0.7.13.0~ynh1",
"maintainer": {
"name": "rafi59",
"email": ""
},
"requirements": {
"yunohost": ">= 2.7.2"
"yunohost": ">= 3.6.0"
},
"multi_instance": "false",
"multi_instance": true,
"services": [
"nginx",
"php5-fpm",
"mysql"
"postgresql"
],
"arguments": {
"install" : [
@ -37,20 +36,29 @@
"name": "path",
"type": "path",
"ask": {
"en": "Choose a path for ynhexample",
"fr": "Choisissez un chemin pour diaspora (uniquement / est accepté)"
"en": "Choose a path for ynhexample (only / is accepted for now)",
"fr": "Choisissez un chemin pour diaspora (pour l'instant, uniquement / est accepté)"
},
"example": "/",
"default": "/"
},
{
"name": "is_public",
"type": "boolean",
"name": "admin",
"type": "user",
"ask": {
"en": "Is it a public Diaspora site?",
"fr": "Est-ce un site public ?"
"en": "Choose the diaspora* administrator (must be an existing YunoHost user)",
"fr": "Choisissez l'administrateur de diaspora* (doit être un utilisateur YunoHost)"
},
"default": true
"example": "johndoe"
},
{
"name": "admin_password",
"type": "password",
"ask": {
"en": "Admin password. Must contain at least 10 characters, one lowercase letter, one uppercase letter, one number, and one symbol (e.g. '~!@#$%^&*()').",
"fr": "Mot de passe pour ladministrateur. Doit contenir au moins 10 caractères, une majuscule, une minuscule, un chiffre, et une ponctuation (ex. '~!@#$%^&*()')."
},
"optional": false
}
]
}

View file

@ -1,848 +1,4 @@
#!/bin/bash
#=================================================
#=================================================
# TESTING
#=================================================
#=================================================
YNH_EXECUTION_DIR="."
ynh_backup_abstract () {
# A intégrer à ynh_backup directement.
ynh_backup "$@"
echo "$2" "$1" >> backup_list
}
ynh_restore_file () {
file_and_dest=$(grep "^$1" backup_list)
backup_file=${file_and_dest%% *}
backup_dest=${file_and_dest#* }
if [ -f "$backup_dest" ]; then
ynh_die "There is already a file at this path: $backup_dest"
fi
if test -d "$backup_file"; then
sudo cp -a "$backup_file/." "$backup_dest"
else
sudo cp -a "$backup_file" "$backup_dest"
fi
}
ynh_fpm_config () {
finalphpconf="/etc/php5/fpm/pool.d/$app.conf"
ynh_backup_if_checksum_is_different "$finalphpconf" 1
sudo cp ../conf/php-fpm.conf "$finalphpconf"
ynh_replace_string "__NAMETOCHANGE__" "$app" "$finalphpconf"
ynh_replace_string "__FINALPATH__" "$final_path" "$finalphpconf"
ynh_replace_string "__USER__" "$app" "$finalphpconf"
sudo chown root: "$finalphpconf"
ynh_store_file_checksum "$finalphpconf"
if [ -e "../conf/php-fpm.ini" ]
then
finalphpini="/etc/php5/fpm/conf.d/20-$app.ini"
ynh_backup_if_checksum_is_different "$finalphpini" 1
sudo cp ../conf/php-fpm.ini "$finalphpini"
sudo chown root: "$finalphpini"
ynh_store_file_checksum "$finalphpini"
fi
sudo systemctl reload php5-fpm
}
ynh_remove_fpm_config () {
ynh_secure_remove "/etc/php5/fpm/pool.d/$app.conf"
ynh_secure_remove "/etc/php5/fpm/conf.d/20-$app.ini"
sudo systemctl reload php5-fpm
}
ynh_nginx_config () {
finalnginxconf="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup_if_checksum_is_different "$finalnginxconf" 1
sudo cp ../conf/nginx.conf "$finalnginxconf"
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
# Substitute in a nginx config file only if the variable is not empty
if test -n "${path_url:-}"; then
ynh_replace_string "__PATH__" "$path_url" "$finalnginxconf"
fi
if test -n "${domain:-}"; then
ynh_replace_string "__DOMAIN__" "$domain" "$finalnginxconf"
fi
if test -n "${port:-}"; then
ynh_replace_string "__PORT__" "$port" "$finalnginxconf"
fi
if test -n "${app:-}"; then
ynh_replace_string "__NAME__" "$app" "$finalnginxconf"
fi
if test -n "${final_path:-}"; then
ynh_replace_string "__FINALPATH__" "$final_path" "$finalnginxconf"
fi
ynh_store_file_checksum "$finalnginxconf"
sudo systemctl reload nginx
}
ynh_remove_nginx_config () {
ynh_secure_remove "/etc/nginx/conf.d/$domain.d/$app.conf"
sudo systemctl reload nginx
}
ynh_systemd_config () {
finalsystemdconf="/etc/systemd/system/$app.service"
ynh_backup_if_checksum_is_different "$finalsystemdconf" 1
sudo cp ../conf/systemd.service "$finalsystemdconf"
# To avoid a break by set -u, use a void substitution ${var:-}. If the variable is not set, it's simply set with an empty variable.
# Substitute in a nginx config file only if the variable is not empty
if test -n "${final_path:-}"; then
ynh_replace_string "__FINALPATH__" "$final_path" "$finalsystemdconf"
fi
if test -n "${app:-}"; then
ynh_replace_string "__APP__" "$app" "$finalsystemdconf"
fi
ynh_store_file_checksum "$finalsystemdconf"
sudo chown root: "$finalsystemdconf"
sudo systemctl enable $app
sudo systemctl daemon-reload
}
ynh_remove_systemd_config () {
finalsystemdconf="/etc/systemd/system/$app.service"
if [ -e "$finalsystemdconf" ]; then
sudo systemctl stop $app
sudo systemctl disable $app
ynh_secure_remove "$finalsystemdconf"
fi
}
#=================================================
#=================================================
#=================================================
# CHECKING
#=================================================
CHECK_DOMAINPATH () { # Vérifie la disponibilité du path et du domaine.
sudo yunohost app checkurl $domain$path_url -a $app
}
CHECK_FINALPATH () { # Vérifie que le dossier de destination n'est pas déjà utilisé.
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
}
#=================================================
# DISPLAYING
#=================================================
NO_PRINT () { # Supprime l'affichage dans stdout pour la commande en argument.
set +x
$@
set -x
}
WARNING () { # Écrit sur le canal d'erreur pour passer en warning.
$@ >&2
}
SUPPRESS_WARNING () { # Force l'écriture sur la sortie standard
$@ 2>&1
}
QUIET () { # Redirige la sortie standard dans /dev/null
$@ > /dev/null
}
ALL_QUIET () { # Redirige la sortie standard et d'erreur dans /dev/null
$@ > /dev/null 2>&1
}
#=================================================
# BACKUP
#=================================================
BACKUP_FAIL_UPGRADE () {
WARNING echo "Upgrade failed."
app_bck=${app//_/-} # Replace all '_' by '-'
if sudo yunohost backup list | grep -q $app_bck-pre-upgrade$backup_number; then # Vérifie l'existence de l'archive avant de supprimer l'application et de restaurer
sudo yunohost app remove $app # Supprime l'application avant de la restaurer.
sudo yunohost backup restore --ignore-hooks $app_bck-pre-upgrade$backup_number --apps $app --force # Restore the backup if upgrade failed
ynh_die "The app was restored to the way it was before the failed upgrade."
fi
}
BACKUP_BEFORE_UPGRADE () { # Backup the current version of the app, restore it if the upgrade fails
backup_number=1
old_backup_number=2
app_bck=${app//_/-} # Replace all '_' by '-'
if sudo yunohost backup list | grep -q $app_bck-pre-upgrade1; then # Vérifie l'existence d'une archive déjà numéroté à 1.
backup_number=2 # Et passe le numéro de l'archive à 2
old_backup_number=1
fi
sudo yunohost backup create --ignore-hooks --apps $app --name $app_bck-pre-upgrade$backup_number # Créer un backup différent de celui existant.
if [ "$?" -eq 0 ]; then # Si le backup est un succès, supprime l'archive précédente.
if sudo yunohost backup list | grep -q $app_bck-pre-upgrade$old_backup_number; then # Vérifie l'existence de l'ancienne archive avant de la supprimer, pour éviter une erreur.
QUIET sudo yunohost backup delete $app_bck-pre-upgrade$old_backup_number
fi
else # Si le backup a échoué
ynh_die "Backup failed, the upgrade process was aborted."
fi
}
HUMAN_SIZE () { # Transforme une taille en Ko en une taille lisible pour un humain
human=$(numfmt --to=iec --from-unit=1K $1)
echo $human
}
CHECK_SIZE () { # Vérifie avant chaque backup que l'espace est suffisant
file_to_analyse=$1
backup_size=$(sudo du --summarize "$file_to_analyse" | cut -f1)
free_space=$(sudo df --output=avail "/home/yunohost.backup" | sed 1d)
if [ $free_space -le $backup_size ]
then
WARNING echo "Espace insuffisant pour sauvegarder $file_to_analyse."
WARNING echo "Espace disponible: $(HUMAN_SIZE $free_space)"
ynh_die "Espace nécessaire: $(HUMAN_SIZE $backup_size)"
fi
}
#=================================================
# PACKAGE CHECK BYPASSING...
#=================================================
IS_PACKAGE_CHECK () { # Détermine une exécution en conteneur (Non testé)
return $(uname -n | grep -c 'pchecker_lxc')
}
#=================================================
# NODEJS
#=================================================
sudo_path () {
sudo env "PATH=$PATH" $@
}
# INFOS
# nvm utilise la variable PATH pour stocker le path de la version de node à utiliser.
# C'est ainsi qu'il change de version
# En attendant une généralisation de root, il est possible d'utiliser sudo aevc le helper temporaire sudo_path
# Il permet d'utiliser sudo en gardant le $PATH modifié
# ynh_install_nodejs installe la version de nodejs demandée en argument, avec nvm
# ynh_use_nodejs active une version de nodejs dans le script courant
# 3 variables sont mises à disposition, et 2 sont stockées dans la config de l'app
# - nodejs_path: Le chemin absolu de cette version de node
# Utilisé pour des appels directs à npm ou node.
# - nodejs_version: Simplement le numéro de version de nodejs pour cette application
# - nodejs_use_version: Un alias pour charger une version de node dans le shell courant.
# Utilisé pour démarrer un service ou un script qui utilise node ou npm
# Dans ce cas, c'est $PATH qui contient le chemin de la version de node. Il doit être propagé sur les autres shell si nécessaire.
nvm_install_dir="/opt/nvm"
ynh_use_nodejs () {
nodejs_path=$(ynh_app_setting_get $app nodejs_path)
nodejs_version=$(ynh_app_setting_get $app nodejs_version)
# And store the command to use a specific version of node. Equal to `nvm use version`
nodejs_use_version="source $nvm_install_dir/nvm.sh; nvm use \"$nodejs_version\""
# Desactive set -u for this script.
set +u
eval $nodejs_use_version
set -u
}
ynh_install_nodejs () {
local nodejs_version="$1"
local nvm_install_script="https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh"
local nvm_exec="source $nvm_install_dir/nvm.sh; nvm"
sudo mkdir -p "$nvm_install_dir"
# If nvm is not previously setup, install it
"$nvm_exec --version" > /dev/null 2>&1 || \
( cd "$nvm_install_dir"
echo "Installation of NVM"
sudo wget --no-verbose "$nvm_install_script" -O- | sudo NVM_DIR="$nvm_install_dir" bash > /dev/null)
# Install the requested version of nodejs
sudo su -c "$nvm_exec install \"$nodejs_version\" > /dev/null"
# Store the ID of this app and the version of node requested for it
echo "$YNH_APP_ID:$nodejs_version" | sudo tee --append "$nvm_install_dir/ynh_app_version"
# Get the absolute path of this version of node
nodejs_path="$(dirname "$(sudo su -c "$nvm_exec which \"$nodejs_version\"")")"
# Store nodejs_path and nodejs_version into the config of this app
ynh_app_setting_set $app nodejs_path $nodejs_path
ynh_app_setting_set $app nodejs_version $nodejs_version
ynh_use_nodejs
}
ynh_remove_nodejs () {
nodejs_version=$(ynh_app_setting_get $app nodejs_version)
# Remove the line for this app
sudo sed --in-place "/$YNH_APP_ID:$nodejs_version/d" "$nvm_install_dir/ynh_app_version"
# If none another app uses this version of nodejs, remove it.
if ! grep --quiet "$nodejs_version" "$nvm_install_dir/ynh_app_version"
then
sudo su -c "source $nvm_install_dir/nvm.sh; nvm deactivate; nvm uninstall \"$nodejs_version\" > /dev/null"
fi
# If none another app uses nvm, remove nvm and clean the root's bashrc file
if [ ! -s "$nvm_install_dir/ynh_app_version" ]
then
ynh_secure_remove "$nvm_install_dir"
sudo sed --in-place "/NVM_DIR/d" /root/.bashrc
fi
}
#=================================================
#=================================================
# FUTUR YNH HELPERS
#=================================================
# Importer ce fichier de fonction avant celui des helpers officiel
# Ainsi, les officiels prendront le pas sur ceux-ci le cas échéant
#=================================================
# Normalize the url path syntax
# Handle the slash at the beginning of path and its absence at ending
# Return a normalized url path
#
# example: url_path=$(ynh_normalize_url_path $url_path)
# ynh_normalize_url_path example -> /example
# ynh_normalize_url_path /example -> /example
# ynh_normalize_url_path /example/ -> /example
# ynh_normalize_url_path / -> /
#
# usage: ynh_normalize_url_path path_to_normalize
# | arg: url_path_to_normalize - URL path to normalize before using it
ynh_normalize_url_path () {
path_url=$1
test -n "$path_url" || ynh_die "ynh_normalize_url_path expect a URL path as first argument and received nothing."
if [ "${path_url:0:1}" != "/" ]; then # If the first character is not a /
path_url="/$path_url" # Add / at begin of path variable
fi
if [ "${path_url:${#path_url}-1}" == "/" ] && [ ${#path_url} -gt 1 ]; then # If the last character is a / and that not the only character.
path_url="${path_url:0:${#path_url}-1}" # Delete the last character
fi
echo $path_url
}
# Check if a mysql user exists
#
# usage: ynh_mysql_user_exists user
# | arg: user - the user for which to check existence
function ynh_mysql_user_exists()
{
local user=$1
if [[ -z $(ynh_mysql_execute_as_root "SELECT User from mysql.user WHERE User = '$user';") ]]
then
return 1
else
return 0
fi
}
# Create a database, an user and its password. Then store the password in the app's config
#
# After executing this helper, the password of the created database will be available in $db_pwd
# It will also be stored as "mysqlpwd" into the app settings.
#
# usage: ynh_mysql_setup_db user name [pwd]
# | arg: user - Owner of the database
# | arg: name - Name of the database
# | arg: pwd - Password of the database. If not given, a password will be generated
ynh_mysql_setup_db () {
local db_user="$1"
local db_name="$2"
local new_db_pwd=$(ynh_string_random) # Generate a random password
db_pwd=${3:-$new_db_pwd}
ynh_mysql_create_db "$db_name" "$db_user" "$db_pwd" # Create the database
ynh_app_setting_set $app mysqlpwd $db_pwd # Store the password in the app's config
}
# Remove a database if it exists, and the associated user
#
# usage: ynh_mysql_remove_db user name
# | arg: user - Owner of the database
# | arg: name - Name of the database
ynh_mysql_remove_db () {
local db_user="$1"
local db_name="$2"
local mysql_root_password=$(sudo cat $MYSQL_ROOT_PWD_FILE)
if mysqlshow -u root -p$mysql_root_password | grep -q "^| $db_name"; then # Check if the database exists
echo "Removing database $db_name" >&2
ynh_mysql_drop_db $db_name # Remove the database
else
echo "Database $db_name not found" >&2
fi
# Remove mysql user if it exists
if $(ynh_mysql_user_exists $db_user); then
ynh_mysql_drop_user $db_user
fi
}
# Correct the name given in argument for mariadb
#
# Avoid invalid name for your database
#
# Exemple: dbname=$(ynh_make_valid_dbid $app)
#
# usage: ynh_make_valid_dbid name
# | arg: name - name to correct
# | ret: the corrected name
ynh_make_valid_dbid () {
dbid=${1//[-.]/_} # Mariadb doesn't support - and . in the name of databases. It will be replace by _
echo $dbid
}
# Manage a fail of the script
#
# Print a warning to inform that the script was failed
# Execute the ynh_clean_setup function if used in the app script
#
# usage of ynh_clean_setup function
# This function provide a way to clean some residual of installation that not managed by remove script.
# To use it, simply add in your script:
# ynh_clean_setup () {
# instructions...
# }
# This function is optionnal.
#
# Usage: ynh_exit_properly is used only by the helper ynh_abort_if_errors.
# You must not use it directly.
ynh_exit_properly () {
exit_code=$?
if [ "$exit_code" -eq 0 ]; then
exit 0 # Exit without error if the script ended correctly
fi
trap '' EXIT # Ignore new exit signals
set +eu # Do not exit anymore if a command fail or if a variable is empty
echo -e "!!\n $app's script has encountered an error. Its execution was cancelled.\n!!" >&2
if type -t ynh_clean_setup > /dev/null; then # Check if the function exist in the app script.
ynh_clean_setup # Call the function to do specific cleaning for the app.
fi
ynh_die # Exit with error status
}
# Exit if an error occurs during the execution of the script.
#
# Stop immediatly the execution if an error occured or if a empty variable is used.
# The execution of the script is derivate to ynh_exit_properly function before exit.
#
# Usage: ynh_abort_if_errors
ynh_abort_if_errors () {
set -eu # Exit if a command fail, and if a variable is used unset.
trap ynh_exit_properly EXIT # Capturing exit signals on shell script
}
# Define and install dependencies with a equivs control file
# This helper can/should only be called once per app
#
# usage: ynh_install_app_dependencies dep [dep [...]]
# | arg: dep - the package name to install in dependence
ynh_install_app_dependencies () {
dependencies=$@
manifest_path="../manifest.json"
if [ ! -e "$manifest_path" ]; then
manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place
fi
version=$(sudo grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file.
dep_app=${app//_/-} # Replace all '_' by '-'
if ynh_package_is_installed "${dep_app}-ynh-deps"; then
echo "A package named ${dep_app}-ynh-deps is already installed" >&2
else
cat > ./${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build
Section: misc
Priority: optional
Package: ${dep_app}-ynh-deps
Version: ${version}
Depends: ${dependencies// /, }
Architecture: all
Description: Fake package for ${app} (YunoHost app) dependencies
This meta-package is only responsible of installing its dependencies.
EOF
ynh_package_install_from_equivs ./${dep_app}-ynh-deps.control \
|| ynh_die "Unable to install dependencies" # Install the fake package and its dependencies
ynh_app_setting_set $app apt_dependencies $dependencies
fi
}
# Remove fake package and its dependencies
#
# Dependencies will removed only if no other package need them.
#
# usage: ynh_remove_app_dependencies
ynh_remove_app_dependencies () {
dep_app=${app//_/-} # Replace all '_' by '-'
ynh_package_autoremove ${dep_app}-ynh-deps # Remove the fake package and its dependencies if they not still used.
}
# Use logrotate to manage the logfile
#
# usage: ynh_use_logrotate [logfile]
# | arg: logfile - absolute path of logfile
#
# If no argument provided, a standard directory will be use. /var/log/${app}
# You can provide a path with the directory only or with the logfile.
# /parentdir/logdir/
# /parentdir/logdir/logfile.log
#
# It's possible to use this helper several times, each config will added to same logrotate config file.
ynh_use_logrotate () {
if [ "$#" -gt 0 ]; then
if [ "$(echo ${1##*.})" == "log" ]; then # Keep only the extension to check if it's a logfile
logfile=$1 # In this case, focus logrotate on the logfile
else
logfile=$1/.log # Else, uses the directory and all logfile into it.
fi
else
logfile="/var/log/${app}/.log" # Without argument, use a defaut directory in /var/log
fi
cat > ./${app}-logrotate << EOF # Build a config file for logrotate
$logfile {
# Rotate if the logfile exceeds 100Mo
size 100M
# Keep 12 old log maximum
rotate 12
# Compress the logs with gzip
compress
# Compress the log at the next cycle. So keep always 2 non compressed logs
delaycompress
# Copy and truncate the log to allow to continue write on it. Instead of move the log.
copytruncate
# Do not do an error if the log is missing
missingok
# Not rotate if the log is empty
notifempty
# Keep old logs in the same dir
noolddir
}
EOF
sudo mkdir -p $(dirname "$logfile") # Create the log directory, if not exist
cat ${app}-logrotate | sudo tee -a /etc/logrotate.d/$app > /dev/null # Append this config to the others for this app. If a config file already exist
}
# Remove the app's logrotate config.
#
# usage: ynh_remove_logrotate
ynh_remove_logrotate () {
if [ -e "/etc/logrotate.d/$app" ]; then
sudo rm "/etc/logrotate.d/$app"
fi
}
# Find a free port and return it
#
# example: port=$(ynh_find_port 8080)
#
# usage: ynh_find_port begin_port
# | arg: begin_port - port to start to search
ynh_find_port () {
port=$1
test -n "$port" || ynh_die "The argument of ynh_find_port must be a valid port."
while netcat -z 127.0.0.1 $port # Check if the port is free
do
port=$((port+1)) # Else, pass to next port
done
echo $port
}
# Create a system user
#
# usage: ynh_system_user_create user_name [home_dir]
# | arg: user_name - Name of the system user that will be create
# | arg: home_dir - Path of the home dir for the user. Usually the final path of the app. If this argument is omitted, the user will be created without home
ynh_system_user_create () {
if ! ynh_system_user_exists "$1" # Check if the user exists on the system
then # If the user doesn't exist
if [ $# -ge 2 ]; then # If a home dir is mentioned
user_home_dir="-d $2"
else
user_home_dir="--no-create-home"
fi
sudo useradd $user_home_dir --system --user-group $1 --shell /usr/sbin/nologin || ynh_die "Unable to create $1 system account"
fi
}
# Delete a system user
#
# usage: ynh_system_user_delete user_name
# | arg: user_name - Name of the system user that will be create
ynh_system_user_delete () {
if ynh_system_user_exists "$1" # Check if the user exists on the system
then
echo "Remove the user $1" >&2
sudo userdel $1
else
echo "The user $1 was not found" >&2
fi
}
# Curl abstraction to help with POST requests to local pages (such as installation forms)
#
# $domain and $path_url should be defined externally (and correspond to the domain.tld and the /path (of the app?))
#
# example: ynh_local_curl "/install.php?installButton" "foo=$var1" "bar=$var2"
#
# usage: ynh_local_curl "page_uri" "key1=value1" "key2=value2" ...
# | arg: page_uri - Path (relative to $path_url) of the page where POST data will be sent
# | arg: key1=value1 - (Optionnal) POST key and corresponding value
# | arg: key2=value2 - (Optionnal) Another POST key and corresponding value
# | arg: ... - (Optionnal) More POST keys and values
ynh_local_curl () {
# Define url of page to curl
full_page_url=https://localhost$path_url$1
# Concatenate all other arguments with '&' to prepare POST data
POST_data=""
for arg in "${@:2}"
do
POST_data="${POST_data}${arg}&"
done
if [ -n "$POST_data" ]
then
# Add --data arg and remove the last character, which is an unecessary '&'
POST_data="--data \"${POST_data::-1}\""
fi
# Curl the URL
curl --silent --show-error -kL -H "Host: $domain" --resolve $domain:443:127.0.0.1 $POST_data "$full_page_url"
}
# Substitute/replace a string by another in a file
#
# usage: ynh_replace_string match_string replace_string target_file
# | arg: match_string - String to be searched and replaced in the file
# | arg: replace_string - String that will replace matches
# | arg: target_file - File in which the string will be replaced.
ynh_replace_string () {
delimit=@
match_string=${1//${delimit}/"\\${delimit}"} # Escape the delimiter if it's in the string.
replace_string=${2//${delimit}/"\\${delimit}"}
workfile=$3
sudo sed --in-place "s${delimit}${match_string}${delimit}${replace_string}${delimit}g" "$workfile"
}
# Remove a file or a directory securely
#
# usage: ynh_secure_remove path_to_remove
# | arg: path_to_remove - File or directory to remove
ynh_secure_remove () {
path_to_remove=$1
forbidden_path=" \
/var/www \
/home/yunohost.app"
if [[ "$forbidden_path" =~ "$path_to_remove" \
# Match all paths or subpaths in $forbidden_path
|| "$path_to_remove" =~ ^/[[:alnum:]]+$ \
# Match all first level paths from / (Like /var, /root, etc...)
|| "${path_to_remove:${#path_to_remove}-1}" = "/" ]]
# Match if the path finishes by /. Because it seems there is an empty variable
then
echo "Avoid deleting $path_to_remove." >&2
else
if [ -e "$path_to_remove" ]
then
sudo rm -R "$path_to_remove"
else
echo "$path_to_remove wasn't deleted because it doesn't exist." >&2
fi
fi
}
# Download, check integrity, uncompress and patch the source from app.src
#
# The file conf/app.src need to contains:
#
# SOURCE_URL=Address to download the app archive
# SOURCE_SUM=Control sum
# # (Optional) Programm to check the integrity (sha256sum, md5sum$YNH_EXECUTION_DIR/...)
# # default: sha256
# SOURCE_SUM_PRG=sha256
# # (Optional) Archive format
# # default: tar.gz
# SOURCE_FORMAT=tar.gz
# # (Optional) Put false if source are directly in the archive root
# # default: true
# SOURCE_IN_SUBDIR=false
# # (Optionnal) Name of the local archive (offline setup support)
# # default: ${src_id}.${src_format}
# SOURCE_FILENAME=example.tar.gz
#
# Details:
# This helper download sources from SOURCE_URL if there is no local source
# archive in /opt/yunohost-apps-src/APP_ID/SOURCE_FILENAME
#
# Next, it check the integrity with "SOURCE_SUM_PRG -c --status" command.
#
# If it's ok, the source archive will be uncompress in $dest_dir. If the
# SOURCE_IN_SUBDIR is true, the first level directory of the archive will be
# removed.
#
# Finally, patches named sources/patches/${src_id}-*.patch and extra files in
# sources/extra_files/$src_id will be applyed to dest_dir
#
#
# usage: ynh_setup_source dest_dir [source_id]
# | arg: dest_dir - Directory where to setup sources
# | arg: source_id - Name of the app, if the package contains more than one app
ynh_setup_source () {
local dest_dir=$1
local src_id=${2:-app} # If the argument is not given, source_id equal "app"
# Load value from configuration file (see above for a small doc about this file
# format)
local src_url=$(grep 'SOURCE_URL=' "$YNH_EXECUTION_DIR/../conf/${src_id}.src" | cut -d= -f2-)
local src_sum=$(grep 'SOURCE_SUM=' "$YNH_EXECUTION_DIR/../conf/${src_id}.src" | cut -d= -f2-)
local src_sumprg=$(grep 'SOURCE_SUM_PRG=' "$YNH_EXECUTION_DIR/../conf/${src_id}.src" | cut -d= -f2-)
local src_format=$(grep 'SOURCE_FORMAT=' "$YNH_EXECUTION_DIR/../conf/${src_id}.src" | cut -d= -f2-)
local src_in_subdir=$(grep 'SOURCE_IN_SUBDIR=' "$YNH_EXECUTION_DIR/../conf/${src_id}.src" | cut -d= -f2-)
local src_filename=$(grep 'SOURCE_FILENAME=' "$YNH_EXECUTION_DIR/../conf/${src_id}.src" | cut -d= -f2-)
# Default value
src_sumprg=${src_sumprg:-sha256sum}
src_in_subdir=${src_in_subdir:-true}
src_format=${src_format:-tar.gz}
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
if [ "$src_filename" = "" ] ; then
src_filename="${src_id}.${src_format}"
fi
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${src_filename}"
if test -e "$local_src"
then # Use the local source file if it is present
sudo cp $local_src $src_filename
else # If not, download the source
wget -nv -O $src_filename $src_url
fi
# Check the control sum
echo "${src_sum} ${src_filename}" | ${src_sumprg} -c --status \
|| ynh_die "Corrupt source"
# Extract source into the app dir
sudo mkdir -p "$dest_dir"
if [ "$src_format" = "zip" ]
then
# Zip format
# Using of a temp directory, because unzip doesn't manage --strip-components
if $src_in_subdir ; then
local tmp_dir=$(mktemp -d)
unzip -quo $src_filename -d "$tmp_dir"
sudo cp -a $tmp_dir/*/. "$dest_dir"
ynh_secure_remove "$tmp_dir"
else
sudo unzip -quo $src_filename -d "$dest_dir"
fi
else
local strip=""
if $src_in_subdir ; then
strip="--strip-components 1"
fi
if [[ "$src_format" =~ ^tar.gz|tar.bz2|tar.xz$ ]] ; then
sudo tar -xf $src_filename -C "$dest_dir" $strip
else
ynh_die "Archive format unrecognized."
fi
fi
# Apply patches
if (( $(find $YNH_EXECUTION_DIR/../sources/patches/ -type f -name "${src_id}-*.patch" 2> /dev/null | wc -l) > "0" )); then
local old_dir=$(pwd)
(cd "$dest_dir" \
&& for p in $YNH_EXECUTION_DIR/../sources/patches/${src_id}-*.patch; do \
patch -p1 < $p; done) \
|| ynh_die "Unable to apply patches"
cd $old_dir
fi
# Add supplementary files
if test -e "$YNH_EXECUTION_DIR/../sources/extra_files/${src_id}"; then
cp -a $YNH_EXECUTION_DIR/../sources/extra_files/$src_id/. "$dest_dir"
fi
}
# Check availability of a web path
#
# example: ynh_webpath_available some.domain.tld /coffee
#
# usage: ynh_webpath_available domain path
# | arg: domain - the domain/host of the url
# | arg: path - the web path to check the availability of
ynh_webpath_available () {
local domain=$1
local path=$2
sudo yunohost domain url-available $domain $path
}
# Register/book a web path for an app
#
# example: ynh_webpath_register wordpress some.domain.tld /coffee
#
# usage: ynh_webpath_register app domain path
# | arg: app - the app for which the domain should be registered
# | arg: domain - the domain/host of the web path
# | arg: path - the web path to be registered
ynh_webpath_register () {
local app=$1
local domain=$2
local path=$3
sudo yunohost app register-url $app $domain $path
}
# Calculate and store a file checksum into the app settings
#
# $app should be defined when calling this helper
#
# usage: ynh_store_file_checksum file
# | arg: file - The file on which the checksum will performed, then stored.
ynh_store_file_checksum () {
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
ynh_app_setting_set $app $checksum_setting_name $(sudo md5sum "$1" | cut -d' ' -f1)
}
# Verify the checksum and backup the file if it's different
# This helper is primarily meant to allow to easily backup personalised/manually
# modified config files.
#
# $app should be defined when calling this helper
#
# usage: ynh_backup_if_checksum_is_different file
# | arg: file - The file on which the checksum test will be perfomed.
#
# | ret: Return the name a the backup file, or nothing
ynh_backup_if_checksum_is_different () {
local file=$1
local checksum_setting_name=checksum_${file//[\/ ]/_} # Replace all '/' and ' ' by '_'
local checksum_value=$(ynh_app_setting_get $app $checksum_setting_name)
if [ -n "$checksum_value" ]
then # Proceed only if a value was stored into the app settings
if ! echo "$checksum_value $file" | sudo md5sum -c --status
then # If the checksum is now different
backup_file="/home/yunohost.conf/backup/$file.backup.$(date '+%Y%m%d.%H%M%S')"
sudo mkdir -p "$(dirname "$backup_file")"
sudo cp -a "$file" "$backup_file" # Backup the current file
echo "File $file has been manually modified since the installation or last upgrade. So it has been duplicated in $backup_file" >&2
echo "$backup_file" # Return the name of the backup file
fi
fi
}
pkg_dependencies="build-essential cmake libssl-dev libcurl4-openssl-dev libxml2-dev libxslt-dev imagemagick ghostscript curl libmagickwand-dev git libpq-dev redis-server nodejs postgresql bison "
ruby_build_dependencies="bison libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libyaml-dev pkg-config sqlite3 zlib1g-dev libgmp-dev libreadline-dev libssl-dev"

61
scripts/backup Normal file
View file

@ -0,0 +1,61 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
#=================================================
# STANDARD BACKUP STEPS
#=================================================
# clean folder
rm -rf $final_path/backup
mkdir -p $final_path/backup
#=================================================
# BACKUP DIASPORA DATABASE
#=================================================
ynh_script_progression --message="Backup Diaspora DB..." --weight=10
db_pass=$(ynh_app_setting_get --app=$app --key=psqlpwd)
dump_file="$final_path/backup/$app.dump"
pg_dump -d "dbname=$app user=$app password=$db_pass host=localhost" -Fc -f $dump_file
ynh_backup --src_path="$dump_file"
#=================================================
# BACKUP DIASPORA UPLOADS
#=================================================
ynh_script_progression --message="Backup uploads..." --weight=10
if [ -x $final_path/diaspora/public/uploads]; then
ynh_backup --src_path="$final_path/diaspora/public/uploads"
else
echo "uploads folder does not exist. Skipping."
fi
#=================================================
# BACKUP CONF FILES
#=================================================
ynh_script_progression --message="Backup configuration files of Diaspora..." --weight=10
ynh_backup --src_path="$final_path/diaspora/config/database.yml"
ynh_backup --src_path="$final_path/diaspora/config/diaspora.yml"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last

View file

@ -1,5 +1,14 @@
#!/bin/bash
# TODO
# - which service to register to ynuhosto? diaspora.target only ? All of them ?
# - backup / restore
# - changeurl ? Is that possible ? or even a good idea ?
# - make an admin automatically
# - integration with ssowat? Or not? How exactly?
# - a setting to enable / disable registration
# - say something about the registration to https://the-federation.info/
#=================================================
# GENERIC START
#=================================================
@ -22,7 +31,9 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN
path_url=$YNH_APP_ARG_PATH
is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN
admin_password=$YNH_APP_ARG_ADMIN_PASSWORD
admin_email=$(ynh_user_get_info --username=$admin --key=mail)
# This is a multi-instance app, meaning it can be installed several times independently
@ -40,130 +51,155 @@ app=$YNH_APP_INSTANCE_NAME
#=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
#=================================================
ynh_script_progression --message="Validating installation parameters..." --time --weight=1
# Normalize the url path syntax
path_url=$(ynh_normalize_url_path $path_url)
# Check web path availability
ynh_webpath_available $domain $path_url
# Register (book) web path
ynh_webpath_register $app $domain $path_url
ynh_webpath_available --domain=$domain --path_url=$path_url
# check path availability
final_path=/var/www/$app
test ! -e "$final_path" || ynh_die "This path already contains a folder"
# Register (book) web path
ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_app_setting_set $app domain $domain
ynh_app_setting_set $app path $path_url
ynh_app_setting_set $app is_public $is_public
ynh_script_progression --message="Saving app settings..." --time --weight=1
ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# FIND AND OPEN A PORT
#=================================================
# Find a free port
port=$(ynh_find_port 8095)
# Open this port
yunohost firewall allow --no-upnp TCP $port 2>&1
ynh_app_setting_set $app port $port
#=================================================
# INSTALL DEPENDENCIES
#=================================================
ynh_install_app_dependencies build-essential libssl-dev libcurl4-openssl-dev libxml2-dev libxslt-dev imagemagick ghostscript curl libmagickwand-dev git libmysqlclient-dev redis-server nodejs
ynh_script_progression --message="Installing dependencies..." --time --weight=27
ynh_install_app_dependencies $pkg_dependencies $ruby_build_dependencies
#=================================================
# CREATE A MYSQL DATABASE
# CREATE A POSTGRESQL DATABASE
#=================================================
# If your app uses a MySQL database, you can use these lines to bootstrap
# a database, an associated user and save the password in app settings
ynh_script_progression --message="Creating database..." --time --weight=1
db_name=$(ynh_sanitize_dbid $app)
ynh_app_setting_set $app db_name $db_name
ynh_mysql_setup_db $db_name $db_name
ynh_app_setting_set --app=$app --key=db_name --value=$db_name
ynh_psql_test_if_first_run
ynh_psql_setup_db $db_name $db_name
db_pass=$(ynh_app_setting_get --app=$app --key=psqlpwd)
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Creating user..." --time --weight=1
# Create a system user
ynh_system_user_create $app
ynh_system_user_create --username=$app --home_dir=$final_path --use_shell
mkdir -p $final_path
chown $app:$app $final_path
# SWITCH TO NEW USER UNTIL EOF
#=================================================
# INSTALL RVM AND RUBY FOR CURRENT USER
#=================================================
ynh_script_progression --message="Installing rvm..." --time --weight=10
sudo -u $app gpg --import ../conf/piotr.kuczynski\@gmail.com.pgp ../conf/mpapis\@gmail.com.pgp
pushd $final_path
sudo -u $app curl -sSL https://get.rvm.io | sudo -u $app bash -s stable
ynh_script_progression --message="Installing ruby 2.4 (this can take a long time)..." --time --weight=230
sudo -u $app $final_path/.rvm/bin/rvm autolibs read-fail
sudo -u $app $final_path/.rvm/bin/rvm install 2.4
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
# Download, check integrity, unucompress and patch the source from app.src
ynh_script_progression --message="Download the sources..." --time --weight=16
sudo -u $app git clone https://github.com/diaspora/diaspora.git -b v0.7.13.0
popd
ynh_app_setting_set $app final_path $final_path
# Download, check integrity, uncompress and patch the source from app.src
su -l $app -s /bin/bash
cd ~
git clone -b master https://github.com/diaspora/diaspora.git
cd diaspora
config/database.yml
cp config/diaspora.yml
curl -L https://s.diaspora.software/1t | bash
echo [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" | tee ~/.bashrc
gem install bundler
RAILS_ENV=production bin/bundle install --jobs $(nproc) --deployment --without test development --with mysql
#=================================================
# EXPORT VARIABLES FOR TEMPLATING
#=================================================
export app
export domain
export path_url
export db_pass
export final_path
export admin
#=================================================
# CONFIGURE DIASPORA
#=================================================
ynh_script_progression --message="Configure diaspora..." --time --weight=1
ynh_render_template ../conf/diaspora.yml $final_path/diaspora/config/diaspora.yml
ynh_render_template ../conf/database.yml $final_path/diaspora/config/database.yml
#=================================================
# Bundle the ruby app
#=================================================
pushd $final_path/diaspora
ynh_script_progression --message="bundle the app..." --time --weight=1000
# here we *absolutely* need bash (not dash) because dash does not understand what rvm puts in .profile
# (wtf rvm for assuming everybody uses bash as default shell??)
# we also need a login shell to make sure .profile is loaded
sudo -u $app /bin/bash --login << EOF
rvm use --default 2.4
rvm 2.4 do gem install bundler:1.17.3
script/configure_bundler
bin/bundle install --full-index --with=postgresql
EOF
ynh_script_progression --message="Create db schema..." --time --weight=22
sudo -u $app /bin/bash --login << EOF
RAILS_ENV=production bundle exec rake db:migrate
EOF
#=================================================
# ASSETS PRECOMPILATION
#=================================================
ynh_script_progression --message="Precompile assets..." --time --weight=400
sudo -u $app /bin/bash --login << EOF
RAILS_ENV=production bin/rake assets:precompile
EOF
popd
#=================================================
# NGINX CONFIGURATION
#=================================================
# TODO serve public/ ?
# Create a dedicated nginx config
ynh_script_progression --message="configure nginx..." --time --weight=1
ynh_add_nginx_config
#=================================================
# SPECIFIC SETUP
#=================================================
#=================================================
# SETUP SYSTEMD
#=================================================
# Create a dedicated systemd config
ynh_systemd_config
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
# Set right permissions for curl install
chown -R $app: $final_path
# Set the app as temporarily public for curl call
ynh_app_setting_set $app unprotected_uris "/"
# Reload SSOwat config
yunohost app ssowatconf
# Reload Nginx
systemctl reload nginx
# Installation with curl
ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
# TODO add service in yunohost panel ?
ynh_script_progression --message="configure systemd unit..." --time --weight=1
ynh_render_template ../conf/diaspora_sidekiq.service /etc/systemd/system/${app}_sidekiq.service
ynh_render_template ../conf/diaspora_web.service /etc/systemd/system/${app}_web.service
ynh_render_template ../conf/diaspora.tmpfiles.d /etc/tmpfiles.d/${app}.conf
ynh_render_template ../conf/diaspora.target /etc/systemd/system/${app}.target
systemctl daemon-reload
systemd-tmpfiles --create
systemctl enable ${app}.target ${app}_sidekiq.service ${app}_web.service
systemctl restart ${app}.target
#=================================================
# STORE THE CHECKSUM OF THE CONFIG FILE
#=================================================
# Calculate and store the config file checksum into the app settings
ynh_store_file_checksum "$final_path/CONFIG_FILE"
ynh_store_file_checksum --file="$final_path/diaspora/config/diaspora.yml"
ynh_store_file_checksum --file="$final_path/diaspora/config/database.yml"
#=================================================
# GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
chown -R root: $final_path
#=================================================
# SETUP LOGROTATE
@ -175,26 +211,38 @@ ynh_use_logrotate
#=================================================
# ADVERTISE SERVICE IN ADMIN PANEL
#=================================================
yunohost service add NAME_INIT.D --log "/var/log/FILE.log"
yunohost service add postgresql --log /var/log/postgresql/postgresql-9.4-main.log --description "PostgreSQL RDBMS"
yunohost service add $app.target\
--log $final_path/diaspora/log/production.log \
$final_path/diaspora/log/unicorn-stderr.log\
$final_path/diaspora/log/unicorn-stdout.log\
$final_path/diaspora/log/sidekiq.log\
--description "Diaspora service (unicorn web and sidekiq)"
#=================================================
# SETUP SSOWAT
#=================================================
if [ $is_public -eq 0 ]
then # Remove the public access
ynh_app_setting_delete $app skipped_uris
fi
# Make app public if necessary
if [ $is_public -eq 1 ]
then
# unprotected_uris allows SSO credentials to be passed anyway.
ynh_app_setting_set $app unprotected_uris "/"
fi
#=================================================
# RELOAD NGINX
#=================================================
ynh_script_progression --message="Reload nginx..." --time --weight=1
systemctl reload nginx
#=================================================
# CREATE AN ADMIN
#=================================================
ynh_script_progression --message="Create admin..." --time --weight=1
pushd $final_path/diaspora
sudo -u diaspora /bin/bash --login << EOF
RAILS_ENV=production bundle exec rails console << END
user = User.build({username: '$admin', email: '$admin_email', password: '$admin_password', password_confirmation: '$admin_password' })
user.seed_aspects
user.save
Role.add_admin user.person
END
EOF
popd

View file

@ -16,7 +16,6 @@ source /usr/share/yunohost/helpers
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain)
port=$(ynh_app_setting_get $app port)
db_name=$(ynh_app_setting_get $app db_name)
final_path=$(ynh_app_setting_get $app final_path)
@ -26,8 +25,15 @@ final_path=$(ynh_app_setting_get $app final_path)
# STOP AND REMOVE SERVICE
#=================================================
# Remove the dedicated systemd config
ynh_remove_systemd_config
yunohost service remove $app.target
systemctl stop ${app}.target ${app}_sidekiq.service ${app}_web.service
systemctl disable ${app}.target ${app}_sidekiq.service ${app}_web.service
ynh_secure_remove --file="/etc/systemd/system/${app}_web.service"
ynh_secure_remove --file="/etc/systemd/system/${app}_sidekiq.service"
ynh_secure_remove --file="/etc/tmpfiles.d/${app}.conf"
ynh_secure_remove --file="/etc/systemd/system/${app}.target"
ynh_secure_remove --file="/run/${app}"
systemctl daemon-reload
#=================================================
# REMOVE SERVICE FROM ADMIN PANEL
@ -39,6 +45,13 @@ then
yunohost service remove $app
fi
#=================================================
# REMOVE THE POSTGRESQL DATABASE
#=================================================
# Remove a database if it exists, along with the associated user
ynh_psql_remove_db $db_name $db_name
#=================================================
# REMOVE DEPENDENCIES
#=================================================
@ -46,20 +59,6 @@ fi
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#=================================================
# REMOVE THE MYSQL DATABASE
#=================================================
# Remove a database if it exists, along with the associated user
ynh_mysql_remove_db $db_name $db_name
#=================================================
# REMOVE APP MAIN DIR
#=================================================
# Remove the app directory securely
ynh_secure_remove "$final_path"
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
@ -67,45 +66,14 @@ ynh_secure_remove "$final_path"
# Remove the dedicated nginx config
ynh_remove_nginx_config
#=================================================
# REMOVE PHP-FPM CONFIGURATION
#=================================================
# Remove the dedicated php-fpm config
ynh_remove_fpm_config
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
# Remove the app-specific logrotate config
# TODO setup logrotate ?
ynh_remove_logrotate
#=================================================
# CLOSE A PORT
#=================================================
if yunohost firewall list | grep -q "\- $port$"
then
echo "Close port $port"
yunohost firewall disallow TCP $port 2>&1
fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE THE CRON FILE
#=================================================
# Remove a cron file
ynh_secure_remove "/etc/cron.d/$app"
# Remove a directory securely
ynh_secure_remove "/etc/$app/"
# Remove the log files
ynh_secure_remove "/var/log/$app/"
#=================================================
# GENERIC FINALIZATION
#=================================================
@ -113,4 +81,14 @@ ynh_secure_remove "/var/log/$app/"
#=================================================
# Delete a system user
# because we use gpg, sometimes rogue processes (gpg an d dirmngr) stays a bit,
# preventing the deletion of the user. Hence we kill all processes belonging to $app
pkill -9 -u `id -u $app`
ynh_system_user_delete $app
#=================================================
# REMOVE APP MAIN DIR
#=================================================
# Remove the app directory securely
ynh_secure_remove "$final_path"

40
scripts/restore Normal file
View file

@ -0,0 +1,40 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#=================================================
# LOAD SETTINGS
#=================================================
ynh_script_progression --message="Loading settings..." --time --weight=1
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name
#=================================================
# CHECK IF THE APP CAN BE RESTORED
#=================================================
ynh_script_progression --message="Validating restoration parameters..." --time --weight=1
ynh_webpath_available --domain=$domain --path_url=$path_url \
|| ynh_die --message="Path not available: ${domain}${path_url}"
test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path "

View file

@ -1,20 +1,31 @@
#!/bin/sh
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# IMPORT GENERIC HELPERS
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
app=$YNH_APP_INSTANCE_NAME
# Retrieve arguments
domain=$(sudo yunohost app setting diaspora domain)
admin=$(sudo yunohost app setting diaspora admin)
final_path=$(sudo yunohost app setting diaspora final_path)
domain=$(ynh_app_setting_get --app $app --key domain)
admin=$(ynh_app_setting_get --app $app --key admin)
final_path=$(ynh_app_setting_get --app $app --key final_path)
sudo service diaspora_ynh stop
sleep 3
ynh_abort_if_errors
sudo cp ../conf/diaspora_ynh /etc/init.d/diaspora_ynh
sudo chmod 754 /etc/init.d/diaspora_ynh
sudo su - diaspora -c "rvm get stable"
sudo su - diaspora -c "git checkout Gemfile.lock db/schema.rb ; git pull"
sudo su - diaspora -c "bundle"
sudo su - diaspora -c "RAILS_ENV=production bundle exec rake db:migrate"
sudo su - diaspora -c "RAILS_ENV=production bundle exec rake tmp:cache:clear assets:precompile"
sudo service diaspora_ynh start
upgrade_type=$(ynh_check_app_version_changed)
# nothing to do yet!!
if [ "$upgrade_type" == "UPGRADE_APP" ]
then
# do something!
echo "to be implemented"
fi