From 01422087eebbc3b27e8cc9a59b3e22fbdc18187e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Thu, 6 Jun 2024 12:02:24 +0200 Subject: [PATCH] Automated packaging v2 conversion --- conf/app.src | 6 - conf/app_server.service | 6 +- conf/classification_color_processor.service | 6 +- conf/classification_event_processor.service | 6 +- ...ification_face_detection_processor.service | 6 +- .../classification_location_processor.service | 6 +- conf/classification_object_processor.service | 6 +- conf/classification_scheduler.service | 6 +- conf/classification_style_processor.service | 6 +- conf/nginx.conf | 6 +- conf/photonix.env | 2 +- conf/raw_processor.service | 6 +- conf/raw_scheduler.service | 6 +- conf/rescan_photos_periodically.service | 6 +- conf/thumbnail_processor.service | 6 +- conf/watch_photos.service | 6 +- manifest.toml | 108 ++++++++++++++++++ scripts/_common.sh | 102 ++++++++--------- scripts/backup | 10 +- scripts/change_url | 46 ++++---- scripts/install | 96 ++++++++-------- scripts/remove | 20 ++-- scripts/restore | 34 +++--- scripts/upgrade | 32 +++--- 24 files changed, 322 insertions(+), 218 deletions(-) delete mode 100644 conf/app.src create mode 100644 manifest.toml diff --git a/conf/app.src b/conf/app.src deleted file mode 100644 index 78beff9..0000000 --- a/conf/app.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://github.com/photonixapp/photonix/archive/refs/tags/v0.22.0.tar.gz -SOURCE_SUM=1a34e4ee981455e826fe5bf4fbcba7d9fba36b94802f8c927dfbfa5b6c3e3848 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_EXTRACT=true diff --git a/conf/app_server.service b/conf/app_server.service index dd0ef50..cdcadab 100644 --- a/conf/app_server.service +++ b/conf/app_server.service @@ -6,9 +6,9 @@ After=network.target postgresql.service redis-server.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/srv/photonix -EnvironmentFile=__FINALPATH__/photonix.env -ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/venv/bin:$PATH __FINALPATH__/venv/bin/python __FINALPATH__/srv/photonix/manage.py rescan_photos && __FINALPATH__/venv/bin/python __FINALPATH__/srv/photonix/manage.py reset_redis_locks && __FINALPATH__/venv/bin/python __FINALPATH__/srv/photonix/manage.py housekeeping && __FINALPATH__/venv/bin/gunicorn -b 0.0.0.0:$PHOTONIX_PORT web.wsgi" +WorkingDirectory=__INSTALL_DIR__/srv/photonix +EnvironmentFile=__INSTALL_DIR__/photonix.env +ExecStart=/usr/bin/env bash -c "PATH=__INSTALL_DIR__/venv/bin:$PATH __INSTALL_DIR__/venv/bin/python __INSTALL_DIR__/srv/photonix/manage.py rescan_photos && __INSTALL_DIR__/venv/bin/python __INSTALL_DIR__/srv/photonix/manage.py reset_redis_locks && __INSTALL_DIR__/venv/bin/python __INSTALL_DIR__/srv/photonix/manage.py housekeeping && __INSTALL_DIR__/venv/bin/gunicorn -b 0.0.0.0:$PHOTONIX_PORT web.wsgi" StandardOutput=append:/var/log/__APP__/__APP__-app_server.log StandardError=inherit diff --git a/conf/classification_color_processor.service b/conf/classification_color_processor.service index 6e58f1a..3368ebb 100644 --- a/conf/classification_color_processor.service +++ b/conf/classification_color_processor.service @@ -6,9 +6,9 @@ After=network.target __APP__-app_server.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/srv/photonix -EnvironmentFile=__FINALPATH__/photonix.env -ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/venv/bin:$PATH sleep 9 && nice -n 19 __FINALPATH__/venv/bin/python __FINALPATH__/srv/photonix/manage.py classification_color_processor" +WorkingDirectory=__INSTALL_DIR__/srv/photonix +EnvironmentFile=__INSTALL_DIR__/photonix.env +ExecStart=/usr/bin/env bash -c "PATH=__INSTALL_DIR__/venv/bin:$PATH sleep 9 && nice -n 19 __INSTALL_DIR__/venv/bin/python __INSTALL_DIR__/srv/photonix/manage.py classification_color_processor" StandardOutput=append:/var/log/__APP__/__APP__-classification_color_processor.log StandardError=inherit diff --git a/conf/classification_event_processor.service b/conf/classification_event_processor.service index 522df81..d5ef1cd 100644 --- a/conf/classification_event_processor.service +++ b/conf/classification_event_processor.service @@ -6,9 +6,9 @@ After=network.target __APP__-app_server.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/srv/photonix -EnvironmentFile=__FINALPATH__/photonix.env -ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/venv/bin:$PATH sleep 14 && nice -n 19 __FINALPATH__/venv/bin/python __FINALPATH__/srv/photonix/manage.py classification_event_processor" +WorkingDirectory=__INSTALL_DIR__/srv/photonix +EnvironmentFile=__INSTALL_DIR__/photonix.env +ExecStart=/usr/bin/env bash -c "PATH=__INSTALL_DIR__/venv/bin:$PATH sleep 14 && nice -n 19 __INSTALL_DIR__/venv/bin/python __INSTALL_DIR__/srv/photonix/manage.py classification_event_processor" StandardOutput=append:/var/log/__APP__/__APP__-classification_event_processor.log StandardError=inherit diff --git a/conf/classification_face_detection_processor.service b/conf/classification_face_detection_processor.service index cd71bb7..8236b6c 100644 --- a/conf/classification_face_detection_processor.service +++ b/conf/classification_face_detection_processor.service @@ -6,9 +6,9 @@ After=network.target __APP__-app_server.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/srv/photonix -EnvironmentFile=__FINALPATH__/photonix.env -ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/venv/bin:$PATH sleep 11 && nice -n 19 __FINALPATH__/venv/bin/python __FINALPATH__/srv/photonix/manage.py classification_face_processor" +WorkingDirectory=__INSTALL_DIR__/srv/photonix +EnvironmentFile=__INSTALL_DIR__/photonix.env +ExecStart=/usr/bin/env bash -c "PATH=__INSTALL_DIR__/venv/bin:$PATH sleep 11 && nice -n 19 __INSTALL_DIR__/venv/bin/python __INSTALL_DIR__/srv/photonix/manage.py classification_face_processor" StandardOutput=append:/var/log/__APP__/__APP__-classification_face_processor.log StandardError=inherit diff --git a/conf/classification_location_processor.service b/conf/classification_location_processor.service index a70f1f7..a1ff704 100644 --- a/conf/classification_location_processor.service +++ b/conf/classification_location_processor.service @@ -6,9 +6,9 @@ After=network.target __APP__-app_server.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/srv/photonix -EnvironmentFile=__FINALPATH__/photonix.env -ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/venv/bin:$PATH sleep 10 && nice -n 19 __FINALPATH__/venv/bin/python __FINALPATH__/srv/photonix/manage.py classification_location_processor" +WorkingDirectory=__INSTALL_DIR__/srv/photonix +EnvironmentFile=__INSTALL_DIR__/photonix.env +ExecStart=/usr/bin/env bash -c "PATH=__INSTALL_DIR__/venv/bin:$PATH sleep 10 && nice -n 19 __INSTALL_DIR__/venv/bin/python __INSTALL_DIR__/srv/photonix/manage.py classification_location_processor" StandardOutput=append:/var/log/__APP__/__APP__-classification_location_processor.log StandardError=inherit diff --git a/conf/classification_object_processor.service b/conf/classification_object_processor.service index ac9385d..e57a2cc 100644 --- a/conf/classification_object_processor.service +++ b/conf/classification_object_processor.service @@ -6,9 +6,9 @@ After=network.target __APP__-app_server.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/srv/photonix -EnvironmentFile=__FINALPATH__/photonix.env -ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/venv/bin:$PATH sleep 12 && nice -n 19 __FINALPATH__/venv/bin/python __FINALPATH__/srv/photonix/manage.py classification_object_processor" +WorkingDirectory=__INSTALL_DIR__/srv/photonix +EnvironmentFile=__INSTALL_DIR__/photonix.env +ExecStart=/usr/bin/env bash -c "PATH=__INSTALL_DIR__/venv/bin:$PATH sleep 12 && nice -n 19 __INSTALL_DIR__/venv/bin/python __INSTALL_DIR__/srv/photonix/manage.py classification_object_processor" StandardOutput=append:/var/log/__APP__/__APP__-classification_object_processor.log StandardError=inherit diff --git a/conf/classification_scheduler.service b/conf/classification_scheduler.service index ae44d34..63e149b 100644 --- a/conf/classification_scheduler.service +++ b/conf/classification_scheduler.service @@ -6,9 +6,9 @@ After=network.target __APP__-app_server.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/srv/photonix -EnvironmentFile=__FINALPATH__/photonix.env -ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/venv/bin:$PATH sleep 8 && nice -n 18 __FINALPATH__/venv/bin/python __FINALPATH__/srv/photonix/manage.py classification_scheduler" +WorkingDirectory=__INSTALL_DIR__/srv/photonix +EnvironmentFile=__INSTALL_DIR__/photonix.env +ExecStart=/usr/bin/env bash -c "PATH=__INSTALL_DIR__/venv/bin:$PATH sleep 8 && nice -n 18 __INSTALL_DIR__/venv/bin/python __INSTALL_DIR__/srv/photonix/manage.py classification_scheduler" StandardOutput=append:/var/log/__APP__/__APP__-classification_scheduler.log StandardError=inherit diff --git a/conf/classification_style_processor.service b/conf/classification_style_processor.service index 15829f1..007140c 100644 --- a/conf/classification_style_processor.service +++ b/conf/classification_style_processor.service @@ -6,9 +6,9 @@ After=network.target __APP__-app_server.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/srv/photonix -EnvironmentFile=__FINALPATH__/photonix.env -ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/venv/bin:$PATH sleep 11 && nice -n 19 __FINALPATH__/venv/bin/python __FINALPATH__/srv/photonix/manage.py classification_style_processor" +WorkingDirectory=__INSTALL_DIR__/srv/photonix +EnvironmentFile=__INSTALL_DIR__/photonix.env +ExecStart=/usr/bin/env bash -c "PATH=__INSTALL_DIR__/venv/bin:$PATH sleep 11 && nice -n 19 __INSTALL_DIR__/venv/bin/python __INSTALL_DIR__/srv/photonix/manage.py classification_style_processor" StandardOutput=append:/var/log/__APP__/__APP__-classification_style_processor.log StandardError=inherit diff --git a/conf/nginx.conf b/conf/nginx.conf index 5c2a375..6f994ee 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,7 @@ error_page 500 502 503 504 /500.html; location /500.html { - root __FINALPATH__/srv/ui/public/; + root __INSTALL_DIR__/srv/ui/public/; } location /photos { @@ -15,7 +15,7 @@ location /thumbnails { } location /static-collected { - root __FINALPATH__/srv; + root __INSTALL_DIR__/srv; expires 1d; } @@ -33,7 +33,7 @@ location ~ ^/(admin|graphql|thumbnailer) { } location / { - root __FINALPATH__/srv/ui/build; + root __INSTALL_DIR__/srv/ui/build; expires 1d; ssi on; try_files $uri /index.html =404; diff --git a/conf/photonix.env b/conf/photonix.env index c74a9dc..d1308e8 100644 --- a/conf/photonix.env +++ b/conf/photonix.env @@ -12,4 +12,4 @@ SAMPLE_DATA=0 PHOTONIX_PORT=__PORT__ DJANGO_SECRET_KEY=__SECRET_KEY__ -PYTHONPATH=__FINALPATH__/srv \ No newline at end of file +PYTHONPATH=__INSTALL_DIR__/srv \ No newline at end of file diff --git a/conf/raw_processor.service b/conf/raw_processor.service index 76afaf1..49ae718 100644 --- a/conf/raw_processor.service +++ b/conf/raw_processor.service @@ -6,9 +6,9 @@ After=network.target __APP__-app_server.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/srv/photonix -EnvironmentFile=__FINALPATH__/photonix.env -ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/venv/bin:$PATH sleep 6 && nice -n 17 __FINALPATH__/venv/bin/python __FINALPATH__/srv/photonix/manage.py raw_processor" +WorkingDirectory=__INSTALL_DIR__/srv/photonix +EnvironmentFile=__INSTALL_DIR__/photonix.env +ExecStart=/usr/bin/env bash -c "PATH=__INSTALL_DIR__/venv/bin:$PATH sleep 6 && nice -n 17 __INSTALL_DIR__/venv/bin/python __INSTALL_DIR__/srv/photonix/manage.py raw_processor" StandardOutput=append:/var/log/__APP__/__APP__-raw_processor.log StandardError=inherit diff --git a/conf/raw_scheduler.service b/conf/raw_scheduler.service index fc45bea..f9ffc9b 100644 --- a/conf/raw_scheduler.service +++ b/conf/raw_scheduler.service @@ -6,9 +6,9 @@ After=network.target __APP__-app_server.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/srv/photonix -EnvironmentFile=__FINALPATH__/photonix.env -ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/venv/bin:$PATH sleep 5 && nice -n 17 __FINALPATH__/venv/bin/python __FINALPATH__/srv/photonix/manage.py raw_scheduler" +WorkingDirectory=__INSTALL_DIR__/srv/photonix +EnvironmentFile=__INSTALL_DIR__/photonix.env +ExecStart=/usr/bin/env bash -c "PATH=__INSTALL_DIR__/venv/bin:$PATH sleep 5 && nice -n 17 __INSTALL_DIR__/venv/bin/python __INSTALL_DIR__/srv/photonix/manage.py raw_scheduler" StandardOutput=append:/var/log/__APP__/__APP__-raw_scheduler.log StandardError=inherit diff --git a/conf/rescan_photos_periodically.service b/conf/rescan_photos_periodically.service index a070f31..7c807cb 100644 --- a/conf/rescan_photos_periodically.service +++ b/conf/rescan_photos_periodically.service @@ -6,9 +6,9 @@ After=network.target __APP__-app_server.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/srv/photonix -EnvironmentFile=__FINALPATH__/photonix.env -ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/venv/bin:$PATH sleep 60 && nice -n 16 __FINALPATH__/venv/bin/python __FINALPATH__/srv/photonix/manage.py rescan_photos_periodically" +WorkingDirectory=__INSTALL_DIR__/srv/photonix +EnvironmentFile=__INSTALL_DIR__/photonix.env +ExecStart=/usr/bin/env bash -c "PATH=__INSTALL_DIR__/venv/bin:$PATH sleep 60 && nice -n 16 __INSTALL_DIR__/venv/bin/python __INSTALL_DIR__/srv/photonix/manage.py rescan_photos_periodically" StandardOutput=append:/var/log/__APP__/__APP__-rescan_photos_periodically.log StandardError=inherit diff --git a/conf/thumbnail_processor.service b/conf/thumbnail_processor.service index f73a566..558c00a 100644 --- a/conf/thumbnail_processor.service +++ b/conf/thumbnail_processor.service @@ -6,9 +6,9 @@ After=network.target __APP__-app_server.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/srv/photonix -EnvironmentFile=__FINALPATH__/photonix.env -ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/venv/bin:$PATH sleep 7 && nice -n 17 __FINALPATH__/venv/bin/python __FINALPATH__/srv/photonix/manage.py thumbnail_processor" +WorkingDirectory=__INSTALL_DIR__/srv/photonix +EnvironmentFile=__INSTALL_DIR__/photonix.env +ExecStart=/usr/bin/env bash -c "PATH=__INSTALL_DIR__/venv/bin:$PATH sleep 7 && nice -n 17 __INSTALL_DIR__/venv/bin/python __INSTALL_DIR__/srv/photonix/manage.py thumbnail_processor" StandardOutput=append:/var/log/__APP__/__APP__-thumbnail_processor.log StandardError=inherit diff --git a/conf/watch_photos.service b/conf/watch_photos.service index 969f7d9..d7d9e63 100644 --- a/conf/watch_photos.service +++ b/conf/watch_photos.service @@ -6,9 +6,9 @@ After=network.target __APP__-app_server.service Type=simple User=__APP__ Group=__APP__ -WorkingDirectory=__FINALPATH__/srv/photonix -EnvironmentFile=__FINALPATH__/photonix.env -ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/venv/bin:$PATH nice -n 16 __FINALPATH__/photonix/manage.py watch_photos" +WorkingDirectory=__INSTALL_DIR__/srv/photonix +EnvironmentFile=__INSTALL_DIR__/photonix.env +ExecStart=/usr/bin/env bash -c "PATH=__INSTALL_DIR__/venv/bin:$PATH nice -n 16 __INSTALL_DIR__/photonix/manage.py watch_photos" StandardOutput=append:/var/log/__APP__/__APP__-watch_photos.log StandardError=inherit diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..b73f2a5 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,108 @@ +#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json + +packaging_format = 2 + +id = "photonix" +name = "Photonix" +description.en = "Photo management application that streamlines the process of storing, presenting and re-discovering photos" +description.fr = "Application de gestion de photos qui simplifie le processus de stocker, présenter er re-découvrir ses photos" + +version = "0.22.0~ynh1" + +maintainers = ["Jules Bertholet"] + +[upstream] +license = "AGPL-3.0-only" +website = "https://photonix.org/" +cpe = "???" # FIXME: optional but recommended if relevant, this is meant to contain the Common Platform Enumeration, which is sort of a standard id for applications defined by the NIST. In particular, Yunohost may use this is in the future to easily track CVE (=security reports) related to apps. The CPE may be obtained by searching here: https://nvd.nist.gov/products/cpe/search. For example, for Nextcloud, the CPE is 'cpe:2.3:a:nextcloud:nextcloud' (no need to include the version number) +fund = "???" # FIXME: optional but recommended (or remove if irrelevant / not applicable). This is meant to be an URL where people can financially support this app, especially when its development is based on volunteers and/or financed by its community. YunoHost may later advertise it in the webadmin. + +[integration] +yunohost = ">= 4.2.4" +architectures = "all" # FIXME: can be replaced by a list of supported archs using the dpkg --print-architecture nomenclature (amd64/i386/armhf/arm64), for example: ["amd64", "i386"] +multi_instance = true +ldap = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "sso" key : the "ldap" key corresponds to wether or not a user *can* login on the app using its YunoHost credentials. +sso = "?" # FIXME: replace with true, false, or "not_relevant". Not to confuse with the "ldap" key : the "sso" key corresponds to wether or not a user is *automatically logged-in* on the app when logged-in on the YunoHost portal. +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] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "domain" + + [install.admin] + # this is a generic question - ask strings are automatically handled by Yunohost's core + type = "user" + + [install.classification_color_enabled] + ask.en = "Analyse photo colors (fast)?" + ask.fr = "Analyser les couleurs des photos (rapide) ?" + help.en = "This default parameter can be overridden for individual libraries" + help.fr = "Ce paramètre par dèfault peut être modifié pour chaque bibliothèque individuelle" + type = "boolean" + default = true + + [install.classification_location_enabled] + ask.en = "Identify photo locations (medium)?" + ask.fr = "Identifier la localizations des photos (moyen) ?" + help.en = "This default parameter can be overridden for individual libraries" + help.fr = "Ce paramètre par dèfault peut être modifié pour chaque bibliothèque individuelle" + type = "boolean" + default = true + + [install.classification_face_enabled] + ask.en = "Identify faces in photos (medium)?" + ask.fr = "Identifier les visages dans les photos (moyen) ?" + help.en = "This default parameter can be overridden for individual libraries" + help.fr = "Ce paramètre par dèfault peut être modifié pour chaque bibliothèque individuelle" + type = "boolean" + default = true + + [install.classification_style_enabled] + ask.en = "Recognize photo styles (medium)?" + ask.fr = "Reconnaître le style des photos (moyen) ?" + help.en = "This default parameter can be overridden for individual libraries" + help.fr = "Ce paramètre par dèfault peut être modifié pour chaque bibliothèque individuelle" + type = "boolean" + default = true + + [install.classification_object_enabled] + ask.en = "Detect objects in photos (slow)?" + ask.fr = "Reconnaître les objets dans les photos (lent) ?" + help.en = "This default parameter can be overridden for individual libraries" + help.fr = "Ce paramètre par dèfault peut être modifié pour chaque bibliothèque individuelle" + type = "boolean" + default = true + + [install.init_main_permission] + type = "group" + default = false + +[resources] + [resources.sources.main] + url = "https://github.com/photonixapp/photonix/archive/refs/tags/v0.22.0.tar.gz" + sha256 = "1a34e4ee981455e826fe5bf4fbcba7d9fba36b94802f8c927dfbfa5b6c3e3848" + + + [resources.system_user] + + [resources.install_dir] + + [resources.permissions] + main.url = "/" + + [resources.ports] + main.default = 8888 + + [resources.apt] + packages = "acl, python3, python3-pip, python3-venv, nodejs, postgresql, postgresql-contrib, postgresql-common, redis-server, libsasl2-dev, libldap2-dev, libssl-dev, build-essential, curl, gfortran, gnupg, libatlas-base-dev, libblas-dev, libblas3, libfreetype6, libfreetype6-dev, libhdf5-dev, libheif-examples, libjpeg-dev, liblapack-dev, liblapack3, libpq-dev, libtiff5-dev, netcat, libimage-exiftool-perl" + + [[resources.apt.extras]] + repo = "deb https://dl.yarnpkg.com/debian/ stable main" + key = "https://dl.yarnpkg.com/debian/pubkey.gpg" + packages = "yarn" + + [resources.database] + type = "postgresql" diff --git a/scripts/_common.sh b/scripts/_common.sh index 1736ad2..68ea52b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # dependencies used by the app -pkg_dependencies="acl python3 python3-pip python3-venv nodejs postgresql postgresql-contrib postgresql-common redis-server libsasl2-dev libldap2-dev libssl-dev build-essential curl gfortran gnupg libatlas-base-dev libblas-dev libblas3 libfreetype6 libfreetype6-dev libhdf5-dev libheif-examples libjpeg-dev liblapack-dev liblapack3 libpq-dev libtiff5-dev netcat libimage-exiftool-perl" +#REMOVEME? pkg_dependencies="acl python3 python3-pip python3-venv nodejs postgresql postgresql-contrib postgresql-common redis-server libsasl2-dev libldap2-dev libssl-dev build-essential curl gfortran gnupg libatlas-base-dev libblas-dev libblas3 libfreetype6 libfreetype6-dev libhdf5-dev libheif-examples libjpeg-dev liblapack-dev liblapack3 libpq-dev libtiff5-dev netcat libimage-exiftool-perl" #================================================= # PERSONAL HELPERS @@ -16,11 +16,11 @@ pkg_dependencies="acl python3 python3-pip python3-venv nodejs postgresql postgre #================================================= function set_permissions { - mkdir -p "$final_path/srv" - chown -R root:$app "$final_path" - chmod -R g=u,g-w,o-rwx "$final_path" - setfacl -n -m g:www-data:--x "$final_path"; - setfacl -nR -m d:g:www-data:r-x -m g:www-data:r-x "$final_path/srv"; + mkdir -p "$install_dir/srv" + chown -R root:$app "$install_dir" + chmod -R g=u,g-w,o-rwx "$install_dir" + setfacl -n -m g:www-data:--x "$install_dir"; + setfacl -nR -m d:g:www-data:r-x -m g:www-data:r-x "$install_dir/srv"; mkdir -p "$data_path/data/"{photos,raw-photos-processed,cache,models} chown -R $app:$app "$data_path" @@ -34,8 +34,8 @@ function set_permissions { } function patch_files { - find "$final_path" -type f | while read file; do - ynh_replace_string -m "'/srv" -r "'$final_path/srv" -f "$file" + find "$install_dir" -type f | while read file; do + ynh_replace_string -m "'/srv" -r "'$install_dir/srv" -f "$file" ynh_replace_string -m "'/data" -r "'$data_path/data" -f "$file" done @@ -43,21 +43,21 @@ function patch_files { } function build_django_backend { - chown -R $app:$app "$final_path" - pushd "$final_path" - sudo -u $app python3 -m venv "$final_path/venv" - sudo -u $app $final_path/venv/bin/pip --cache-dir "$final_path/.cache/pip" install -U wheel pip setuptools 2>&1 + chown -R $app:$app "$install_dir" + pushd "$install_dir" + sudo -u $app python3 -m venv "$install_dir/venv" + sudo -u $app $install_dir/venv/bin/pip --cache-dir "$install_dir/.cache/pip" install -U wheel pip setuptools 2>&1 while read requirement ; do if [ ! -z "$requirement" ] && [[ ! "$requirement" =~ ^'#'.* ]]; then - sudo -u $app PYTHONUNBUFFERED=1 "$final_path/venv/bin/pip" --cache-dir "$final_path/.cache/pip" install "$requirement" 2>&1 + sudo -u $app PYTHONUNBUFFERED=1 "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install "$requirement" 2>&1 fi - done < "$final_path/requirements.txt" - sudo -u $app $final_path/venv/bin/pip --cache-dir "$final_path/.cache/pip" install -U django-auth-ldap 2>&1 - sudo -u $app mkdir -p "$final_path/srv" - sudo -u $app cp -rT "$final_path/photonix" "$final_path/srv/photonix" + done < "$install_dir/requirements.txt" + sudo -u $app $install_dir/venv/bin/pip --cache-dir "$install_dir/.cache/pip" install -U django-auth-ldap 2>&1 + sudo -u $app mkdir -p "$install_dir/srv" + sudo -u $app cp -rT "$install_dir/photonix" "$install_dir/srv/photonix" popd - pushd "$final_path/srv" - sudo -u $app $final_path/venv/bin/python "$final_path/srv/photonix/manage.py" collectstatic --noinput --link 2>&1 + pushd "$install_dir/srv" + sudo -u $app $install_dir/venv/bin/python "$install_dir/srv/photonix/manage.py" collectstatic --noinput --link 2>&1 popd set_permissions @@ -72,47 +72,47 @@ function set_node_vars { function build_node_frontend { set_node_vars - chown -R $app:$app "$final_path" - sudo -u $app touch "$final_path/.yarnrc" - sudo -u $app mkdir -p "$final_path/srv/ui" - pushd "$final_path" - sudo -u $app cp -T "$final_path/ui/package.json" "$final_path/srv/ui/package.json" - sudo -u $app cp -T "$final_path/ui/yarn.lock" "$final_path/srv/ui/yarn.lock" + chown -R $app:$app "$install_dir" + sudo -u $app touch "$install_dir/.yarnrc" + sudo -u $app mkdir -p "$install_dir/srv/ui" + pushd "$install_dir" + sudo -u $app cp -T "$install_dir/ui/package.json" "$install_dir/srv/ui/package.json" + sudo -u $app cp -T "$install_dir/ui/yarn.lock" "$install_dir/srv/ui/yarn.lock" popd - pushd "$final_path/srv/ui" - sudo -u $app env "PATH=$node_path" yarn --cache-folder $final_path/yarn-cache --use-yarnrc $final_path/.yarnrc install 2>&1 - sudo -u $app cp -rT "$final_path/ui/public" "$final_path/srv/ui/public" - sudo -u $app cp -rT "$final_path/ui/src" "$final_path/srv/ui/src" - sudo -u $app env "PATH=$node_path" yarn --cache-folder $final_path/yarn-cache --use-yarnrc $final_path/.yarnrc build 2>&1 + pushd "$install_dir/srv/ui" + sudo -u $app env "PATH=$node_path" yarn --cache-folder $install_dir/yarn-cache --use-yarnrc $install_dir/.yarnrc install 2>&1 + sudo -u $app cp -rT "$install_dir/ui/public" "$install_dir/srv/ui/public" + sudo -u $app cp -rT "$install_dir/ui/src" "$install_dir/srv/ui/src" + sudo -u $app env "PATH=$node_path" yarn --cache-folder $install_dir/yarn-cache --use-yarnrc $install_dir/.yarnrc build 2>&1 popd - sudo -u $app cp -rT "$final_path/ui/public" "$final_path/srv/ui/public" + sudo -u $app cp -rT "$install_dir/ui/public" "$install_dir/srv/ui/public" set_permissions } function add_envfile { - secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) +#REMOVEME? secret_key=$(ynh_app_setting_get --app=$app --key=secret_key) if [ -z $secret_key ]; then secret_key=$(ynh_string_random -l 64) ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key fi - ynh_add_config --template="photonix.env" --destination="$final_path/photonix.env" + ynh_add_config --template="photonix.env" --destination="$install_dir/photonix.env" set_permissions } function apply_db_migrations { - pushd "$final_path/srv/photonix" || ynh_die + pushd "$install_dir/srv/photonix" || ynh_die sudo -u $app bash -c " - source \"$final_path/venv/bin/activate\" + source \"$install_dir/venv/bin/activate\" set -a - source \"$final_path/photonix.env\" - python \"$final_path/photonix/manage.py\" makemigrations - python \"$final_path/photonix/manage.py\" migrate" + source \"$install_dir/photonix.env\" + python \"$install_dir/photonix/manage.py\" makemigrations + python \"$install_dir/photonix/manage.py\" migrate" popd } @@ -173,20 +173,20 @@ function backup_services { } function load_settings { - final_path="$(ynh_app_setting_get --app=$app --key=final_path)" - data_path="$(ynh_app_setting_get --app=$app --key=data_path)" - domain=$(ynh_app_setting_get --app=$app --key=domain) - path_url=$(ynh_app_setting_get --app=$app --key=path) - db_name=$(ynh_app_setting_get --app=$app --key=db_name) +#REMOVEME? #REMOVEME? install_dir="$(ynh_app_setting_get --app=$app --key=install_dir)" +#REMOVEME? data_path="$(ynh_app_setting_get --app=$app --key=data_path)" +#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain) +#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path) +#REMOVEME? 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) - admin=$(ynh_app_setting_get --app=$app --key=admin) - port=$(ynh_app_setting_get --app=$app --key=port) - classification_color_enabled=$(ynh_app_setting_get --app=$app --key=classification_color_enabled) - classification_location_enabled=$(ynh_app_setting_get --app=$app --key=classification_location_enabled) - classification_face_enabled=$(ynh_app_setting_get --app=$app --key=classification_face_enabled) - classification_style_enabled=$(ynh_app_setting_get --app=$app --key=classification_style_enabled) - classification_object_enabled=$(ynh_app_setting_get --app=$app --key=classification_object_enabled) +#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +#REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin) +#REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port) +#REMOVEME? classification_color_enabled=$(ynh_app_setting_get --app=$app --key=classification_color_enabled) +#REMOVEME? classification_location_enabled=$(ynh_app_setting_get --app=$app --key=classification_location_enabled) +#REMOVEME? classification_face_enabled=$(ynh_app_setting_get --app=$app --key=classification_face_enabled) +#REMOVEME? classification_style_enabled=$(ynh_app_setting_get --app=$app --key=classification_style_enabled) +#REMOVEME? classification_object_enabled=$(ynh_app_setting_get --app=$app --key=classification_object_enabled) } #================================================= diff --git a/scripts/backup b/scripts/backup index 6ee8d27..d225383 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 load_settings @@ -38,7 +38,7 @@ 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 APP DATA DIR diff --git a/scripts/change_url b/scripts/change_url index 1c56ade..7c9fe46 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -13,49 +13,49 @@ 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 load_settings #================================================= # BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=140 +#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=140 # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { # 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 +#REMOVEME? change_path=0 #================================================= # STANDARD MODIFICATIONS @@ -71,16 +71,18 @@ stop_services #================================================= 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 #================================================= @@ -95,9 +97,9 @@ start_services #================================================= # 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 85be5ff..4eb2721 100755 --- a/scripts/install +++ b/scripts/install @@ -13,49 +13,49 @@ 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 #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -domain=$YNH_APP_ARG_DOMAIN -path_url="/" -admin=$YNH_APP_ARG_ADMIN -is_public=$YNH_APP_ARG_IS_PUBLIC -classification_color_enabled=$YNH_APP_ARG_CLASSIFICATION_COLOR_ENABLED -classification_location_enabled=$YNH_APP_ARG_CLASSIFICATION_LOCATION_ENABLED -classification_face_enabled=$YNH_APP_ARG_CLASSIFICATION_FACE_ENABLED -classification_style_enabled=$YNH_APP_ARG_CLASSIFICATION_STYLE_ENABLED -classification_object_enabled=$YNH_APP_ARG_CLASSIFICATION_OBJECT_ENABLED +#REMOVEME? domain=$YNH_APP_ARG_DOMAIN +path="/" +#REMOVEME? admin=$YNH_APP_ARG_ADMIN +#REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC +#REMOVEME? classification_color_enabled=$YNH_APP_ARG_CLASSIFICATION_COLOR_ENABLED +#REMOVEME? classification_location_enabled=$YNH_APP_ARG_CLASSIFICATION_LOCATION_ENABLED +#REMOVEME? classification_face_enabled=$YNH_APP_ARG_CLASSIFICATION_FACE_ENABLED +#REMOVEME? classification_style_enabled=$YNH_APP_ARG_CLASSIFICATION_STYLE_ENABLED +#REMOVEME? classification_object_enabled=$YNH_APP_ARG_CLASSIFICATION_OBJECT_ENABLED -app=$YNH_APP_INSTANCE_NAME +#REMOVEME? app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=1 +#REMOVEME? 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" +#REMOVEME? install_dir=/opt/yunohost/$app +#REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder" data_path=/home/yunohost.app/$app test ! -e "$data_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 +#REMOVEME? ynh_webpath_register --app=$app --domain=$domain --path=$path #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 +#REMOVEME? 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 +#REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain +#REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path +#REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin ynh_app_setting_set --app=$app --key=classification_color_enabled --value=$classification_color_enabled ynh_app_setting_set --app=$app --key=classification_location_enabled --value=$classification_location_enabled ynh_app_setting_set --app=$app --key=classification_face_enabled --value=$classification_face_enabled @@ -67,48 +67,48 @@ ynh_app_setting_set --app=$app --key=classification_object_enabled --value=$clas #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Finding an available port..." --weight=1 +#REMOVEME? ynh_script_progression --message="Finding an available port..." --weight=1 # Find an available port -port=$(ynh_find_port --port=8888) -ynh_app_setting_set --app=$app --key=port --value=$port +#REMOVEME? port=$(ynh_find_port --port=8888) +#REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=50 +#REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=50 -ynh_install_app_dependencies $pkg_dependencies -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring system user..." --weight=1 # Create a system user -ynh_system_user_create --username=$app --home_dir="$data_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$data_path" #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 +#REMOVEME? ynh_script_progression --message="Creating a PostgreSQL database..." --weight=1 -db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name -ynh_psql_test_if_first_run -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name +#REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app) +#REMOVEME? db_user=$db_name +#REMOVEME? ynh_psql_test_if_first_run +#REMOVEME? ynh_app_setting_set --app=$app --key=db_name --value=$db_name +#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name #================================================= # 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 -ynh_app_setting_set --app=$app --key=data_path --value=$data_path +#REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value=$install_dir +#REMOVEME? ynh_app_setting_set --app=$app --key=data_path --value=$data_path # 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" set_permissions @@ -179,20 +179,20 @@ ynh_script_progression --message="Creating users and libraries..." --weight=5 admin_mail=$(ynh_user_get_info "$admin" mail) sudo -u $app bash -c " - source \"$final_path/venv/bin/activate\" + source \"$install_dir/venv/bin/activate\" set -a - source \"$final_path/photonix.env\" - python \"$final_path/photonix/manage.py\" createsuperuser --noinput --username \"$admin\" --email \"$admin_mail\" + source \"$install_dir/photonix.env\" + python \"$install_dir/photonix/manage.py\" createsuperuser --noinput --username \"$admin\" --email \"$admin_mail\" " for username in $(ynh_user_list); do user_email=$(ynh_user_get_info --username="$username" --key=mail) user_firstname=$(ynh_user_get_info --username="$username" --key=firstname) user_lastname=$(ynh_user_get_info --username="$username" --key=lastname) sudo -u $app bash -c " - source \"$final_path/venv/bin/activate\" + source \"$install_dir/venv/bin/activate\" set -a - source \"$final_path/photonix.env\" - python \"$final_path/photonix/manage.py\" shell + source \"$install_dir/photonix.env\" + python \"$install_dir/photonix/manage.py\" shell " <<< " from django.contrib.auth import get_user_model from photonix.photos.models import Library, LibraryUser, LibraryPath @@ -271,22 +271,22 @@ start_services #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 +#REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1 # Make app public if necessary -if [ $is_public -eq 1 ] +#REMOVEME? 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" +#REMOVEME? ynh_permission_update --permission="main" --add="visitors" fi #================================================= # 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/scripts/remove b/scripts/remove index 4aa17ed..df0123c 100755 --- a/scripts/remove +++ b/scripts/remove @@ -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 load_settings @@ -38,26 +38,26 @@ remove_systemd_configs #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." --weight=1 +#REMOVEME? 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 +#REMOVEME? ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=5 +#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=5 # Remove metapackage and its dependencies -ynh_remove_app_dependencies +#REMOVEME? ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=1 # Remove the app directory securely -ynh_secure_remove --file="$final_path" +#REMOVEME? ynh_secure_remove --file="$install_dir" #================================================= # REMOVE APP DATA DIR @@ -105,10 +105,10 @@ ynh_remove_nodejs #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 +#REMOVEME? ynh_script_progression --message="Removing the dedicated system user..." --weight=1 # Delete a system user -ynh_system_user_delete --username=$app +#REMOVEME? ynh_system_user_delete --username=$app #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 89c763e..cb10c38 100755 --- a/scripts/restore +++ b/scripts/restore @@ -14,30 +14,30 @@ 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_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 load_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 -ynh_webpath_available --domain=$domain --path_url=$path_url \ - || ynh_die --message="Path not available: ${domain}${path_url}" -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " +#REMOVEME? ynh_webpath_available --domain=$domain --path=$path \ + || ynh_die --message="Path not available: ${domain}${path}" +#REMOVEME? test ! -d $install_dir \ + || ynh_die --message="There is already a directory: $install_dir " test ! -d $data_path \ || ynh_die --message="There is already a directory: $data_path " @@ -52,25 +52,25 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # 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="$data_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$data_path" #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=15 +#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=15 # Define and install dependencies -ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies #================================================= # 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" set_permissions @@ -88,10 +88,10 @@ set_permissions #================================================= # 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 -ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +#REMOVEME? ynh_psql_test_if_first_run +#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 9df3984..e06c5ca 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 load_settings @@ -27,16 +27,16 @@ 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=115 +#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=115 # Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { +#REMOVEME? ynh_backup_before_upgrade +#REMOVEME? ynh_clean_setup () { # 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 @@ -50,10 +50,10 @@ stop_services #================================================= # 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="$data_path" +#REMOVEME? ynh_system_user_create --username=$app --home_dir="$data_path" #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -68,10 +68,10 @@ fi #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=15 +#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=15 -ynh_install_app_dependencies $pkg_dependencies -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +#REMOVEME? ynh_install_app_dependencies $pkg_dependencies +#REMOVEME? ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -81,10 +81,10 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=5 - ynh_secure_remove --file="$final_path" +#REMOVEME? ynh_secure_remove --file="$install_dir" # 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 @@ -179,9 +179,9 @@ start_services #================================================= # 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