From ce3869c7e208f054c9202ef5241c837ec4e6ce6b Mon Sep 17 00:00:00 2001 From: longbowman Date: Tue, 23 Apr 2024 22:15:34 +0400 Subject: [PATCH] initial commit --- .directory | 6 + ALL_README.md | 8 + LICENSE | 21 ++ README.md | 57 +++++ README_fr.md | 57 +++++ conf/extra_php-fpm.conf | 15 ++ conf/nginx.conf | 102 +++++++++ conf/php.ini | 2 + config_panel.toml.example | 302 +++++++++++++++++++++++++ doc/.gitkeep | 0 doc/ADMIN.md | 1 + doc/DESCRIPTION.md | 14 ++ doc/POST_INSTALL.md | 5 + doc/screenshots/.gitkeep | 0 manifest.toml | 250 +++++++++++++++++++++ scripts/_common.sh | 17 ++ scripts/backup | 82 +++++++ scripts/change_url | 54 +++++ scripts/install | 349 +++++++++++++++++++++++++++++ scripts/remove | 95 ++++++++ scripts/restore | 95 ++++++++ scripts/upgrade | 168 ++++++++++++++ sources/extra_files/app/.gitignore | 2 + sources/patches/.gitignore | 2 + tests.toml | 78 +++++++ 25 files changed, 1782 insertions(+) create mode 100644 .directory create mode 100644 ALL_README.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 README_fr.md create mode 100644 conf/extra_php-fpm.conf create mode 100644 conf/nginx.conf create mode 100644 conf/php.ini create mode 100644 config_panel.toml.example create mode 100644 doc/.gitkeep create mode 100644 doc/ADMIN.md create mode 100644 doc/DESCRIPTION.md create mode 100644 doc/POST_INSTALL.md create mode 100644 doc/screenshots/.gitkeep create mode 100644 manifest.toml create mode 100644 scripts/_common.sh create mode 100755 scripts/backup create mode 100644 scripts/change_url create mode 100755 scripts/install create mode 100755 scripts/remove create mode 100755 scripts/restore create mode 100755 scripts/upgrade create mode 100644 sources/extra_files/app/.gitignore create mode 100644 sources/patches/.gitignore create mode 100644 tests.toml diff --git a/.directory b/.directory new file mode 100644 index 0000000..5ddc427 --- /dev/null +++ b/.directory @@ -0,0 +1,6 @@ +[Dolphin] +Timestamp=2024,3,2,12,32,25.023 +Version=4 + +[Settings] +HiddenFilesShown=true diff --git a/ALL_README.md b/ALL_README.md new file mode 100644 index 0000000..b412b5e --- /dev/null +++ b/ALL_README.md @@ -0,0 +1,8 @@ +# All available README files by language + +[Read the README in English](README.md) + + +* [Lire le README en français](README_fr.md) + + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..38aef3b --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Dale Davies + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ccfa85c --- /dev/null +++ b/README.md @@ -0,0 +1,57 @@ + + +# Jump pour YunoHost + +[![Niveau d'intégration](https://dash.yunohost.org/integration/jump.svg)](https://dash.yunohost.org/appci/app/jump) ![Status du fonctionnement](https://ci-apps.yunohost.org/ci/badges/jump.status.svg) ![Statut demaintenance](https://ci-apps.yunohost.org/ci/badges/jump.maintain.svg) + +[![Installer Jump avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=jump) + +*[Lire le README dans d'autres langues.](./ALL_README.md)* + +> *Ce package vous permet d’installer Jump rapidement et simplement sur un serveur YunoHost. +Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l’installer et en profiter.* + +## Vue d'ensemble + +# Jump +Jump is a self-hosted startpage and real-time status page for your server designed to be simple, stylish, fast and secure. +### Features + +- Fast, easy to deploy, secure. +- Easily add sites and use custom icons, or let Jump fetch their original favicons. +- Categorise sites with tags across multiple pages. +- Real-time status monitoring for each site. +- Use your own background images or get random background images from Unsplash. +- Fast search by name, tag, url with keyboard shortcut. +- Custom list of search engines accessed via search box. +- Open Weather Map integration for local time and weather. +- Several layout options, including responsive UI for mobile devices. +- Easily enable/disable all configuration options, tailor Jump to suit your needs. + +**Version incluse :** 1.0~ynh1 + +**Démo:** +## Documentations et ressources + +- Documentation officielle utilisateur : +- Dépôt de code officiel de l’app : +- YunoHost Store : +- Signaler un bug : + +## Informations pour les développeurs + +Merci de faire vos pull request sur la [branche branch](https://github.com/YunoHost-Apps/jump_ynh/tree/testing), + + +Pour essayer la branche testing, procédez comme suit. + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/jump_ynh/tree/testing --debug +or +sudo yunohost app upgrade jump -u https://github.com/YunoHost-Apps/jump_ynh/tree/testing --debug +``` + +**Plus d'infos sur le packaging d'applications :** diff --git a/README_fr.md b/README_fr.md new file mode 100644 index 0000000..ccfa85c --- /dev/null +++ b/README_fr.md @@ -0,0 +1,57 @@ + + +# Jump pour YunoHost + +[![Niveau d'intégration](https://dash.yunohost.org/integration/jump.svg)](https://dash.yunohost.org/appci/app/jump) ![Status du fonctionnement](https://ci-apps.yunohost.org/ci/badges/jump.status.svg) ![Statut demaintenance](https://ci-apps.yunohost.org/ci/badges/jump.maintain.svg) + +[![Installer Jump avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=jump) + +*[Lire le README dans d'autres langues.](./ALL_README.md)* + +> *Ce package vous permet d’installer Jump rapidement et simplement sur un serveur YunoHost. +Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l’installer et en profiter.* + +## Vue d'ensemble + +# Jump +Jump is a self-hosted startpage and real-time status page for your server designed to be simple, stylish, fast and secure. +### Features + +- Fast, easy to deploy, secure. +- Easily add sites and use custom icons, or let Jump fetch their original favicons. +- Categorise sites with tags across multiple pages. +- Real-time status monitoring for each site. +- Use your own background images or get random background images from Unsplash. +- Fast search by name, tag, url with keyboard shortcut. +- Custom list of search engines accessed via search box. +- Open Weather Map integration for local time and weather. +- Several layout options, including responsive UI for mobile devices. +- Easily enable/disable all configuration options, tailor Jump to suit your needs. + +**Version incluse :** 1.0~ynh1 + +**Démo:** +## Documentations et ressources + +- Documentation officielle utilisateur : +- Dépôt de code officiel de l’app : +- YunoHost Store : +- Signaler un bug : + +## Informations pour les développeurs + +Merci de faire vos pull request sur la [branche branch](https://github.com/YunoHost-Apps/jump_ynh/tree/testing), + + +Pour essayer la branche testing, procédez comme suit. + +```bash +sudo yunohost app install https://github.com/YunoHost-Apps/jump_ynh/tree/testing --debug +or +sudo yunohost app upgrade jump -u https://github.com/YunoHost-Apps/jump_ynh/tree/testing --debug +``` + +**Plus d'infos sur le packaging d'applications :** diff --git a/conf/extra_php-fpm.conf b/conf/extra_php-fpm.conf new file mode 100644 index 0000000..768193f --- /dev/null +++ b/conf/extra_php-fpm.conf @@ -0,0 +1,15 @@ +; Additional php.ini defines, specific to this pool of workers. + +php_admin_value[upload_max_filesize] = 128M +php_admin_value[post_max_size] = 128M +listen.mode = 0660 + +;pm = ondemand +;pm.max_children = 100 +;pm.process_idle_timeout = 10s +;pm.max_requests = 1000 + +clear_env = no +catch_workers_output = yes +decorate_workers_output = no +ping.path = /fpm-ping diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..4d84117 --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,102 @@ +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { + + # Path to source + alias __INSTALL_DIR__/; + + ### Example PHP configuration (remove it if not used) + sendfile off; + absolute_redirect off; + + # Hide nginx server tokens and version number + server_tokens off; + + index index.php; + #listen [::]:8080; + #listen 8080; + # Common parameter to increase upload size limit in conjunction with dedicated php-fpm file + # client_max_body_size 50M; + + try_files $uri $uri/ index.php; + #location ~ [^/]\.php(/|$) { + #fastcgi_split_path_info ^(.+?\.php)(/.*)$; + #fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; + + #fastcgi_index index.php; + #include fastcgi_params; + #fastcgi_param REMOTE_USER $remote_user; + #fastcgi_param PATH_INFO $fastcgi_path_info; + #fastcgi_param SCRIPT_FILENAME $request_filename; + #} \.php$ + + location ~ [^/]\.php(/|$) { + include fastcgi_params; + fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; + fastcgi_index index.php; + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + #fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param SCRIPT_FILENAME $request_filename; + } +### End of PHP configuration part + + + # Tell browsers to cache static assets + location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml|svg)$ { + expires 3d; + } + + # Deny access to dot files + location ~ /\. { + log_not_found off; + deny all; + } + + # Deny yaml, twig, markdown, ini file access. + location ~* /.+\.(markdown|md|twig|yaml|yml|ini)$ { + deny all; + log_not_found off; + } + + # Deny all grunt, package files. + location ~* (Gruntfile|package)\.(js|json|jsonc)$ { + deny all; + log_not_found off; + } + # Deny all composer files. + location ~* composer\. { + deny all; + log_not_found off; + } + + ## Deny vendor directory. + location ^~ __PATH__/vendor/ { + deny all; + log_not_found off; + } + + # Allow fpm ping from localhost, useful for docker HEALTHCHECK. + location ~ ^/(fpm-ping)$ { + access_log off; + allow 127.0.0.1; + deny all; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock; + #unix:/run/php-fpm.sock; + #unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__*.sock; + } + + # Gzip compression options + gzip on; + gzip_proxied any; + gzip_types text/plain application/xml text/css text/js text/xml application/x-javascript text/javascript application/json application/xml+rss; + gzip_vary on; + gzip_disable "msie6"; + + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; +} + diff --git a/conf/php.ini b/conf/php.ini new file mode 100644 index 0000000..ac9c3cc --- /dev/null +++ b/conf/php.ini @@ -0,0 +1,2 @@ +date.timezone="UTC" +expose_php = Off diff --git a/config_panel.toml.example b/config_panel.toml.example new file mode 100644 index 0000000..ed147af --- /dev/null +++ b/config_panel.toml.example @@ -0,0 +1,302 @@ + +## Config panel are available from webadmin > Apps > YOUR_APP > Config Panel Button +## Those panels let user configure some params on their apps using a friendly interface, +## and remove the need to manually edit files from the command line. + +## From a packager perspective, this .toml is coupled to the scripts/config script, +## which may be used to define custom getters/setters. However, most use cases +## should be covered automagically by the core, thus it may not be necessary +## to define a scripts/config at all! + +## ----------------------------------------------------------------------------- +## IMPORTANT: In accordance with YunoHost's spirit, please keep things simple and +## do not overwhelm the admin with tons of misunderstandable or advanced settings. +## ----------------------------------------------------------------------------- + +## The top level describe the entire config panels screen. + +## The version is a required property. +## Here a small reminder to associate config panel version with YunoHost version +## | Config | YNH | Config panel small change log | +## | ------ | --- | ------------------------------------------------------- | +## | 0.1 | 3.x | 0.1 config script not compatible with YNH >= 4.3 | +## | 1.0 | 4.3.x | The new config panel system with 'bind' property | +version = "1.0" + +## (optional) i18n property let you internationalize questions, however this feature +## is only available in core configuration panel (like yunohost domain config). +## So in app config panel this key is ignored for now, but you can internationalize +## by using a lang dictionary (see property name bellow) +# i18n = "prefix_translation_key" + +################################################################################ +#### ABOUT PANELS +################################################################################ + +## The next level describes web admin panels +## You have to choose an ID for each panel, in this example the ID is "main" +## Keep in mind this ID will be used in CLI to refer to your question, so choose +## something short and meaningfull. +## In the webadmin, each panel corresponds to a distinct tab / form +[main] + +## Define the label for your panel +## Internationalization works similarly to the 'description' and 'ask' questions in the manifest +# name.en = "Main configuration" +# name.fr = "Configuration principale" + +## (optional) If you need to trigger a service reload-or-restart after the user +## change a question in this panel, you can add your service in the list. +services = ["__APP__"] +# or services = ["nginx", "__APP__"] to also reload-or-restart nginx + +## (optional) This help properties is a short help displayed on the same line +## than the panel title but not displayed in the tab. +# help = "" + + ############################################################################ + #### ABOUT SECTIONS + ############################################################################ + + ## A panel is composed of one or several sections. + ## + ## Sections are meant to group questions together when they correspond to + ## a same subtopic. This impacts the rendering in terms of CLI prompts + ## and HTML forms + ## + ## You should choose an ID for your section, and prefix it with the panel ID + ## (Be sure to not make a typo in the panel ID, which would implicitly create + ## an other entire panel) + ## + ## We use the context of pepettes_ynh as an example, + ## which is a simple donation form app written in python, + ## and for which the admin will want to edit the configuration + [main.customization] + + ## (optional) Defining a proper title for sections is not mandatory + ## and depends on the exact rendering you're aiming for the CLI / webadmin + name = "" + + ## (optional) This help properties is a short help displayed on the same line + ## than the section title, meant to provide additional details + # help = "" + + ## (optional) As for panel, you can specify to trigger a service + ## reload-or-restart after the user change a question in this section. + ## This property is added to the panel property, it doesn't deactivate it. + ## So no need to replicate, the service list from panel services property. + # services = [] + + ## (optional) By default all questions are optionals, but you can specify a + ## default behaviour for question in the section + optional = false + + ## (optional) It's also possible with the 'visible' property to only + ## display the section depending on the user's answers to previous questions. + ## + ## Be careful that the 'visible' property should only refer to **previous** questions + ## Hence, it should not make sense to have a "visible" property on the very first section. + ## + ## Also, keep in mind that this feature only works in the webadmin and not in CLI + ## (therefore a user could be prompted in CLI for a question that may not be relevant) + # visible = true + + ######################################################################## + #### ABOUT QUESTIONS + ######################################################################## + + ## A section is compound of one or several questions. + + ## --------------------------------------------------------------------- + ## IMPORTANT: as for panel and section you have to choose an ID, but this + ## one should be unique in all this document, even if the question is in + ## an other panel. + ## --------------------------------------------------------------------- + + ## You can use same questions types and properties than in manifest.yml + ## install part. However, in YNH 4.3, a lot of change has been made to + ## extend availables questions types list. + ## See: TODO DOC LINK + + [main.customization.project_name] + + ## (required) The ask property is equivalent to the ask property in + ## the manifest. However, in config panels, questions are displayed on the + ## left side and therefore have less space to be rendered. Therefore, + ## it is better to use a short question, and use the "help" property to + ## provide additional details if necessary. + ask.en = "Name of the project" + + ## (required) The type property indicates how the question should be + ## displayed, validated and managed. Some types have specific properties. + ## + ## Types available: string, boolean, number, range, text, password, path + ## email, url, date, time, color, select, domain, user, tags, file. + ## + ## For a complete list with specific properties, see: TODO DOC LINK + type = "string" + + ######################################################################## + #### ABOUT THE BIND PROPERTY + ######################################################################## + + ## (recommended) 'bind' property is a powerful feature that let you + ## configure how and where the data will be read, validated and written. + + ## By default, 'bind property is in "settings" mode, it means it will + ## **only** read and write the value in application settings file. + ## bind = "settings" + + ## However, settings usually correspond to key/values in actual app configurations + ## Hence, a more useful mode is to have bind = ":FILENAME". In that case, YunoHost + ## will automagically find a line with "KEY=VALUE" in FILENAME + ## (with the adequate separator between KEY and VALUE) + ## + ## YunoHost will then use this value for the read/get operation. + ## During write/set operations, YunoHost will overwrite the value + ## in **both** FILENAME and in the app's settings.yml + + ## Configuration file format supported: yaml, toml, json, ini, env, php, + ## python. The feature probably works with others formats, but should be tested carefully. + + ## Note that this feature only works with relatively simple cases + ## such as `KEY: VALUE`, but won't properly work with + ## complex data structures like multilin array/lists or dictionnaries. + ## It also doesn't work with XML format, custom config function call, php define(), ... + + ## More info on TODO + # bind = ":/var/www/__APP__/settings.py" + + + ## By default, bind = ":FILENAME" will use the question ID as KEY + ## ... but the question ID may sometime not be the exact KEY name in the configuration file. + ## + ## In particular, in pepettes, the python variable is 'name' and not 'project_name' + ## (c.f. https://github.com/YunoHost-Apps/pepettes_ynh/blob/5cc2d3ffd6529cc7356ff93af92dbb6785c3ab9a/conf/settings.py##L11 ) + ## + ## In that case, the key name can be specified before the column ':' + + bind = "name:/var/www/__APP__/settings.py" + + ## --------------------------------------------------------------------- + ## IMPORTANT: other 'bind' mode exists: + ## + ## bind = "FILENAME" (with no column character before FILENAME) + ## may be used to bind to the **entire file content** (instead of a single KEY/VALUE) + ## This could be used to expose an entire configuration file, or binary files such as images + ## For example: + ## bind = "/var/www/__APP__/img/logo.png" + ## + ## bind = "null" can be used to disable reading / writing in settings. + ## This creates sort of a "virtual" or "ephemeral" question which is not related to any actual setting + ## In this mode, you are expected to define custom getter/setters/validators in scripts/config: + ## + ## getter: get__QUESTIONID() + ## setter: set__QUESTIONID() + ## validator: validate__QUESTIONID() + ## + ## You can also specify a common getter / setter / validator, with the + ## function 'bind' mode, for example here it will try to run + ## get__array_settings() first. + # bind = "array_settings()" + ## --------------------------------------------------------------------- + + ## --------------------------------------------------------------------- + ## IMPORTANT: with the exception of bind=null questions, + ## question IDs should almost **always** correspond to an app setting + ## initialized / reused during install/upgrade. + ## Not doing so may result in inconsistencies between the config panel mechanism + ## and the use of ynh_add_config + ## --------------------------------------------------------------------- + + ######################################################################## + #### OTHER GENERIC PROPERTY FOR QUESTIONS + ######################################################################## + + ## (optional) An help text for the question + help = "Fill the name of the project which will received donation" + + ## (optional) An example display as placeholder in web form + # example = "YunoHost" + + ## (optional) set to true in order to redact the value in operation logs + # redact = false + + ## (optional) for boolean questions you can specify replacement values + ## bound to true and false, in case property is bound to config file + # useful if bound property in config file expects something else than integer 1 + yes = "Enable" + # useful if bound property in config file expects something else than integer 0 + no = "Disable" + + ## (optional) A validation pattern + ## --------------------------------------------------------------------- + ## IMPORTANT: your pattern should be between simple quote, not double. + ## --------------------------------------------------------------------- + pattern.regexp = '^\w{3,30}$' + pattern.error = "The name should be at least 3 chars and less than 30 chars. Alphanumeric chars are accepted" + + ## Note: visible and optional properties are also available for questions + + + [main.customization.contact_url] + ask = "Contact url" + type = "url" + example = "mailto: contact@example.org" + help = "mailto: accepted" + pattern.regexp = '^mailto:[^@]+@[^@]+|https://$' + pattern.error = "Should be https or mailto:" + bind = ":/var/www/__APP__/settings.py" + + [main.customization.logo] + ask = "Logo" + type = "file" + accept = ".png" + help = "Fill with an already resized logo" + bind = "__INSTALL_DIR__/img/logo.png" + + [main.customization.favicon] + ask = "Favicon" + type = "file" + accept = ".png" + help = "Fill with an already sized favicon" + bind = "__INSTALL_DIR__/img/favicon.png" + + + [main.stripe] + name = "Stripe general info" + optional = false + + # The next alert is overwrited with a getter from the config script + [main.stripe.amount] + ask = "Donation in the month : XX € + type = "alert" + style = "success" + + [main.stripe.publishable_key] + ask = "Publishable key" + type = "string" + redact = true + help = "Indicate here the stripe publishable key" + bind = ":/var/www/__APP__/settings.py" + + [main.stripe.secret_key] + ask = "Secret key" + type = "string" + redact = true + help = "Indicate here the stripe secret key" + bind = ":/var/www/__APP__/settings.py" + + [main.stripe.prices] + ask = "Prices ID" + type = "tags" + help = """\ + Indicates here the prices ID of donation products you created in stripe interfaces. \ + Go on [Stripe products](https://dashboard.stripe.com/products) to create those donation products. \ + Fill it tag with 'FREQUENCY/CURRENCY/PRICE_ID' \ + FREQUENCY: 'one_time' or 'recuring' \ + CURRENCY: 'EUR' or 'USD' \ + PRICE_ID: ID from stripe interfaces starting with 'price_' \ + """ + pattern.regexp = '^(one_time|recuring)/(EUR|USD)/price_.*$' + pattern.error = "Please respect the format describe in help text for each price ID" diff --git a/doc/.gitkeep b/doc/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/doc/ADMIN.md b/doc/ADMIN.md new file mode 100644 index 0000000..f35b3f6 --- /dev/null +++ b/doc/ADMIN.md @@ -0,0 +1 @@ +The app install dir is `__INSTALL_DIR__` diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md new file mode 100644 index 0000000..e22ea8e --- /dev/null +++ b/doc/DESCRIPTION.md @@ -0,0 +1,14 @@ +# Jump +Jump is a self-hosted startpage and real-time status page for your server designed to be simple, stylish, fast and secure. +### Features + +- Fast, easy to deploy, secure. +- Easily add sites and use custom icons, or let Jump fetch their original favicons. +- Categorise sites with tags across multiple pages. +- Real-time status monitoring for each site. +- Use your own background images or get random background images from Unsplash. +- Fast search by name, tag, url with keyboard shortcut. +- Custom list of search engines accessed via search box. +- Open Weather Map integration for local time and weather. +- Several layout options, including responsive UI for mobile devices. +- Easily enable/disable all configuration options, tailor Jump to suit your needs. diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..1452cfc --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1,5 @@ +The app url is + +The app install dir is `__INSTALL_DIR__` + +The app id is `__ID__` diff --git a/doc/screenshots/.gitkeep b/doc/screenshots/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..1056b76 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,250 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "jump" +name = "Jump" +description.en = "A self-hosted startpage and real-time status page for your server designed to be simple, stylish, fast and secure" + +version = "1.0~ynh1" + +maintainers = [] + +[upstream] +# NB: Only the "license" key is mandatory. Remove entries for which there's no relevant data +license = "MIT" # you can see the available licenses identifiers list here: https://spdx.org/licenses/ +# website = "https://github.com/daledavies/jump/blob/main/README.md" +demo = "https://jumpdemo.daledavies.co.uk/" +# admindoc = "https://yunohost.org/packaging_apps" +userdoc = "https://github.com/daledavies/jump/blob/main/README.md" +code = "https://github.com/daledavies/jump/tree/main" +# cpe = "???" + +# fund = "???" + +[integration] +yunohost = ">= 11.2" +architectures = "all" +multi_instance = true + +ldap = "not_relevant" +sso = "not_relevant" + + +disk = "50M" +ram.build = "150M" +ram.runtime = "50M" + +[install] + [install.domain] + # this is a generic question - ask strings are automatically handled by YunoHost's core + type = "domain" + + [install.path] + # this is a generic question - ask strings are automatically handled by YunoHost's core + type = "path" + default = "/jump" + + [install.init_main_permission] + # this is a generic question - ask strings are automatically handled by YunoHost's core + # This won't be saved as setting and will instead be used to initialize the SSOwat permission + type = "group" + default = "visitors" + + [install.admin] + # this is a generic question - ask strings are automatically handled by YunoHost's core + type = "user" + + [install.password] + # this is a generic question - ask strings are automatically handled by YunoHost's core + # Note that user-provided passwords questions are not automatically saved as setting + help.en = "Use the help field to add an information for the admin about this question." + type = "password" + + [install.site_name] + ask.en = "Site Name" + help.en = "Custom site name." + type = "string" + optional = true + + [install.show_clock] + ask.en = "Show/Hide clock" + help.en = "Show/Hide clock." + type = "boolean" + optional = true + default = false + + [install.am_pm_clock] + ask.en = "Clock Format" + help.en = "Show 12 hour clock format if true." + type = "boolean" + optional = true + default = true + + [install.show_greeting] + ask.en = "Show Greeting" + help.en = "Show/Hide the label \"#home\" instead of a friendly greeting message." + type = "boolean" + optional = true + default = false + + [install.show_search] + ask.en = "Show Search" + help.en = "Show/Hide the search button (disable search)." + type = "boolean" + optional = true + default = false + + [install.alt_layout] + ask.en = "Alternative Layout" + help.en = "Display list of sites using an alternative layout." + type = "boolean" + optional = true + default = true + + [install.custom_width] + ask.en = "Custom Width" + help.en = "Set a custom with for the page container/site list." + type = "number" + optional = true + default = 1000 + + [install.bg_blur] + ask.en = "Background Blur" + help.en = " Background image blur percentage." + type = "number" + optional = true + default = 50 + + [install.bg_bright] + ask.en = "Background Bright" + help.en = "Background image brightness percentage." + type = "number" + optional = true + default = 50 + + [install.unsplash_api_key] + ask.en = "Unsplash API Key" + help.en = "An API key for Unsplash, enables fetching random background images from Unsplash." + type = "string" + optional = true + + [install.unsplash_collections] + ask.en = "Unsplash Collections" + help.en = "List of Unsplash collection ID's (separated by commas) to select random images from." + type = "string" + optional = true + + [install.alt_bg_provider] + ask.en = "Alternative Background provider URL" + help.en = "An alternative background provider url." + type = "url" + optional = true + + [install.owm_api_key] + ask.en = "OpenWeatherMap API Key" + help.en = "An API key for Open Weather Map, LATLONG (below) must also be defined." + type = "string" + optional = true + + [install.lat_long] + ask.en = "Latitude & Longitude" + help.en = "A latitude and longitude for the default location (e.g. \"51.509865,-0.118092\")." + type = "string" + optional = true + + [install.metric_temp] + ask.en = "Temperature Units" + help.en = "Metric (C) (enabled) or imperial (F) (disabled) temperature units." + type = "boolean" + optional = true + default = true + + [install.check_status] + ask.en = "Check Status" + help.en = "Disable checking site availability status." + type = "boolean" + optional = true + default = false + + [install.status_cache] + ask.en = "Status Cache" + help.en = "Duration in minutes to cache site availability status." + type = "string" + optional = true + default = 5 + + [install.cache_bypass] + ask.en = "Cache Bypass" + help.en = "Bypass all caches, useful for testing changes." + type = "boolean" + optional = true + default = true + + [install.www_url] + ask.en = "WWW URL" + help.en = "Useful if Jump is hosted in a sub-directory (e.g. \"/startpage\")." + type = "url" + optional = true + + [install.disable_ip6] + ask.en = "Disable IPV6" + help.en = "Disable IPV6 if required." + type = "boolean" + optional = true + +[resources] + # See the packaging documentation for the full set + # of explanation regarding the behavior and properties for each of those + + [resources.sources] + + [resources.sources.main] + # This will pre-fetch the asset which can then be deployed during the install/upgrade scripts with : + # ynh_setup_source --dest_dir="$install_dir" + # You can also define other assets than "main" and add --source_id="foobar" in the previous command + url = "https://github.com/daledavies/jump/archive/refs/tags/v1.3.2.zip" + sha256 = "d4003fa5f668e27de7b6c39dcff9b73f4ee7179059caac5be441194fa6b3b0c9" + in_subdir = false + autoupdate.strategy = "latest_github_release" + autoupdate.asset = "^v[0-9\\.\\-]*zip$" + + # These infos are used by https://github.com/YunoHost/apps/blob/master/tools/autoupdate_app_sources/autoupdate_app_sources.py + # to auto-update the previous asset urls and sha256sum + manifest version + # assuming the upstream's code repo is on github and relies on tags or releases + # See the 'sources' resource documentation for more details + + # autoupdate.strategy = "latest_github_tag" + + [resources.system_user] + # This will provision/deprovision a unix system user + + [resources.install_dir] + dir = "/var/www/html" + # This will create/remove the install dir as /var/www/$app + # and store the corresponding setting $install_dir + + [resources.data_dir] + # This will create/remove the data dir as /home/yunohost.app/$app + # and store the corresponding setting $data_dir + + [resources.permissions] + # This will configure SSOwat permission for $domain/$path/ + # The initial allowed group of user is configured via the init_main_permission question (public=visitors, private=all_users) + main.url = "/" + main.allowed = "visitors" + + [resources.ports] + # This will pick a random port for reverse-proxying and store it as the $port setting + main.default = 8080 + main.exposed = true + + + [resources.apt] + # This will automatically install/uninstall the following apt packages + # and implicitly define the $phpversion setting as 8.0 (if phpX.Y-foobar dependencies are listed) + packages = "mariadb-server, bash, curl, nginx, composer, php8.1, php8.1-bcmath, php8.1-bz2, php8.1-cgi, php8.1-common, php8.1-curl, php8.1-dba, php8.1-dev, php8.1-fpm, php8.1-ldap, php8.1-mysql, php8.1-mbstring, php8.1-odbc, php8.1-opcache, php8.1-pgsql, php8.1-phpdbg, php8.1-pspell, php8.1-readline, php8.1-snmp, php8.1-soap, php8.1-sqlite3, php8.1-sybase, php8.1-tidy, php8.1-xml, php8.1-xsl, php8.1-zip" + + [resources.database] + # This will automatically provision/deprovison a MySQL DB and store the corresponding credentials in settings $db_user, $db_name, $db_pwd + type = "mysql" diff --git a/scripts/_common.sh b/scripts/_common.sh new file mode 100644 index 0000000..944a65e --- /dev/null +++ b/scripts/_common.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +#================================================= +# COMMON VARIABLES +#================================================= + +#================================================= +# PERSONAL HELPERS +#================================================= + +#================================================= +# EXPERIMENTAL HELPERS +#================================================= + +#================================================= +# FUTURE OFFICIAL HELPERS +#================================================= diff --git a/scripts/backup b/scripts/backup new file mode 100755 index 0000000..6b84488 --- /dev/null +++ b/scripts/backup @@ -0,0 +1,82 @@ +#!/bin/bash + +#================================================= +# 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 + +#================================================= +# DECLARE DATA AND CONF FILES TO BACKUP +#================================================= +ynh_print_info --message="Declaring files to be backed up..." + +### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs +### to be backuped and not an actual copy of any file. The actual backup that +### creates and fills the archive with the files happens in the core after this +### script is called. Hence ynh_backups calls take basically 0 seconds to run. + +#================================================= +# BACKUP THE APP MAIN DIR +#================================================= + +ynh_backup --src_path="$install_dir" + +#================================================= +# BACKUP THE DATA DIR +#================================================= + +### Only relevant if there is a "data_dir" resource for this app +ynh_backup --src_path="$data_dir" --is_big + +#================================================= +# SYSTEM CONFIGURATION +#================================================= + +# Backup the PHP-FPM configuration +ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + +# Backup the nginx configuration +ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +# Backup the systemd service unit +# ynh_backup --src_path="/etc/systemd/system/$app.service" + +# Backup the logrotate configuration +ynh_backup --src_path="/etc/logrotate.d/$app" + +# Backup the Fail2Ban config +# ynh_backup --src_path="/etc/fail2ban/jail.d/$app.conf" +# ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" + +#================================================= +# BACKUP VARIOUS FILES +#================================================= + +# ynh_backup --src_path="/etc/cron.d/$app" + +# ynh_backup --src_path="/etc/$app/" + +ynh_backup --src_path="/var/www/cache/application" + +### For apps with huge logs, you might want to pass --is_big, +### and in restore script, mkdir and pass --not_mandatory to ynh_restore_file. +ynh_backup --src_path="/var/log/$app/" + +#================================================= +# BACKUP THE MYSQL DATABASE +#================================================= +ynh_print_info --message="Backing up the MySQL database..." + +### (However, things like MySQL dumps *do* take some time to run, though the +### copy of the generated dump to the archive still happens later) + +ynh_mysql_dump_db --database="$db_name" > db.sql + +#================================================= +# END OF SCRIPT +#================================================= + +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 new file mode 100644 index 0000000..0f5a552 --- /dev/null +++ b/scripts/change_url @@ -0,0 +1,54 @@ +#!/bin/bash + +## this script is only run if actual change to domain/path is detected, if you're here either $domain or $path changed +## new location is available via $domain and $path (or $new_domain and $new_path variables if you want to be explicit) +## old values are available via, you guessed it, $old_domain and $old_path + +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping $app's systemd service..." --weight=1 + +#ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" + +ynh_systemd_action --service_name="php$phpversion-fpm" --action=stop + +ynh_systemd_action --service_name=nginx --action=stop + +#================================================= +# MODIFY URL IN NGINX CONF +#================================================= +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 + +# this will most likely adjust NGINX config correctly +ynh_change_url_nginx_config + +#================================================= +# SPECIFIC MODIFICATIONS +#================================================= + +## do any changes to files that reference specific installation domain/path, i.e. regenerate configs etc + +#================================================= +# START SYSTEMD SERVICE +#================================================= +# ynh_script_progression --message="Starting $app's systemd service..." --weight=1 +# +# ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" + +ynh_systemd_action --service_name="php$phpversion-fpm" --action=start + +ynh_systemd_action --service_name=nginx --action=start + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install new file mode 100755 index 0000000..785c911 --- /dev/null +++ b/scripts/install @@ -0,0 +1,349 @@ +#!/bin/bash + +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +### Install parameters are automatically saved as settings +### +### Settings are automatically loaded as bash variables +### in every app script context, therefore typically these will exist: +### - $domain +### - $path +### - $language +### ... etc +### +### Resources defined in the manifest are provisioned prior to this script +### and corresponding settings are also available, such as: +### - $install_dir +### - $port +### - $db_name +### ... +### +### $app is the app id (i.e. 'example' for first install, +### or 'example__2', '__3', ... for multi-instance installs) + +#================================================= +# INITIALIZE AND STORE SETTINGS +#================================================= + +# If you need to, you can define custom settings +# (or remove this section entirely if not relevant for you) +ynh_app_setting_set --app=$app --key=SITENAME --value=$site_name +ynh_app_setting_set --app=$app --key=SHOWCLOCK --value=$show_clock +ynh_app_setting_set --app=$app --key=AMPMCLOCK --value=$am_pm_clock +ynh_app_setting_set --app=$app --key=SHOWGREETING --value=$show_greeting +ynh_app_setting_set --app=$app --key=SHOWSEARCH --value=$show_search +ynh_app_setting_set --app=$app --key=ALTLAYOUT --value=$alt_layout +ynh_app_setting_set --app=$app --key=CUSTOMWIDTH --value=$custom_width +ynh_app_setting_set --app=$app --key=BGBLUR --value=$bg_blur +ynh_app_setting_set --app=$app --key=BGBRIGHT --value=$bg_bright +ynh_app_setting_set --app=$app --key=UNSPLASHAPIKEY --value=$unsplash_api_key +ynh_app_setting_set --app=$app --key=UNSPLASHCOLLECTIONS --value=$unsplash_collections +ynh_app_setting_set --app=$app --key=ALTBGPROVIDER --value=$alt_bg_provider +ynh_app_setting_set --app=$app --key=OWMAPIKEY --value=$owm_api_key +ynh_app_setting_set --app=$app --key=LATLONG --value=$lat_long +ynh_app_setting_set --app=$app --key=METRICTEMP --value=$metric_temp +ynh_app_setting_set --app=$app --key=CHECKSTATUS --value=$check_status +ynh_app_setting_set --app=$app --key=STATUSCACHE --value=$status_cache +ynh_app_setting_set --app=$app --key=CACHEBYPASS --value=$cache_bypass +ynh_app_setting_set --app=$app --key=WWWURL --value=$www_url +ynh_app_setting_set --app=$app --key=DISABLEIPV6 --value=$disable_ip6 + + + +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_script_progression --message="Setting up source files..." --weight=1 + +### `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 manifest.toml + +# Download, check integrity, uncompress and patch the source from manifest.toml +ynh_setup_source --dest_dir="$install_dir" + +#================================================= +# APP INITIAL CONFIGURATION +#================================================= +ynh_script_progression --message="Adding $app's configuration files..." --weight=1 + +update-alternatives --set php /usr/bin/php8.1 +export COMPOSER_HOME="/home/user/.config/composer" +echo "export COMPOSER_HOME=\"/home/user/.config/composer\"" >> ~/.bashrc +mkdir -p $COMPOSER_HOME +#rm -f /etc/php/8.1/fpm/pool.d/jump.conf + +### You can add specific configuration files. +### +### Typically, put your template conf file in ../conf/your_config_file +### The template may contain strings such as __FOO__ or __FOO_BAR__, +### which will automatically be replaced by the values of $foo and $foo_bar +### +### ynh_add_config will also keep track of the config file's checksum, +### which later during upgrade may allow to automatically backup the config file +### if it's found that the file was manually modified +### +### Check the documentation of `ynh_add_config` for more info. + +ynh_add_config --template="php.ini" --destination="/etc/php/8.1/cgi/conf.d/30-jump.ini" +chmod 755 "/etc/php/8.1/cgi/conf.d/30-jump.ini" + +# FIXME: this should be handled by the core in the future +### You may need to use chmod 600 instead of 400, +### for example if the app is expected to be able to modify its own config +#chmod 400 "/etc/php81/conf.d/custom.ini" +#chown "$app:$app" "/etc/php81/conf.d/custom.ini" +#mkdir -p /var/www/cache/application \ +# && chown -R jumpapp:jumpapp /var/www/html /var/www/cache/application + +### For more complex cases where you want to replace stuff using regexes, +### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) +### When doing so, you also need to manually call ynh_store_file_checksum +### +### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$install_dir/some_config_file" +### ynh_store_file_checksum --file="$install_dir/some_config_file" + + + +#================================================= +# SYSTEM CONFIGURATION +#================================================= +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 + +### `ynh_add_fpm_config` is used to set up a PHP config. +### You can remove it if your app doesn't use PHP. +### `ynh_add_fpm_config` will use the files conf/extra_php-fpm.conf +### If you're not using these lines: +### - You can remove these files in conf/. +### - Remove the section "BACKUP THE PHP-FPM CONFIGURATION" in the backup script +### - Remove also the section "REMOVE PHP-FPM CONFIGURATION" in the remove script +### - As well as the section "RESTORE THE PHP-FPM CONFIGURATION" in the restore script +### with the reload at the end of the script. +### - And the section "PHP-FPM CONFIGURATION" in the upgrade script + +# Create a PHP-FPM config (with conf/extra_php-fpm.conf being appended to it) +ynh_add_fpm_config + +# Create a dedicated NGINX config using the conf/nginx.conf template +ynh_add_nginx_config + +### `ynh_systemd_config` is used to configure a systemd script for an app. +### It can be used for apps that use sysvinit (with adaptation) or systemd. +### Have a look at the app to be sure this app needs a systemd script. +### `ynh_systemd_config` will use the file conf/systemd.service +### If you're not using these lines: +### - You can remove those files in conf/. +### - Remove the section "BACKUP SYSTEMD" in the backup script +### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script +### - As well as the section "RESTORE SYSTEMD" in the restore script +### - And the section "SETUP SYSTEMD" in the upgrade script + +# Create a dedicated systemd config +# ynh_add_systemd_config + +### `yunohost service add` integrates a service in YunoHost. It then gets +### displayed in the admin interface and through the others `yunohost service` commands. +### (N.B.: this line only makes sense if the app adds a service to the system!) +### If you're not using these lines: +### - You can remove these files in conf/. +### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script +### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script +### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script + +### Additional options starting with 3.8: +### +### --needs_exposed_ports "$port" a list of ports that needs to be publicly exposed +### which will then be checked by YunoHost's diagnosis system +### (N.B. DO NOT USE THIS if the port is only internal!!!) +### +### --test_status "some command" a custom command to check the status of the service +### (only relevant if 'systemctl status' doesn't do a good job) +### +### --test_conf "some command" some command similar to "nginx -t" that validates the conf of the service +### +### Re-calling 'yunohost service add' during the upgrade script is the right way +### to proceed if you later realize that you need to enable some flags that +### weren't enabled on old installs (be careful it'll override the existing +### service though so you should re-provide all relevant flags when doing so) +# yunohost service add "$app" --description="A short description of the app" --log="/var/log/$app/$app.log" + +### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app. +### Use this helper only if there is effectively a log file for this app. +### If you're not using this helper: +### - Remove the section "BACKUP LOGROTATE" in the backup script +### - Remove also the section "REMOVE LOGROTATE CONFIGURATION" in the remove script +### - As well as the section "RESTORE THE LOGROTATE CONFIGURATION" in the restore script +### - And the section "SETUP LOGROTATE" in the upgrade script + +# Use logrotate to manage application logfile(s) +ynh_use_logrotate + +# Create a dedicated Fail2Ban config +# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" + +#================================================= +# SETUP APPLICATION WITH CURL +#================================================= + +### Use these lines only if the app installation needs to be finalized through +### web forms. We generally don't want to ask the final user, +### so we're going to use curl to automatically fill the fields and submit the +### forms. + +# Installation with curl +ynh_script_progression --message="Finalizing installation..." --weight=1 +# ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3" + + +cp $install_dir/jump-*/jumpapp/* $install_dir -r +rm $install_dir/jump-* -rf +# ls $install_dir +# ls -al /run/php +mkdir -p /var/www/cache/application +#mkdir -p /var/www/cache/"$app" +#chown -R "$app:$app" "$install_dir" +#chown "$app:$app" "/etc/php/8.1/fpm/pool.d/$app.conf" +#chown "$app:$app" "/var/log/php8.1-fpm.log" +#chown "$app:$app" "/run/php/php8.1-fpm-$app.sock" +#chown "$app:$app" "/var/run/php/php8.1-fpm-$app.sock" +chown -R www-data "$install_dir" +#chown -R www-data "/var/www/cache/application" +#chown "$app:$app" "/var/log/nginx/error.log" +#chown "$app:$app" "/var/run/php/php8.1-fpm-jump.sock" +#chown "$app:$app" "/etc/yunohost/certs/domain.tld/crt.pem" + +#chown -R "$app:$app" "/etc/nginx" + +#chown -R "$app:$www-data" "$install_dir" +#chown -R "$app:$www-data" "/etc/php" +#chown -R "$app:$www-data" "/var/log/php8.1-fpm.log" +#chown -R "$app:$www-data" "/run/php" +#chown -R "$app:$www-data" "/var/run/" + +#chmod -R 755 "/etc/nginx/conf.d" +#chmod -R 755 "/var/log/nginx/" +#chmod -R 755 "/etc/php" +#chmod -R 755 "/run/php" +#chmod -R 755 "/var/run/" +#chmod -R 755 "/var/www/jump" +#chmod -R 700 "/etc/yunohost/certs/domain.tld/crt.pem" + +#chmod 755 /etc/php/8.1/fpm/pool.d/jump.conf +#chmod 755 /var/log/php8.1-fpm.log +#rm /run/php/php8.1-fpm* +#find $(echo "$PATH" | tr ':' ' ') -type f -executable | grep nginx +#composer update --lock \ +#--working-dir=/app +#composer self-update --1 +#ynh_spawn_app_shell --app=$app <<< ls -al /var/www/jump + +#ynh_install_composer -v 8.1 +#ynh_composer_exec -v 8.1 --working-dir=/var/www/jump --commands=--optimize-autoloader --no-dev --no-interaction +# echo $install_dir +composer install --no-dev \ + --optimize-autoloader \ + --no-interaction \ + --no-progress \ + --quiet \ + --working-dir=$install_dir + +#netstat -tulpn +#ls -al /run/php/ +#ls -al /etc/php/8.1/fpm/ +#ls -al /etc/php/8.1/fpm/pool.d/ +#ls -al /var/run/php +#ls -al /run/php +# ls -al /var/log/nginx/ +# ls -al /etc/nginx/conf.d/ +# ls -al /etc/nginx/conf.d/sub.domain.tld.d/ +# php-fpm8.1 -y /etc/php/8.1/fpm/pool.d/$app.conf --test +#groups $app +#groups +# env +# printenv +#set +# nginx -t +# journalctl -u php8.1-fpm.service -b +# cat /etc/systemd/system/$app.service +#ls -al /etc/systemd/system/ +#ynh_replace_string --match_string="listen.owner = www-data" --replace_string="listen.owner = $app" --target_file="/etc/php/8.1/fpm/pool.d/$app.conf" +#ynh_replace_string --match_string="listen.group = www-data" --replace_string="listen.group = $app" --target_file="/etc/php/8.1/fpm/pool.d/$app.conf" +#sudo systemctl restart php8.1-fpm +#cat /etc/php/8.1/fpm/pool.d/$app.conf +#ls -al /etc/nginx/conf.d/ 2> /dev/null +# [ -f /etc/nginx/conf.d/sub.maindomain2.tld.d/$app.conf ] && cat /etc/nginx/conf.d/sub.maindomain2.tld.d/$app.conf +# [ -f /etc/nginx/conf.d/sub.domain.tld.d/$app.conf ] && cat /etc/nginx/conf.d/sub.domain.tld.d/$app.conf +# [ -f cat /var/log/$app/$app.log ] && cat /var/log/$app/$app.log + + +if [ -e "$install_dir/backgrounds" ]; then + #echo >&2 " - Backgrounds directory is mapped... symlinking." + ynh_script_progression --message="- Backgrounds directory is mapped... symlinking." --weight=1 + rm /$install_dir/assets/backgrounds -r + ln -s /backgrounds $install_dir/assets/ + if [ ! "$(ls -A $install_dir/backgrounds)" ]; then +# echo >&2 " -- Empty so populating with default files." + ynh_script_progression --message=" -- Empty so populating with default files." --weight=1 + cp $install_dir/assets/backgrounds/* $install_dir/backgrounds -r + fi +fi + +if [ -e "$install_dir/favicon" ]; then + echo >&2 " - Favicon directory is mapped... symlinking." + ynh_script_progression --message=" - Favicon directory is mapped... symlinking." --weight=1 + rm /var/www/html/assets/images/favicon -r + ln -s $install_dir/favicon $install_dir/assets/images/ + if [ ! "$(ls -A /favicon)" ]; then + echo >&2 " -- Empty so populating with default favicon image." + ynh_script_progression --message=" -- Empty so populating with default favicon image." --weight=1 + cp $install_dir/assets/images/favicon/* $install_dir/favicon -r + fi +fi + +# if [ -e "/sites" ]; then +# echo >&2 " - Sites directory is mapped... symlinking." +# rm /var/www/html/sites -r +# ln -s /sites /var/www/html/ +# if [ ! "$(ls -A /sites)" ]; then +# echo >&2 " -- Empty so populating with default files." +# cp /usr/src/jumpapp/sites/* /sites -r +# fi +# fi + +# if [ -e "/search" ]; then +# echo >&2 " - Search directory is mapped... symlinking." +# rm /var/www/html/search -r +# ln -s /search /var/www/html/ +# if [ ! "$(ls -A /search)" ]; then +# echo >&2 " -- Empty so populating with default files." +# cp /usr/src/jumpapp/search/* /search -r +# fi +# fi + +#ynh_spawn_app_shell --app=$app <<< ls -l /etc/alternatives/php + +#================================================= +# START SYSTEMD SERVICE +#================================================= +# ynh_script_progression --message="Starting $app's systemd service..." --weight=1 + +### `ynh_systemd_action` is used to start a systemd service for an app. +### Only needed if you have configure a systemd service +### If you're not using these lines: +### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script +### - As well as the section "START SYSTEMD SERVICE" in the restore script +### - As well as the section"STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the upgrade script +### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script + +# Start a systemd service +#ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" + +#================================================= +# END OF SCRIPT +#================================================= +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove new file mode 100755 index 0000000..ce17842 --- /dev/null +++ b/scripts/remove @@ -0,0 +1,95 @@ +#!/bin/bash + +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +### Settings are automatically loaded as bash variables +### in every app script context, therefore typically these will exist: +### - $domain +### - $path +### - $language +### - $install_dir +### - $port +### ... + +### For remove operations : +### - the core will deprovision every resource defined in the manifest **after** this script is ran +### this includes removing the install directory, and data directory (if --purge was used) +# export COMPOSER_HOME="/home/user/.config/composer" + +#================================================= +# REMOVE SYSTEM CONFIGURATIONS +#================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 + +### This should be a symetric version of what happens in the install script + +# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) +if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then + ynh_script_progression --message="Removing $app service integration..." --weight=1 + yunohost service remove "$app" +fi + +# ynh_remove_fail2ban_config + +ynh_remove_logrotate + +ynh_remove_systemd_config + +ynh_remove_nginx_config + +ynh_remove_fpm_config + +# Remove other various files specific to the app... such as : + +# ynh_secure_remove --file="/etc/cron.d/$app" + +# ynh_secure_remove --file="/etc/$app" + +ynh_secure_remove --file="/var/log/$app" + +ynh_secure_remove --file="/etc/php81/conf.d/30-jump.ini" + +ynh_secure_remove --file="/var/www/cache/application" + +# Remove app from composer + +composer remove $app + +# Remove settings + +ynh_app_setting_delete --app=$app --key=SITENAME +ynh_app_setting_delete --app=$app --key=SHOWCLOCK +ynh_app_setting_delete --app=$app --key=AMPMCLOCK +ynh_app_setting_delete --app=$app --key=SHOWGREETING +ynh_app_setting_delete --app=$app --key=SHOWSEARCH +ynh_app_setting_delete --app=$app --key=ALTLAYOUT +ynh_app_setting_delete --app=$app --key=CUSTOMWIDTH +ynh_app_setting_delete --app=$app --key=BGBLUR +ynh_app_setting_delete --app=$app --key=BGBRIGHT +ynh_app_setting_delete --app=$app --key=UNSPLASHAPIKEY +ynh_app_setting_delete --app=$app --key=UNSPLASHCOLLECTIONS +ynh_app_setting_delete --app=$app --key=ALTBGPROVIDER +ynh_app_setting_delete --app=$app --key=OWMAPIKEY +ynh_app_setting_delete --app=$app --key=LATLONG +ynh_app_setting_delete --app=$app --key=METRICTEMP +ynh_app_setting_delete --app=$app --key=CHECKSTATUS +ynh_app_setting_delete --app=$app --key=STATUSCACHE +ynh_app_setting_delete --app=$app --key=CACHEBYPASS +ynh_app_setting_delete --app=$app --key=WWWURL +ynh_app_setting_delete --app=$app --key=DISABLEIPV6 + +ynh_secure_remove --file="$install_dir" +# ynh_secure_remove --file="$COMPOSER_HOME" +ynh_secure_remove --file="/home/user/.config/composer" +ynh_secure_remove --file="/var/www/html/vendor" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore new file mode 100755 index 0000000..0197f72 --- /dev/null +++ b/scripts/restore @@ -0,0 +1,95 @@ +#!/bin/bash + +#================================================= +# 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 + +#================================================= +# RESTORE THE APP MAIN DIR +#================================================= +ynh_script_progression --message="Restoring the app main directory..." --weight=1 + +ynh_restore_file --origin_path="$install_dir" + +### $install_dir will automatically be initialized with some decent +### permissions by default ... however, you may need to recursively reapply +### ownership to all files such as after the ynh_setup_source step +chown -R "$app:www-data" "$install_dir" + +#================================================= +# RESTORE THE DATA DIRECTORY +#================================================= +ynh_script_progression --message="Restoring the data directory..." --weight=1 + +ynh_restore_file --origin_path="$data_dir" --not_mandatory + +### (Same as for install dir) +chown -R "$app:www-data" "$data_dir" + +#================================================= +# RESTORE THE MYSQL DATABASE +#================================================= +ynh_script_progression --message="Restoring the MySQL database..." --weight=1 + +ynh_mysql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql + +#================================================= +# RESTORE SYSTEM CONFIGURATIONS +#================================================= +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +### This should be a symetric version of what happens in the install script + +ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf" + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" + +# ynh_restore_file --origin_path="/etc/systemd/system/$app.service" +# systemctl enable "$app.service" --quiet +# +# yunohost service add "$app" --description="A short description of the app" --log="/var/log/$app/$app.log" + +ynh_restore_file --origin_path="/etc/logrotate.d/$app" + +# ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf" +# ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf" +ynh_systemd_action --action=restart --service_name=fail2ban + +#================================================= +# RESTORE VARIOUS FILES +#================================================= + +# ynh_restore_file --origin_path="/etc/cron.d/$app" +# ynh_restore_file --origin_path="/etc/$app/" + +ynh_restore_file --origin_path="/var/www/cache/application" + +### For apps with huge logs, you might want to not backup logs every time: +### The mkdir call is just here in case the log directory was not backed up. +### mkdir -p "/var/log/$app" +### chown $app:www-data "/var/log/$app" +### ynh_restore_file --src_path="/var/log/$app/" --not_mandatory +### +### For other apps, the simple way is better: +ynh_restore_file --origin_path="/var/log/$app/" + +#================================================= +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE +#================================================= +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 + +### Typically you only have either $app or php-fpm but not both at the same time... +# ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="php$phpversion-fpm" --action=reload + +ynh_systemd_action --service_name=nginx --action=reload + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Restoration completed for $app" --last diff --git a/scripts/upgrade b/scripts/upgrade new file mode 100755 index 0000000..c5183bf --- /dev/null +++ b/scripts/upgrade @@ -0,0 +1,168 @@ +#!/bin/bash + + +#================================================= +# IMPORT GENERIC HELPERS +#================================================= + +source _common.sh +source /usr/share/yunohost/helpers + +### Settings are automatically loaded as bash variables +### in every app script context, therefore typically these will exist: +### - $domain +### - $path +### - $language +### - $install_dir +### - $port +### ... + +### In the context of upgrade, +### - resources are automatically provisioned / updated / deleted (depending on existing resources) +### - a safety backup is automatically created by the core and will be restored if the upgrade fails + +### This variable describes which upgrade type is occurring, allowing the script to handle different modes: +### - UPGRADE_PACKAGE if only the YunoHost package has changed +### - UPGRADE_APP if the upstream app version has changed +### If your package needs to handle other things, like same-version upgrades or downgrades, please +### check out the $YNH_APP_UPGRADE_TYPE variable that can contain DOWNGRADE and UPGRADE_SAME too. +# upgrade_type=$(ynh_check_app_version_changed) + +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +# ynh_script_progression --message="Stopping $app's systemd service..." --weight=1 + +# ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" + +#================================================= +# ENSURE DOWNWARD COMPATIBILITY +#================================================= +#ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 + +### N.B. : the following setting migration snippets are provided as *EXAMPLES* +### of what you may want to do in some cases (e.g. a setting was not defined on +### some legacy installs and you therefore want to initiaze stuff during upgrade) + +# If db_name doesn't exist, create it +# if [ -z "$db_name" ]; then +# db_name=$(ynh_sanitize_dbid --db_name=$app) +# ynh_app_setting_set --app=$app --key=db_name --value=$db_name +# fi + +# If install_dir doesn't exist, create it +# if [ -z "$install_dir" ]; then +# install_dir=/var/www/$app +# ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir +# fi + +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= +ynh_script_progression --message="Upgrading source files..." --weight=1 + +# Download, check integrity, uncompress and patch the source from manifest.toml +ynh_setup_source --dest_dir="$install_dir" + +### $install_dir will automatically be initialized with some decent +### permissions by default ... however, you may need to recursively reapply +### ownership to all files such as after the ynh_setup_source step +chown -R "$app:www-data" "$install_dir" + + +#================================================= +# UPDATE A CONFIG FILE +#================================================= +ynh_script_progression --message="Updating $app's configuration files..." --weight=1 + +### Same as during install +### +### The file will automatically be backed-up if it's found to be manually modified (because +### ynh_add_config keeps track of the file's checksum) + +ynh_add_config --template="php.ini" --destination="/etc/php/8.1/cgi/conf.d/30-jump.ini" +chmod 755 "/etc/php/8.1/cgi/conf.d/30-jump.ini" + +# FIXME: this should be handled by the core in the future +### You may need to use chmod 600 instead of 400, +### for example if the app is expected to be able to modify its own config +# chmod 400 "$install_dir/some_config_file" +# chown "$app:$app" "$install_dir/some_config_file" + +### For more complex cases where you want to replace stuff using regexes, +### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) +### When doing so, you also need to manually call ynh_store_file_checksum +### +### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$install_dir/some_config_file" +### ynh_store_file_checksum --file="$install_dir/some_config_file" + +#================================================= +# REAPPLY SYSTEM CONFIGURATIONS +#================================================= +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 + +### This should be a literal copypaste of what happened in the install's "System configuration" section + +ynh_add_fpm_config + +ynh_add_nginx_config + +# ynh_add_systemd_config + +# yunohost service add "$app" --description="A short description of the app" --log="/var/log/$app/$app.log" + +ynh_use_logrotate --non-append + +# ynh_add_fail2ban_config --logpath="/var/log/nginx/${domain}-error.log" --failregex="Regex to match into the log for a failed login" + +#================================================= +# UPGRADE COMPOSER +#================================================= +ynh_script_progression --message="Upgrade $app" --weight=1 + +update-alternatives --set php /usr/bin/php8.1 +export COMPOSER_HOME="/home/user/.config/composer" +echo "export COMPOSER_HOME=\"/home/user/.config/composer\"" >> ~/.bashrc +mkdir -p $COMPOSER_HOME + +cp $install_dir/jump-*/jumpapp/* $install_dir -r +rm $install_dir/jump-* -rf + +composer install --no-dev \ + --optimize-autoloader \ + --no-interaction \ + --no-progress \ + --quiet \ + --working-dir=$install_dir + + +if [ -e "$install_dir/backgrounds" ]; then + #echo >&2 " - Backgrounds directory is mapped... symlinking." + ynh_script_progression --message="- Backgrounds directory is mapped... symlinking." --weight=1 + rm /$install_dir/assets/backgrounds -r + ln -s /backgrounds $install_dir/assets/ + if [ ! "$(ls -A $install_dir/backgrounds)" ]; then +# echo >&2 " -- Empty so populating with default files." + ynh_script_progression --message=" -- Empty so populating with default files." --weight=1 + cp $install_dir/assets/backgrounds/* $install_dir/backgrounds -r + fi +fi + +if [ -e "$install_dir/favicon" ]; then + echo >&2 " - Favicon directory is mapped... symlinking." + ynh_script_progression --message=" - Favicon directory is mapped... symlinking." --weight=1 + rm /var/www/html/assets/images/favicon -r + ln -s $install_dir/favicon $install_dir/assets/images/ + if [ ! "$(ls -A /favicon)" ]; then + echo >&2 " -- Empty so populating with default favicon image." + ynh_script_progression --message=" -- Empty so populating with default favicon image." --weight=1 + cp $install_dir/assets/images/favicon/* $install_dir/favicon -r + fi +fi +#ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" + +#================================================= +# END OF SCRIPT +#================================================= + +ynh_script_progression --message="Upgrade of $app completed" --last diff --git a/sources/extra_files/app/.gitignore b/sources/extra_files/app/.gitignore new file mode 100644 index 0000000..783a4ae --- /dev/null +++ b/sources/extra_files/app/.gitignore @@ -0,0 +1,2 @@ +*~ +*.sw[op] diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore new file mode 100644 index 0000000..783a4ae --- /dev/null +++ b/sources/patches/.gitignore @@ -0,0 +1,2 @@ +*~ +*.sw[op] diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..1f29471 --- /dev/null +++ b/tests.toml @@ -0,0 +1,78 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + +test_format = 1.0 + +[default] + + # ------------ + # Tests to run + # ------------ + + # ------------------------------------------------------------------------------- + # EVERYTHING PAST THIS POINT IS OPTIONAL AND MOST LIKELY UNNECESSARY FOR NEW APPS + #-------------------------------------------------------------------------------- + ## Conventions in this sample: + ## <- An actual comment + # <- uncommenting this should be a valid entry in 'tests.toml' + + ## NB: the tests to run are automatically deduced by the CI script according to the + ## content of the app's manifest. The declarations below allow to customize which + ## tests are ran, possibly add special test suite to test special args, or + ## declare which commits to test upgrade from. + ## + ## You can also decide (though this is discouraged!) to ban/ignore some tests, + ## The test IDs to be used in only/exclude statements are: + ## * install.root + ## * install.subdir + ## * install.nourl + ## * install.multi + ## * backup_restore + ## * upgrade + ## * upgrade.someCommitId + ## * change_url + ## NB: you should NOT need this except if you really have a good reason... + + exclude = [ "install.root" ] # "install.root" , "install.nourl" , "change_url" , "install.private" , "install.multi" ,"upgrade", "backup_restore" + + ## For special usecases, sometimes you need to setup other things on the machine + ## prior to installing the app (such as installing another app) + ## (Remove this key entirely if not needed) + + # preinstall = """ + # sudo yunohost app install foobar + # sudo yunohost user list + # """ + + # ------------------------------- + # Default args to use for install + # ------------------------------- + + ## By default, the CI will automagically fill the 'standard' args + ## such as domain, path, admin, is_public and password with relevant values + ## and also install args with a "default" provided in the manifest.. + ## It should only make sense to declare custom args here for args with no default values + ## NB: you should NOT need those lines unless for custom questions with no obvious/default value + + # args.language = "fr_FR" + # args.multisite = 0 + + # ------------------------------- + # Commits to test upgrade from + # ------------------------------- + + ## 00a1a6e7 is part of commit SHA, preferrably from 'master' branch + ## that points to valid install of previous version + + # test_upgrade_from.00a1a6e7.name = "Upgrade from 5.4" + # test_upgrade_from.00a1a6e7.args.foo = "bar" + + +## This is an additional test suite +# [some_additional_testsuite] + + ## On additional tests suites, you can decide to run only specific tests + + # only = ["install.subdir"] + + # args.language = "en_GB" + # args.multisite = 1