From fca48e20b2b28d97068a8a7d355c5a6fac8d9b01 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 04:17:05 +0200 Subject: [PATCH 01/94] Apply example_ynh on ReadMe --- README.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8fc24e4..b2db47e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,54 @@ -# syncthing_ynh +# Syncthing app for YunoHost -Only for Debian Jessie and after +[![Integration level](https://dash.yunohost.org/integration/syncthing.svg)](https://dash.yunohost.org/appci/app/syncthing) +[![Install Syncthing with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=syncthing) +> *This package allow you to install Syncthing quickly and simply on a YunoHost server. +If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* + +## Overview +Syncthing replaces proprietary sync and cloud services with something open, trustworthy and decentralized. Your data is your data alone and you deserve to choose where it is stored, if it is shared with some third party and how it's transmitted over the Internet. + +**Shipped version:** 1.0 + +## Screenshots + +![](https://docs.syncthing.net/_images/gs1.png) + +## Configuration + +How to configure this app: by an admin panel, a plain file with SSH, or any other way. + +## Documentation + + * Official documentation: https://docs.syncthing.net + +## YunoHost specific features + +#### Supported architectures + +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/syncthing%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/syncthing/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/syncthing%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/syncthing/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/syncthing%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/syncthing/) + +## Links + + * Report a bug: https://github.com/YunoHost-Apps/syncthing_ynh/issues + * App website: https://syncthing.net/ + * Git App website: https://github.com/syncthing/syncthing + * YunoHost website: https://yunohost.org/ + +--- + +Developers info +---------------- + +**Only if you want to use a testing branch for coding, instead of merging directly into master.** +Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/syncthing_ynh/tree/testing). + +To try the testing branch, please proceed like that. +``` +sudo yunohost app install https://github.com/YunoHost-Apps/syncthing_ynh/tree/testing --debug +or +sudo yunohost app upgrade syncthing -u https://github.com/YunoHost-Apps/syncthing_ynh/tree/testing --debug +``` From a9561bf865818c06cb365d47998e901fd074bdcf Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 04:23:16 +0200 Subject: [PATCH 02/94] Fix licence --- LICENSE | 1047 ++++++++++++++++++------------------------------- manifest.json | 2 +- 2 files changed, 374 insertions(+), 675 deletions(-) diff --git a/LICENSE b/LICENSE index 94a9ed0..d0a1fa1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,674 +1,373 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is 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. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - 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. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - 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 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. Use with the GNU Affero General Public License. - - 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 Affero 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 special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU 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 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 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 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. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - 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 GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at https://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/manifest.json b/manifest.json index 38e1e3e..cbc0fe2 100644 --- a/manifest.json +++ b/manifest.json @@ -7,7 +7,7 @@ "fr": "Syncthing remplace les services propriétaires de synchro et de cloud avec quelque chose d'ouvert, digne de confiance et décentralisée." }, "url": "https://syncthing.net/", - "license": "free", + "license": "MPL-2.0", "maintainer": { "name": "txmrl", "email": "txmrl@txmrl.net" From 07bf2fc122f00bf8bf8a10777bc7f89fc18c6e9b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 15:28:57 +0200 Subject: [PATCH 03/94] Fix GENERIC START --- scripts/_common.sh | 20 ++++++++++++++++++++ scripts/install | 22 ++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 scripts/_common.sh diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..8bb05b4 --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +#================================================= +# COMMON VARIABLES +#================================================= + +# dependencies used by the app +pkg_dependencies="deb1 deb2" + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/install b/scripts/install index dbaf09e..f93ee82 100644 --- a/scripts/install +++ b/scripts/install @@ -1,5 +1,27 @@ #!/bin/bash +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + ### Remove this function if there's nothing to clean before calling the remove script. + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + + + # Configurable variables SYNCHOME="/home/yunohost.app/syncthing" SYNCUSER=debian-syncthing From 117d5308a45cd780e9302920b9dee068a7f25d77 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 15:31:19 +0200 Subject: [PATCH 04/94] RETRIEVE ARGUMENTS FROM THE MANIFEST --- scripts/install | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index f93ee82..a4483a4 100644 --- a/scripts/install +++ b/scripts/install @@ -20,6 +20,17 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# RETRIEVE ARGUMENTS FROM THE MANIFEST +#================================================= + +domain=$YNH_APP_ARG_DOMAIN +path=$YNH_APP_ARG_PATH +user=$YNH_APP_ARG_ADMIN +channel=$YNH_APP_ARG_CHANNEL + +app=$YNH_APP_INSTANCE_NAME + # Configurable variables @@ -28,11 +39,7 @@ SYNCUSER=debian-syncthing SYNCPORT=22000 GUIPORT=8384 -# Retrieve arguments -domain=$1 -path=$2 -user=$3 -channel=$4 + # Check Debian version if [[ $(cat /etc/debian_version) < 8 ]] From 11cc64c37f41d63954f45f1afc8af1b833d2eeb5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 15:32:24 +0200 Subject: [PATCH 05/94] remove Debian version check --- scripts/install | 9 --------- 1 file changed, 9 deletions(-) diff --git a/scripts/install b/scripts/install index a4483a4..2e5bdc5 100644 --- a/scripts/install +++ b/scripts/install @@ -39,15 +39,6 @@ SYNCUSER=debian-syncthing SYNCPORT=22000 GUIPORT=8384 - - -# Check Debian version -if [[ $(cat /etc/debian_version) < 8 ]] -then - echo "You need debian Jessie (8.x) or more to install syncthing_ynh." - exit 1 -fi - # Check that admin user is an existing account sudo yunohost user list --json | grep -q "\"username\": \"$admin\"" \ || (echo "Error: the chosen admin user does not exist" && exit 1) From c822fc9ffaf07bc9821e2ef7ff17082f37f24808 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 15:42:34 +0200 Subject: [PATCH 06/94] remove check not used --- scripts/install | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/install b/scripts/install index 2e5bdc5..352809f 100644 --- a/scripts/install +++ b/scripts/install @@ -39,10 +39,6 @@ SYNCUSER=debian-syncthing SYNCPORT=22000 GUIPORT=8384 -# Check that admin user is an existing account -sudo yunohost user list --json | grep -q "\"username\": \"$admin\"" \ - || (echo "Error: the chosen admin user does not exist" && exit 1) - # Check domain/path availability sudo yunohost app checkurl $domain$path -a syncthing if [[ ! $? -eq 0 ]]; then From 7fc85b61481c1af7bf5090be329a0d5dd535f6dc Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 15:44:40 +0200 Subject: [PATCH 07/94] switch domain/path availability check --- scripts/install | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/install b/scripts/install index 352809f..2256ac0 100644 --- a/scripts/install +++ b/scripts/install @@ -39,15 +39,15 @@ SYNCUSER=debian-syncthing SYNCPORT=22000 GUIPORT=8384 -# Check domain/path availability -sudo yunohost app checkurl $domain$path -a syncthing -if [[ ! $? -eq 0 ]]; then - echo $domain$path is not available. Please choose another url for Syncthing. - exit 1 -fi +#================================================= +# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS +#================================================= +ynh_print_info "Validating installation parameters..." -# Remove trailing "/" for next commands -path=${path%/} + + +# Register (book) web path +ynh_webpath_register $app $domain $path # Check port availability sudo yunohost app checkport $GUIPORT From a43f1527dc666699ccd51348eb097ed74421021a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 15:46:21 +0200 Subject: [PATCH 08/94] STORE SETTINGS FROM MANIFEST --- scripts/install | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/install b/scripts/install index 2256ac0..4886b35 100644 --- a/scripts/install +++ b/scripts/install @@ -49,6 +49,16 @@ ynh_print_info "Validating installation parameters..." # Register (book) web path ynh_webpath_register $app $domain $path +#================================================= +# STORE SETTINGS FROM MANIFEST +#================================================= +ynh_print_info "Storing installation settings..." + +ynh_app_setting_set $app domain $domain +ynh_app_setting_set $app path $path +ynh_app_setting_set $app user $user +ynh_app_setting_set $app channel $channel + # Check port availability sudo yunohost app checkport $GUIPORT if [[ ! $? -eq 0 ]]; then From 8656e21f00924c4358d0c205ba24ee25c282cae4 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 15:49:55 +0200 Subject: [PATCH 09/94] Swicth checkports --- scripts/install | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 4886b35..b8f610d 100644 --- a/scripts/install +++ b/scripts/install @@ -59,20 +59,30 @@ ynh_app_setting_set $app path $path ynh_app_setting_set $app user $user ynh_app_setting_set $app channel $channel +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# FIND AND OPEN A PORT +#================================================= +ynh_print_info "Configuring firewall..." + # Check port availability sudo yunohost app checkport $GUIPORT if [[ ! $? -eq 0 ]]; then echo Port $GUIPORT for Syncthing UI is not available. exit 1 fi +ynh_app_setting_set $app guiport $GUIPORT + sudo yunohost app checkport $SYNCPORT if [[ ! $? -eq 0 ]]; then echo Port $SYNCPORT is for Syncthing protocol is not available. exit 1 fi -# Open port in firewall -sudo yunohost firewall allow TCP $SYNCPORT > /dev/null 2>&1 +# Open this port +ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $SYNCPORT +ynh_app_setting_set $app syncport $SYNCPORT # Create $SYNCUSER user to run syncthing service sudo useradd -m -d $SYNCHOME/ -s /bin/bash $SYNCUSER From d90907e81aecd34a9bc39b4a60c8213dd08a84e6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 16:37:10 +0200 Subject: [PATCH 10/94] swicth to CREATE DEDICATED USER --- scripts/install | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index b8f610d..4a50929 100644 --- a/scripts/install +++ b/scripts/install @@ -84,8 +84,13 @@ fi ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $SYNCPORT ynh_app_setting_set $app syncport $SYNCPORT -# Create $SYNCUSER user to run syncthing service -sudo useradd -m -d $SYNCHOME/ -s /bin/bash $SYNCUSER +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_print_info "Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$SYNCUSER --home_dir=$SYNCHOME/ --use_shell # Make directories and set rights sudo chown -R $SYNCUSER:$SYNCUSER $SYNCHOME/ From eae20d82a6441edc590a45858978da9b57d90d55 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 16:38:19 +0200 Subject: [PATCH 11/94] CREATE SYNC DIRECTORY --- scripts/install | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/install b/scripts/install index 4a50929..d162ffe 100644 --- a/scripts/install +++ b/scripts/install @@ -92,6 +92,11 @@ ynh_print_info "Configuring system user..." # Create a system user ynh_system_user_create --username=$SYNCUSER --home_dir=$SYNCHOME/ --use_shell +#================================================= +# CREATE SYNC DIRECTORY +#================================================= +ynh_print_info "Creating sync directory..." + # Make directories and set rights sudo chown -R $SYNCUSER:$SYNCUSER $SYNCHOME/ sudo find $SYNCHOME/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done From f448f9c31354a68fc1dd660a45939ed2e4025a0e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 16:39:48 +0200 Subject: [PATCH 12/94] INSTALL DEPENDENCIES --- scripts/install | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/install b/scripts/install index d162ffe..cd3f889 100644 --- a/scripts/install +++ b/scripts/install @@ -102,6 +102,11 @@ sudo chown -R $SYNCUSER:$SYNCUSER $SYNCHOME/ sudo find $SYNCHOME/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done sudo find $SYNCHOME/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_print_info "Installing dependencies..." + # Download and install syncthing binary sudo apt-get install curl ## Add the release PGP keys: From eff0682f87bd1a77469667c42247c7ec125f1eaf Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 16:40:17 +0200 Subject: [PATCH 13/94] SETUP SYSTEMD --- scripts/install | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/install b/scripts/install index cd3f889..25c5937 100644 --- a/scripts/install +++ b/scripts/install @@ -117,6 +117,11 @@ echo "deb http://apt.syncthing.net/ syncthing $channel" | sudo tee /etc/apt/sour sudo apt-get update -qq sudo apt-get install syncthing -y --force-yes +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_print_info "Configuring a systemd service..." + # Install and monitor service sudo sed -i '/^\[Service\]$/,/^\[/ s/^Restart=on-failure/Restart=always/' /lib/systemd/system/syncthing@.service sudo systemctl daemon-reload From 9ddb806db3987a0bf1ecc44f974a5cc54e505b6b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 16:40:48 +0200 Subject: [PATCH 14/94] SETUP LOGROTATE --- scripts/install | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/install b/scripts/install index 25c5937..e48304b 100644 --- a/scripts/install +++ b/scripts/install @@ -129,6 +129,11 @@ sudo systemctl enable syncthing@$SYNCUSER.service sudo yunohost service add syncthing@$SYNCUSER -l /var/log/syncthing.log sudo systemctl start syncthing@$SYNCUSER.service +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_print_info "Configuring log rotation..." + # Configure logrotate if present if [ -d "/etc/logrotate.d" ]; then sed -i "s@SYNCUSER@$SYNCUSER@g" ../conf/logrotate.conf From 71fc7e13b8aa0631c4c1a3681e63e6d484554f10 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 16:41:23 +0200 Subject: [PATCH 15/94] NGINX CONFIGURATION --- scripts/install | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/install b/scripts/install index e48304b..02a2228 100644 --- a/scripts/install +++ b/scripts/install @@ -141,6 +141,11 @@ if [ -d "/etc/logrotate.d" ]; then sudo chmod 0644 /etc/logrotate.d/syncthing fi +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_print_info "Configuring nginx web server..." + # Configure Nginx sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf sed -i "s@PORTTOCHANGE@$GUIPORT@g" ../conf/nginx.conf From 6bda8ed9c4bcda41903c515e000f1dcbafe721af Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 16:46:07 +0200 Subject: [PATCH 16/94] SECURE FILES AND DIRECTORIES --- scripts/install | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/install b/scripts/install index 02a2228..aba9fa2 100644 --- a/scripts/install +++ b/scripts/install @@ -151,6 +151,12 @@ sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf sed -i "s@PORTTOCHANGE@$GUIPORT@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + # Remove acces to all users sudo yunohost app removeaccess syncthing sudo yunohost app addaccess syncthing -u $user From 99af16202246678438fed54f3d390b691f25c17d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 16:46:27 +0200 Subject: [PATCH 17/94] RELOAD NGINX --- scripts/install | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/install b/scripts/install index aba9fa2..b4f09bd 100644 --- a/scripts/install +++ b/scripts/install @@ -161,6 +161,11 @@ sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf sudo yunohost app removeaccess syncthing sudo yunohost app addaccess syncthing -u $user +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info "Reloading nginx web server..." + # Reload nginx and update ssowatch sudo systemctl reload nginx.service sudo yunohost app ssowatconf From 4be756d328f9a2af471d1cda9b8e85dc7b49a06b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 16:46:42 +0200 Subject: [PATCH 18/94] END OF SCRIPT --- scripts/install | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index b4f09bd..3d15cdf 100644 --- a/scripts/install +++ b/scripts/install @@ -170,4 +170,9 @@ ynh_print_info "Reloading nginx web server..." sudo systemctl reload nginx.service sudo yunohost app ssowatconf -echo $? + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Installation of $app completed" From 2c4708756bae3a76cdccb55f6502e23bb86ad9ae Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 16:47:45 +0200 Subject: [PATCH 19/94] SETUP SSOWAT --- scripts/install | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 3d15cdf..0278f49 100644 --- a/scripts/install +++ b/scripts/install @@ -161,6 +161,14 @@ sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf sudo yunohost app removeaccess syncthing sudo yunohost app addaccess syncthing -u $user +#================================================= +# SETUP SSOWAT +#================================================= +ynh_print_info "Configuring SSOwat..." + +# Make app public +ynh_app_setting_set $app unprotected_uris "/" + #================================================= # RELOAD NGINX #================================================= @@ -168,8 +176,6 @@ ynh_print_info "Reloading nginx web server..." # Reload nginx and update ssowatch sudo systemctl reload nginx.service -sudo yunohost app ssowatconf - #================================================= # END OF SCRIPT From 42deb5098c9bceadc52dc12f18a722ec3517ebeb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 16:48:58 +0200 Subject: [PATCH 20/94] reorder INSTALL DEPENDENCIES --- scripts/install | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/install b/scripts/install index 0278f49..01285a1 100644 --- a/scripts/install +++ b/scripts/install @@ -84,6 +84,21 @@ fi ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $SYNCPORT ynh_app_setting_set $app syncport $SYNCPORT +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_print_info "Installing dependencies..." + +# Download and install syncthing binary +sudo apt-get install curl +## Add the release PGP keys: +curl -s https://syncthing.net/release-key.txt | sudo apt-key add - +## Add the choosed channel to your APT sources: +echo "deb http://apt.syncthing.net/ syncthing $channel" | sudo tee /etc/apt/sources.list.d/syncthing.list +## Update and install syncthing: +sudo apt-get update -qq +sudo apt-get install syncthing -y --force-yes + #================================================= # CREATE DEDICATED USER #================================================= @@ -102,21 +117,6 @@ sudo chown -R $SYNCUSER:$SYNCUSER $SYNCHOME/ sudo find $SYNCHOME/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done sudo find $SYNCHOME/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_print_info "Installing dependencies..." - -# Download and install syncthing binary -sudo apt-get install curl -## Add the release PGP keys: -curl -s https://syncthing.net/release-key.txt | sudo apt-key add - -## Add the choosed channel to your APT sources: -echo "deb http://apt.syncthing.net/ syncthing $channel" | sudo tee /etc/apt/sources.list.d/syncthing.list -## Update and install syncthing: -sudo apt-get update -qq -sudo apt-get install syncthing -y --force-yes - #================================================= # SETUP SYSTEMD #================================================= From 26cfb1d65b435a574033a40118aa90d4793092e8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 16:49:47 +0200 Subject: [PATCH 21/94] reorder NGINX CONFIGURATION --- scripts/install | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/install b/scripts/install index 01285a1..8318895 100644 --- a/scripts/install +++ b/scripts/install @@ -99,6 +99,16 @@ echo "deb http://apt.syncthing.net/ syncthing $channel" | sudo tee /etc/apt/sour sudo apt-get update -qq sudo apt-get install syncthing -y --force-yes +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_print_info "Configuring nginx web server..." + +# Configure Nginx +sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf +sed -i "s@PORTTOCHANGE@$GUIPORT@g" ../conf/nginx.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf + #================================================= # CREATE DEDICATED USER #================================================= @@ -141,16 +151,6 @@ if [ -d "/etc/logrotate.d" ]; then sudo chmod 0644 /etc/logrotate.d/syncthing fi -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_print_info "Configuring nginx web server..." - -# Configure Nginx -sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf -sed -i "s@PORTTOCHANGE@$GUIPORT@g" ../conf/nginx.conf -sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf - #================================================= # GENERIC FINALIZATION #================================================= From a5bb4eb688f059a7784eb950bc5595d017828689 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 16:50:17 +0200 Subject: [PATCH 22/94] SPECIFIC SETUP --- scripts/install | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install b/scripts/install index 8318895..218422c 100644 --- a/scripts/install +++ b/scripts/install @@ -117,6 +117,8 @@ ynh_print_info "Configuring system user..." # Create a system user ynh_system_user_create --username=$SYNCUSER --home_dir=$SYNCHOME/ --use_shell +#================================================= +# SPECIFIC SETUP #================================================= # CREATE SYNC DIRECTORY #================================================= From 6266247e61f2a8d3b1d57f96614f4479f98413cf Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 16:51:02 +0200 Subject: [PATCH 23/94] reorder SETUP LOGROTATE --- scripts/install | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/install b/scripts/install index 218422c..1308305 100644 --- a/scripts/install +++ b/scripts/install @@ -141,6 +141,16 @@ sudo systemctl enable syncthing@$SYNCUSER.service sudo yunohost service add syncthing@$SYNCUSER -l /var/log/syncthing.log sudo systemctl start syncthing@$SYNCUSER.service +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +# Remove acces to all users +sudo yunohost app removeaccess syncthing +sudo yunohost app addaccess syncthing -u $user + #================================================= # SETUP LOGROTATE #================================================= @@ -153,16 +163,6 @@ if [ -d "/etc/logrotate.d" ]; then sudo chmod 0644 /etc/logrotate.d/syncthing fi -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Remove acces to all users -sudo yunohost app removeaccess syncthing -sudo yunohost app addaccess syncthing -u $user - #================================================= # SETUP SSOWAT #================================================= From 5869156ea9630dd9f407f794324ab513019cfa55 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:02:29 +0200 Subject: [PATCH 24/94] switch to ynh_install_app_dependencies --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 1308305..504093c 100644 --- a/scripts/install +++ b/scripts/install @@ -89,8 +89,8 @@ ynh_app_setting_set $app syncport $SYNCPORT #================================================= ynh_print_info "Installing dependencies..." -# Download and install syncthing binary -sudo apt-get install curl +ynh_install_app_dependencies $pkg_dependencies + ## Add the release PGP keys: curl -s https://syncthing.net/release-key.txt | sudo apt-key add - ## Add the choosed channel to your APT sources: From 29df699a6392ce740c498c57fc107c6c18319cf8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:09:07 +0200 Subject: [PATCH 25/94] switch to ynh_remove_app_dependencies --- scripts/remove | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/remove b/scripts/remove index 8644d4e..ef1be5a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -11,6 +11,14 @@ sudo systemctl stop syncthing@$SYNCUSER.service sudo yunohost service remove syncthing sudo systemctl disable syncthing@$SYNCUSER.service +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_print_info "Removing dependencies" + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + # Remove syncthing binairy sudo apt-get autoremove syncthing -y --purge sudo rm /etc/apt/sources.list.d/syncthing.list From 73310d98a519a5226418149d9309e927fcaefcb8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:09:27 +0200 Subject: [PATCH 26/94] define dependencies --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 8bb05b4..67ea80b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="deb1 deb2" +pkg_dependencies="curl" #================================================= # PERSONAL HELPERS From 52bbc39bb65653b601ddb413e8fa387afd4adf16 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:10:42 +0200 Subject: [PATCH 27/94] update requirements --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index cbc0fe2..ae387da 100644 --- a/manifest.json +++ b/manifest.json @@ -13,7 +13,7 @@ "email": "txmrl@txmrl.net" }, "requirements": { - "yunohost": ">= 2.4.0" + "yunohost": ">= 3.4" }, "multi_instance": false, "services": [ From 23cee18750f3dc3639e1a578fe4d4bce5d46d386 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:11:40 +0200 Subject: [PATCH 28/94] GENERIC START --- scripts/remove | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/remove b/scripts/remove index ef1be5a..19f0652 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,5 +1,15 @@ #!/bin/bash +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + + # Configurable variables SYNCHOME="/home/yunohost.app/syncthing" SYNCUSER=debian-syncthing From 937377f3552abc2e0ac2acabadf59facd3884693 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:17:35 +0200 Subject: [PATCH 29/94] amanage settings --- scripts/install | 2 ++ scripts/remove | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index 504093c..455dda6 100644 --- a/scripts/install +++ b/scripts/install @@ -58,6 +58,8 @@ ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path ynh_app_setting_set $app user $user ynh_app_setting_set $app channel $channel +ynh_app_setting_set $app synchome $SYNCHOME +ynh_app_setting_set $app syncuser $SYNCUSER #================================================= # STANDARD MODIFICATIONS diff --git a/scripts/remove b/scripts/remove index 19f0652..ca51c65 100644 --- a/scripts/remove +++ b/scripts/remove @@ -9,12 +9,22 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info "Loading installation settings..." + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get $app domain) + +SYNCHOME=$(ynh_app_setting_get $app synchome) +SYNCUSER=$(ynh_app_setting_get $app syncuser) +SYNCPORT=$(ynh_app_setting_get $app syncport) +GUIPORT=$(ynh_app_setting_get $app guiport) + +final_path=$(ynh_app_setting_get $app final_path) -# Configurable variables -SYNCHOME="/home/yunohost.app/syncthing" -SYNCUSER=debian-syncthing -SYNCPORT=22000 -GUIPORT=8384 # Stop and remove syncthing service sudo systemctl stop syncthing@$SYNCUSER.service From c7c4e003c4749f338bda5dbd3c48d9f695da5f2f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:18:37 +0200 Subject: [PATCH 30/94] STOP AND REMOVE SERVICE --- scripts/remove | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index ca51c65..ce24d4f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -25,8 +25,12 @@ GUIPORT=$(ynh_app_setting_get $app guiport) final_path=$(ynh_app_setting_get $app final_path) +#================================================= +# STOP AND REMOVE SERVICE +#================================================= +ynh_print_info "Stopping and removing the systemd service" -# Stop and remove syncthing service +# Remove the dedicated systemd config sudo systemctl stop syncthing@$SYNCUSER.service sudo yunohost service remove syncthing sudo systemctl disable syncthing@$SYNCUSER.service From 6e3c8d0e994b0cb58a6ab79f18c395c33adfa294 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:22:54 +0200 Subject: [PATCH 31/94] REMOVE DEDICATED USER --- scripts/remove | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index ce24d4f..e7ddeeb 100644 --- a/scripts/remove +++ b/scripts/remove @@ -52,7 +52,15 @@ sudo apt-get update -qq sudo mv $SYNCHOME $SYNCHOME.old # sudo rm -rf $SYNCHOME -# Remove syncthing user + +#================================================= +# GENERIC FINALIZATION +#================================================= +# REMOVE DEDICATED USER +#================================================= +ynh_print_info "Removing the dedicated system user" + +# Delete a system user sudo userdel $SYNCUSER # Close port in firewall From 302b7708bc6adf9862853e9a3b1a1ff3a3df1445 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:23:16 +0200 Subject: [PATCH 32/94] CLOSE A PORT --- scripts/remove | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/remove b/scripts/remove index e7ddeeb..69c08e2 100644 --- a/scripts/remove +++ b/scripts/remove @@ -63,6 +63,10 @@ ynh_print_info "Removing the dedicated system user" # Delete a system user sudo userdel $SYNCUSER +#================================================= +# CLOSE A PORT +#================================================= + # Close port in firewall sudo yunohost firewall disallow TCP $SYNCPORT From 3c7b83299467fe797e0bbbd271a5748d089f44e8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:23:49 +0200 Subject: [PATCH 33/94] REMOVE LOGROTATE CONFIGURATION --- scripts/remove | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 69c08e2..bf5ab3a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -70,7 +70,13 @@ sudo userdel $SYNCUSER # Close port in firewall sudo yunohost firewall disallow TCP $SYNCPORT -# Remove syncthing logrotate configuration + +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_print_info "Removing logrotate configuration" + +# Remove the app-specific logrotate config if [ -f /etc/logrotate.d/syncthing ] then sudo rm /etc/logrotate.d/syncthing From 1a35241b1ae74ac020251b492e9e4e0686bbbc80 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:24:17 +0200 Subject: [PATCH 34/94] REMOVE NGINX CONFIGURATION --- scripts/remove | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index bf5ab3a..5c819a5 100644 --- a/scripts/remove +++ b/scripts/remove @@ -82,7 +82,12 @@ then sudo rm /etc/logrotate.d/syncthing fi -# Remove syncthing nginx configuration + +#================================================= +# REMOVE NGINX CONFIGURATION +#================================================= +ynh_print_info "Removing nginx web server configuration" + domain=$(sudo yunohost app setting syncthing domain) sudo rm /etc/nginx/conf.d/$domain.d/syncthing.conf From 3f8571b9882e9efe9ca0305d62ad25b3b702a2da Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:24:41 +0200 Subject: [PATCH 35/94] END OF SCRIPT --- scripts/remove | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 5c819a5..ba3a834 100644 --- a/scripts/remove +++ b/scripts/remove @@ -95,4 +95,10 @@ sudo rm /etc/nginx/conf.d/$domain.d/syncthing.conf sudo systemctl reload nginx.service sudo yunohost app ssowatconf -echo $? + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Removal of $app completed" + From 853d85ffba1c643004a43748bb2d0d4b6bb212d9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:24:50 +0200 Subject: [PATCH 36/94] Update remove --- scripts/remove | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index ba3a834..c05e130 100644 --- a/scripts/remove +++ b/scripts/remove @@ -101,4 +101,3 @@ sudo yunohost app ssowatconf #================================================= ynh_print_info "Removal of $app completed" - From 729c2caa7bdfdf9b58822e8ab761aca2cf48996e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:26:02 +0200 Subject: [PATCH 37/94] reorder REMOVE DEDICATED USER --- scripts/remove | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/remove b/scripts/remove index c05e130..a598d4b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -53,15 +53,6 @@ sudo mv $SYNCHOME $SYNCHOME.old # sudo rm -rf $SYNCHOME -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_print_info "Removing the dedicated system user" - -# Delete a system user -sudo userdel $SYNCUSER #================================================= # CLOSE A PORT @@ -95,6 +86,15 @@ sudo rm /etc/nginx/conf.d/$domain.d/syncthing.conf sudo systemctl reload nginx.service sudo yunohost app ssowatconf +#================================================= +# GENERIC FINALIZATION +#================================================= +# REMOVE DEDICATED USER +#================================================= +ynh_print_info "Removing the dedicated system user" + +# Delete a system user +sudo userdel $SYNCUSER #================================================= # END OF SCRIPT From c9ae959fefd8dc243ce4ae742cbf7022e4d6d3ae Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:26:44 +0200 Subject: [PATCH 38/94] reorder CLOSE A PORT --- scripts/remove | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/remove b/scripts/remove index a598d4b..2f4b1ab 100644 --- a/scripts/remove +++ b/scripts/remove @@ -54,12 +54,6 @@ sudo mv $SYNCHOME $SYNCHOME.old -#================================================= -# CLOSE A PORT -#================================================= - -# Close port in firewall -sudo yunohost firewall disallow TCP $SYNCPORT #================================================= @@ -86,6 +80,13 @@ sudo rm /etc/nginx/conf.d/$domain.d/syncthing.conf sudo systemctl reload nginx.service sudo yunohost app ssowatconf +#================================================= +# CLOSE A PORT +#================================================= + +# Close port in firewall +sudo yunohost firewall disallow TCP $SYNCPORT + #================================================= # GENERIC FINALIZATION #================================================= From 173e6447efbcd2f735132d8785a10dff0342736c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:27:22 +0200 Subject: [PATCH 39/94] reorder REMOVE LOGROTATE CONFIGURATION --- scripts/remove | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/remove b/scripts/remove index 2f4b1ab..b3ecd33 100644 --- a/scripts/remove +++ b/scripts/remove @@ -56,17 +56,6 @@ sudo mv $SYNCHOME $SYNCHOME.old -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_print_info "Removing logrotate configuration" - -# Remove the app-specific logrotate config -if [ -f /etc/logrotate.d/syncthing ] -then - sudo rm /etc/logrotate.d/syncthing -fi - #================================================= # REMOVE NGINX CONFIGURATION @@ -80,6 +69,17 @@ sudo rm /etc/nginx/conf.d/$domain.d/syncthing.conf sudo systemctl reload nginx.service sudo yunohost app ssowatconf +#================================================= +# REMOVE LOGROTATE CONFIGURATION +#================================================= +ynh_print_info "Removing logrotate configuration" + +# Remove the app-specific logrotate config +if [ -f /etc/logrotate.d/syncthing ] +then + sudo rm /etc/logrotate.d/syncthing +fi + #================================================= # CLOSE A PORT #================================================= From b4ee645fe881c21eef32ffa6e2ba52ce84c2e0cc Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:37:39 +0200 Subject: [PATCH 40/94] GENERIC START --- scripts/upgrade | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 8965cb9..5654ab3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,5 +1,16 @@ #!/bin/bash +#================================================= +# GENERIC START +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + + + # Configurable variables SYNCHOME="/home/yunohost.app/syncthing" SYNCUSER=debian-syncthing From f1506f09d2e445f69a8f09ba1dff69033181eab2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:37:58 +0200 Subject: [PATCH 41/94] LOAD SETTINGS --- scripts/upgrade | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 5654ab3..c8b96b9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,13 +9,23 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info "Loading installation settings..." + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get $app domain) + +SYNCHOME=$(ynh_app_setting_get $app synchome) +SYNCUSER=$(ynh_app_setting_get $app syncuser) +SYNCPORT=$(ynh_app_setting_get $app syncport) +GUIPORT=$(ynh_app_setting_get $app guiport) + +final_path=$(ynh_app_setting_get $app final_path) -# Configurable variables -SYNCHOME="/home/yunohost.app/syncthing" -SYNCUSER=debian-syncthing -SYNCPORT=22000 -GUIPORT=8384 # Retrieve arguments domain=$(sudo yunohost app setting syncthing domain) From 39e2c8a51af0ffe023f4b3757624fbd47afbdb1f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:39:35 +0200 Subject: [PATCH 42/94] LOAD SETTINGS --- scripts/upgrade | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index c8b96b9..4e04738 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -17,20 +17,17 @@ ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) +path=$(ynh_app_setting_get $app path) + +final_path=$(ynh_app_setting_get $app final_path) SYNCHOME=$(ynh_app_setting_get $app synchome) SYNCUSER=$(ynh_app_setting_get $app syncuser) SYNCPORT=$(ynh_app_setting_get $app syncport) GUIPORT=$(ynh_app_setting_get $app guiport) -final_path=$(ynh_app_setting_get $app final_path) - -# Retrieve arguments -domain=$(sudo yunohost app setting syncthing domain) -path=$(sudo yunohost app setting syncthing path) - # Remove trailing "/" for next commands path=${path%/} From 7fdc823ebc3301023c4e0a5d4f7f29631ba8d967 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:39:46 +0200 Subject: [PATCH 43/94] cleanup --- scripts/upgrade | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 4e04738..51b6f20 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -28,9 +28,6 @@ GUIPORT=$(ynh_app_setting_get $app guiport) -# Remove trailing "/" for next commands -path=${path%/} - # Upgrade official debian package sudo apt-get update -qq sudo apt-get upgrade syncthing -y From b907e425c6b022b12814bd9c27094ac23ba8635d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:40:46 +0200 Subject: [PATCH 44/94] UPGRADE DEPENDENCIES --- scripts/upgrade | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 51b6f20..0c31a99 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -26,9 +26,16 @@ SYNCUSER=$(ynh_app_setting_get $app syncuser) SYNCPORT=$(ynh_app_setting_get $app syncport) GUIPORT=$(ynh_app_setting_get $app guiport) +#================================================= +# STANDARD UPGRADE STEPS +#================================================= -# Upgrade official debian package +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_print_info "Upgrading dependencies..." + sudo apt-get update -qq sudo apt-get upgrade syncthing -y From 2312696340d824922739f6e9decd9ea58ef701ee Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:41:10 +0200 Subject: [PATCH 45/94] NGINX CONFIGURATION --- scripts/upgrade | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 0c31a99..e711af9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -39,7 +39,12 @@ ynh_print_info "Upgrading dependencies..." sudo apt-get update -qq sudo apt-get upgrade syncthing -y -# Update Nginx configuration + +#================================================= +# NGINX CONFIGURATION +#================================================= +ynh_print_info "Upgrading nginx web server configuration..." + sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf sed -i "s@PORTTOCHANGE@$GUIPORT@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf From f7a1ab40c1036096b4b10d9e701478beac696d29 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:41:57 +0200 Subject: [PATCH 46/94] RELOAD NGINX --- scripts/upgrade | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index e711af9..03b43a0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -49,7 +49,12 @@ sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf sed -i "s@PORTTOCHANGE@$GUIPORT@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf -# And reload + +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info "Reloading nginx web server..." + sudo service nginx reload sudo yunohost app ssowatconf From a13d1e59c0bb57d5eadb46d5cdf68f853d20ccc8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 17:42:09 +0200 Subject: [PATCH 47/94] END OF SCRIPT --- scripts/upgrade | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 03b43a0..806b131 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -58,4 +58,9 @@ ynh_print_info "Reloading nginx web server..." sudo service nginx reload sudo yunohost app ssowatconf -echo $? + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Upgrade of $app completed" From 55f3def36d369032c71ae4163a61e4cf5338a876 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 23:19:50 +0200 Subject: [PATCH 48/94] make synhome instance dependent --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 455dda6..2ca9786 100644 --- a/scripts/install +++ b/scripts/install @@ -34,7 +34,7 @@ app=$YNH_APP_INSTANCE_NAME # Configurable variables -SYNCHOME="/home/yunohost.app/syncthing" +SYNCHOME="/home/yunohost.app/$app" SYNCUSER=debian-syncthing SYNCPORT=22000 GUIPORT=8384 From 88d741f1dda1001730ca03d14ece9367af520014 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Apr 2019 23:20:46 +0200 Subject: [PATCH 49/94] spacing --- scripts/install | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/install b/scripts/install index 2ca9786..012ed62 100644 --- a/scripts/install +++ b/scripts/install @@ -31,8 +31,6 @@ channel=$YNH_APP_ARG_CHANNEL app=$YNH_APP_INSTANCE_NAME - - # Configurable variables SYNCHOME="/home/yunohost.app/$app" SYNCUSER=debian-syncthing From 3d852129b46d23d36673ed7239907ed970175b5f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 00:34:30 +0200 Subject: [PATCH 50/94] Spacing --- manifest.json | 116 +++++++++++++++++++++++++------------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/manifest.json b/manifest.json index ae387da..fbd5250 100644 --- a/manifest.json +++ b/manifest.json @@ -1,61 +1,61 @@ { - "name": "Syncthing", - "id": "syncthing", - "packaging_format": 1, - "description": { - "en": "Syncthing replaces proprietary sync and cloud services with something open, trustworthy and decentralized.", - "fr": "Syncthing remplace les services propriétaires de synchro et de cloud avec quelque chose d'ouvert, digne de confiance et décentralisée." - }, - "url": "https://syncthing.net/", - "license": "MPL-2.0", - "maintainer": { - "name": "txmrl", - "email": "txmrl@txmrl.net" - }, - "requirements": { + "name": "Syncthing", + "id": "syncthing", + "packaging_format": 1, + "description": { + "en": "Syncthing replaces proprietary sync and cloud services with something open, trustworthy and decentralized.", + "fr": "Syncthing remplace les services propriétaires de synchro et de cloud avec quelque chose d'ouvert, digne de confiance et décentralisée." + }, + "url": "https://syncthing.net/", + "license": "MPL-2.0", + "maintainer": { + "name": "txmrl", + "email": "txmrl@txmrl.net" + }, + "requirements": { "yunohost": ">= 3.4" - }, - "multi_instance": false, - "services": [ - "nginx" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain", - "ask": { - "en": "Choose a domain for Syncthing" - }, - "example": "domain.org" - }, - { - "name": "path", - "type": "path", - "ask": { - "en": "Choose a path for Syncthing" - }, - "example": "/syncthing", - "default": "/syncthing" - }, - { - "name": "user", - "type": "user", - "ask": { - "en": "Choose the user for Syncthing (must be an existing yunohost user)", - "fr": "Choisissez l'utilisateur de Syncthing (doit être un utilisateur yunohost existant)" - }, - "example": "johndoe" - }, - { - "name": "channel", - "ask": { - "en": "Choose Syncthing channel ?", - "fr": "Choissez la version de Syncthing ?" - }, - "choices": ["stable", "candidate"], - "default": "stable" - } - ] - } + }, + "multi_instance": true, + "services": [ + "nginx" + ], + "arguments": { + "install": [ + { + "name": "domain", + "type": "domain", + "ask": { + "en": "Choose a domain for Syncthing" + }, + "example": "domain.org" + }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for Syncthing" + }, + "example": "/syncthing", + "default": "/syncthing" + }, + { + "name": "admin", + "type": "user", + "ask": { + "en": "Choose the user for Syncthing (must be an existing yunohost user)", + "fr": "Choisissez l'utilisateur de Syncthing (doit être un utilisateur yunohost existant)" + }, + "example": "johndoe" + }, + { + "name": "channel", + "ask": { + "en": "Choose Syncthing channel ?", + "fr": "Choissez la version de Syncthing ?" + }, + "choices": ["stable", "candidate"], + "default": "stable" + } + ] + } } From 3da966c982db12402c42fb4ef9ae059e02f36215 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 00:46:46 +0200 Subject: [PATCH 51/94] Clean variables --- conf/logrotate.conf | 2 +- scripts/install | 60 ++++++++++++++++++++++----------------------- scripts/remove | 22 ++++++++--------- scripts/upgrade | 14 +++++------ 4 files changed, 48 insertions(+), 50 deletions(-) diff --git a/conf/logrotate.conf b/conf/logrotate.conf index 3069a4d..5008367 100644 --- a/conf/logrotate.conf +++ b/conf/logrotate.conf @@ -8,7 +8,7 @@ compress delaycompress postrotate - systemctl restart syncthing@SYNCUSER > /dev/null + systemctl restart syncthing@sync_user > /dev/null endscript } diff --git a/scripts/install b/scripts/install index 012ed62..8c5b1aa 100644 --- a/scripts/install +++ b/scripts/install @@ -25,27 +25,25 @@ ynh_abort_if_errors #================================================= domain=$YNH_APP_ARG_DOMAIN -path=$YNH_APP_ARG_PATH -user=$YNH_APP_ARG_ADMIN +path_url=$YNH_APP_ARG_PATH +admin=$YNH_APP_ARG_ADMIN channel=$YNH_APP_ARG_CHANNEL app=$YNH_APP_INSTANCE_NAME # Configurable variables -SYNCHOME="/home/yunohost.app/$app" -SYNCUSER=debian-syncthing -SYNCPORT=22000 -GUIPORT=8384 +sync_home="/home/yunohost.app/$app" +sync_user=debian-syncthing +sync_port=22000 +gui_port=8384 #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= ynh_print_info "Validating installation parameters..." - - # Register (book) web path -ynh_webpath_register $app $domain $path +ynh_webpath_register $app $domain $path_url #================================================= # STORE SETTINGS FROM MANIFEST @@ -53,11 +51,11 @@ ynh_webpath_register $app $domain $path ynh_print_info "Storing installation settings..." ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path -ynh_app_setting_set $app user $user +ynh_app_setting_set $app path $path_url +ynh_app_setting_set $app admin $admin ynh_app_setting_set $app channel $channel -ynh_app_setting_set $app synchome $SYNCHOME -ynh_app_setting_set $app syncuser $SYNCUSER +ynh_app_setting_set $app sync_home $sync_home +ynh_app_setting_set $app sync_user $sync_user #================================================= # STANDARD MODIFICATIONS @@ -67,22 +65,22 @@ ynh_app_setting_set $app syncuser $SYNCUSER ynh_print_info "Configuring firewall..." # Check port availability -sudo yunohost app checkport $GUIPORT +sudo yunohost app checkport $gui_port if [[ ! $? -eq 0 ]]; then - echo Port $GUIPORT for Syncthing UI is not available. + echo Port $gui_port for Syncthing UI is not available. exit 1 fi -ynh_app_setting_set $app guiport $GUIPORT +ynh_app_setting_set $app gui_port $gui_port -sudo yunohost app checkport $SYNCPORT +sudo yunohost app checkport $sync_port if [[ ! $? -eq 0 ]]; then - echo Port $SYNCPORT is for Syncthing protocol is not available. + echo Port $sync_port for Syncthing protocol is not available. exit 1 fi # Open this port -ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $SYNCPORT -ynh_app_setting_set $app syncport $SYNCPORT +ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $sync_port +ynh_app_setting_set $app sync_port $sync_port #================================================= # INSTALL DEPENDENCIES @@ -105,8 +103,8 @@ sudo apt-get install syncthing -y --force-yes ynh_print_info "Configuring nginx web server..." # Configure Nginx -sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf -sed -i "s@PORTTOCHANGE@$GUIPORT@g" ../conf/nginx.conf +sed -i "s@PATHTOCHANGE@$path_url@g" ../conf/nginx.conf +sed -i "s@PORTTOCHANGE@$gui_port@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf #================================================= @@ -115,7 +113,7 @@ sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf ynh_print_info "Configuring system user..." # Create a system user -ynh_system_user_create --username=$SYNCUSER --home_dir=$SYNCHOME/ --use_shell +ynh_system_user_create --username=$sync_user --home_dir=$sync_home/ --use_shell #================================================= # SPECIFIC SETUP @@ -125,9 +123,9 @@ ynh_system_user_create --username=$SYNCUSER --home_dir=$SYNCHOME/ --use_shell ynh_print_info "Creating sync directory..." # Make directories and set rights -sudo chown -R $SYNCUSER:$SYNCUSER $SYNCHOME/ -sudo find $SYNCHOME/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done -sudo find $SYNCHOME/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done +sudo chown -R $sync_user:$sync_user $sync_home/ +sudo find $sync_home/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done +sudo find $sync_home/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done #================================================= # SETUP SYSTEMD @@ -137,9 +135,9 @@ ynh_print_info "Configuring a systemd service..." # Install and monitor service sudo sed -i '/^\[Service\]$/,/^\[/ s/^Restart=on-failure/Restart=always/' /lib/systemd/system/syncthing@.service sudo systemctl daemon-reload -sudo systemctl enable syncthing@$SYNCUSER.service -sudo yunohost service add syncthing@$SYNCUSER -l /var/log/syncthing.log -sudo systemctl start syncthing@$SYNCUSER.service +sudo systemctl enable syncthing@$sync_user.service +sudo yunohost service add syncthing@$sync_user -l /var/log/syncthing.log +sudo systemctl start syncthing@$sync_user.service #================================================= # GENERIC FINALIZATION @@ -149,7 +147,7 @@ sudo systemctl start syncthing@$SYNCUSER.service # Remove acces to all users sudo yunohost app removeaccess syncthing -sudo yunohost app addaccess syncthing -u $user +sudo yunohost app addaccess syncthing -u $admin #================================================= # SETUP LOGROTATE @@ -158,7 +156,7 @@ ynh_print_info "Configuring log rotation..." # Configure logrotate if present if [ -d "/etc/logrotate.d" ]; then - sed -i "s@SYNCUSER@$SYNCUSER@g" ../conf/logrotate.conf + sed -i "s@sync_user@$sync_user@g" ../conf/logrotate.conf sudo cp ../conf/logrotate.conf /etc/logrotate.d/syncthing sudo chmod 0644 /etc/logrotate.d/syncthing fi diff --git a/scripts/remove b/scripts/remove index b3ecd33..1bf9f95 100644 --- a/scripts/remove +++ b/scripts/remove @@ -18,10 +18,10 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) -SYNCHOME=$(ynh_app_setting_get $app synchome) -SYNCUSER=$(ynh_app_setting_get $app syncuser) -SYNCPORT=$(ynh_app_setting_get $app syncport) -GUIPORT=$(ynh_app_setting_get $app guiport) +sync_home=$(ynh_app_setting_get $app sync_home) +sync_user=$(ynh_app_setting_get $app sync_user) +sync_port=$(ynh_app_setting_get $app sync_port) +gui_port=$(ynh_app_setting_get $app gui_port) final_path=$(ynh_app_setting_get $app final_path) @@ -31,9 +31,9 @@ final_path=$(ynh_app_setting_get $app final_path) ynh_print_info "Stopping and removing the systemd service" # Remove the dedicated systemd config -sudo systemctl stop syncthing@$SYNCUSER.service +sudo systemctl stop syncthing@$sync_user.service sudo yunohost service remove syncthing -sudo systemctl disable syncthing@$SYNCUSER.service +sudo systemctl disable syncthing@$sync_user.service #================================================= # REMOVE DEPENDENCIES @@ -48,9 +48,9 @@ sudo apt-get autoremove syncthing -y --purge sudo rm /etc/apt/sources.list.d/syncthing.list sudo apt-get update -qq -# Backup syncthing SYNCHOME directory -sudo mv $SYNCHOME $SYNCHOME.old -# sudo rm -rf $SYNCHOME +# Backup syncthing sync_home directory +sudo mv $sync_home $sync_home.old +# sudo rm -rf $sync_home @@ -85,7 +85,7 @@ fi #================================================= # Close port in firewall -sudo yunohost firewall disallow TCP $SYNCPORT +sudo yunohost firewall disallow TCP $sync_port #================================================= # GENERIC FINALIZATION @@ -95,7 +95,7 @@ sudo yunohost firewall disallow TCP $SYNCPORT ynh_print_info "Removing the dedicated system user" # Delete a system user -sudo userdel $SYNCUSER +sudo userdel $sync_user #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index 806b131..5f71b87 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -17,14 +17,14 @@ ynh_print_info "Loading installation settings..." app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) -path=$(ynh_app_setting_get $app path) +path_url=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) -SYNCHOME=$(ynh_app_setting_get $app synchome) -SYNCUSER=$(ynh_app_setting_get $app syncuser) -SYNCPORT=$(ynh_app_setting_get $app syncport) -GUIPORT=$(ynh_app_setting_get $app guiport) +sync_home=$(ynh_app_setting_get $app sync_home) +sync_user=$(ynh_app_setting_get $app sync_user) +sync_port=$(ynh_app_setting_get $app sync_port) +gui_port=$(ynh_app_setting_get $app gui_port) #================================================= # STANDARD UPGRADE STEPS @@ -45,8 +45,8 @@ sudo apt-get upgrade syncthing -y #================================================= ynh_print_info "Upgrading nginx web server configuration..." -sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf -sed -i "s@PORTTOCHANGE@$GUIPORT@g" ../conf/nginx.conf +sed -i "s@PATHTOCHANGE@$path_url@g" ../conf/nginx.conf +sed -i "s@PORTTOCHANGE@$gui_port@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf From abd17eee3daf3db8d06657b4fb9aa3bd084ef1fd Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 00:50:36 +0200 Subject: [PATCH 52/94] clean nginx --- conf/nginx.conf | 4 ++-- scripts/install | 2 ++ scripts/remove | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 93bf750..abbaac9 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,10 +1,10 @@ -location PATHTOCHANGE/ { +location __PATH__/ { proxy_set_header Host 127.0.0.1; 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 $scheme; - proxy_pass http://127.0.0.1:PORTTOCHANGE/; + proxy_pass http://127.0.0.1:__GUI_PORT__/; proxy_read_timeout 600s; proxy_send_timeout 600s; diff --git a/scripts/install b/scripts/install index 8c5b1aa..b5c94a6 100644 --- a/scripts/install +++ b/scripts/install @@ -107,6 +107,8 @@ sed -i "s@PATHTOCHANGE@$path_url@g" ../conf/nginx.conf sed -i "s@PORTTOCHANGE@$gui_port@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf +ynh_add_nginx_config "gui_port" + #================================================= # CREATE DEDICATED USER #================================================= diff --git a/scripts/remove b/scripts/remove index 1bf9f95..eb481eb 100644 --- a/scripts/remove +++ b/scripts/remove @@ -62,8 +62,8 @@ sudo mv $sync_home $sync_home.old #================================================= ynh_print_info "Removing nginx web server configuration" -domain=$(sudo yunohost app setting syncthing domain) -sudo rm /etc/nginx/conf.d/$domain.d/syncthing.conf +# Remove the dedicated nginx config +ynh_remove_nginx_config # Reload nginx and update ssowatch sudo systemctl reload nginx.service From e6a6063ed23b4e9063e0db8fcdfaabb7b1185241 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 01:17:26 +0200 Subject: [PATCH 53/94] implement ynh_add_nginx_config --- scripts/install | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index b5c94a6..e5bca24 100644 --- a/scripts/install +++ b/scripts/install @@ -102,11 +102,7 @@ sudo apt-get install syncthing -y --force-yes #================================================= ynh_print_info "Configuring nginx web server..." -# Configure Nginx -sed -i "s@PATHTOCHANGE@$path_url@g" ../conf/nginx.conf -sed -i "s@PORTTOCHANGE@$gui_port@g" ../conf/nginx.conf -sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf - +# Create a dedicated nginx config ynh_add_nginx_config "gui_port" #================================================= From 62047cbb75229c3d84e0d3522005e8ea353bac7a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 01:18:33 +0200 Subject: [PATCH 54/94] implement ynh_use_logrotate --- scripts/install | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index e5bca24..8d4e9de 100644 --- a/scripts/install +++ b/scripts/install @@ -152,12 +152,8 @@ sudo yunohost app addaccess syncthing -u $admin #================================================= ynh_print_info "Configuring log rotation..." -# Configure logrotate if present -if [ -d "/etc/logrotate.d" ]; then - sed -i "s@sync_user@$sync_user@g" ../conf/logrotate.conf - sudo cp ../conf/logrotate.conf /etc/logrotate.d/syncthing - sudo chmod 0644 /etc/logrotate.d/syncthing -fi +# Use logrotate to manage application logfile(s) +ynh_use_logrotate #================================================= # SETUP SSOWAT From bbffc328074a04593017466d8426392de42ace08 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 01:18:47 +0200 Subject: [PATCH 55/94] Update install --- scripts/install | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 8d4e9de..a3408b4 100644 --- a/scripts/install +++ b/scripts/install @@ -168,8 +168,7 @@ ynh_app_setting_set $app unprotected_uris "/" #================================================= ynh_print_info "Reloading nginx web server..." -# Reload nginx and update ssowatch -sudo systemctl reload nginx.service +systemctl reload nginx #================================================= # END OF SCRIPT From 6e1516552341414f56ea1ad63869d0e00e398f8f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 01:19:47 +0200 Subject: [PATCH 56/94] Update remove --- scripts/remove | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/remove b/scripts/remove index eb481eb..fb40e7c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -18,13 +18,15 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) +final_path=$(ynh_app_setting_get $app final_path) + sync_home=$(ynh_app_setting_get $app sync_home) sync_user=$(ynh_app_setting_get $app sync_user) sync_port=$(ynh_app_setting_get $app sync_port) gui_port=$(ynh_app_setting_get $app gui_port) -final_path=$(ynh_app_setting_get $app final_path) - +#================================================= +# STANDARD REMOVE #================================================= # STOP AND REMOVE SERVICE #================================================= From 64512ea3aac8edd6210742a101ef24a7e06d55a5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 01:20:30 +0200 Subject: [PATCH 57/94] Update remove --- scripts/remove | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/remove b/scripts/remove index fb40e7c..822881a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -67,10 +67,6 @@ ynh_print_info "Removing nginx web server configuration" # Remove the dedicated nginx config ynh_remove_nginx_config -# Reload nginx and update ssowatch -sudo systemctl reload nginx.service -sudo yunohost app ssowatconf - #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= From 72cc1bb84818d73036d709b8929d83976fcb7bd9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 01:20:59 +0200 Subject: [PATCH 58/94] implement ynh_remove_logrotate --- scripts/remove | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/remove b/scripts/remove index 822881a..85ab159 100644 --- a/scripts/remove +++ b/scripts/remove @@ -73,10 +73,7 @@ ynh_remove_nginx_config ynh_print_info "Removing logrotate configuration" # Remove the app-specific logrotate config -if [ -f /etc/logrotate.d/syncthing ] -then - sudo rm /etc/logrotate.d/syncthing -fi +ynh_remove_logrotate #================================================= # CLOSE A PORT From c84877015f0e662efa176c4bad0d43686c35f40e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 01:24:42 +0200 Subject: [PATCH 59/94] Update remove --- scripts/remove | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/remove b/scripts/remove index 85ab159..82a7634 100644 --- a/scripts/remove +++ b/scripts/remove @@ -79,8 +79,8 @@ ynh_remove_logrotate # CLOSE A PORT #================================================= -# Close port in firewall -sudo yunohost firewall disallow TCP $sync_port +ynh_print_info "Closing port $sync_port" +ynh_exec_warn_less yunohost firewall disallow TCP $sync_port #================================================= # GENERIC FINALIZATION @@ -90,7 +90,7 @@ sudo yunohost firewall disallow TCP $sync_port ynh_print_info "Removing the dedicated system user" # Delete a system user -sudo userdel $sync_user +ynh_system_user_delete $sync_user #================================================= # END OF SCRIPT From 0bd1b8f3ecf97dca46d59d639ed8e7aa16e68afb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 01:31:41 +0200 Subject: [PATCH 60/94] Update upgrade --- scripts/upgrade | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 5f71b87..f31dbad 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -29,7 +29,12 @@ gui_port=$(ynh_app_setting_get $app gui_port) #================================================= # STANDARD UPGRADE STEPS #================================================= +# NGINX CONFIGURATION +#================================================= +ynh_print_info "Upgrading nginx web server configuration..." +# Create a dedicated nginx config +ynh_add_nginx_config "gui_port" #================================================= # UPGRADE DEPENDENCIES @@ -40,24 +45,37 @@ sudo apt-get update -qq sudo apt-get upgrade syncthing -y -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_print_info "Upgrading nginx web server configuration..." -sed -i "s@PATHTOCHANGE@$path_url@g" ../conf/nginx.conf -sed -i "s@PORTTOCHANGE@$gui_port@g" ../conf/nginx.conf -sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/syncthing.conf +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_print_info "Making sure dedicated system user exists..." + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$sync_user --home_dir=$sync_home/ --use_shell + +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_print_info "Upgrading logrotate configuration..." + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --non-append + +#================================================= +# SETUP SSOWAT +#================================================= +ynh_print_info "Upgrading SSOwat configuration..." + +ynh_app_setting_set $app unprotected_uris "/" #================================================= # RELOAD NGINX #================================================= ynh_print_info "Reloading nginx web server..." -sudo service nginx reload -sudo yunohost app ssowatconf - +systemctl reload nginx #================================================= # END OF SCRIPT From cbbd2f10bf1e3d4f36db80cd5491921ef6f5c085 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 02:59:35 +0200 Subject: [PATCH 61/94] swicth from deb repository to app.src --- README.md | 2 +- conf/app.src | 6 +++ conf/config.xml | 9 +++++ conf/systemd.service | 21 ++++++++++ manifest.json | 3 +- scripts/install | 94 +++++++++++++++++++++++++++----------------- scripts/remove | 35 +++++++++-------- 7 files changed, 115 insertions(+), 55 deletions(-) create mode 100644 conf/app.src create mode 100644 conf/config.xml create mode 100644 conf/systemd.service diff --git a/README.md b/README.md index b2db47e..c67d984 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to ## Overview Syncthing replaces proprietary sync and cloud services with something open, trustworthy and decentralized. Your data is your data alone and you deserve to choose where it is stored, if it is shared with some third party and how it's transmitted over the Internet. -**Shipped version:** 1.0 +**Shipped version:** 1.1.1 ## Screenshots diff --git a/conf/app.src b/conf/app.src new file mode 100644 index 0000000..f187466 --- /dev/null +++ b/conf/app.src @@ -0,0 +1,6 @@ +SOURCE_URL=https://github.com/syncthing/syncthing/releases/download/v1.1.1/syncthing-linux-amd64-v1.1.1.tar.gz +SOURCE_SUM=33554cdc9c6ed4f540cca234c10c046b40d036e24730eebe95e9cffa1c3dd61e +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=tar.gz +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= diff --git a/conf/config.xml b/conf/config.xml new file mode 100644 index 0000000..c95f195 --- /dev/null +++ b/conf/config.xml @@ -0,0 +1,9 @@ + + + + +
127.0.0.1:__GUI_PORT__
+
+ + +
diff --git a/conf/systemd.service b/conf/systemd.service new file mode 100644 index 0000000..991e74b --- /dev/null +++ b/conf/systemd.service @@ -0,0 +1,21 @@ +[Unit] +Description=Syncthing - Open Source Continuous File Synchronization for %I +Documentation=man:syncthing(1) +After=multi-user.target network.target + +[Service] +User=__APP__ +ExecStart=__FINALPATH__/syncthing -no-browser -no-restart -logflags=0 +Restart=on-failure +SuccessExitStatus=3 4 +RestartForceExitStatus=3 4 + +# Hardening +ProtectSystem=full +PrivateTmp=true +SystemCallArchitectures=native +MemoryDenyWriteExecute=true +NoNewPrivileges=true + +[Install] +WantedBy=multi-user.target diff --git a/manifest.json b/manifest.json index fbd5250..831cb40 100644 --- a/manifest.json +++ b/manifest.json @@ -6,6 +6,7 @@ "en": "Syncthing replaces proprietary sync and cloud services with something open, trustworthy and decentralized.", "fr": "Syncthing remplace les services propriétaires de synchro et de cloud avec quelque chose d'ouvert, digne de confiance et décentralisée." }, + "version": "1.1.1~ynh1", "url": "https://syncthing.net/", "license": "MPL-2.0", "maintainer": { @@ -15,7 +16,7 @@ "requirements": { "yunohost": ">= 3.4" }, - "multi_instance": true, + "multi_instance": false, "services": [ "nginx" ], diff --git a/scripts/install b/scripts/install index a3408b4..b6803da 100644 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. + read -p "key" true } # Exit if an error occurs during the execution of the script @@ -33,15 +33,15 @@ app=$YNH_APP_INSTANCE_NAME # Configurable variables sync_home="/home/yunohost.app/$app" -sync_user=debian-syncthing -sync_port=22000 -gui_port=8384 #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= ynh_print_info "Validating installation parameters..." +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 $domain $path_url @@ -55,7 +55,6 @@ ynh_app_setting_set $app path $path_url ynh_app_setting_set $app admin $admin ynh_app_setting_set $app channel $channel ynh_app_setting_set $app sync_home $sync_home -ynh_app_setting_set $app sync_user $sync_user #================================================= # STANDARD MODIFICATIONS @@ -64,20 +63,10 @@ ynh_app_setting_set $app sync_user $sync_user #================================================= ynh_print_info "Configuring firewall..." -# Check port availability -sudo yunohost app checkport $gui_port -if [[ ! $? -eq 0 ]]; then - echo Port $gui_port for Syncthing UI is not available. - exit 1 -fi +gui_port=$(ynh_find_port 8384) ynh_app_setting_set $app gui_port $gui_port -sudo yunohost app checkport $sync_port -if [[ ! $? -eq 0 ]]; then - echo Port $sync_port for Syncthing protocol is not available. - exit 1 -fi - +sync_port=$(ynh_find_port 22000) # Open this port ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $sync_port ynh_app_setting_set $app sync_port $sync_port @@ -89,13 +78,18 @@ ynh_print_info "Installing dependencies..." ynh_install_app_dependencies $pkg_dependencies -## Add the release PGP keys: -curl -s https://syncthing.net/release-key.txt | sudo apt-key add - -## Add the choosed channel to your APT sources: -echo "deb http://apt.syncthing.net/ syncthing $channel" | sudo tee /etc/apt/sources.list.d/syncthing.list -## Update and install syncthing: -sudo apt-get update -qq -sudo apt-get install syncthing -y --force-yes +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_print_info "Setting up source files..." + +### `ynh_setup_source` is used to install an app from a zip or tar.gz file, +### downloaded from an upstream source, like a git repository. +### `ynh_setup_source` use the file conf/app.src + +ynh_app_setting_set $app final_path $final_path +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source "$final_path" #================================================= # NGINX CONFIGURATION @@ -111,7 +105,7 @@ ynh_add_nginx_config "gui_port" ynh_print_info "Configuring system user..." # Create a system user -ynh_system_user_create --username=$sync_user --home_dir=$sync_home/ --use_shell +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # SPECIFIC SETUP @@ -121,21 +115,34 @@ ynh_system_user_create --username=$sync_user --home_dir=$sync_home/ --use_shell ynh_print_info "Creating sync directory..." # Make directories and set rights -sudo chown -R $sync_user:$sync_user $sync_home/ -sudo find $sync_home/ -type f | while read LINE; do sudo chmod 640 "$LINE" ; done -sudo find $sync_home/ -type d | while read LINE; do sudo chmod 750 "$LINE" ; done +mkdir -p "$sync_home" +chown -R "$app": "$sync_home" #================================================= # SETUP SYSTEMD #================================================= ynh_print_info "Configuring a systemd service..." -# Install and monitor service -sudo sed -i '/^\[Service\]$/,/^\[/ s/^Restart=on-failure/Restart=always/' /lib/systemd/system/syncthing@.service -sudo systemctl daemon-reload -sudo systemctl enable syncthing@$sync_user.service -sudo yunohost service add syncthing@$sync_user -l /var/log/syncthing.log -sudo systemctl start syncthing@$sync_user.service +# Create a dedicated systemd config +ynh_add_systemd_config + +#================================================= +# MODIFY A CONFIG FILE +#================================================= + +mkdir -p "$final_path/.config/syncthing" +config_file="$final_path/.config/syncthing/config.xml" +cp "../conf/config.xml" "$config_file" + +ynh_replace_string "__GUI_PORT__" "$gui_port" "$config_file" +ynh_replace_string "__SYNC_HOME__" "$sync_home" "$config_file" + +#================================================= +# STORE THE CONFIG FILE CHECKSUM +#================================================= + +# Calculate and store the config file checksum into the app settings +ynh_store_file_checksum "$config_file" #================================================= # GENERIC FINALIZATION @@ -143,9 +150,8 @@ sudo systemctl start syncthing@$sync_user.service # SECURE FILES AND DIRECTORIES #================================================= -# Remove acces to all users -sudo yunohost app removeaccess syncthing -sudo yunohost app addaccess syncthing -u $admin +# Set permissions to app files +chown -R $app: $final_path #================================================= # SETUP LOGROTATE @@ -155,6 +161,12 @@ ynh_print_info "Configuring log rotation..." # Use logrotate to manage application logfile(s) ynh_use_logrotate +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add $app --description "$app daemon for Syncthing" + #================================================= # SETUP SSOWAT #================================================= @@ -170,6 +182,14 @@ ynh_print_info "Reloading nginx web server..." systemctl reload nginx +#================================================= +# START SYNCTHING SERVICES +#================================================= +ynh_print_info "Starting Syncthing services..." + +ynh_systemd_action --action=start --service_name=$app --log_path=systemd +#--line_match="Started $app" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/remove b/scripts/remove index 82a7634..2cf471a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -27,15 +27,24 @@ gui_port=$(ynh_app_setting_get $app gui_port) #================================================= # STANDARD REMOVE +#================================================= +# REMOVE SERVICE FROM ADMIN PANEL +#================================================= + +# Remove a service from the admin panel, added by `yunohost service add` +if yunohost service status $app >/dev/null 2>&1 +then + ynh_print_info "Removing $app service" + yunohost service remove $app +fi + #================================================= # STOP AND REMOVE SERVICE #================================================= ynh_print_info "Stopping and removing the systemd service" # Remove the dedicated systemd config -sudo systemctl stop syncthing@$sync_user.service -sudo yunohost service remove syncthing -sudo systemctl disable syncthing@$sync_user.service +ynh_remove_systemd_config #================================================= # REMOVE DEPENDENCIES @@ -45,19 +54,13 @@ ynh_print_info "Removing dependencies" # Remove metapackage and its dependencies ynh_remove_app_dependencies -# Remove syncthing binairy -sudo apt-get autoremove syncthing -y --purge -sudo rm /etc/apt/sources.list.d/syncthing.list -sudo apt-get update -qq - -# Backup syncthing sync_home directory -sudo mv $sync_home $sync_home.old -# sudo rm -rf $sync_home - - - - +#================================================= +# REMOVE APP MAIN DIR +#================================================= +ynh_print_info "Removing app main directory" +# Remove the app directory securely +ynh_secure_remove "$final_path" #================================================= # REMOVE NGINX CONFIGURATION @@ -90,7 +93,7 @@ ynh_exec_warn_less yunohost firewall disallow TCP $sync_port ynh_print_info "Removing the dedicated system user" # Delete a system user -ynh_system_user_delete $sync_user +ynh_system_user_delete $app #================================================= # END OF SCRIPT From a783a196320a04e880f67c72d7a857e235209c66 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 03:09:41 +0200 Subject: [PATCH 62/94] Implement backup and restore --- scripts/backup | 70 ++++++++++++++++++++++++++++ scripts/restore | 118 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 188 insertions(+) diff --git a/scripts/backup b/scripts/backup index e69de29..fffab08 100644 --- a/scripts/backup +++ b/scripts/backup @@ -0,0 +1,70 @@ +#!/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 ../settings/scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info "Loading installation settings..." + +app=$YNH_APP_INSTANCE_NAME + +final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get $app domain) +db_name=$(ynh_app_setting_get $app db_name) + +#================================================= +# STANDARD BACKUP STEPS +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= +ynh_print_info "Backing up the main app directory..." + +ynh_backup "$final_path" + +#================================================= +# BACKUP THE NGINX CONFIGURATION +#================================================= +ynh_print_info "Backing up nginx web server configuration..." + +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# SPECIFIC BACKUP +#================================================= +# BACKUP LOGROTATE +#================================================= +ynh_print_info "Backing up logrotate configuration..." + +ynh_backup "/etc/logrotate.d/$app" + +#================================================= +# BACKUP SYSTEMD +#================================================= +ynh_print_info "Backing up systemd configuration..." + +ynh_backup "/etc/systemd/system/$app.service" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/restore b/scripts/restore index e69de29..78ae3d7 100644 --- a/scripts/restore +++ b/scripts/restore @@ -0,0 +1,118 @@ +#!/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 ../settings/scripts/_common.sh +source /usr/share/yunohost/helpers + +#================================================= +# MANAGE SCRIPT FAILURE +#================================================= + +ynh_clean_setup () { + true +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info "Loading settings..." + +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get $app domain) +path_url=$(ynh_app_setting_get $app path) +final_path=$(ynh_app_setting_get $app final_path) +db_name=$(ynh_app_setting_get $app db_name) + +#================================================= +# CHECK IF THE APP CAN BE RESTORED +#================================================= +ynh_print_info "Validating restoration parameters..." + +ynh_webpath_available $domain $path_url \ + || ynh_die "Path not available: ${domain}${path_url}" +test ! -d $final_path \ + || ynh_die "There is already a directory: $final_path " + +#================================================= +# STANDARD RESTORATION STEPS +#================================================= +# RESTORE THE NGINX CONFIGURATION +#================================================= + +ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_print_info "Restoring the app main directory..." + +ynh_restore_file "$final_path" + +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_print_info "Recreating the dedicated system user..." + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir=$final_path + +#================================================= +# RESTORE USER RIGHTS +#================================================= + +# Restore permissions on app files +chown -R "$app": $final_path + +#================================================= +# SPECIFIC RESTORATION +#================================================= +# REINSTALL DEPENDENCIES +#================================================= +ynh_print_info "Reinstalling dependencies..." + +# Define and install dependencies +ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# RESTORE SYSTEMD +#================================================= +ynh_print_info "Restoring the systemd configuration..." + +ynh_restore_file "/etc/systemd/system/$app.service" +systemctl enable $app.service + +#================================================= +# ADVERTISE SERVICE IN ADMIN PANEL +#================================================= + +yunohost service add $app --description "$app daemon for Syncthing" + +#================================================= +# RESTORE THE LOGROTATE CONFIGURATION +#================================================= + +ynh_restore_file "/etc/logrotate.d/$app" + +#================================================= +# GENERIC FINALIZATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info "Reloading nginx web server..." + +systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Restoration completed for $app" From dfba6daefdaf2141b26493043af24540b494157e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 03:09:48 +0200 Subject: [PATCH 63/94] Update upgrade --- scripts/upgrade | 58 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index f31dbad..f8a913f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,12 +22,33 @@ path_url=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) sync_home=$(ynh_app_setting_get $app sync_home) -sync_user=$(ynh_app_setting_get $app sync_user) sync_port=$(ynh_app_setting_get $app sync_port) gui_port=$(ynh_app_setting_get $app gui_port) +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_print_info "Backing up the app before upgrading (may take a while)..." + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # STANDARD UPGRADE STEPS +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_print_info "Upgrading source files..." + +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= @@ -41,11 +62,7 @@ ynh_add_nginx_config "gui_port" #================================================= ynh_print_info "Upgrading dependencies..." -sudo apt-get update -qq -sudo apt-get upgrade syncthing -y - - - +ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE DEDICATED USER @@ -55,6 +72,18 @@ ynh_print_info "Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create --username=$sync_user --home_dir=$sync_home/ --use_shell +#================================================= +# SPECIFIC UPGRADE +#================================================= +# ... +#================================================= + +config_file="$final_path/.config/syncthing/config.xml" + +ynh_backup_if_checksum_is_different "$config_file" +# Recalculate and store the checksum of the file for the next upgrade. +ynh_store_file_checksum "$config_file" + #================================================= # SETUP LOGROTATE #================================================= @@ -63,6 +92,23 @@ ynh_print_info "Upgrading logrotate configuration..." # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_print_info "Upgrading systemd configuration..." + +# Create a dedicated systemd config +ynh_add_systemd_config + +#================================================= +# GENERIC FINALIZATION +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= + +# Set permissions on app files +chown -R $app: $final_path + #================================================= # SETUP SSOWAT #================================================= From 22a73443b99a35e6223ff4df7d2afa345201d09e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 03:10:15 +0200 Subject: [PATCH 64/94] Delete logrotate.conf --- conf/logrotate.conf | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 conf/logrotate.conf diff --git a/conf/logrotate.conf b/conf/logrotate.conf deleted file mode 100644 index 5008367..0000000 --- a/conf/logrotate.conf +++ /dev/null @@ -1,14 +0,0 @@ -/var/log/syncthing.log { - rotate 4 - weekly - minsize 1M - missingok - create 640 root adm - notifempty - compress - delaycompress - postrotate - systemctl restart syncthing@sync_user > /dev/null - endscript -} - From b761a5ba6760fa8c73005fddad74c1c084b5a0ae Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 03:12:58 +0200 Subject: [PATCH 65/94] remove chanel --- manifest.json | 11 +---------- scripts/install | 2 -- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/manifest.json b/manifest.json index 831cb40..44e7f01 100644 --- a/manifest.json +++ b/manifest.json @@ -47,16 +47,7 @@ "fr": "Choisissez l'utilisateur de Syncthing (doit être un utilisateur yunohost existant)" }, "example": "johndoe" - }, - { - "name": "channel", - "ask": { - "en": "Choose Syncthing channel ?", - "fr": "Choissez la version de Syncthing ?" - }, - "choices": ["stable", "candidate"], - "default": "stable" - } + } ] } } diff --git a/scripts/install b/scripts/install index b6803da..2c30c94 100644 --- a/scripts/install +++ b/scripts/install @@ -27,7 +27,6 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH admin=$YNH_APP_ARG_ADMIN -channel=$YNH_APP_ARG_CHANNEL app=$YNH_APP_INSTANCE_NAME @@ -53,7 +52,6 @@ ynh_print_info "Storing installation settings..." ynh_app_setting_set $app domain $domain ynh_app_setting_set $app path $path_url ynh_app_setting_set $app admin $admin -ynh_app_setting_set $app channel $channel ynh_app_setting_set $app sync_home $sync_home #================================================= From bdc544d42d66174e7629fc59275d637450527899 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 03:13:04 +0200 Subject: [PATCH 66/94] Create check_process --- check_process | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 check_process diff --git a/check_process b/check_process new file mode 100644 index 0000000..92a2183 --- /dev/null +++ b/check_process @@ -0,0 +1,41 @@ +# See here for more information +# https://github.com/YunoHost/package_check#syntax-check_process-file + +# Move this file from check_process.default to check_process when you have filled it. + +;; Test complet + ; Manifest + domain="domain.tld" (DOMAIN) + path="/path" (PATH) + admin="john" (USER) + ; Checks + pkg_linter=1 + setup_sub_dir=1 + setup_root=1 + setup_nourl=0 + setup_private=1 + setup_public=1 + upgrade=1 + backup_restore=1 + multi_instance=0 + incorrect_path=1 + port_already_use=0 + change_url=0 +;;; Levels + Level 1=auto + Level 2=auto + Level 3=auto +# Level 4: If the app supports LDAP and SSOwat, turn level 4 to '1' and add a link to an issue or a part of your code to show it. +# If the app does not use LDAP nor SSOwat, and can't use them, turn level 4 to 'na' and explain as well. + Level 4=0 + Level 5=auto + Level 6=auto + Level 7=auto + Level 8=0 + Level 9=0 + Level 10=0 +;;; Options +Email= +Notification=none + + From 034c27a24f9bca73ce4ea6d8ff6b3259c200daa9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 03:27:33 +0200 Subject: [PATCH 67/94] Update config.xml --- conf/config.xml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/conf/config.xml b/conf/config.xml index c95f195..7227e99 100644 --- a/conf/config.xml +++ b/conf/config.xml @@ -1,9 +1,14 @@ - - - +
127.0.0.1:__GUI_PORT__
- - + +
localhost:389
+ uid=%s,ou=users,dc=yunohost,dc=org + nontls + false +
+ + __SYNC_HOME__ +
From 3f1570e9352f2aec7128e89d1c15a8b4b69141b6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 03:27:44 +0200 Subject: [PATCH 68/94] adding automation --- .travis.yml | 7 +++++++ pull_request_template.md | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 .travis.yml create mode 100644 pull_request_template.md diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6133a24 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: python + +before_install: + - git clone https://github.com/YunoHost/package_linter /tmp/package_linter + +script: +- /tmp/package_linter/package_linter.py ./ \ No newline at end of file diff --git a/pull_request_template.md b/pull_request_template.md new file mode 100644 index 0000000..f84c118 --- /dev/null +++ b/pull_request_template.md @@ -0,0 +1,23 @@ +## Problem +- *Description of why you made this PR* + +## Solution +- *And how do you fix that problem* + +## PR Status +- [ ] Code finished. +- [ ] Tested with Package_check. +- [ ] Fix or enhancement tested. +- [ ] Upgrade from last version tested. +- [ ] Can be reviewed and tested. + +## Validation +--- +- [ ] **Code review** +- [ ] **Approval (LGTM)** +*Code review and approval have to be from a member of @YunoHost/apps group* +- **CI succeeded** : +[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/syncthing_ynh%20-BRANCH-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/syncthing_ynh%20-BRANCH-/) +*Please replace '-BRANCH-' in this link by the name of the branch used.* +*If the PR is from a forked repository. Please provide public results from package_check.* +When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. From eb241a51f4855efc2609fb427f07af8718e92cc9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 19:34:12 +0200 Subject: [PATCH 69/94] Update install --- scripts/install | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/install b/scripts/install index 2c30c94..ebccc04 100644 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - read -p "key" true } # Exit if an error occurs during the execution of the script From 6671a35e75b89e5056a388b6f8620da46015bdea Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 21:08:31 +0200 Subject: [PATCH 70/94] Remove dependencies --- scripts/_common.sh | 2 +- scripts/install | 10 ---------- scripts/remove | 8 -------- scripts/restore | 16 ++++++++-------- scripts/upgrade | 9 +-------- 5 files changed, 10 insertions(+), 35 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 67ea80b..ecd263f 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="curl" +pkg_dependencies="" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index ebccc04..afd1d21 100644 --- a/scripts/install +++ b/scripts/install @@ -13,9 +13,6 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { - true -} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -68,13 +65,6 @@ sync_port=$(ynh_find_port 22000) ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $sync_port ynh_app_setting_set $app sync_port $sync_port -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_print_info "Installing dependencies..." - -ynh_install_app_dependencies $pkg_dependencies - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= diff --git a/scripts/remove b/scripts/remove index 2cf471a..3dda65f 100644 --- a/scripts/remove +++ b/scripts/remove @@ -46,14 +46,6 @@ ynh_print_info "Stopping and removing the systemd service" # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_print_info "Removing dependencies" - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - #================================================= # REMOVE APP MAIN DIR #================================================= diff --git a/scripts/restore b/scripts/restore index 78ae3d7..ed082eb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -74,14 +74,6 @@ chown -R "$app": $final_path #================================================= # SPECIFIC RESTORATION -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -ynh_print_info "Reinstalling dependencies..." - -# Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies - #================================================= # RESTORE SYSTEMD #================================================= @@ -111,6 +103,14 @@ ynh_print_info "Reloading nginx web server..." systemctl reload nginx +#================================================= +# START SYNCTHING SERVICES +#================================================= +ynh_print_info "Starting Syncthing services..." + +ynh_systemd_action --action=start --service_name=$app --log_path=systemd +#--line_match="Started $app" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f8a913f..01b8405 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -57,20 +57,13 @@ ynh_print_info "Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config "gui_port" -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -ynh_print_info "Upgrading dependencies..." - -ynh_install_app_dependencies $pkg_dependencies - #================================================= # CREATE DEDICATED USER #================================================= ynh_print_info "Making sure dedicated system user exists..." # Create a dedicated user (if not existing) -ynh_system_user_create --username=$sync_user --home_dir=$sync_home/ --use_shell +ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # SPECIFIC UPGRADE From 2b0b52d181f78c1f10c59075d2323f528ecabfe4 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 21:13:32 +0200 Subject: [PATCH 71/94] Remove LOGROTATE --- scripts/backup | 7 ------- scripts/install | 12 ------------ scripts/remove | 8 -------- scripts/restore | 6 ------ scripts/upgrade | 8 -------- 5 files changed, 41 deletions(-) diff --git a/scripts/backup b/scripts/backup index fffab08..f19b290 100644 --- a/scripts/backup +++ b/scripts/backup @@ -49,13 +49,6 @@ ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP -#================================================= -# BACKUP LOGROTATE -#================================================= -ynh_print_info "Backing up logrotate configuration..." - -ynh_backup "/etc/logrotate.d/$app" - #================================================= # BACKUP SYSTEMD #================================================= diff --git a/scripts/install b/scripts/install index afd1d21..f17d47d 100644 --- a/scripts/install +++ b/scripts/install @@ -70,10 +70,6 @@ ynh_app_setting_set $app sync_port $sync_port #================================================= ynh_print_info "Setting up source files..." -### `ynh_setup_source` is used to install an app from a zip or tar.gz file, -### downloaded from an upstream source, like a git repository. -### `ynh_setup_source` use the file conf/app.src - ynh_app_setting_set $app final_path $final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source "$final_path" @@ -140,14 +136,6 @@ ynh_store_file_checksum "$config_file" # Set permissions to app files chown -R $app: $final_path -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_print_info "Configuring log rotation..." - -# Use logrotate to manage application logfile(s) -ynh_use_logrotate - #================================================= # ADVERTISE SERVICE IN ADMIN PANEL #================================================= diff --git a/scripts/remove b/scripts/remove index 3dda65f..2d35488 100644 --- a/scripts/remove +++ b/scripts/remove @@ -62,14 +62,6 @@ ynh_print_info "Removing nginx web server configuration" # Remove the dedicated nginx config ynh_remove_nginx_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_print_info "Removing logrotate configuration" - -# Remove the app-specific logrotate config -ynh_remove_logrotate - #================================================= # CLOSE A PORT #================================================= diff --git a/scripts/restore b/scripts/restore index ed082eb..76f329a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -88,12 +88,6 @@ systemctl enable $app.service yunohost service add $app --description "$app daemon for Syncthing" -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= - -ynh_restore_file "/etc/logrotate.d/$app" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 01b8405..a65b426 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -77,14 +77,6 @@ ynh_backup_if_checksum_is_different "$config_file" # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum "$config_file" -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_print_info "Upgrading logrotate configuration..." - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - #================================================= # SETUP SYSTEMD #================================================= From c6466a7d2b56759290ee5dd834fa46d8de251858 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 21:29:47 +0200 Subject: [PATCH 72/94] implement ynh_clean_check_starting --- scripts/backup | 2 +- scripts/install | 7 +++++-- scripts/restore | 2 +- scripts/upgrade | 1 + 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/backup b/scripts/backup index f19b290..749292f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors diff --git a/scripts/install b/scripts/install index f17d47d..8d1594f 100644 --- a/scripts/install +++ b/scripts/install @@ -13,6 +13,9 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= +ynh_clean_setup () { + ynh_clean_check_starting +} # Exit if an error occurs during the execution of the script ynh_abort_if_errors @@ -112,6 +115,7 @@ ynh_add_systemd_config #================================================= # MODIFY A CONFIG FILE #================================================= +ynh_print_info "Modifying a config file..." mkdir -p "$final_path/.config/syncthing" config_file="$final_path/.config/syncthing/config.xml" @@ -162,8 +166,7 @@ systemctl reload nginx #================================================= ynh_print_info "Starting Syncthing services..." -ynh_systemd_action --action=start --service_name=$app --log_path=systemd -#--line_match="Started $app" +ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Access the GUI via the following URL" #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 76f329a..b933e6e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_clean_setup () { - true + ynh_clean_check_starting } # Exit if an error occurs during the execution of the script ynh_abort_if_errors diff --git a/scripts/upgrade b/scripts/upgrade index a65b426..66dbaba 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -33,6 +33,7 @@ ynh_print_info "Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade ynh_clean_setup () { + ynh_clean_check_starting # restore it if the upgrade fails ynh_restore_upgradebackup } From 31e154327c7652db6228d7775354f7bb04eedde7 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 21:37:53 +0200 Subject: [PATCH 73/94] Update remove --- scripts/remove | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 2d35488..6512c61 100644 --- a/scripts/remove +++ b/scripts/remove @@ -21,7 +21,6 @@ domain=$(ynh_app_setting_get $app domain) final_path=$(ynh_app_setting_get $app final_path) sync_home=$(ynh_app_setting_get $app sync_home) -sync_user=$(ynh_app_setting_get $app sync_user) sync_port=$(ynh_app_setting_get $app sync_port) gui_port=$(ynh_app_setting_get $app gui_port) From 53ebb68abff02d534437755696554bf076d9d013 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 21:57:45 +0200 Subject: [PATCH 74/94] Variables cleanup --- scripts/backup | 1 - scripts/remove | 2 -- scripts/restore | 14 +++++++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/backup b/scripts/backup index 749292f..b00dc77 100644 --- a/scripts/backup +++ b/scripts/backup @@ -29,7 +29,6 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get $app final_path) domain=$(ynh_app_setting_get $app domain) -db_name=$(ynh_app_setting_get $app db_name) #================================================= # STANDARD BACKUP STEPS diff --git a/scripts/remove b/scripts/remove index 6512c61..e245418 100644 --- a/scripts/remove +++ b/scripts/remove @@ -20,9 +20,7 @@ domain=$(ynh_app_setting_get $app domain) final_path=$(ynh_app_setting_get $app final_path) -sync_home=$(ynh_app_setting_get $app sync_home) sync_port=$(ynh_app_setting_get $app sync_port) -gui_port=$(ynh_app_setting_get $app gui_port) #================================================= # STANDARD REMOVE diff --git a/scripts/restore b/scripts/restore index b933e6e..ad00d56 100644 --- a/scripts/restore +++ b/scripts/restore @@ -30,7 +30,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get $app domain) path_url=$(ynh_app_setting_get $app path) final_path=$(ynh_app_setting_get $app final_path) -db_name=$(ynh_app_setting_get $app db_name) +sync_home=$(ynh_app_setting_get $app sync_home) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -74,6 +74,15 @@ chown -R "$app": $final_path #================================================= # SPECIFIC RESTORATION +#================================================= +# RECREATE SYNC DIRECTORY +#================================================= +ynh_print_info "Recreating sync directory..." + +# Make directories and set rights +mkdir -p "$sync_home" +chown -R "$app": "$sync_home" + #================================================= # RESTORE SYSTEMD #================================================= @@ -102,8 +111,7 @@ systemctl reload nginx #================================================= ynh_print_info "Starting Syncthing services..." -ynh_systemd_action --action=start --service_name=$app --log_path=systemd -#--line_match="Started $app" +ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Access the GUI via the following URL" #================================================= # END OF SCRIPT From c6827ccf6c774907a3c96fea0c0f6a45a48d5329 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 21:58:06 +0200 Subject: [PATCH 75/94] Typo --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 8d1594f..a289f63 100644 --- a/scripts/install +++ b/scripts/install @@ -29,7 +29,7 @@ admin=$YNH_APP_ARG_ADMIN app=$YNH_APP_INSTANCE_NAME -# Configurable variables +# Configure sync folder sync_home="/home/yunohost.app/$app" #================================================= From 02243a6a8bf0eb1702016110e9564b3d23ad31aa Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 21:58:14 +0200 Subject: [PATCH 76/94] Update upgrade --- scripts/upgrade | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 66dbaba..73cc330 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -69,7 +69,16 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # SPECIFIC UPGRADE #================================================= -# ... +# CREATE SYNC DIRECTORY +#================================================= +ynh_print_info "Creating sync directory..." + +# Make directories and set rights +mkdir -p "$sync_home" +chown -R "$app": "$sync_home" + +#================================================= +# STORE THE CONFIG FILE CHECKSUM #================================================= config_file="$final_path/.config/syncthing/config.xml" From e4ee1687153ec8421c24691195e80ca8d592fe44 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 21:58:26 +0200 Subject: [PATCH 77/94] Update check_process --- check_process | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/check_process b/check_process index 92a2183..752d977 100644 --- a/check_process +++ b/check_process @@ -16,8 +16,9 @@ setup_private=1 setup_public=1 upgrade=1 + upgrade=1 from_commit=160278bb9f3a56466d04605eb34278a483c0901c backup_restore=1 - multi_instance=0 + multi_instance=1 incorrect_path=1 port_already_use=0 change_url=0 From d7cf6e46996d0b35a2c01824956dc2fec90fc9f9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Apr 2019 22:02:52 +0200 Subject: [PATCH 78/94] Implement change url --- scripts/change_url | 101 +++++++++++++++++++++++++++++++++++++++++++++ scripts/upgrade | 14 +++++++ 2 files changed, 115 insertions(+) create mode 100644 scripts/change_url diff --git a/scripts/change_url b/scripts/change_url new file mode 100644 index 0000000..61694d2 --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,101 @@ +#!/bin/bash + +#================================================= +# GENERIC STARTING +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# RETRIEVE ARGUMENTS +#================================================= + +old_domain=$YNH_APP_OLD_DOMAIN +old_path=$YNH_APP_OLD_PATH + +new_domain=$YNH_APP_NEW_DOMAIN +new_path=$YNH_APP_NEW_PATH + +app=$YNH_APP_INSTANCE_NAME + +#================================================= +# LOAD SETTINGS +#================================================= +ynh_print_info "Loading installation settings..." + +# Needed for helper "ynh_add_nginx_config" +final_path=$(ynh_app_setting_get $app final_path) + +# Add settings here as needed by your application +#db_name=$(ynh_app_setting_get "$app" db_name) + +#================================================= +# CHECK WHICH PARTS SHOULD BE CHANGED +#================================================= + +change_domain=0 +if [ "$old_domain" != "$new_domain" ] +then + change_domain=1 +fi + +change_path=0 +if [ "$old_path" != "$new_path" ] +then + change_path=1 +fi + +#================================================= +# STANDARD MODIFICATIONS +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_print_info "Updating nginx web server configuration..." + +nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf + +# Change the path in the nginx config file +if [ $change_path -eq 1 ] +then + # Make a backup of the original nginx config file if modified + ynh_backup_if_checksum_is_different "$nginx_conf_path" + # Set global variables for nginx helper + domain="$old_domain" + path_url="$new_path" + # Create a dedicated nginx config + ynh_add_nginx_config +fi + +# Change the domain for nginx +if [ $change_domain -eq 1 ] +then + # Delete file checksum for the old conf file location + ynh_delete_file_checksum "$nginx_conf_path" + mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf + # Store file checksum for the new config file location + ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" +fi + +#================================================= +# SPECIFIC MODIFICATIONS +#================================================= +# ... +#================================================= + +#================================================= +# GENERIC FINALISATION +#================================================= +# RELOAD NGINX +#================================================= +ynh_print_info "Reloading nginx web server..." + +systemctl reload nginx + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_print_info "Change of URL completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 73cc330..47a7c7a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -40,6 +40,13 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +#================================================= +# STOP SYNCTHING SERVICES +#================================================= +ynh_print_info "Stopping Syncthing services..." + +ynh_systemd_action --action=stop --service_name=$app --log_path=systemd + #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -118,6 +125,13 @@ ynh_print_info "Reloading nginx web server..." systemctl reload nginx +#================================================= +# START SYNCTHING SERVICES +#================================================= +ynh_print_info "Starting Syncthing services..." + +ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Access the GUI via the following URL" + #================================================= # END OF SCRIPT #================================================= From 20a1cdc06e9056cb221466519238f75a52e80dfb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 15 Apr 2019 03:13:09 +0200 Subject: [PATCH 79/94] Update check_process --- check_process | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index 752d977..d65221e 100644 --- a/check_process +++ b/check_process @@ -13,12 +13,12 @@ setup_sub_dir=1 setup_root=1 setup_nourl=0 - setup_private=1 + setup_private=0 setup_public=1 upgrade=1 upgrade=1 from_commit=160278bb9f3a56466d04605eb34278a483c0901c backup_restore=1 - multi_instance=1 + multi_instance=0 incorrect_path=1 port_already_use=0 change_url=0 From 0cbcf4f6ebd736159ab03f6e553b599cbfa15175 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 15 Apr 2019 21:00:52 +0200 Subject: [PATCH 80/94] move to CI dev --- pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pull_request_template.md b/pull_request_template.md index f84c118..cd79100 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -17,7 +17,7 @@ - [ ] **Approval (LGTM)** *Code review and approval have to be from a member of @YunoHost/apps group* - **CI succeeded** : -[![Build Status](https://ci-apps-hq.yunohost.org/jenkins/job/syncthing_ynh%20-BRANCH-/badge/icon)](https://ci-apps-hq.yunohost.org/jenkins/job/syncthing_ynh%20-BRANCH-/) +[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/syncthing_ynh%20-BRANCH-/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/syncthing_ynh%20-BRANCH-/) *Please replace '-BRANCH-' in this link by the name of the branch used.* *If the PR is from a forked repository. Please provide public results from package_check.* When the PR is marked as ready to merge, you have to wait for 3 days before really merging it. From 1f063e245cec9b1fe3e10f90d46760977438e418 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 16 Apr 2019 03:14:33 +0200 Subject: [PATCH 81/94] Update config.xml --- conf/config.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conf/config.xml b/conf/config.xml index 7227e99..2805b98 100644 --- a/conf/config.xml +++ b/conf/config.xml @@ -9,6 +9,8 @@ false + default __SYNC_HOME__ + 1
From 4d1e103cc99809b2b8c7d2634d133d3fc925a158 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 16 Apr 2019 03:42:47 +0200 Subject: [PATCH 82/94] Fix upgrade from previous version --- scripts/upgrade | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 47a7c7a..8d111d8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,6 +25,39 @@ sync_home=$(ynh_app_setting_get $app sync_home) sync_port=$(ynh_app_setting_get $app sync_port) gui_port=$(ynh_app_setting_get $app gui_port) +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +ynh_print_info "Ensuring downward compatibility..." + +# If gui_port doesn't exist, create it +if [ -z $gui_port ]; then + + OLD_SYNCHOME="/home/yunohost.app/syncthing" + OLD_SYNCUSER=debian-syncthing + OLD_SYNCPORT=22000 + OLD_GUIPORT=8384 + OLD_CONFIG="$OLD_SYNCHOME/.config/syncthing/config.xml" + + admin=$(ynh_app_setting_get $app allowed_users) + ynh_app_setting_set $app admin $admin + ynh_app_setting_delete --app="$app" --key="allowed_users" + + final_path=/var/www/$app + ynh_app_setting_set $app final_path $final_path + + gui_port=$(grep -oP "
127.0.0.1:\K[^<]*" $OLD_CONFIG) + ynh_app_setting_set $app gui_port $gui_port + + sync_home=$(grep -oP "\K[^<]*" $OLD_CONFIG) + ynh_app_setting_set $app sync_home $gui_port + + sync_port=$(grep -oP "\K[^<]*" $OLD_CONFIG) + ynh_app_setting_set $app sync_port $gui_port + + mkdir -p $final_path + cp -R $OLD_SYNCHOME/.config $final_path/.config +fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -65,6 +98,14 @@ ynh_print_info "Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config "gui_port" +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_print_info "Removing dependencies" + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies + #================================================= # CREATE DEDICATED USER #================================================= From 5eeb239f8d50dfc97256b21ae51a9d81ef67821c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 17 Apr 2019 01:54:01 +0200 Subject: [PATCH 83/94] Fix dependencies removal --- scripts/upgrade | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 8d111d8..40b5b11 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -57,6 +57,8 @@ if [ -z $gui_port ]; then mkdir -p $final_path cp -R $OLD_SYNCHOME/.config $final_path/.config + + ynh_remove_app_dependencies fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP @@ -98,14 +100,6 @@ ynh_print_info "Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config "gui_port" -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_print_info "Removing dependencies" - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - #================================================= # CREATE DEDICATED USER #================================================= From 41207e591349bbe1c19d1d8b0ca4002b04213b3b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 18 Apr 2019 04:21:14 +0200 Subject: [PATCH 84/94] Fix upgrade from previous version --- check_process | 1 + 1 file changed, 1 insertion(+) diff --git a/check_process b/check_process index d65221e..37c06fc 100644 --- a/check_process +++ b/check_process @@ -8,6 +8,7 @@ domain="domain.tld" (DOMAIN) path="/path" (PATH) admin="john" (USER) + user="john" ; Checks pkg_linter=1 setup_sub_dir=1 From 32075302c712467e449c15589ac512d488b2eac1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 18 Apr 2019 11:58:33 +0200 Subject: [PATCH 85/94] Update check_process --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 37c06fc..b19bf08 100644 --- a/check_process +++ b/check_process @@ -8,7 +8,7 @@ domain="domain.tld" (DOMAIN) path="/path" (PATH) admin="john" (USER) - user="john" + user="john" (USER) ; Checks pkg_linter=1 setup_sub_dir=1 From d80bbd85689740030d936b7d51ab1e13959b869d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 18 Apr 2019 21:37:25 +0200 Subject: [PATCH 86/94] fix Invalid value for argument 'user' --- check_process | 1 - manifest.json | 2 +- scripts/install | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/check_process b/check_process index b19bf08..9114ab9 100644 --- a/check_process +++ b/check_process @@ -7,7 +7,6 @@ ; Manifest domain="domain.tld" (DOMAIN) path="/path" (PATH) - admin="john" (USER) user="john" (USER) ; Checks pkg_linter=1 diff --git a/manifest.json b/manifest.json index 44e7f01..870e876 100644 --- a/manifest.json +++ b/manifest.json @@ -40,7 +40,7 @@ "default": "/syncthing" }, { - "name": "admin", + "name": "user", "type": "user", "ask": { "en": "Choose the user for Syncthing (must be an existing yunohost user)", diff --git a/scripts/install b/scripts/install index a289f63..461200c 100644 --- a/scripts/install +++ b/scripts/install @@ -25,7 +25,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH -admin=$YNH_APP_ARG_ADMIN +admin=$YNH_APP_ARG_USER app=$YNH_APP_INSTANCE_NAME From d0c1c12e2aea80900063003d114d3b4703f62b24 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 20 Apr 2019 01:17:18 +0200 Subject: [PATCH 87/94] Update check_process --- check_process | 1 - 1 file changed, 1 deletion(-) diff --git a/check_process b/check_process index 9114ab9..42dce20 100644 --- a/check_process +++ b/check_process @@ -16,7 +16,6 @@ setup_private=0 setup_public=1 upgrade=1 - upgrade=1 from_commit=160278bb9f3a56466d04605eb34278a483c0901c backup_restore=1 multi_instance=0 incorrect_path=1 From 17688ea2b0a72695ce60938d48557531e219bcbb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 20 Apr 2019 01:17:34 +0200 Subject: [PATCH 88/94] Switch back to admin --- manifest.json | 2 +- scripts/install | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 870e876..44e7f01 100644 --- a/manifest.json +++ b/manifest.json @@ -40,7 +40,7 @@ "default": "/syncthing" }, { - "name": "user", + "name": "admin", "type": "user", "ask": { "en": "Choose the user for Syncthing (must be an existing yunohost user)", diff --git a/scripts/install b/scripts/install index 461200c..a289f63 100644 --- a/scripts/install +++ b/scripts/install @@ -25,7 +25,7 @@ ynh_abort_if_errors domain=$YNH_APP_ARG_DOMAIN path_url=$YNH_APP_ARG_PATH -admin=$YNH_APP_ARG_USER +admin=$YNH_APP_ARG_ADMIN app=$YNH_APP_INSTANCE_NAME From a627c25e9f51a0a1a54360689791a7b767722aba Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 20 Apr 2019 01:17:51 +0200 Subject: [PATCH 89/94] Add old version remove steps --- scripts/upgrade | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 40b5b11..b778850 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -58,7 +58,18 @@ if [ -z $gui_port ]; then mkdir -p $final_path cp -R $OLD_SYNCHOME/.config $final_path/.config + systemctl stop syncthing@$SYNCUSER.service + yunohost service remove syncthing + systemctl disable syncthing@$SYNCUSER.service + + ynh_secure_remove --file="/etc/apt/sources.list.d/syncthing.list" + + ynh_system_user_delete --username="$SYNCUSER" + + ynh_remove_logrotate + ynh_remove_app_dependencies + fi #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP From 556ea4d7872b4b249b3d34b2aa00862f641484dd Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 20 Apr 2019 02:06:06 +0200 Subject: [PATCH 90/94] Fix listening port --- conf/config.xml | 34 +++++++++++++++++++++++++++++++++- scripts/install | 14 +++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/conf/config.xml b/conf/config.xml index 2805b98..c4f6100 100644 --- a/conf/config.xml +++ b/conf/config.xml @@ -10,7 +10,39 @@ default + default + true + true + 0 + 0 + 60 + true + 10 + true + false + 0 + 0 + 0 + 3 + 3 + + https://data.syncthing.net/newdata + false + 1800 + true + 12 + false + 24 + false + 5 + false + 0 + https://upgrades1.syncthing.net/meta.json + true + 10 + 0 __SYNC_HOME__ - 1 + true + 0 diff --git a/scripts/install b/scripts/install index a289f63..b7bf811 100644 --- a/scripts/install +++ b/scripts/install @@ -65,7 +65,7 @@ ynh_app_setting_set $app gui_port $gui_port sync_port=$(ynh_find_port 22000) # Open this port -ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $sync_port +ynh_exec_warn_less yunohost firewall allow TCP $sync_port ynh_app_setting_set $app sync_port $sync_port #================================================= @@ -124,6 +124,18 @@ cp "../conf/config.xml" "$config_file" ynh_replace_string "__GUI_PORT__" "$gui_port" "$config_file" ynh_replace_string "__SYNC_HOME__" "$sync_home" "$config_file" +#================================================= +# FIX LISTENING SERVICE +#================================================= + +chown -R $app: $final_path + +ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Access the GUI via the following URL" + +ynh_replace_string "tcp://default" "default" "$config_file" + +ynh_systemd_action --action=stop --service_name=$app --log_path=systemd + #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= From d4d3d9d103e70d15890da40d9e7c1ef8b577d4b1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 20 Apr 2019 02:55:30 +0200 Subject: [PATCH 91/94] Update check_process --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index 42dce20..f784b5f 100644 --- a/check_process +++ b/check_process @@ -7,7 +7,7 @@ ; Manifest domain="domain.tld" (DOMAIN) path="/path" (PATH) - user="john" (USER) + admin="john" (USER) ; Checks pkg_linter=1 setup_sub_dir=1 From c2ffe480631d4dd7f6b3cd8a1c24b4993a6b9399 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 22 Apr 2019 17:18:21 +0200 Subject: [PATCH 92/94] Fix upgrade from previous version --- scripts/upgrade | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index b778850..2deca10 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -46,21 +46,23 @@ if [ -z $gui_port ]; then final_path=/var/www/$app ynh_app_setting_set $app final_path $final_path - gui_port=$(grep -oP "
127.0.0.1:\K[^<]*" $OLD_CONFIG) + gui_port=$OLD_GUIPORT ynh_app_setting_set $app gui_port $gui_port - sync_home=$(grep -oP "\K[^<]*" $OLD_CONFIG) - ynh_app_setting_set $app sync_home $gui_port + sync_home="/home/yunohost.app/$app" + ynh_app_setting_set $app sync_home $sync_home - sync_port=$(grep -oP "\K[^<]*" $OLD_CONFIG) - ynh_app_setting_set $app sync_port $gui_port + sync_port=$OLD_SYNCPORT + ynh_app_setting_set $app sync_port $sync_port mkdir -p $final_path cp -R $OLD_SYNCHOME/.config $final_path/.config - systemctl stop syncthing@$SYNCUSER.service - yunohost service remove syncthing - systemctl disable syncthing@$SYNCUSER.service + ynh_replace_string "~" "$sync_home" "$final_path/.config/syncthing/config.xml" + + systemctl stop syncthing@$OLD_SYNCUSER.service + yunohost service remove syncthing@$OLD_SYNCUSER.service + systemctl disable syncthing@$OLD_SYNCUSER.service ynh_secure_remove --file="/etc/apt/sources.list.d/syncthing.list" @@ -70,7 +72,8 @@ if [ -z $gui_port ]; then ynh_remove_app_dependencies -fi +else + #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= @@ -93,6 +96,7 @@ ynh_print_info "Stopping Syncthing services..." ynh_systemd_action --action=stop --service_name=$app --log_path=systemd +fi #================================================= # STANDARD UPGRADE STEPS #================================================= From 2ddf324c405b197bd70c3ada7f6ac0ea4b5ee1eb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 17 May 2019 01:33:38 +0200 Subject: [PATCH 93/94] Apply example_ynh --- README.md | 8 +-- manifest.json | 2 +- scripts/backup | 20 ++++---- scripts/change_url | 36 +++++++++---- scripts/install | 78 ++++++++++++++-------------- scripts/remove | 26 +++++----- scripts/restore | 52 +++++++++---------- scripts/upgrade | 123 ++++++++++++++++++++++++--------------------- 8 files changed, 186 insertions(+), 159 deletions(-) diff --git a/README.md b/README.md index c67d984..c6e62bb 100644 --- a/README.md +++ b/README.md @@ -27,15 +27,15 @@ How to configure this app: by an admin panel, a plain file with SSH, or any othe #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/syncthing%20%28Community%29.svg)](https://ci-apps.yunohost.org/ci/apps/syncthing/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/syncthing%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/syncthing/) -* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/syncthing%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/syncthing/) +* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/syncthing%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/syncthing/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/syncthing%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/syncthing/) +* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/syncthing%20%28Apps%29.svg)](https://ci-stretch.nohost.me/ci/apps/syncthing/) ## Links * Report a bug: https://github.com/YunoHost-Apps/syncthing_ynh/issues * App website: https://syncthing.net/ - * Git App website: https://github.com/syncthing/syncthing + * Upstream app repository: https://github.com/syncthing/syncthing * YunoHost website: https://yunohost.org/ --- diff --git a/manifest.json b/manifest.json index 44e7f01..f2dc4c9 100644 --- a/manifest.json +++ b/manifest.json @@ -14,7 +14,7 @@ "email": "txmrl@txmrl.net" }, "requirements": { - "yunohost": ">= 3.4" + "yunohost": ">= 3.5" }, "multi_instance": false, "services": [ diff --git a/scripts/backup b/scripts/backup index b00dc77..c1e753b 100644 --- a/scripts/backup +++ b/scripts/backup @@ -23,40 +23,40 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -final_path=$(ynh_app_setting_get $app final_path) -domain=$(ynh_app_setting_get $app domain) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) +domain=$(ynh_app_setting_get --app=$app --key=domain) #================================================= # STANDARD BACKUP STEPS #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_print_info "Backing up the main app directory..." +ynh_print_info --message="Backing up the main app directory..." -ynh_backup "$final_path" +ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_print_info "Backing up nginx web server configuration..." +ynh_print_info --message="Backing up nginx web server configuration..." -ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # SPECIFIC BACKUP #================================================= # BACKUP SYSTEMD #================================================= -ynh_print_info "Backing up systemd configuration..." +ynh_print_info --message="Backing up systemd configuration..." -ynh_backup "/etc/systemd/system/$app.service" +ynh_backup --src_path="/etc/systemd/system/$app.service" #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/change_url b/scripts/change_url index 61694d2..3e28062 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -24,13 +24,15 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." # Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get $app final_path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) # Add settings here as needed by your application -#db_name=$(ynh_app_setting_get "$app" db_name) +#db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#db_user=$db_name +#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED @@ -50,10 +52,17 @@ fi #================================================= # STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Stopping a systemd service..." + +ynh_systemd_action --service_name=$app --action="stop" + #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_print_info "Updating nginx web server configuration..." +ynh_print_info --message="Updating nginx web server configuration..." nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf @@ -61,7 +70,7 @@ nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf if [ $change_path -eq 1 ] then # Make a backup of the original nginx config file if modified - ynh_backup_if_checksum_is_different "$nginx_conf_path" + ynh_backup_if_checksum_is_different --file="$nginx_conf_path" # Set global variables for nginx helper domain="$old_domain" path_url="$new_path" @@ -73,10 +82,10 @@ fi if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location - ynh_delete_file_checksum "$nginx_conf_path" + ynh_delete_file_checksum --file="$nginx_conf_path" mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf # Store file checksum for the new config file location - ynh_store_file_checksum "/etc/nginx/conf.d/$new_domain.d/$app.conf" + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= @@ -87,15 +96,22 @@ fi #================================================= # GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" + #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -systemctl reload nginx +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Change of URL completed for $app" +ynh_print_info --message="Change of URL completed for $app" diff --git a/scripts/install b/scripts/install index b7bf811..8e02da2 100644 --- a/scripts/install +++ b/scripts/install @@ -35,52 +35,52 @@ sync_home="/home/yunohost.app/$app" #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_print_info "Validating installation parameters..." +ynh_print_info --message="Validating installation parameters..." final_path=/var/www/$app -test ! -e "$final_path" || ynh_die "This path already contains a folder" +test ! -e "$final_path" || ynh_die --message="This path already contains a folder" # Register (book) web path -ynh_webpath_register $app $domain $path_url +ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_print_info "Storing installation settings..." +ynh_print_info --message="Storing installation settings..." -ynh_app_setting_set $app domain $domain -ynh_app_setting_set $app path $path_url -ynh_app_setting_set $app admin $admin -ynh_app_setting_set $app sync_home $sync_home +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=admin --value=$admin +ynh_app_setting_set --app=$app --key=sync_home --value=$sync_home #================================================= # STANDARD MODIFICATIONS #================================================= # FIND AND OPEN A PORT #================================================= -ynh_print_info "Configuring firewall..." +ynh_print_info --message="Configuring firewall..." -gui_port=$(ynh_find_port 8384) -ynh_app_setting_set $app gui_port $gui_port +gui_port=$(ynh_find_port --port=8384) +ynh_app_setting_set --app=$app --key=gui_port --value=$gui_port -sync_port=$(ynh_find_port 22000) +sync_port=$(ynh_find_port --port=22000) # Open this port ynh_exec_warn_less yunohost firewall allow TCP $sync_port -ynh_app_setting_set $app sync_port $sync_port +ynh_app_setting_set --app=$app s--key=ync_port --value=$sync_port #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Setting up source files..." +ynh_print_info --message="Setting up source files..." -ynh_app_setting_set $app final_path $final_path +ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +ynh_setup_source --dest_dir="$final_path" #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Configuring nginx web server..." +ynh_print_info --message="Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config "gui_port" @@ -88,7 +88,7 @@ ynh_add_nginx_config "gui_port" #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Configuring system user..." +ynh_print_info --message="Configuring system user..." # Create a system user ynh_system_user_create --username=$app --home_dir=$final_path @@ -98,7 +98,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # CREATE SYNC DIRECTORY #================================================= -ynh_print_info "Creating sync directory..." +ynh_print_info --message="Creating sync directory..." # Make directories and set rights mkdir -p "$sync_home" @@ -107,7 +107,7 @@ chown -R "$app": "$sync_home" #================================================= # SETUP SYSTEMD #================================================= -ynh_print_info "Configuring a systemd service..." +ynh_print_info --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config @@ -115,14 +115,14 @@ ynh_add_systemd_config #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_print_info "Modifying a config file..." +ynh_print_info --message="Modifying a config file..." mkdir -p "$final_path/.config/syncthing" config_file="$final_path/.config/syncthing/config.xml" cp "../conf/config.xml" "$config_file" -ynh_replace_string "__GUI_PORT__" "$gui_port" "$config_file" -ynh_replace_string "__SYNC_HOME__" "$sync_home" "$config_file" +ynh_replace_string --match_string="__GUI_PORT__" --replace_string="$gui_port" --target_file="$config_file" +ynh_replace_string --match_string="__SYNC_HOME__" --replace_string="$sync_home" --target_file="$config_file" #================================================= # FIX LISTENING SERVICE @@ -130,18 +130,18 @@ ynh_replace_string "__SYNC_HOME__" "$sync_home" "$config_file" chown -R $app: $final_path -ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Access the GUI via the following URL" +ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access the GUI via the following URL" -ynh_replace_string "tcp://default" "default" "$config_file" +ynh_replace_string --match_string="tcp://default" --replace_string="default" --target_file="$config_file" -ynh_systemd_action --action=stop --service_name=$app --log_path=systemd +ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= # Calculate and store the config file checksum into the app settings -ynh_store_file_checksum "$config_file" +ynh_store_file_checksum --file="$config_file" #================================================= # GENERIC FINALIZATION @@ -158,30 +158,30 @@ chown -R $app: $final_path yunohost service add $app --description "$app daemon for Syncthing" +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access the GUI via the following URL" + #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Configuring SSOwat..." +ynh_print_info --message="Configuring SSOwat..." # Make app public -ynh_app_setting_set $app unprotected_uris "/" +ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -systemctl reload nginx - -#================================================= -# START SYNCTHING SERVICES -#================================================= -ynh_print_info "Starting Syncthing services..." - -ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Access the GUI via the following URL" +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Installation of $app completed" +ynh_print_info --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index e245418..e7aa158 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,15 +12,15 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) +domain=$(ynh_app_setting_get --app=$app --key=domain) -final_path=$(ynh_app_setting_get $app final_path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) -sync_port=$(ynh_app_setting_get $app sync_port) +sync_port=$(ynh_app_setting_get --app=$app --key=sync_port) #================================================= # STANDARD REMOVE @@ -31,14 +31,14 @@ sync_port=$(ynh_app_setting_get $app sync_port) # Remove a service from the admin panel, added by `yunohost service add` if yunohost service status $app >/dev/null 2>&1 then - ynh_print_info "Removing $app service" + ynh_print_info --message="Removing $app service..." yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_print_info "Stopping and removing the systemd service" +ynh_print_info --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config @@ -46,15 +46,15 @@ ynh_remove_systemd_config #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_print_info "Removing app main directory" +ynh_print_info --message="Removing app main directory..." # Remove the app directory securely -ynh_secure_remove "$final_path" +ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_print_info "Removing nginx web server configuration" +ynh_print_info --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -63,7 +63,7 @@ ynh_remove_nginx_config # CLOSE A PORT #================================================= -ynh_print_info "Closing port $sync_port" +ynh_print_info --message="Closing port $sync_port" ynh_exec_warn_less yunohost firewall disallow TCP $sync_port #================================================= @@ -71,13 +71,13 @@ ynh_exec_warn_less yunohost firewall disallow TCP $sync_port #================================================= # REMOVE DEDICATED USER #================================================= -ynh_print_info "Removing the dedicated system user" +ynh_print_info --message="Removing the dedicated system user..." # Delete a system user -ynh_system_user_delete $app +ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Removal of $app completed" +ynh_print_info --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index ad00d56..e801b00 100644 --- a/scripts/restore +++ b/scripts/restore @@ -23,24 +23,24 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading settings..." +ynh_print_info --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) -final_path=$(ynh_app_setting_get $app final_path) -sync_home=$(ynh_app_setting_get $app sync_home) +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) +sync_home=$(ynh_app_setting_get --app=$app --key=sync_home) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_print_info "Validating restoration parameters..." +ynh_print_info --message="Validating restoration parameters..." -ynh_webpath_available $domain $path_url \ - || ynh_die "Path not available: ${domain}${path_url}" +ynh_webpath_available --domain=$domain --path_url=$path_url \ + || ynh_die --message="Path not available: ${domain}${path_url}" test ! -d $final_path \ - || ynh_die "There is already a directory: $final_path " + || ynh_die --message="There is already a directory: $final_path " #================================================= # STANDARD RESTORATION STEPS @@ -48,19 +48,19 @@ test ! -d $final_path \ # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_print_info "Restoring the app main directory..." +ynh_print_info --message="Restoring the app main directory..." -ynh_restore_file "$final_path" +ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_print_info "Recreating the dedicated system user..." +ynh_print_info --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir=$final_path @@ -77,7 +77,7 @@ chown -R "$app": $final_path #================================================= # RECREATE SYNC DIRECTORY #================================================= -ynh_print_info "Recreating sync directory..." +ynh_print_info --message="Recreating sync directory..." # Make directories and set rights mkdir -p "$sync_home" @@ -86,9 +86,9 @@ chown -R "$app": "$sync_home" #================================================= # RESTORE SYSTEMD #================================================= -ynh_print_info "Restoring the systemd configuration..." +ynh_print_info --message="Restoring the systemd configuration..." -ynh_restore_file "/etc/systemd/system/$app.service" +ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service #================================================= @@ -97,24 +97,24 @@ systemctl enable $app.service yunohost service add $app --description "$app daemon for Syncthing" +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access the GUI via the following URL" + #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -systemctl reload nginx - -#================================================= -# START SYNCTHING SERVICES -#================================================= -ynh_print_info "Starting Syncthing services..." - -ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Access the GUI via the following URL" +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Restoration completed for $app" +ynh_print_info --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index 2deca10..315d4d3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,23 +12,29 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_print_info "Loading installation settings..." +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME -domain=$(ynh_app_setting_get $app domain) -path_url=$(ynh_app_setting_get $app path) +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 final_path) +final_path=$(ynh_app_setting_get --app=$app --key=final_path) -sync_home=$(ynh_app_setting_get $app sync_home) -sync_port=$(ynh_app_setting_get $app sync_port) -gui_port=$(ynh_app_setting_get $app gui_port) +sync_home=$(ynh_app_setting_get --app=$app --key=sync_home) +sync_port=$(ynh_app_setting_get --app=$app --key=sync_port) +gui_port=$(ynh_app_setting_get --app=$app --key=gui_port) + +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_print_info "Ensuring downward compatibility..." +ynh_print_info --message="Ensuring downward compatibility..." # If gui_port doesn't exist, create it if [ -z $gui_port ]; then @@ -40,20 +46,20 @@ if [ -z $gui_port ]; then OLD_CONFIG="$OLD_SYNCHOME/.config/syncthing/config.xml" admin=$(ynh_app_setting_get $app allowed_users) - ynh_app_setting_set $app admin $admin + ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_delete --app="$app" --key="allowed_users" final_path=/var/www/$app - ynh_app_setting_set $app final_path $final_path + ynh_app_setting_set --app=$app --key=final_path --value=$final_path gui_port=$OLD_GUIPORT - ynh_app_setting_set $app gui_port $gui_port + ynh_app_setting_set --app=$app --key=gui_port --value=$gui_port sync_home="/home/yunohost.app/$app" - ynh_app_setting_set $app sync_home $sync_home + ynh_app_setting_set --app=$app --key=sync_home --value=$sync_home sync_port=$OLD_SYNCPORT - ynh_app_setting_set $app sync_port $sync_port + ynh_app_setting_set --app=$app --key=sync_port --value=$sync_port mkdir -p $final_path cp -R $OLD_SYNCHOME/.config $final_path/.config @@ -74,43 +80,48 @@ if [ -z $gui_port ]; then else -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_print_info "Backing up the app before upgrading (may take a while)..." + #================================================= + # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP + #================================================= + ynh_print_info --message="Backing up the app before upgrading (may take a while)..." -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - ynh_clean_check_starting - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# STOP SYNCTHING SERVICES -#================================================= -ynh_print_info "Stopping Syncthing services..." - -ynh_systemd_action --action=stop --service_name=$app --log_path=systemd + # Backup the current version of the app + ynh_backup_before_upgrade + ynh_clean_setup () { + ynh_clean_check_starting + # restore it if the upgrade fails + ynh_restore_upgradebackup + } + # Exit if an error occurs during the execution of the script + ynh_abort_if_errors + + #================================================= + # STANDARD UPGRADE STEPS + #================================================= + # STOP SYSTEMD SERVICE + #================================================= + ynh_print_info --message="Stopping Syncthing services..." + + ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd fi -#================================================= -# STANDARD UPGRADE STEPS + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_print_info "Upgrading source files..." -# Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source "$final_path" +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + ynh_print_info --message="Upgrading source files..." + + # Download, check integrity, uncompress and patch the source from app.src + ynh_setup_source --dest_dir="$final_path" +fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_print_info "Upgrading nginx web server configuration..." +ynh_print_info --message="Upgrading nginx web server configuration..." # Create a dedicated nginx config ynh_add_nginx_config "gui_port" @@ -118,7 +129,7 @@ ynh_add_nginx_config "gui_port" #================================================= # CREATE DEDICATED USER #================================================= -ynh_print_info "Making sure dedicated system user exists..." +ynh_print_info --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir=$final_path @@ -128,7 +139,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # CREATE SYNC DIRECTORY #================================================= -ynh_print_info "Creating sync directory..." +ynh_print_info --message="Creating sync directory..." # Make directories and set rights mkdir -p "$sync_home" @@ -140,14 +151,14 @@ chown -R "$app": "$sync_home" config_file="$final_path/.config/syncthing/config.xml" -ynh_backup_if_checksum_is_different "$config_file" +ynh_backup_if_checksum_is_different --file="$config_file" # Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum "$config_file" +ynh_store_file_checksum --file="$config_file" #================================================= # SETUP SYSTEMD #================================================= -ynh_print_info "Upgrading systemd configuration..." +ynh_print_info --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_add_systemd_config @@ -164,26 +175,26 @@ chown -R $app: $final_path #================================================= # SETUP SSOWAT #================================================= -ynh_print_info "Upgrading SSOwat configuration..." +ynh_print_info --message="Upgrading SSOwat configuration..." -ynh_app_setting_set $app unprotected_uris "/" +ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" + +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_print_info --message="Starting a systemd service..." + +ynh_systemd_action --service_name=$app --action="start" --log_path=systemd --line_match="Access the GUI via the following URL" #================================================= # RELOAD NGINX #================================================= -ynh_print_info "Reloading nginx web server..." +ynh_print_info --message="Reloading nginx web server..." -systemctl reload nginx - -#================================================= -# START SYNCTHING SERVICES -#================================================= -ynh_print_info "Starting Syncthing services..." - -ynh_systemd_action --action=start --service_name=$app --log_path=systemd --line_match="Access the GUI via the following URL" +ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT #================================================= -ynh_print_info "Upgrade of $app completed" +ynh_print_info --message="Upgrade of $app completed" From a06c67a6d773043d58aeea7948b4d7bb28175957 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 17 May 2019 11:38:56 +0200 Subject: [PATCH 94/94] Update install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 8e02da2..0a74227 100644 --- a/scripts/install +++ b/scripts/install @@ -66,7 +66,7 @@ ynh_app_setting_set --app=$app --key=gui_port --value=$gui_port sync_port=$(ynh_find_port --port=22000) # Open this port ynh_exec_warn_less yunohost firewall allow TCP $sync_port -ynh_app_setting_set --app=$app s--key=ync_port --value=$sync_port +ynh_app_setting_set --app=$app --key=sync_port --value=$sync_port #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE