From 6a5add3635c6cb13437e3d0b13c460b0d268c385 Mon Sep 17 00:00:00 2001 From: obrenckle <57949757+obrenckle@users.noreply.github.com> Date: Tue, 26 Sep 2023 17:07:11 +0200 Subject: [PATCH 01/24] :heavy_plus_sign: Add missing dependencies (#24) --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index c115d80..ffd8858 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="acl python3 python3-dev python3-pip python3-venv postgresql postgresql-contrib libpq-dev redis-server libldap2-dev libsasl2-dev" +pkg_dependencies="acl libffi-dev libjpeg-dev libwebp-dev python3 python3-dev python3-pip python3-venv postgresql postgresql-contrib libpq-dev redis-server libldap2-dev libsasl2-dev" #================================================= # PERSONAL HELPERS From 49dbd4941dd245c64b64141fc18589bfb6b01841 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 26 Sep 2023 15:07:15 +0000 Subject: [PATCH 02/24] Auto-update README --- README.md | 3 ++- README_fr.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 629b4eb..6b6c996 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,8 @@ It shall NOT be edited by hand. # mygpo (gPodder.net) for YunoHost -[![Integration level](https://dash.yunohost.org/integration/mygpo.svg)](https://dash.yunohost.org/appci/app/mygpo) ![Working status](https://ci-apps.yunohost.org/ci/badges/mygpo.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/mygpo.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/mygpo.svg)](https://dash.yunohost.org/appci/app/mygpo) ![Working status](https://ci-apps.yunohost.org/ci/badges/mygpo.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/mygpo.maintain.svg) + [![Install mygpo (gPodder.net) with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mygpo) *[Lire ce readme en français.](./README_fr.md)* diff --git a/README_fr.md b/README_fr.md index 47e2e47..0840033 100644 --- a/README_fr.md +++ b/README_fr.md @@ -5,7 +5,8 @@ It shall NOT be edited by hand. # mygpo (gPodder.net) pour YunoHost -[![Niveau d’intégration](https://dash.yunohost.org/integration/mygpo.svg)](https://dash.yunohost.org/appci/app/mygpo) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/mygpo.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/mygpo.maintain.svg) +[![Niveau d’intégration](https://dash.yunohost.org/integration/mygpo.svg)](https://dash.yunohost.org/appci/app/mygpo) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/mygpo.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/mygpo.maintain.svg) + [![Installer mygpo (gPodder.net) avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mygpo) *[Read this readme in english.](./README.md)* From 338130611ea7efda3050ab3a89ae95674fe31065 Mon Sep 17 00:00:00 2001 From: orhtej2 <2871798+orhtej2@users.noreply.github.com> Date: Tue, 26 Sep 2023 21:30:35 +0200 Subject: [PATCH 03/24] Bump to 20221222. --- README.md | 2 +- README_fr.md | 2 +- conf/app.src | 4 ++-- manifest.json | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6b6c996..d1b51fb 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in This is the webservice powering the https://gpodder.net website. It can be used to sync podcast subscriptions with [supported clients](https://gpoddernet.readthedocs.io/en/latest/user/clients.html). -**Shipped version:** 2.11.20220622~ynh2 +**Shipped version:** 2.11.20221222~ynh1 **Demo:** https://gpodder.net diff --git a/README_fr.md b/README_fr.md index 0840033..4e7c131 100644 --- a/README_fr.md +++ b/README_fr.md @@ -19,7 +19,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po This is the webservice powering the https://gpodder.net website. It can be used to sync podcast subscriptions with [supported clients](https://gpoddernet.readthedocs.io/en/latest/user/clients.html). -**Version incluse :** 2.11.20220622~ynh2 +**Version incluse :** 2.11.20221222~ynh1 **Démo :** https://gpodder.net diff --git a/conf/app.src b/conf/app.src index bd87588..bcd61a5 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/gpodder/mygpo/archive/60caf1adfb6c0dbeb21828a0d1ae0dfebc279abd.tar.gz -SOURCE_SUM=15076ba34b6a85f61923e78dd84ce93384daca92331f34d20333be4c3d915b08 +SOURCE_URL=https://github.com/gpodder/mygpo/archive/80c41dc0c9a58dc0e85f6ef56662cdfd0d6e3b16.tar.gz +SOURCE_SUM=cce51ef812e5a692ea38b82cb559a4982dcf76ad34d6adf73aff2c5299cb5573 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 72abf38..3c3a136 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Manage podcast subscriptions, and sync them between apps and devices", "fr": "Gérez vos sousciptions balado, et sychronisez-lez entre vos applis et appareils" }, - "version": "2.11.20220622~ynh2", + "version": "2.11.20221222~ynh1", "url": "https://github.com/gpodder/mygpo", "upstream": { "license": "AGPL-3.0-only", From a904ab993147fefe546890e49660a11eb68378c2 Mon Sep 17 00:00:00 2001 From: orhtej2 <2871798+orhtej2@users.noreply.github.com> Date: Wed, 27 Sep 2023 11:03:42 +0200 Subject: [PATCH 04/24] Don't use gunicorn logging. --- sources/patches/app-00-gunicorn.conf.py.patch | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/sources/patches/app-00-gunicorn.conf.py.patch b/sources/patches/app-00-gunicorn.conf.py.patch index 126ee3b..0ef5f62 100644 --- a/sources/patches/app-00-gunicorn.conf.py.patch +++ b/sources/patches/app-00-gunicorn.conf.py.patch @@ -1,25 +1,27 @@ diff --git a/conf/gunicorn.conf.py b/conf/gunicorn.conf.py -index 726cd5f4..c13809cc 100644 +index c5940616..28c84d79 100644 --- a/conf/gunicorn.conf.py +++ b/conf/gunicorn.conf.py -@@ -1,16 +1,16 @@ - import multiprocessing +@@ -1,17 +1,17 @@ + # import multiprocessing import os - + -bind = "unix:/tmp/mygpo.sock" +#bind = "unix:/tmp/mygpo.sock" #workers = multiprocessing.cpu_count() workers = 3 - + # The maximum number of requests a worker will process before restarting. # max_requests = 1000 - --errorlog = "/var/log/gunicorn/error.log" --accesslog = "/var/log/gunicorn/access.log" + +-log_dir = os.getenv("LOGGING_DIR_GUNICRON", "/var/log/gunicorn/") +-errorlog = log_dir + "error.log" +-accesslog = log_dir + "access.log" -loglevel = "info" -+#errorlog = "/var/log/gunicorn/error.log" -+#accesslog = "/var/log/gunicorn/access.log" ++#log_dir = os.getenv("LOGGING_DIR_GUNICRON", "/var/log/gunicorn/") ++#errorlog = log_dir + "error.log" ++#accesslog = log_dir + "access.log" +#loglevel = "info" access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s %(T)s "%(f)s" "%(a)s"' - + timeout = 120 From 92ab6bdf6512201e046c734858e8af6e4c29f541 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 31 Oct 2023 14:24:34 +0000 Subject: [PATCH 05/24] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6b6c996..35916ed 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Edit files under `/opt/yunohost/APPDIR/envs/prod` to set environment variables. * Official app website: * Official admin documentation: * Upstream app code repository: -* YunoHost documentation for this app: +* YunoHost Store: * Report a bug: ## Developer info diff --git a/README_fr.md b/README_fr.md index 0840033..d6efee3 100644 --- a/README_fr.md +++ b/README_fr.md @@ -42,7 +42,7 @@ Edit files under `/opt/yunohost/APPDIR/envs/prod` to set environment variables. * Site officiel de l’app : * Documentation officielle de l’admin : * Dépôt de code officiel de l’app : -* Documentation YunoHost pour cette app : +* YunoHost Store: * Signaler un bug : ## Informations pour les développeurs From 7b2d8ab81db8109326079279fefec61fae1b5ede Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 31 Oct 2023 21:06:10 +0000 Subject: [PATCH 06/24] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d1b51fb..cc53801 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Edit files under `/opt/yunohost/APPDIR/envs/prod` to set environment variables. * Official app website: * Official admin documentation: * Upstream app code repository: -* YunoHost documentation for this app: +* YunoHost Store: * Report a bug: ## Developer info diff --git a/README_fr.md b/README_fr.md index 4e7c131..00278cb 100644 --- a/README_fr.md +++ b/README_fr.md @@ -42,7 +42,7 @@ Edit files under `/opt/yunohost/APPDIR/envs/prod` to set environment variables. * Site officiel de l’app : * Documentation officielle de l’admin : * Dépôt de code officiel de l’app : -* Documentation YunoHost pour cette app : +* YunoHost Store: * Signaler un bug : ## Informations pour les développeurs From 2c1a9daaa6ca211b282702b0fdd6262fc14893de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 4 Mar 2024 12:04:56 +0100 Subject: [PATCH 07/24] Manifestv2 --- check_process | 30 ------ conf/app.src | 7 -- conf/nginx.conf | 8 +- conf/systemd-beat.service | 4 +- conf/systemd-celery.service | 4 +- conf/systemd.service | 4 +- manifest.json | 53 ----------- manifest.toml | 91 ++++++++++++++++++ scripts/_common.sh | 64 +++++-------- scripts/backup | 12 +-- scripts/change_url | 58 ++++++------ scripts/install | 183 +++++++----------------------------- scripts/remove | 89 ++---------------- scripts/restore | 42 ++++----- scripts/upgrade | 34 +++---- tests.toml | 9 ++ 16 files changed, 250 insertions(+), 442 deletions(-) delete mode 100644 check_process delete mode 100644 conf/app.src delete mode 100644 manifest.json create mode 100644 manifest.toml create mode 100644 tests.toml diff --git a/check_process b/check_process deleted file mode 100644 index d898e6a..0000000 --- a/check_process +++ /dev/null @@ -1,30 +0,0 @@ -;; Test complet - ; Manifest - domain="domain.tld" - is_public=1 - admin="john" - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=1 - setup_nourl=0 - setup_private=1 - setup_public=1 - upgrade=1 - # 2.11.1~ynh3 - upgrade=1 from_commit=a50d46ae3a01d8a5b08ca9f9e62bfc9269fdedfa - # 2.11.20210519~ynh1 - upgrade=1 from_commit=59b41b65dc33c3da471175002f37576ff460dc46 - # 2.11.20211020~ynh1 - upgrade=1 from_commit=8284155ea371f4b8a9f0c333d486c5a2342acfae - backup_restore=1 - multi_instance=0 - port_already_use=0 - change_url=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=CommitHash - name=Tweak starting of systemd services (April 1) - manifest_arg=domain=DOMAIN&admin=USER&is_public=1& diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index bcd61a5..0000000 --- a/conf/app.src +++ /dev/null @@ -1,7 +0,0 @@ -SOURCE_URL=https://github.com/gpodder/mygpo/archive/80c41dc0c9a58dc0e85f6ef56662cdfd0d6e3b16.tar.gz -SOURCE_SUM=cce51ef812e5a692ea38b82cb559a4982dcf76ad34d6adf73aff2c5299cb5573 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -SOURCE_EXTRACT=true diff --git a/conf/nginx.conf b/conf/nginx.conf index f284493..dd09e42 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,4 @@ -root __FINALPATH__/static; +root __INSTALL_DIR__/static; location /media { root /home/yunohost.app/__NAME__; @@ -7,7 +7,7 @@ location /media { } location /static/ { - alias __FINALPATH__/static/; + alias __INSTALL_DIR__/static/; } location /logo { @@ -46,11 +46,11 @@ location @proxy_to_app { } location /media/admin { - alias __FINALPATH__/venv/lib/python3.7/site-packages/django/contrib/admin/static/admin; + alias __INSTALL_DIR__/venv/lib/python3.7/site-packages/django/contrib/admin/static/admin; } location /static/admin { - alias __FINALPATH__/venv/lib/python3.7/site-packages/django/contrib/admin/static/admin; + alias __INSTALL_DIR__/venv/lib/python3.7/site-packages/django/contrib/admin/static/admin; } location ~ /(favicon.ico|favicon.png|robots.txt|clientconfig.json) { diff --git a/conf/systemd-beat.service b/conf/systemd-beat.service index 56e7757..b481eb0 100644 --- a/conf/systemd-beat.service +++ b/conf/systemd-beat.service @@ -5,9 +5,9 @@ After=network.target postgresql.service redis.service __APP__.scoket [Service] User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__ +WorkingDirectory=__INSTALL_DIR__ -ExecStart=__FINALPATH__/venv/bin/envdir __FINALPATH__/envs/prod __FINALPATH__/venv/bin/celery -A __APP__ beat --pidfile /tmp/celerybeat.pid -S django +ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/celery -A __APP__ beat --pidfile /tmp/celerybeat.pid -S django ExecReload=/bin/kill -s HUP $MAINPID Restart=on-failure KillMode=mixed diff --git a/conf/systemd-celery.service b/conf/systemd-celery.service index 6235004..d77afe3 100644 --- a/conf/systemd-celery.service +++ b/conf/systemd-celery.service @@ -5,9 +5,9 @@ After=network.target postgresql.service redis.service __APP__.socket [Service] User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__ +WorkingDirectory=__INSTALL_DIR__ -ExecStart=__FINALPATH__/venv/bin/envdir __FINALPATH__/envs/prod __FINALPATH__/venv/bin/celery -A __APP__ worker -l info -Ofair +ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/celery -A __APP__ worker -l info -Ofair ExecReload=/bin/kill -s HUP $MAINPID Restart=on-failure KillMode=mixed diff --git a/conf/systemd.service b/conf/systemd.service index 1ac6082..6e5ad2a 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,9 +7,9 @@ Requires=__APP__.socket Type=notify User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/ +WorkingDirectory=__INSTALL_DIR__/ -ExecStart=__FINALPATH__/venv/bin/envdir __FINALPATH__/envs/prod __FINALPATH__/venv/bin/gunicorn -c __FINALPATH__/conf/gunicorn.conf.py mygpo.wsgi:application --bind unix:/run/__APP__.sock +ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/gunicorn -c __INSTALL_DIR__/conf/gunicorn.conf.py mygpo.wsgi:application --bind unix:/run/__APP__.sock ExecReload=/bin/kill -s HUP $MAINPID Restart=on-failure KillMode=mixed diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 3c3a136..0000000 --- a/manifest.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "name": "mygpo (gPodder.net)", - "id": "mygpo", - "packaging_format": 1, - "description": { - "en": "Manage podcast subscriptions, and sync them between apps and devices", - "fr": "Gérez vos sousciptions balado, et sychronisez-lez entre vos applis et appareils" - }, - "version": "2.11.20221222~ynh1", - "url": "https://github.com/gpodder/mygpo", - "upstream": { - "license": "AGPL-3.0-only", - "website": "https://gpodder.net", - "demo": "https://gpodder.net", - "admindoc": "https://gpoddernet.readthedocs.io/", - "code": "https://github.com/gpodder/mygpo" - }, - "license": "AGPL-3.0-only", - "maintainer": { - "name": "Jules Bertholet", - "email": "jules.bertholet@gmail.com" - }, - "requirements": { - "yunohost": ">= 11.0.9" - }, - "multi_instance": false, - "services": [ - "nginx", - "postgresql", - "redis-server" - ], - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name": "is_public", - "type": "boolean", - "help": { - "en": "If set to public, anybody will be able to create an account and access some statistics about usage of the app. If set to private, some parts of the API will be blocked off", - "fr": "Si public, n'importe-qui pourra créer un compte et accéder a certaines statistiques d'utilization. Si privé, certaines parties de l'API seront inaccessibles" - }, - "default": true - }, - { - "name": "admin", - "type": "user" - } - ] - } -} diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..9a2e661 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,91 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "mygpo" +name = "mygpo (gPodder.net)" +description.en = "Manage podcast subscriptions, and sync them between apps and devices" +description.fr = "Gérez vos sousciptions balado, et sychronisez-lez entre vos applis et appareils" + +version = "2.11.20221222~ynh2" + +maintainers = ["Jules Bertholet"] + +[upstream] +license = "AGPL-3.0-only" +website = "https://gpodder.net" +demo = "https://gpodder.net" +admindoc = "https://gpoddernet.readthedocs.io/" +code = "https://github.com/gpodder/mygpo" + +[integration] +yunohost = ">= 11.2" +architectures = "all" +multi_instance = false +ldap = true +sso = false +disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... +ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... + +[install] + [install.domain] + type = "domain" + + [install.init_main_permission] + help.en = "If set to public, anybody will be able to create an account and access some statistics about usage of the app. If set to private, some parts of the API will be blocked off" + help.fr = "Si public, n'importe-qui pourra créer un compte et accéder a certaines statistiques d'utilization. Si privé, certaines parties de l'API seront inaccessibles" + type = "group" + default = "visitors" + + [install.admin] + type = "user" + +[resources] + [resources.sources.main] + url = "https://github.com/gpodder/mygpo/archive/80c41dc0c9a58dc0e85f6ef56662cdfd0d6e3b16.tar.gz" + sha256 = "cce51ef812e5a692ea38b82cb559a4982dcf76ad34d6adf73aff2c5299cb5573" + + autoupdate.strategy = "latest_github_commit" + + [resources.system_user] + + [resources.install_dir] + + [resources.data_dir] + + [resources.permissions] + main.url = "/" + api.url = "/api" + api.additional_urls = ["/clientconfig.json", "/subscriptions", "/suggestions"] + api.allowed = "visitors" + api.protected = true + + api_noauth.url = "/toplist" + api_noauth.additional_urls = ["/api/2/data", "/api/2/tag", "/api/2/tags", "/search.opml", "/search.json", "/search.jsonp", "/search.txt", "/search.xml", "/toplist.opml"] + api_noauth.allowed = "visitors" + + api_lists.url = "/api/2/lists" + api_lists.allowed = "visitors" + + [resources.apt] + packages = [ + "acl", + "libffi-dev", + "libjpeg-dev", + "libwebp-dev", + "python3", + "python3-dev", + "python3-pip", + "python3-venv", + "libpq-dev", + "redis-server", + "libldap2-dev", + "libsasl2-dev", + + "postgresql", + "postgresql-contrib", + ] + + [resources.database] + type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index ffd8858..dc52748 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,77 +4,61 @@ # COMMON VARIABLES #================================================= -# dependencies used by the app -pkg_dependencies="acl libffi-dev libjpeg-dev libwebp-dev python3 python3-dev python3-pip python3-venv postgresql postgresql-contrib libpq-dev redis-server libldap2-dev libsasl2-dev" - #================================================= # PERSONAL HELPERS #================================================= function set_permissions { - mkdir -p $datadir + mkdir -p $data_dir - env_path=$final_path/envs/prod + env_path=$install_dir/envs/prod mkdir -p $env_path - chown -R $app:$app $datadir - chmod o-rwx $datadir - setfacl -n -R -m u:www-data:rx -m d:u:www-data:rx $datadir + chown -R $app:$app $data_dir + chmod o-rwx $data_dir + setfacl -n -R -m u:www-data:rx -m d:u:www-data:rx $data_dir - chown -R root:$app $final_path - chmod -R g=u,g-w,o-rwx $final_path - setfacl -n -R -m user:www-data:rx -m default:user:www-data:rx $final_path - setfacl -n -R -m user:www-data:- -m default:user:www-data:- $final_path/envs + chown -R root:$app $install_dir + chmod -R g=u,g-w,o-rwx $install_dir + setfacl -n -R -m user:www-data:rx -m default:user:www-data:rx $install_dir + setfacl -n -R -m user:www-data:- -m default:user:www-data:- $install_dir/envs } function set_up_virtualenv { - env_path=$final_path/envs/prod + env_path=$install_dir/envs/prod mkdir -p $env_path - pushd $final_path || ynh_die - chown -R $app:$app $final_path - ynh_exec_warn_less ynh_exec_as $app python3 -m venv $final_path/venv - ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/pip --cache-dir $final_path/.cache/pip install -U wheel pip --cache-dir $final_path/.cache/pip setuptools - ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/pip --cache-dir $final_path/.cache/pip install -U --requirement $final_path/requirements.txt - ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/pip --cache-dir $final_path/.cache/pip install -U --requirement $final_path/requirements-setup.txt - ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/pip --cache-dir $final_path/.cache/pip install -U --requirement $final_path/requirements-ynh.txt + pushd $install_dir || ynh_die + chown -R $app:$app $install_dir + ynh_exec_warn_less ynh_exec_as $app python3 -m venv $install_dir/venv + ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U wheel pip --cache-dir $install_dir/.cache/pip setuptools + ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U --requirement $install_dir/requirements.txt + ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U --requirement $install_dir/requirements-setup.txt + ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U --requirement $install_dir/requirements-ynh.txt set_permissions popd || ynh_dies } function initialize_db { - pushd $final_path || ynh_die - chown -R $app:$app $final_path + pushd $install_dir || ynh_die + chown -R $app:$app $install_dir perform_db_migrations - ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/envdir $env_path $final_path/venv/bin/python $final_path/manage.py createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0 + ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/envdir $env_path $install_dir/venv/bin/python $install_dir/manage.py createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0 set_permissions popd || ynh_die } function upgrade_db { - pushd $final_path || ynh_die - chown -R $app:$app $final_path + pushd $install_dir || ynh_die + chown -R $app:$app $install_dir perform_db_migrations set_permissions popd || ynh_die } function perform_db_migrations { - echo "y" | ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/envdir $env_path $final_path/venv/bin/python $final_path/manage.py makemigrations --merge - ynh_exec_warn_less ynh_exec_as $app $final_path/venv/bin/envdir $env_path $final_path/venv/bin/python $final_path/manage.py migrate -} - -function get_app_settings { - 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) - datadir=$(ynh_app_setting_get --app=$app --key=datadir) - admin=$(ynh_app_setting_get --app=$app --key=admin) - secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) - admin_email=$(ynh_user_get_info --username=$admin --key="mail") - db_name=$(ynh_app_setting_get --app=$app --key=db_name) - db_user="$db_name" - db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) + echo "y" | ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/envdir $env_path $install_dir/venv/bin/python $install_dir/manage.py makemigrations --merge + ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/envdir $env_path $install_dir/venv/bin/python $install_dir/manage.py migrate } #================================================= diff --git a/scripts/backup b/scripts/backup index bfc4d1b..6e967ef 100755 --- a/scripts/backup +++ b/scripts/backup @@ -14,18 +14,18 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { true } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_print_info --message="Loading installation settings..." +#REMOVEME? ynh_print_info --message="Loading installation settings..." -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME get_app_settings @@ -38,13 +38,13 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE DATA DIR #================================================= -ynh_backup --src_path="$datadir" --is_big +ynh_backup --src_path="$data_dir" --is_big #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 5a44357..94ec32a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -13,53 +13,53 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH +#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN +#REMOVEME? old_path=$YNH_APP_OLD_PATH -new_domain=$YNH_APP_NEW_DOMAIN -new_path="/" +#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN +#REMOVEME? new_path="/" -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 get_app_settings #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." +#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - ynh_clean_check_starting +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { + #REMOVEME? ynh_clean_check_starting # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. - ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # CHECK WHICH PARTS SHOULD BE CHANGED #================================================= -change_domain=0 -if [ "$old_domain" != "$new_domain" ] +#REMOVEME? change_domain=0 +#REMOVEME? if [ "$old_domain" != "$new_domain" ] then - change_domain=1 + #REMOVEME? change_domain=1 fi -change_path=0 -if [ "$old_path" != "$new_path" ] +#REMOVEME? change_path=0 +#REMOVEME? if [ "$old_path" != "$new_path" ] then - change_path=1 + #REMOVEME? change_path=1 fi #================================================= @@ -79,24 +79,26 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf +ynh_change_url_nginx_config + +#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf # Change the domain for NGINX if [ $change_domain -eq 1 ] then # Delete file checksum for the old conf file location - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf +#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" +#REMOVEME? 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 --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" +#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" fi #================================================= # SPECIFIC MODIFICATIONS #================================================= -echo $new_domain > $final_path/envs/prod/DEFAULT_BASE_URL -echo "$app@$new_domain" > $final_path/envs/prod/DEFAULT_FROM_EMAIL -echo "$app@$new_domain" > $final_path/envs/prod/SERVER_EMAIL +echo $new_domain > $install_dir/envs/prod/DEFAULT_BASE_URL +echo "$app@$new_domain" > $install_dir/envs/prod/DEFAULT_FROM_EMAIL +echo "$app@$new_domain" > $install_dir/envs/prod/SERVER_EMAIL set_permissions @@ -115,9 +117,9 @@ ynh_systemd_action --service_name=$app-beat --action="start" --log_path="/var/lo #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 6dadb55..81c0dc3 100755 --- a/scripts/install +++ b/scripts/install @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,126 +8,42 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# MANAGE SCRIPT FAILURE +# INITIALIZE AND STORE SETTINGS #================================================= -ynh_clean_setup () { - ynh_clean_check_starting -} -# 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_url="/" -is_public=$YNH_APP_ARG_IS_PUBLIC -admin=$YNH_APP_ARG_ADMIN - -app=$YNH_APP_INSTANCE_NAME - -admin_email=$(ynh_user_get_info --username=$admin --key="mail") +admin_email=$(ynh_user_get_info --username="$admin" --key="mail") secret_key=$(ynh_string_random --length=64) staff_token=$(ynh_string_random --length=64) -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 - -final_path=/opt/yunohost/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url - -#================================================= -# STORE SETTINGS FROM MANIFEST -#================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 - -ynh_app_setting_set --app=$app --key=domain --value=$domain -ynh_app_setting_set --app=$app --key=path --value=$path_url -ynh_app_setting_set --app=$app --key=admin --value=$admin -ynh_app_setting_set --app=$app --key=random_key --value=$secret_key - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=3 - -ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path - -#================================================= -# CREATE A POSTGRESQL DATABASE -#================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." - -db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_psql_test_if_first_run -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name -ynh_psql_execute_as_root --sql="ALTER ROLE $db_user SET statement_timeout = 5000;" --database=$db_name +ynh_app_setting_set --app="$app" --key="random_key" --value="$secret_key" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -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 --dest_dir="$final_path" - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=1 - -# Create a dedicated NGINX config -ynh_add_nginx_config - -#================================================= -# SPECIFIC SETUP -#================================================= -# CREATE DATA DIRECTORY -#================================================= -ynh_script_progression --message="Creating a data directory..." - -datadir=/home/yunohost.app/$app -ynh_app_setting_set --app=$app --key=datadir --value=$datadir +ynh_setup_source --dest_dir="$install_dir" set_permissions #================================================= -# ENVDIR CONFIGURATION +# APP INITIAL CONFIGURATION #================================================= -ynh_script_progression --message="Building configuration..." --weight=1 +ynh_script_progression --message="Adding $app's configuration files..." --weight=1 -echo "$admin <$admin_email>" > $env_path/ADMINS -echo "None" > $env_path/BROKER_POOL_LIMIT -echo "redis://localhost:6379" > $env_path/BROKER_URL -echo "postgres://$db_user:$db_pwd@localhost:5432/$db_name" > $env_path/DATABASE_URL -echo False > $env_path/DEBUG -echo $domain > $env_path/DEFAULT_BASE_URL -echo "$app@$domain" > $env_path/DEFAULT_FROM_EMAIL -echo "django.core.mail.backends.console.EmailBackend" > $env_path/EMAIL_BACKEND -echo "$datadir" > $env_path/MEDIA_ROOT -echo $secret_key > $env_path/SECRET_KEY -echo "$app@$domain" > $env_path/SERVER_EMAIL -echo $staff_token > $env_path/STAFF_TOKEN +echo "$admin <$admin_email>" > "$env_path/ADMINS" +echo "None" > "$env_path/BROKER_POOL_LIMIT" +echo "redis://localhost:6379" > "$env_path/BROKER_URL" +echo "postgres://$db_user:$db_pwd@localhost:5432/$db_name" > "$env_path/DATABASE_URL" +echo "False" > "$env_path/DEBUG" +echo "$domain" > "$env_path/DEFAULT_BASE_URL" +echo "$app@$domain" > "$env_path/DEFAULT_FROM_EMAIL" +echo "django.core.mail.backends.console.EmailBackend" > "$env_path/EMAIL_BACKEND" +echo "$data_dir" > "$env_path/MEDIA_ROOT" +echo "$secret_key" > "$env_path/SECRET_KEY" +echo "$app@$domain" > "$env_path/SERVER_EMAIL" +echo "$staff_token" > "$env_path/STAFF_TOKEN" #================================================= # SET UP VIRTUALENV @@ -143,70 +57,39 @@ set_up_virtualenv #================================================= ynh_script_progression --message="Initializing database..." +ynh_psql_execute_as_root --sql="ALTER ROLE $db_user SET statement_timeout = 5000;" --database="$db_name" + initialize_db #================================================= -# SETUP SYSTEMD +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Configuring systemd services..." --weight=1 +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 + +# Create a dedicated NGINX config +ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config -ynh_add_systemd_config --service="$app-socket" --template systemd.socket +yunohost service add "$app" --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log" ynh_add_systemd_config --service="$app-celery" --template systemd-celery.service ynh_add_systemd_config --service="$app-beat" --template systemd-beat.service +# Some workaround bc ynh_add_system_config doesn't know sockets +ynh_add_systemd_config --service="$app-socket" --template systemd.socket systemctl disable "$app-socket.service" --quiet mv "/etc/systemd/system/$app-socket.service" "/etc/systemd/system/$app.socket" systemctl daemon-reload --quiet -#================================================= -# GENERIC FINALIZATION -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log" - #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting systemd services..." --weight=1 +ynh_script_progression --message="Starting $app's systemd services..." --weight=1 # Start systemd services -ynh_systemd_action --service_name=$app.socket --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-celery --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-beat --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 - -# Everyone can access to the api part -# We don't want to display the tile in the sso so we put --show_tile="false" -# And we don't want that the YunoHost Admin can remove visitors group to this permission, so we put --protected="true" -ynh_permission_create --permission="api" --url="/api" -A "/clientconfig.json" "/subscriptions" "/suggestions" --allowed="visitors" --show_tile="false" --protected="true" -ynh_permission_create --permission="api-noauth" --url="/toplist" -A "/api/2/data" "/api/2/tag" "/api/2/tags" "/search.opml" "/search.json" "/search.jsonp" "/search.txt" "/search.xml" "/toplist.opml" --show_tile="false" -ynh_permission_create --permission="api-lists" --url="/api/2/lists" --show_tile="false" - -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # Everyone can access the app. - # The "main" permission is automatically created before the install script. - ynh_permission_update --permission="main" --add="visitors" - ynh_permission_update --permission="api-noauth" --add="visitors" - ynh_permission_update --permission="api-lists" --add="visitors" -fi - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app.socket" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/scripts/remove b/scripts/remove index fe4f4f6..a194bca 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,87 +8,28 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -get_app_settings - -#================================================= -# STANDARD REMOVE -#================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEM CONFIGURATIONS #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # 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 +if ynh_exec_warn_less yunohost service status "$app" >/dev/null; then + yunohost service remove "$app" fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 - # Remove the dedicated systemd config -systemctl stop $app.socket --quiet -systemctl disable $app.socket --quiet -rm /etc/systemd/system/$app.socket +systemctl stop "$app.socket" --quiet +systemctl disable "$app.socket" --quiet +rm "/etc/systemd/system/$app.socket" systemctl daemon-reload --quiet ynh_remove_systemd_config -ynh_remove_systemd_config -s $app-celery -ynh_remove_systemd_config -s $app-beat - -#================================================= -# REMOVE THE POSTGRESQL DATABASE -#================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1 - -# Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user=$db_user --db_name=$db_name - -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 - -# Remove the app directory securely -ynh_secure_remove --file="$final_path" - -#================================================= -# REMOVE DATA DIR -#================================================= - -# Remove the data directory if --purge option is used -if [ "${YNH_APP_PURGE:-0}" -eq 1 ] -then - ynh_script_progression --message="Removing app data directory..." - ynh_secure_remove --file="$datadir" -fi - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 +ynh_remove_systemd_config -s "$app-celery" +ynh_remove_systemd_config -s "$app-beat" # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies - -#================================================= -# SPECIFIC REMOVE #================================================= # REMOVE VARIOUS FILES #================================================= @@ -99,16 +38,6 @@ ynh_script_progression --message="Removing various files..." # Remove the log files ynh_secure_remove --file="/var/log/$app" -#================================================= -# GENERIC FINALIZATION -#================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# Delete a system user -ynh_system_user_delete --username=$app - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index fb49491..47b0161 100755 --- a/scripts/restore +++ b/scripts/restore @@ -14,68 +14,68 @@ source /usr/share/yunohost/helpers # MANAGE SCRIPT FAILURE #================================================= -ynh_clean_setup () { +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME get_app_settings #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 +#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +#REMOVEME? test ! -d $install_dir \ + || ynh_die --message="There is already a directory: $install_dir " #================================================= # STANDARD RESTORATION STEPS #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 # Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path +#REMOVEME? ynh_system_user_create --username=$app --home_dir=$install_dir #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= ynh_script_progression --message="Restoring the data directory..." -ynh_restore_file --origin_path="$datadir" --not_mandatory +ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $datadir +mkdir -p $data_dir -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:www-data "$datadir" +chmod 750 "$data_dir" +chmod -R o-rwx "$data_dir" +chown -R $app:www-data "$data_dir" #================================================= # SPECIFIC RESTORATION #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1 # Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # RESTORE THE NGINX CONFIGURATION @@ -87,11 +87,11 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 +#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 -ynh_psql_test_if_first_run -db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +#REMOVEME? ynh_psql_test_if_first_run +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 0c48fdc..86d9f09 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -12,9 +12,9 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 +#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME get_app_settings @@ -28,17 +28,17 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 +#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { ynh_clean_check_starting # Restore it if the upgrade fails - ynh_restore_upgradebackup +#REMOVEME? ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script -ynh_abort_if_errors +#REMOVEME? ynh_abort_if_errors #================================================= # STANDARD UPGRADE STEPS @@ -62,9 +62,9 @@ systemctl disable $app-celery --quiet #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 -if [ -z "$datadir" ]; then - datadir=$(ynh_app_setting_get --app=$app --key=data_path) - ynh_app_setting_set --app=$app --key=datadir --value=$datadir +if [ -z "$data_dir" ]; then +#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_path) +#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir ynh_app_setting_delete --app=$app --key=data_path ynh_app_setting_delete --app=$app --key=db_pwd ynh_app_setting_delete --app=$app --key=admin_email @@ -73,10 +73,10 @@ fi #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 +#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path +#REMOVEME? ynh_system_user_create --username=$app --home_dir=$install_dir #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -87,7 +87,7 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$final_path" + ynh_setup_source --dest_dir="$install_dir" fi set_permissions @@ -95,9 +95,9 @@ set_permissions #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=1 +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1 -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # NGINX CONFIGURATION @@ -159,9 +159,9 @@ ynh_systemd_action --service_name=$app-beat --action="start" --log_path="/var/lo #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 -ynh_systemd_action --service_name=nginx --action=reload +#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..734006f --- /dev/null +++ b/tests.toml @@ -0,0 +1,9 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/tests.v1.schema.json + +test_format = 1.0 + +[default] + + test_upgrade_from.a50d46ae3a01d8a5b08ca9f9e62bfc9269fdedfa.name = "2.11.1~ynh3" + test_upgrade_from.59b41b65dc33c3da471175002f37576ff460dc46.name = "2.11.20210519~ynh1" + test_upgrade_from.8284155ea371f4b8a9f0c333d486c5a2342acfae.name = "2.11.20211020~ynh1" From ac5aa3274d0b77028e444b11d4dcb24a713e639a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 4 Mar 2024 12:22:38 +0100 Subject: [PATCH 08/24] fix intsall files --- {sources/extra_files/app => conf}/requirements-ynh.txt | 0 scripts/_common.sh | 1 + sources/extra_files/app/.gitignore | 2 -- ...00-gunicorn.conf.py.patch => main-00-gunicorn.conf.py.patch} | 0 .../{app-01-settings.py.patch => main-01-settings.py.patch} | 0 5 files changed, 1 insertion(+), 2 deletions(-) rename {sources/extra_files/app => conf}/requirements-ynh.txt (100%) delete mode 100644 sources/extra_files/app/.gitignore rename sources/patches/{app-00-gunicorn.conf.py.patch => main-00-gunicorn.conf.py.patch} (100%) rename sources/patches/{app-01-settings.py.patch => main-01-settings.py.patch} (100%) diff --git a/sources/extra_files/app/requirements-ynh.txt b/conf/requirements-ynh.txt similarity index 100% rename from sources/extra_files/app/requirements-ynh.txt rename to conf/requirements-ynh.txt diff --git a/scripts/_common.sh b/scripts/_common.sh index dc52748..b8a4b65 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -27,6 +27,7 @@ function set_permissions { function set_up_virtualenv { env_path=$install_dir/envs/prod mkdir -p $env_path + ynh_add_config --template="requirements-ynh.txt" --destination="$install_dir/requirements-ynh.txt" pushd $install_dir || ynh_die chown -R $app:$app $install_dir diff --git a/sources/extra_files/app/.gitignore b/sources/extra_files/app/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/extra_files/app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] diff --git a/sources/patches/app-00-gunicorn.conf.py.patch b/sources/patches/main-00-gunicorn.conf.py.patch similarity index 100% rename from sources/patches/app-00-gunicorn.conf.py.patch rename to sources/patches/main-00-gunicorn.conf.py.patch diff --git a/sources/patches/app-01-settings.py.patch b/sources/patches/main-01-settings.py.patch similarity index 100% rename from sources/patches/app-01-settings.py.patch rename to sources/patches/main-01-settings.py.patch From d3423ad2750e465e694a91a8945a9bc9790574c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 4 Mar 2024 15:42:05 +0100 Subject: [PATCH 09/24] cleanup paths shitfuck --- scripts/_common.sh | 57 ++++++++------------ scripts/backup | 28 ---------- scripts/change_url | 104 +++++------------------------------- scripts/install | 2 +- scripts/restore | 121 ++++++++++------------------------------- scripts/upgrade | 130 ++++++++++----------------------------------- 6 files changed, 91 insertions(+), 351 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index b8a4b65..89fea56 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,62 +4,47 @@ # COMMON VARIABLES #================================================= +env_path="$install_dir/envs/prod" + #================================================= # PERSONAL HELPERS #================================================= function set_permissions { - mkdir -p $data_dir + chmod 750 "$data_dir" + chown -R "$app:$app" "$data_dir" + setfacl -n -R -m u:www-data:rx -m d:u:www-data:rx "$data_dir" - env_path=$install_dir/envs/prod - mkdir -p $env_path - - chown -R $app:$app $data_dir - chmod o-rwx $data_dir - setfacl -n -R -m u:www-data:rx -m d:u:www-data:rx $data_dir - - chown -R root:$app $install_dir - chmod -R g=u,g-w,o-rwx $install_dir - setfacl -n -R -m user:www-data:rx -m default:user:www-data:rx $install_dir - setfacl -n -R -m user:www-data:- -m default:user:www-data:- $install_dir/envs + chmod 750 "$install_dir" + chown -R "$app:$app" "$install_dir" + setfacl -n -R -m user:www-data:rx -m default:user:www-data:rx "$install_dir" + setfacl -n -R -m user:www-data:- -m default:user:www-data:- "$install_dir/envs" } function set_up_virtualenv { - env_path=$install_dir/envs/prod - mkdir -p $env_path + mkdir -p "$env_path" ynh_add_config --template="requirements-ynh.txt" --destination="$install_dir/requirements-ynh.txt" - pushd $install_dir || ynh_die - chown -R $app:$app $install_dir - ynh_exec_warn_less ynh_exec_as $app python3 -m venv $install_dir/venv - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U wheel pip --cache-dir $install_dir/.cache/pip setuptools - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U --requirement $install_dir/requirements.txt - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U --requirement $install_dir/requirements-setup.txt - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U --requirement $install_dir/requirements-ynh.txt - set_permissions - popd || ynh_dies + ynh_exec_warn_less ynh_exec_as "$app" python3 -m venv "$install_dir/venv" + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U wheel pip --cache-dir "$install_dir/.cache/pip" setuptools + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/source/requirements.txt" + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/source/requirements-setup.txt" + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/requirements-ynh.txt" + set_permissions } function initialize_db { - pushd $install_dir || ynh_die - chown -R $app:$app $install_dir - perform_db_migrations - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/envdir $env_path $install_dir/venv/bin/python $install_dir/manage.py createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0 - set_permissions - popd || ynh_die + perform_db_migrations + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/source/manage.py" createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0 } function upgrade_db { - pushd $install_dir || ynh_die - chown -R $app:$app $install_dir - perform_db_migrations - set_permissions - popd || ynh_die + perform_db_migrations } function perform_db_migrations { - echo "y" | ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/envdir $env_path $install_dir/venv/bin/python $install_dir/manage.py makemigrations --merge - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/envdir $env_path $install_dir/venv/bin/python $install_dir/manage.py migrate + yes | ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/source/manage.py" makemigrations --merge + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/source/manage.py" migrate } #================================================= diff --git a/scripts/backup b/scripts/backup index 6e967ef..37e8cfa 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,25 +8,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_print_info --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -get_app_settings - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -52,18 +31,11 @@ ynh_backup --src_path="$data_dir" --is_big ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP SYSTEMD -#================================================= - ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app-celery.service" ynh_backup --src_path="/etc/systemd/system/$app-beat.service" ynh_backup --src_path="/etc/systemd/system/$app.socket" - #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= diff --git a/scripts/change_url b/scripts/change_url index 94ec32a..8f209e2 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -9,70 +7,15 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN -#REMOVEME? old_path=$YNH_APP_OLD_PATH - -#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN -#REMOVEME? new_path="/" - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -get_app_settings - -#================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - #REMOVEME? ynh_clean_check_starting - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. -#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -#REMOVEME? change_domain=0 -#REMOVEME? if [ "$old_domain" != "$new_domain" ] -then - #REMOVEME? change_domain=1 -fi - -#REMOVEME? change_path=0 -#REMOVEME? if [ "$old_path" != "$new_path" ] -then - #REMOVEME? change_path=1 -fi - -#================================================= -# STANDARD MODIFICATIONS #================================================= # STOP SYSTEMD SERVICES #================================================= -ynh_script_progression --message="Stopping systemd services..." --weight=1 +ynh_script_progression --message="Stopping $app's systemd services..." --weight=1 -ynh_systemd_action --service_name=$app-celery --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-beat --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app.socket --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-celery" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-beat" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app.socket" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF @@ -81,45 +24,26 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- ynh_change_url_nginx_config -#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location -#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" -#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location -#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - #================================================= # SPECIFIC MODIFICATIONS #================================================= -echo $new_domain > $install_dir/envs/prod/DEFAULT_BASE_URL -echo "$app@$new_domain" > $install_dir/envs/prod/DEFAULT_FROM_EMAIL -echo "$app@$new_domain" > $install_dir/envs/prod/SERVER_EMAIL +ynh_script_progression --message="Updating $app's configuration files..." --weight=1 + +echo "$new_domain" > "$env_path/envs/prod/DEFAULT_BASE_URL" +echo "$app@$new_domain" > "$env_path/envs/prod/DEFAULT_FROM_EMAIL" +echo "$app@$new_domain" > "$env_path/envs/prod/SERVER_EMAIL" set_permissions -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICES #================================================= ynh_script_progression --message="Starting systemd services..." --weight=1 -ynh_systemd_action --service_name=$app.socket --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-celery --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-beat --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app.socket" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 81c0dc3..3a6766f 100755 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,7 @@ ynh_app_setting_set --app="$app" --key="random_key" --value="$secret_key" ynh_script_progression --message="Setting up source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" +ynh_setup_source --dest_dir="$install_dir/source" set_permissions diff --git a/scripts/restore b/scripts/restore index 47b0161..45484f9 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,43 +8,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -get_app_settings - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -#REMOVEME? test ! -d $install_dir \ - || ynh_die --message="There is already a directory: $install_dir " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir=$install_dir - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -61,83 +22,55 @@ ynh_script_progression --message="Restoring the data directory..." ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $data_dir - -chmod 750 "$data_dir" chmod -R o-rwx "$data_dir" -chown -R $app:www-data "$data_dir" +chown -R "$app:www-data" "$data_dir" #================================================= -# SPECIFIC RESTORATION +# RESTORE THE DATA DIRECTORY #================================================= -# REINSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1 +ynh_script_progression --message="Restoring the data directory..." --weight=1 -# Define and install dependencies -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies +ynh_restore_file --origin_path="$data_dir" --not_mandatory -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." +chown -R "$app:www-data" "$data_dir" -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - -#================================================= -# RESTORE THE POSTGRESQL DATABASE -#================================================= -#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 - -#REMOVEME? ynh_psql_test_if_first_run -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql - -#================================================= -# RESTORE USER RIGHTS -#================================================= # Restore permissions on app files set_permissions #================================================= -# RESTORE SYSTEMD +# RESTORE THE PSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 + +ynh_psql_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 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-celery.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-beat.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.socket" -systemctl enable $app-celery --quiet -systemctl enable $app-beat --quiet -systemctl enable $app --quiet -systemctl enable $app.socket --quiet +systemctl enable "$app-celery" --quiet +systemctl enable "$app-beat" --quiet +systemctl enable "$app" --quiet +systemctl enable "$app.socket" --quiet +yunohost service add "$app" --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log" #================================================= -# INTEGRATE SERVICE IN YUNOHOST +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 -yunohost service add $app --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log" - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting systemd services..." --weight=1 - -ynh_systemd_action --service_name=$app.socket --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-celery --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-beat --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_systemd_action --service_name="$app.socket" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 86d9f09..8605a4d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -9,103 +7,42 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -get_app_settings - -#================================================= -# CHECK VERSION -#================================================= -ynh_script_progression --message="Checking version..." - -upgrade_type=$(ynh_check_app_version_changed) - -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting - # Restore it if the upgrade fails -#REMOVEME? ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# STANDARD UPGRADE STEPS #================================================= # STOP SYSTEMD SERVICES #================================================= -ynh_script_progression --message="Stopping systemd services..." --weight=1 +ynh_script_progression --message="Stopping $app's systemd services..." --weight=1 -ynh_systemd_action --service_name=$app.socket --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-beat --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-celery --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app.socket" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-beat" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-celery" --action="stop" --log_path="/var/log/$app/$app.log" -systemctl disable $app.socket --quiet -systemctl disable $app --quiet -systemctl disable $app-beat --quiet -systemctl disable $app-celery --quiet +systemctl disable "$app.socket" --quiet +systemctl disable "$app" --quiet +systemctl disable "$app-beat" --quiet +systemctl disable "$app-celery" --quiet #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 -if [ -z "$data_dir" ]; then -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_path) -#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir - ynh_app_setting_delete --app=$app --key=data_path - ynh_app_setting_delete --app=$app --key=db_pwd - ynh_app_setting_delete --app=$app --key=admin_email +if [ -n "${data_path:-}" ]; then + ynh_app_setting_delete --app="$app" --key=data_path + ynh_app_setting_delete --app="$app" --key=db_pwd + ynh_app_setting_delete --app="$app" --key=admin_email fi -#================================================= -# CREATE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir=$install_dir - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Upgrading source files..." --weight=1 -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." --weight=1 - - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir" -fi +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="$install_dir" set_permissions -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1 - -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 - -# Create a dedicated NGINX config -ynh_add_nginx_config #================================================= # SPECIFIC UPGRADE @@ -116,6 +53,7 @@ ynh_script_progression --message="Upgrading Python virtualenv..." --weight=2 set_up_virtualenv + #================================================= # PERFORM DATABASE MIGRATIONS #================================================= @@ -124,9 +62,12 @@ ynh_script_progression --message="Performing database migrations..." --weight=2 upgrade_db #================================================= -# SETUP SYSTEMD +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 + +# Create a dedicated NGINX config +ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config @@ -136,32 +77,17 @@ ynh_add_systemd_config --service="$app-beat" --template systemd-beat.service systemctl disable "$app-socket.service" --quiet mv "/etc/systemd/system/$app-socket.service" "/etc/systemd/system/$app.socket" systemctl daemon-reload --quiet - -#================================================= -# GENERIC FINALIZATION -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log" +yunohost service add "$app" --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting systemd services..." --weight=1 +ynh_script_progression --message="Starting $app's systemd service..." --weight=1 -ynh_systemd_action --service_name=$app.socket --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-celery --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-beat --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app.socket" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT From 4221f8819a9e2e926a2312b779feba1200840c4e Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 4 Mar 2024 14:42:12 +0000 Subject: [PATCH 10/24] Auto-update README --- README.md | 6 +++--- README_fr.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cc53801..bc64c28 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ @@ -19,7 +19,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in This is the webservice powering the https://gpodder.net website. It can be used to sync podcast subscriptions with [supported clients](https://gpoddernet.readthedocs.io/en/latest/user/clients.html). -**Shipped version:** 2.11.20221222~ynh1 +**Shipped version:** 2.11.20221222~ynh2 **Demo:** https://gpodder.net @@ -57,4 +57,4 @@ or sudo yunohost app upgrade mygpo -u https://github.com/YunoHost-Apps/mygpo_ynh/tree/testing --debug ``` -**More info regarding app packaging:** +**More info regarding app packaging:** \ No newline at end of file diff --git a/README_fr.md b/README_fr.md index 00278cb..93a537e 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,5 +1,5 @@ @@ -19,7 +19,7 @@ Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) po This is the webservice powering the https://gpodder.net website. It can be used to sync podcast subscriptions with [supported clients](https://gpoddernet.readthedocs.io/en/latest/user/clients.html). -**Version incluse :** 2.11.20221222~ynh1 +**Version incluse :** 2.11.20221222~ynh2 **Démo :** https://gpodder.net From eef1b7eb8b2fc4b48bc8e4827adff4bd0098853d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 4 Mar 2024 15:43:53 +0100 Subject: [PATCH 11/24] fix upgrade --- scripts/install | 4 ++-- scripts/upgrade | 29 ++++++++++++++++++++++------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/scripts/install b/scripts/install index 3a6766f..d95e1ec 100755 --- a/scripts/install +++ b/scripts/install @@ -25,8 +25,6 @@ ynh_script_progression --message="Setting up source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir/source" -set_permissions - #================================================= # APP INITIAL CONFIGURATION #================================================= @@ -45,6 +43,8 @@ echo "$secret_key" > "$env_path/SECRET_KEY" echo "$app@$domain" > "$env_path/SERVER_EMAIL" echo "$staff_token" > "$env_path/STAFF_TOKEN" +set_permissions + #================================================= # SET UP VIRTUALENV #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8605a4d..16aa05e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -39,13 +39,28 @@ fi ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" +ynh_setup_source --dest_dir="$install_dir/source" --full_replace=1 + +#================================================= +# APP INITIAL CONFIGURATION +#================================================= +ynh_script_progression --message="Adding $app's configuration files..." --weight=1 + +echo "$admin <$admin_email>" > "$env_path/ADMINS" +echo "None" > "$env_path/BROKER_POOL_LIMIT" +echo "redis://localhost:6379" > "$env_path/BROKER_URL" +echo "postgres://$db_user:$db_pwd@localhost:5432/$db_name" > "$env_path/DATABASE_URL" +echo "False" > "$env_path/DEBUG" +echo "$domain" > "$env_path/DEFAULT_BASE_URL" +echo "$app@$domain" > "$env_path/DEFAULT_FROM_EMAIL" +echo "django.core.mail.backends.console.EmailBackend" > "$env_path/EMAIL_BACKEND" +echo "$data_dir" > "$env_path/MEDIA_ROOT" +echo "$secret_key" > "$env_path/SECRET_KEY" +echo "$app@$domain" > "$env_path/SERVER_EMAIL" +echo "$staff_token" > "$env_path/STAFF_TOKEN" set_permissions - -#================================================= -# SPECIFIC UPGRADE #================================================= # UPDATE VIRTUALENV #================================================= @@ -53,7 +68,6 @@ ynh_script_progression --message="Upgrading Python virtualenv..." --weight=2 set_up_virtualenv - #================================================= # PERFORM DATABASE MIGRATIONS #================================================= @@ -71,13 +85,14 @@ ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config -ynh_add_systemd_config --service="$app-socket" --template systemd.socket +yunohost service add "$app" --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log" ynh_add_systemd_config --service="$app-celery" --template systemd-celery.service ynh_add_systemd_config --service="$app-beat" --template systemd-beat.service +# Some workaround bc ynh_add_system_config doesn't know sockets +ynh_add_systemd_config --service="$app-socket" --template systemd.socket systemctl disable "$app-socket.service" --quiet mv "/etc/systemd/system/$app-socket.service" "/etc/systemd/system/$app.socket" systemctl daemon-reload --quiet -yunohost service add "$app" --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE From 68023698feabc47a358aac3d4fca19c12a1a4934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 4 Mar 2024 15:47:43 +0100 Subject: [PATCH 12/24] Fix nginx security issue --- conf/nginx.conf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index dd09e42..168b62c 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -45,12 +45,12 @@ location @proxy_to_app { proxy_set_header Connection "upgrade"; } -location /media/admin { - alias __INSTALL_DIR__/venv/lib/python3.7/site-packages/django/contrib/admin/static/admin; +location /media/admin/ { + alias __INSTALL_DIR__/venv/lib/python3.7/site-packages/django/contrib/admin/static/admin/; } -location /static/admin { - alias __INSTALL_DIR__/venv/lib/python3.7/site-packages/django/contrib/admin/static/admin; +location /static/admin/ { + alias __INSTALL_DIR__/venv/lib/python3.7/site-packages/django/contrib/admin/static/admin/; } location ~ /(favicon.ico|favicon.png|robots.txt|clientconfig.json) { From d909fb2acb4c2ea51cbbfed39bbee9e930c6349c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 4 Mar 2024 15:47:48 +0100 Subject: [PATCH 13/24] update doc --- doc/DISCLAIMER.md | 7 ------- doc/POST_INSTALL.md | 3 +++ doc/PRE_INSTALL.md | 3 +++ 3 files changed, 6 insertions(+), 7 deletions(-) delete mode 100644 doc/DISCLAIMER.md create mode 100644 doc/POST_INSTALL.md create mode 100644 doc/PRE_INSTALL.md diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md deleted file mode 100644 index d8a9a58..0000000 --- a/doc/DISCLAIMER.md +++ /dev/null @@ -1,7 +0,0 @@ -## Limitations - -* The feed-parsing service is not included, https://feeds.gpodder.net is used - -## Configuration - -Edit files under `/opt/yunohost/APPDIR/envs/prod` to set environment variables. There is an admin interface at `yourdomain.tld/admin` that the admin user can log in to. diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..adcca03 --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1,3 @@ +## Configuration + +Edit files under `__INSTALL_DIR__/envs/prod` to set environment variables. There is an admin interface at `yourdomain.tld/admin` that the admin user can log in to. diff --git a/doc/PRE_INSTALL.md b/doc/PRE_INSTALL.md new file mode 100644 index 0000000..8face07 --- /dev/null +++ b/doc/PRE_INSTALL.md @@ -0,0 +1,3 @@ +## Limitations + +* The feed-parsing service is not included, https://feeds.gpodder.net is used From 2174ec96a84fbec7ed00099e0f83157505e8757e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 4 Mar 2024 15:47:56 +0100 Subject: [PATCH 14/24] fix linter --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 16aa05e..29ffae0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -25,7 +25,7 @@ systemctl disable "$app-celery" --quiet #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 +ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 if [ -n "${data_path:-}" ]; then ynh_app_setting_delete --app="$app" --key=data_path From 597aa7b03cc6b43fd5af34baacd02d046ee1f53b Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Mon, 4 Mar 2024 14:48:03 +0000 Subject: [PATCH 15/24] Auto-update README --- README.md | 10 ---------- README_fr.md | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/README.md b/README.md index bc64c28..a218918 100644 --- a/README.md +++ b/README.md @@ -27,16 +27,6 @@ This is the webservice powering the https://gpodder.net website. It can be used ![Screenshot of mygpo (gPodder.net)](./doc/screenshots/screenshot1.png) -## Disclaimers / important information - -## Limitations - -* The feed-parsing service is not included, https://feeds.gpodder.net is used - -## Configuration - -Edit files under `/opt/yunohost/APPDIR/envs/prod` to set environment variables. There is an admin interface at `yourdomain.tld/admin` that the admin user can log in to. - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index 93a537e..9e0fffb 100644 --- a/README_fr.md +++ b/README_fr.md @@ -27,16 +27,6 @@ This is the webservice powering the https://gpodder.net website. It can be used ![Capture d’écran de mygpo (gPodder.net)](./doc/screenshots/screenshot1.png) -## Avertissements / informations importantes - -## Limitations - -* The feed-parsing service is not included, https://feeds.gpodder.net is used - -## Configuration - -Edit files under `/opt/yunohost/APPDIR/envs/prod` to set environment variables. There is an admin interface at `yourdomain.tld/admin` that the admin user can log in to. - ## Documentations et ressources * Site officiel de l’app : From 6bec1a4878f60e32f031d9065ab2914cac088096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 4 Mar 2024 15:49:24 +0100 Subject: [PATCH 16/24] fix env_path not existing --- scripts/_common.sh | 1 - scripts/change_url | 1 + scripts/install | 4 ++++ scripts/upgrade | 3 +++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 89fea56..7b28c6a 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -30,7 +30,6 @@ function set_up_virtualenv { ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/source/requirements.txt" ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/source/requirements-setup.txt" ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/requirements-ynh.txt" - set_permissions } function initialize_db { diff --git a/scripts/change_url b/scripts/change_url index 8f209e2..78c040b 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -29,6 +29,7 @@ ynh_change_url_nginx_config #================================================= ynh_script_progression --message="Updating $app's configuration files..." --weight=1 +mkdir -p "$env_path" echo "$new_domain" > "$env_path/envs/prod/DEFAULT_BASE_URL" echo "$app@$new_domain" > "$env_path/envs/prod/DEFAULT_FROM_EMAIL" echo "$app@$new_domain" > "$env_path/envs/prod/SERVER_EMAIL" diff --git a/scripts/install b/scripts/install index d95e1ec..84ca94a 100755 --- a/scripts/install +++ b/scripts/install @@ -30,6 +30,8 @@ ynh_setup_source --dest_dir="$install_dir/source" #================================================= ynh_script_progression --message="Adding $app's configuration files..." --weight=1 +mkdir -p "$env_path" + echo "$admin <$admin_email>" > "$env_path/ADMINS" echo "None" > "$env_path/BROKER_POOL_LIMIT" echo "redis://localhost:6379" > "$env_path/BROKER_URL" @@ -61,6 +63,8 @@ ynh_psql_execute_as_root --sql="ALTER ROLE $db_user SET statement_timeout = 5000 initialize_db +set_permissions + #================================================= # SYSTEM CONFIGURATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 29ffae0..7d079e9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -46,6 +46,7 @@ ynh_setup_source --dest_dir="$install_dir/source" --full_replace=1 #================================================= ynh_script_progression --message="Adding $app's configuration files..." --weight=1 +mkdir -p "$env_path" echo "$admin <$admin_email>" > "$env_path/ADMINS" echo "None" > "$env_path/BROKER_POOL_LIMIT" echo "redis://localhost:6379" > "$env_path/BROKER_URL" @@ -75,6 +76,8 @@ ynh_script_progression --message="Performing database migrations..." --weight=2 upgrade_db +set_permissions + #================================================= # REAPPLY SYSTEM CONFIGURATIONS #================================================= From 454fd5e4667da70acf16df5d82a8773ef687d4f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 4 Mar 2024 16:10:35 +0100 Subject: [PATCH 17/24] fix systemd services --- conf/systemd-beat.service | 4 ++-- conf/systemd-celery.service | 4 ++-- conf/systemd.service | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/conf/systemd-beat.service b/conf/systemd-beat.service index b481eb0..42fe1f0 100644 --- a/conf/systemd-beat.service +++ b/conf/systemd-beat.service @@ -5,7 +5,7 @@ After=network.target postgresql.service redis.service __APP__.scoket [Service] User=__APP__ Group=__APP__ -WorkingDirectory=__INSTALL_DIR__ +WorkingDirectory=__INSTALL_DIR__/source ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/celery -A __APP__ beat --pidfile /tmp/celerybeat.pid -S django ExecReload=/bin/kill -s HUP $MAINPID @@ -15,4 +15,4 @@ TimeoutStopSec=5 PrivateTmp=true [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target diff --git a/conf/systemd-celery.service b/conf/systemd-celery.service index d77afe3..e050e9d 100644 --- a/conf/systemd-celery.service +++ b/conf/systemd-celery.service @@ -5,7 +5,7 @@ After=network.target postgresql.service redis.service __APP__.socket [Service] User=__APP__ Group=__APP__ -WorkingDirectory=__INSTALL_DIR__ +WorkingDirectory=__INSTALL_DIR__/source ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/celery -A __APP__ worker -l info -Ofair ExecReload=/bin/kill -s HUP $MAINPID @@ -15,4 +15,4 @@ TimeoutStopSec=5 PrivateTmp=true [Install] -WantedBy=multi-user.target \ No newline at end of file +WantedBy=multi-user.target diff --git a/conf/systemd.service b/conf/systemd.service index 6e5ad2a..bc603fc 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,9 +7,9 @@ Requires=__APP__.socket Type=notify User=__APP__ Group=__APP__ -WorkingDirectory=__INSTALL_DIR__/ +WorkingDirectory=__INSTALL_DIR__/source/ -ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/gunicorn -c __INSTALL_DIR__/conf/gunicorn.conf.py mygpo.wsgi:application --bind unix:/run/__APP__.sock +ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/gunicorn -c __INSTALL_DIR__/source/conf/gunicorn.conf.py mygpo.wsgi:application --bind unix:/run/__APP__.sock ExecReload=/bin/kill -s HUP $MAINPID Restart=on-failure KillMode=mixed From 20183e756a1c212e8c33752fd8c2c471457a7c2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 4 Mar 2024 16:37:46 +0100 Subject: [PATCH 18/24] fix upgrade --- scripts/install | 2 +- scripts/upgrade | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 84ca94a..3b3c3b0 100755 --- a/scripts/install +++ b/scripts/install @@ -15,7 +15,7 @@ admin_email=$(ynh_user_get_info --username="$admin" --key="mail") secret_key=$(ynh_string_random --length=64) staff_token=$(ynh_string_random --length=64) -ynh_app_setting_set --app="$app" --key="random_key" --value="$secret_key" +ynh_app_setting_set --app="$app" --key="secret_key" --value="$secret_key" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE diff --git a/scripts/upgrade b/scripts/upgrade index 7d079e9..dd25e53 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,6 +7,12 @@ source _common.sh source /usr/share/yunohost/helpers +#================================================= +# INITIALIZE AND STORE SETTINGS +#================================================= + +admin_email=$(ynh_user_get_info --username="$admin" --key="mail") + #================================================= # STOP SYSTEMD SERVICES #================================================= @@ -33,6 +39,12 @@ if [ -n "${data_path:-}" ]; then ynh_app_setting_delete --app="$app" --key=admin_email fi +if [[ -n "${random_key:-}" ]]; then + secret_key="$random_key" + ynh_app_setting_delete --app="$app" --key=random_key + ynh_app_setting_set --app="$app" --key=secret_key --value="$random_key" +fi + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -58,7 +70,6 @@ echo "django.core.mail.backends.console.EmailBackend" > "$env_path/EMAIL_BACKEND echo "$data_dir" > "$env_path/MEDIA_ROOT" echo "$secret_key" > "$env_path/SECRET_KEY" echo "$app@$domain" > "$env_path/SERVER_EMAIL" -echo "$staff_token" > "$env_path/STAFF_TOKEN" set_permissions From 6890380a3639f26d5963ada9db5ac47ab50553ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 4 Mar 2024 16:38:59 +0100 Subject: [PATCH 19/24] Fix change_url --- scripts/change_url | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 78c040b..c2bd411 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -30,9 +30,9 @@ ynh_change_url_nginx_config ynh_script_progression --message="Updating $app's configuration files..." --weight=1 mkdir -p "$env_path" -echo "$new_domain" > "$env_path/envs/prod/DEFAULT_BASE_URL" -echo "$app@$new_domain" > "$env_path/envs/prod/DEFAULT_FROM_EMAIL" -echo "$app@$new_domain" > "$env_path/envs/prod/SERVER_EMAIL" +echo "$new_domain" > "$env_path/DEFAULT_BASE_URL" +echo "$app@$new_domain" > "$env_path/DEFAULT_FROM_EMAIL" +echo "$app@$new_domain" > "$env_path/SERVER_EMAIL" set_permissions From 24ca1507028c6e69b6bb29d8f71c2f0eefdd2378 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 4 Mar 2024 20:50:00 +0100 Subject: [PATCH 20/24] fix update --- conf/systemd-beat.service | 2 +- conf/systemd-celery.service | 2 +- conf/systemd.service | 4 ++-- scripts/_common.sh | 10 +++++----- scripts/install | 2 +- scripts/upgrade | 7 ++++++- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/conf/systemd-beat.service b/conf/systemd-beat.service index 42fe1f0..5cbbfb7 100644 --- a/conf/systemd-beat.service +++ b/conf/systemd-beat.service @@ -5,7 +5,7 @@ After=network.target postgresql.service redis.service __APP__.scoket [Service] User=__APP__ Group=__APP__ -WorkingDirectory=__INSTALL_DIR__/source +WorkingDirectory=__INSTALL_DIR__/sources/ ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/celery -A __APP__ beat --pidfile /tmp/celerybeat.pid -S django ExecReload=/bin/kill -s HUP $MAINPID diff --git a/conf/systemd-celery.service b/conf/systemd-celery.service index e050e9d..3b3074d 100644 --- a/conf/systemd-celery.service +++ b/conf/systemd-celery.service @@ -5,7 +5,7 @@ After=network.target postgresql.service redis.service __APP__.socket [Service] User=__APP__ Group=__APP__ -WorkingDirectory=__INSTALL_DIR__/source +WorkingDirectory=__INSTALL_DIR__/sources/ ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/celery -A __APP__ worker -l info -Ofair ExecReload=/bin/kill -s HUP $MAINPID diff --git a/conf/systemd.service b/conf/systemd.service index bc603fc..7eb4da5 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -7,9 +7,9 @@ Requires=__APP__.socket Type=notify User=__APP__ Group=__APP__ -WorkingDirectory=__INSTALL_DIR__/source/ +WorkingDirectory=__INSTALL_DIR__/sources/ -ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/gunicorn -c __INSTALL_DIR__/source/conf/gunicorn.conf.py mygpo.wsgi:application --bind unix:/run/__APP__.sock +ExecStart=__INSTALL_DIR__/venv/bin/envdir __INSTALL_DIR__/envs/prod __INSTALL_DIR__/venv/bin/gunicorn -c __INSTALL_DIR__/sources/conf/gunicorn.conf.py mygpo.wsgi:application --bind unix:/run/__APP__.sock ExecReload=/bin/kill -s HUP $MAINPID Restart=on-failure KillMode=mixed diff --git a/scripts/_common.sh b/scripts/_common.sh index 7b28c6a..3b9cc22 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -27,14 +27,14 @@ function set_up_virtualenv { ynh_exec_warn_less ynh_exec_as "$app" python3 -m venv "$install_dir/venv" ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U wheel pip --cache-dir "$install_dir/.cache/pip" setuptools - ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/source/requirements.txt" - ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/source/requirements-setup.txt" + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/sources/requirements.txt" + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/sources/requirements-setup.txt" ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/requirements-ynh.txt" } function initialize_db { perform_db_migrations - ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/source/manage.py" createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0 + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/sources/manage.py" createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0 } function upgrade_db { @@ -42,8 +42,8 @@ function upgrade_db { } function perform_db_migrations { - yes | ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/source/manage.py" makemigrations --merge - ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/source/manage.py" migrate + yes | ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/sources/manage.py" makemigrations --merge + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/sources/manage.py" migrate } #================================================= diff --git a/scripts/install b/scripts/install index 3b3c3b0..f862915 100755 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,7 @@ ynh_app_setting_set --app="$app" --key="secret_key" --value="$secret_key" ynh_script_progression --message="Setting up source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir/source" +ynh_setup_source --dest_dir="$install_dir/sources" #================================================= # APP INITIAL CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index dd25e53..205a5bf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -45,13 +45,18 @@ if [[ -n "${random_key:-}" ]]; then ynh_app_setting_set --app="$app" --key=secret_key --value="$random_key" fi +if [ -f "$install_dir/requirements.txt" ]; then + # Move to $install_dir/sources + find "$install_dir" -maxdepth 1 -mindepth 1 -not -name envs -exec rm -rf {} + +fi + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir/source" --full_replace=1 +ynh_setup_source --dest_dir="$install_dir/sources" --full_replace=1 #================================================= # APP INITIAL CONFIGURATION From 6bbb0a34f56865eaa915ad4bdc1a32955506b6f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 4 Mar 2024 20:50:15 +0100 Subject: [PATCH 21/24] Fix broken test_upgrade_from --- tests.toml | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests.toml b/tests.toml index 734006f..95f32c8 100644 --- a/tests.toml +++ b/tests.toml @@ -4,6 +4,4 @@ test_format = 1.0 [default] - test_upgrade_from.a50d46ae3a01d8a5b08ca9f9e62bfc9269fdedfa.name = "2.11.1~ynh3" - test_upgrade_from.59b41b65dc33c3da471175002f37576ff460dc46.name = "2.11.20210519~ynh1" test_upgrade_from.8284155ea371f4b8a9f0c333d486c5a2342acfae.name = "2.11.20211020~ynh1" From bf1a6d6a4ecc61e5d9fb3c78ed8ec50e7564c053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 5 Mar 2024 11:00:54 +0100 Subject: [PATCH 22/24] Fix upgrade linter --- scripts/upgrade | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 205a5bf..4a88d25 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -46,8 +46,10 @@ if [[ -n "${random_key:-}" ]]; then fi if [ -f "$install_dir/requirements.txt" ]; then + mkdir "$install_dir/sources" # Move to $install_dir/sources - find "$install_dir" -maxdepth 1 -mindepth 1 -not -name envs -exec rm -rf {} + + find "$install_dir" -maxdepth 1 -mindepth 1 -not -name sources -exec mv {} "$install_dir/sources" + + mv "$install_dir/sources/envs" "$install_dir" fi #================================================= From 7d2895989fc810aed782fd547ee50b202fb4d4e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 5 Mar 2024 11:25:58 +0100 Subject: [PATCH 23/24] fix upgrade mv --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 4a88d25..43effd3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -48,7 +48,7 @@ fi if [ -f "$install_dir/requirements.txt" ]; then mkdir "$install_dir/sources" # Move to $install_dir/sources - find "$install_dir" -maxdepth 1 -mindepth 1 -not -name sources -exec mv {} "$install_dir/sources" + + find "$install_dir" -maxdepth 1 -mindepth 1 -not -name sources -exec mv -t "$install_dir/sources" {} + mv "$install_dir/sources/envs" "$install_dir" fi From c042b395f32cd6306c0eb7005e50d647d808a0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Tue, 5 Mar 2024 11:50:59 +0100 Subject: [PATCH 24/24] Remove fixmes from manifest --- manifest.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifest.toml b/manifest.toml index 9a2e661..6865c6b 100644 --- a/manifest.toml +++ b/manifest.toml @@ -24,9 +24,9 @@ architectures = "all" multi_instance = false ldap = true sso = false -disk = "50M" # FIXME: replace with an **estimate** minimum disk requirement. e.g. 20M, 400M, 1G, ... -ram.build = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... -ram.runtime = "50M" # FIXME: replace with an **estimate** minimum ram requirement. e.g. 50M, 400M, 1G, ... +disk = "100M" +ram.build = "150M" +ram.runtime = "100M" [install] [install.domain]