1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/librephotos_ynh.git synced 2024-09-03 19:36:12 +02:00

Automated packaging v2 conversion

This commit is contained in:
Salamandar 2024-06-06 12:01:43 +02:00
parent 86a0d1ad46
commit 487678b28b
22 changed files with 305 additions and 252 deletions

View file

@ -8,9 +8,9 @@ Requires=postgresql.service
[Service] [Service]
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
EnvironmentFile=__FINALPATH__/librephotos.env EnvironmentFile=__INSTALL_DIR__/librephotos.env
ExecStart=/usr/bin/env bash -c "PATH=__PATH_PREFIX__:$PATH gunicorn --worker-class=gevent --timeout 3600 --bind 127.0.0.1:$BACKEND_PORT --log-level=info ownphotos.wsgi" ExecStart=/usr/bin/env bash -c "PATH=__PATH_PREFIX__:$PATH gunicorn --worker-class=gevent --timeout 3600 --bind 127.0.0.1:$BACKEND_PORT --log-level=info ownphotos.wsgi"
WorkingDirectory=__FINALPATH__/backend WorkingDirectory=__INSTALL_DIR__/backend
StandardOutput=append:/var/log/__APP__/__APP__-backend.log StandardOutput=append:/var/log/__APP__/__APP__-backend.log
StandardError=inherit StandardError=inherit

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/LibrePhotos/librephotos/tarball/11c6994d3c506d835335f596090a13545d72713a
SOURCE_SUM=0e588d7ed34fa826e8beba3894586b16bb247b00548215190732a1cbec57167b
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=11c6994d3c506d835335f596090a13545d72713a
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/Kitware/CMake/releases/download/v3.20.3/cmake-3.20.3-linux-aarch64.tar.gz
SOURCE_SUM=77620f99e9d5f39cf4a49294c6a68c89a978ecef144894618974b9958efe3c2a
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=cmake-3.20.3-linux-aarch64.tar.gz
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/Kitware/CMake/releases/download/v3.20.3/cmake-3.20.3-linux-x86_64.tar.gz
SOURCE_SUM=97bf730372f9900b2dfb9206fccbcf92f5c7f3b502148b832e77451aa0f9e0e6
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=cmake-3.20.3-linux-x86_64.tar.gz
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/davisking/dlib/archive/refs/tags/v19.22.tar.gz
SOURCE_SUM=5f44b67f762691b92f3e41dcf9c95dd0f4525b59cacb478094e511fdacb5c096
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=v19.22.tar.gz
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/facebookresearch/faiss/archive/refs/tags/v1.7.1.tar.gz
SOURCE_SUM=d676d3107ad41203a49e0afda2630519299dc8666f8d23322cbe1eac0c431871
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=v1.7.1.tar.gz
SOURCE_EXTRACT=true

View file

@ -5,9 +5,9 @@ Documentation=https://github.com/LibrePhotos/librephotos
[Service] [Service]
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
EnvironmentFile=__FINALPATH__/librephotos.env EnvironmentFile=__INSTALL_DIR__/librephotos.env
ExecStart=/usr/bin/env bash -c "PATH=__PATH_PREFIX__:$PATH ./node_modules/.bin/serve build -d -l $httpPort" ExecStart=/usr/bin/env bash -c "PATH=__PATH_PREFIX__:$PATH ./node_modules/.bin/serve build -d -l $httpPort"
WorkingDirectory=__FINALPATH__/frontend WorkingDirectory=__INSTALL_DIR__/frontend
StandardOutput=append:/var/log/__APP__/__APP__-frontend.log StandardOutput=append:/var/log/__APP__/__APP__-frontend.log
StandardError=inherit StandardError=inherit

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/LibrePhotos/librephotos-frontend/tarball/37963756369f11617c456a56f6850b2e8aaf8358
SOURCE_SUM=085b62550214bd9ffecfefde802b96f3542e6867bb25ff1a830623b598e4c61d
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=37963756369f11617c456a56f6850b2e8aaf8358
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/LibrePhotos/librephotos-docker/releases/download/0.1/im2txt.tar.gz
SOURCE_SUM=980670c0365c0e32b5fecfc0907bfee4742bcd6a40e0d6ac5692c69bbd49ccc4
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=im2txt.tar.gz
SOURCE_EXTRACT=true

View file

@ -7,9 +7,9 @@ After=network.target
[Service] [Service]
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
EnvironmentFile=__FINALPATH__/librephotos.env EnvironmentFile=__INSTALL_DIR__/librephotos.env
ExecStart=/usr/bin/env bash -c "PATH=__PATH_PREFIX__:$PATH python3 image_similarity/main.py" ExecStart=/usr/bin/env bash -c "PATH=__PATH_PREFIX__:$PATH python3 image_similarity/main.py"
WorkingDirectory=__FINALPATH__/backend WorkingDirectory=__INSTALL_DIR__/backend
StandardOutput=append:/var/log/__APP__/__APP__-image-similarity.log StandardOutput=append:/var/log/__APP__/__APP__-image-similarity.log
StandardError=inherit StandardError=inherit

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/conda-forge/miniforge/releases/download/4.10.1-4/Miniforge3-4.10.1-4-Linux-aarch64.sh
SOURCE_SUM=68f11be0b8272b9218f62fa3ba1b7c58783427e65db7b7ba77e7cdf91f099540
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=sh
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=Miniforge3-4.10.1-4-Linux-aarch64.sh
SOURCE_EXTRACT=false

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://github.com/LibrePhotos/librephotos-docker/releases/download/0.1/places365.tar.gz
SOURCE_SUM=27792ffcd1f6a4de7abebdea046dda0916f9cd12eba7bed7b5f51f120f91f0d8
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=places365.tar.gz
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://download.pytorch.org/models/resnet152-b121ed2d.pth
SOURCE_SUM=b121ed2db97ec7e9f55a91300ceaf85a326de955e8a4ae09e3a0c8170d27f14f
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar
SOURCE_IN_SUBDIR=false
SOURCE_FILENAME=resnet152-b121ed2d.pth
SOURCE_EXTRACT=false

View file

@ -8,9 +8,9 @@ Requires=postgresql.service
[Service] [Service]
User=__APP__ User=__APP__
Group=__APP__ Group=__APP__
EnvironmentFile=__FINALPATH__/librephotos.env EnvironmentFile=__INSTALL_DIR__/librephotos.env
ExecStart=/usr/bin/env bash -c "PATH=__PATH_PREFIX__:$PATH python manage.py rqworker default" ExecStart=/usr/bin/env bash -c "PATH=__PATH_PREFIX__:$PATH python manage.py rqworker default"
WorkingDirectory=__FINALPATH__/backend WorkingDirectory=__INSTALL_DIR__/backend
StandardOutput=append:/var/log/__APP__/__APP__-worker.log StandardOutput=append:/var/log/__APP__/__APP__-worker.log
StandardError=inherit StandardError=inherit

121
manifest.toml Normal file
View file

@ -0,0 +1,121 @@
#:schema https://raw.githubusercontent.com/YunoHost/apps/master/schemas/manifest.v2.schema.json
packaging_format = 2
id = "librephotos"
name = "Librephotos"
description.en = "A photo viewer and manager similar to Google Photos"
description.fr = "Un gestionnaire de photos semblable à Google Photos"
version = "0.2021.36~ynh1"
maintainers = ["Jules Bertholet"]
[upstream]
license = "MIT"
website = "https://librephotos.com/"
demo = "https://demo2.librephotos.com/ (user: demo, password: demo1234)"
admindoc = "https://docs.librephotos.com/"
userdoc = "https://github.com/LibrePhotos/librephotos"
code = "https://github.com/LibrePhotos/librephotos"
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 = false
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.init_main_permission]
type = "group"
default = "visitors"
[install.allow_multimedia_write]
ask.en = "Allow write access to multimedia directories?"
ask.fr = "Autoriser la modification des fichiers dans les dossiers multimédia ?"
type = "boolean"
default = false
[resources]
[resources.sources]
[resources.sources.backend]
url = "https://github.com/LibrePhotos/librephotos/tarball/11c6994d3c506d835335f596090a13545d72713a"
sha256 = "0e588d7ed34fa826e8beba3894586b16bb247b00548215190732a1cbec57167b"
[resources.sources.cmake]
url = "https://github.com/Kitware/CMake/releases/download/v3.20.3/cmake-3.20.3-linux-aarch64.tar.gz"
sha256 = "77620f99e9d5f39cf4a49294c6a68c89a978ecef144894618974b9958efe3c2a"
[resources.sources.cmake_amd64]
url = "https://github.com/Kitware/CMake/releases/download/v3.20.3/cmake-3.20.3-linux-x86_64.tar.gz"
sha256 = "97bf730372f9900b2dfb9206fccbcf92f5c7f3b502148b832e77451aa0f9e0e6"
[resources.sources.dlib]
url = "https://github.com/davisking/dlib/archive/refs/tags/v19.22.tar.gz"
sha256 = "5f44b67f762691b92f3e41dcf9c95dd0f4525b59cacb478094e511fdacb5c096"
[resources.sources.faiss]
url = "https://github.com/facebookresearch/faiss/archive/refs/tags/v1.7.1.tar.gz"
sha256 = "d676d3107ad41203a49e0afda2630519299dc8666f8d23322cbe1eac0c431871"
[resources.sources.frontend]
url = "https://github.com/LibrePhotos/librephotos-frontend/tarball/37963756369f11617c456a56f6850b2e8aaf8358"
sha256 = "085b62550214bd9ffecfefde802b96f3542e6867bb25ff1a830623b598e4c61d"
[resources.sources.im2txt]
url = "https://github.com/LibrePhotos/librephotos-docker/releases/download/0.1/im2txt.tar.gz"
sha256 = "980670c0365c0e32b5fecfc0907bfee4742bcd6a40e0d6ac5692c69bbd49ccc4"
[resources.sources.miniforge3]
url = "https://github.com/conda-forge/miniforge/releases/download/4.10.1-4/Miniforge3-4.10.1-4-Linux-aarch64.sh"
sha256 = "68f11be0b8272b9218f62fa3ba1b7c58783427e65db7b7ba77e7cdf91f099540"
format = "sh"
rename = "Miniforge3-4.10.1-4-Linux-aarch64.sh"
[resources.sources.places365]
url = "https://github.com/LibrePhotos/librephotos-docker/releases/download/0.1/places365.tar.gz"
sha256 = "27792ffcd1f6a4de7abebdea046dda0916f9cd12eba7bed7b5f51f120f91f0d8"
[resources.sources.resnet152-b121ed2d]
url = "https://download.pytorch.org/models/resnet152-b121ed2d.pth"
sha256 = "b121ed2db97ec7e9f55a91300ceaf85a326de955e8a4ae09e3a0c8170d27f14f"
format = "tar"
rename = "resnet152-b121ed2d.pth"
[resources.system_user]
[resources.install_dir]
[resources.permissions]
main.url = "/"
[resources.ports]
main.default = 3000
backend.default = 8001
similarity.default = 12345
[resources.apt]
packages = "libtinfo5, unzip, ca-certificates, swig, libpq-dev, postgresql, postgresql-contrib, postgresql-common, ffmpeg, libimage-exiftool-perl, curl, libopenblas-dev, libmagic1, libboost-all-dev, libxrender-dev, liblapack-dev, git, bzip2, cmake, build-essential, libsm6, libglib2.0-0, libgl1-mesa-glx, gfortran, gunicorn, libheif-dev, libssl-dev, rustc, liblzma-dev, python3, python3-pip, python3-venv, imagemagick, xsel, nodejs, npm, redis-server, libmagickwand-dev, libldap2-dev, libsasl2-dev, $pkg_dependencies, ufraw-batch"
[[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"

View file

@ -5,13 +5,13 @@
#================================================= #=================================================
# dependencies used by the app # dependencies used by the app
pkg_dependencies="libtinfo5 unzip ca-certificates swig libpq-dev postgresql postgresql-contrib postgresql-common ffmpeg libimage-exiftool-perl curl libopenblas-dev libmagic1 libboost-all-dev libxrender-dev liblapack-dev git bzip2 cmake build-essential libsm6 libglib2.0-0 libgl1-mesa-glx gfortran gunicorn libheif-dev libssl-dev rustc liblzma-dev python3 python3-pip python3-venv imagemagick xsel nodejs npm redis-server libmagickwand-dev libldap2-dev libsasl2-dev" #REMOVEME? pkg_dependencies="libtinfo5 unzip ca-certificates swig libpq-dev postgresql postgresql-contrib postgresql-common ffmpeg libimage-exiftool-perl curl libopenblas-dev libmagic1 libboost-all-dev libxrender-dev liblapack-dev git bzip2 cmake build-essential libsm6 libglib2.0-0 libgl1-mesa-glx gfortran gunicorn libheif-dev libssl-dev rustc liblzma-dev python3 python3-pip python3-venv imagemagick xsel nodejs npm redis-server libmagickwand-dev libldap2-dev libsasl2-dev"
arch="$(dpkg --print-architecture)" arch="$(dpkg --print-architecture)"
arm64_test=0 arm64_test=0
if ! (apt-cache -q=0 show ufraw-batch |& grep ': No packages found' &>/dev/null); then if ! (apt-cache -q=0 show ufraw-batch |& grep ': No packages found' &>/dev/null); then
pkg_dependencies="$pkg_dependencies ufraw-batch" #REMOVEME? pkg_dependencies="$pkg_dependencies ufraw-batch"
fi fi
#================================================= #=================================================
@ -19,12 +19,12 @@ fi
#================================================= #=================================================
function unpack_source { function unpack_source {
ynh_secure_remove "$final_path" #REMOVEME? ynh_secure_remove "$install_dir"
mkdir -p "$final_path/data_models/"{places365,im2txt} mkdir -p "$install_dir/data_models/"{places365,im2txt}
ynh_setup_source --source_id="places365" --dest_dir="$final_path/data_models/places365/" ynh_setup_source --source_id="places365" --dest_dir="$install_dir/data_models/places365/"
ynh_setup_source --source_id="im2txt" --dest_dir="$final_path/data_models/im2txt/" ynh_setup_source --source_id="im2txt" --dest_dir="$install_dir/data_models/im2txt/"
mkdir -p "$data_path" mkdir -p "$data_path"
ln -sf "$final_path/data_models" "$data_path/data_models" ln -sf "$install_dir/data_models" "$data_path/data_models"
mkdir -p "$data_path/protected_media/"{thumbnails_big,square_thumbnails,square_thumbnails_small,faces} mkdir -p "$data_path/protected_media/"{thumbnails_big,square_thumbnails,square_thumbnails_small,faces}
mkdir -p "$data_path/data/nextcloud_media" mkdir -p "$data_path/data/nextcloud_media"
mkdir -p "$data_path/matplotlib" mkdir -p "$data_path/matplotlib"
@ -32,27 +32,27 @@ function unpack_source {
mkdir -p ~/.cache/torch/hub/checkpoints/ mkdir -p ~/.cache/torch/hub/checkpoints/
ynh_setup_source --source_id="resnet152-b121ed2d" --dest_dir="/root/.cache/torch/hub/checkpoints/" ynh_setup_source --source_id="resnet152-b121ed2d" --dest_dir="/root/.cache/torch/hub/checkpoints/"
ynh_setup_source --source_id="backend" --dest_dir="$final_path/backend/" ynh_setup_source --source_id="backend" --dest_dir="$install_dir/backend/"
ynh_setup_source --source_id="frontend" --dest_dir="$final_path/frontend/" ynh_setup_source --source_id="frontend" --dest_dir="$install_dir/frontend/"
ynh_setup_source --source_id="dlib" --dest_dir="$final_path/backend/dlib/" ynh_setup_source --source_id="dlib" --dest_dir="$install_dir/backend/dlib/"
if [ "$arch" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then if [ "$arch" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then
export CONDA_DIR="$final_path/backend/conda" export CONDA_DIR="$install_dir/backend/conda"
mkdir -p "$CONDA_DIR" mkdir -p "$CONDA_DIR"
if [ "$arch" = "arm64" ]; then if [ "$arch" = "arm64" ]; then
ynh_setup_source --source_id="miniforge3" --dest_dir="$CONDA_DIR" ynh_setup_source --source_id="miniforge3" --dest_dir="$CONDA_DIR"
ynh_setup_source --source_id="cmake" --dest_dir="$final_path/backend/cmake/" ynh_setup_source --source_id="cmake" --dest_dir="$install_dir/backend/cmake/"
else else
wget -O "${CONDA_DIR}/Miniforge3-4.10.1-4-Linux-aarch64.sh" https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh 2>&1 wget -O "${CONDA_DIR}/Miniforge3-4.10.1-4-Linux-aarch64.sh" https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh 2>&1
ynh_setup_source --source_id="cmake_amd64" --dest_dir="$final_path/backend/cmake/" ynh_setup_source --source_id="cmake_amd64" --dest_dir="$install_dir/backend/cmake/"
fi fi
#ynh_setup_source --source_id="faiss" --dest_dir="$final_path/backend/faiss/" #ynh_setup_source --source_id="faiss" --dest_dir="$install_dir/backend/faiss/"
fi fi
mkdir -p "/var/log/$app" mkdir -p "/var/log/$app"
} }
function set_up_backend { function set_up_backend {
backend_path="$final_path/backend" backend_path="$install_dir/backend"
pushd "$backend_path" pushd "$backend_path"
chown -R $app:$app "$backend_path" chown -R $app:$app "$backend_path"
sudo -u $app python3 -m venv $backend_path/venv sudo -u $app python3 -m venv $backend_path/venv
@ -111,8 +111,8 @@ function set_node_vars {
function set_up_frontend { function set_up_frontend {
set_node_vars set_node_vars
frontend_path=$final_path/frontend frontend_path=$install_dir/frontend
pushd $final_path/frontend pushd $install_dir/frontend
chown -R $app:$app $frontend_path chown -R $app:$app $frontend_path
sudo -u $app touch $frontend_path/.yarnrc sudo -u $app touch $frontend_path/.yarnrc
sudo -u $app env "PATH=$node_PATH" yarn --cache-folder $frontend_path/yarn-cache --use-yarnrc $frontend_path/.yarnrc install 2>&1 sudo -u $app env "PATH=$node_PATH" yarn --cache-folder $frontend_path/yarn-cache --use-yarnrc $frontend_path/.yarnrc install 2>&1
@ -123,24 +123,24 @@ function set_up_frontend {
} }
function add_configuations { function add_configuations {
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 if [ -z $secret_key ]; then
secret_key=$(ynh_string_random -l 64) secret_key=$(ynh_string_random -l 64)
ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key ynh_app_setting_set --app=$app --key=secret_key --value=$secret_key
fi fi
ynh_add_config --template="librephotos.env" --destination="$final_path/librephotos.env" ynh_add_config --template="librephotos.env" --destination="$install_dir/librephotos.env"
} }
function upgrade_db { function upgrade_db {
pushd "$final_path/backend" pushd "$install_dir/backend"
chown -R $app:$app "$final_path/backend" chown -R $app:$app "$install_dir/backend"
chown -R $app:$app "/var/log/$app" chown -R $app:$app "/var/log/$app"
sudo -u $app bash -c " sudo -u $app bash -c "
set -a set -a
export PATH=\"$path_prefix:"'$PATH'"\" export PATH=\"$path_prefix:"'$PATH'"\"
source \"$final_path\"/librephotos.env source \"$install_dir\"/librephotos.env
python3 manage.py showmigrations python3 manage.py showmigrations
python3 manage.py migrate python3 manage.py migrate
python3 manage.py showmigrations python3 manage.py showmigrations
@ -150,11 +150,11 @@ function upgrade_db {
} }
function set_permissions { function set_permissions {
chown -R root:$app "$final_path" chown -R root:$app "$install_dir"
chmod -R g=u,g-w,o-rwx "$final_path" chmod -R g=u,g-w,o-rwx "$install_dir"
chown -R $app:$app "$data_path" chown -R $app:$app "$data_path"
chmod -R g=u,g-w,o-rwx "$data_path" chmod -R g=u,g-w,o-rwx "$data_path"
chown -R $app:$app "$final_path/data_models" chown -R $app:$app "$install_dir/data_models"
chown -R $app:$app "/var/log/$app" chown -R $app:$app "/var/log/$app"
chmod -R g-w,o-rwx "/var/log/$app" chmod -R g-w,o-rwx "/var/log/$app"
setfacl -n -m user:www-data:rx "$data_path" setfacl -n -m user:www-data:rx "$data_path"

View file

@ -14,23 +14,23 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # 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
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
data_path=$(ynh_app_setting_get --app=$app --key=data_path) #REMOVEME? data_path=$(ynh_app_setting_get --app=$app --key=data_path)
#================================================= #=================================================
# DECLARE DATA AND CONF FILES TO BACKUP # DECLARE DATA AND CONF FILES TO BACKUP
@ -41,7 +41,7 @@ ynh_print_info --message="Declaring files to be backed up..."
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_backup --src_path="$final_path" ynh_backup --src_path="$install_dir"
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION

View file

@ -13,50 +13,50 @@ source /usr/share/yunohost/helpers
# RETRIEVE ARGUMENTS # RETRIEVE ARGUMENTS
#================================================= #=================================================
old_domain=$YNH_APP_OLD_DOMAIN #REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN
old_path=$YNH_APP_OLD_PATH #REMOVEME? old_path=$YNH_APP_OLD_PATH
new_domain=$YNH_APP_NEW_DOMAIN #REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN
new_path="/" #REMOVEME? new_path="/"
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --weight=1 #REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config" #REMOVEME? # Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=30 #REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --weight=30
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade #REMOVEME? ynh_backup_before_upgrade
ynh_clean_setup () { #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. # 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 # Restore it if the upgrade fails
ynh_restore_upgradebackup #REMOVEME? ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # 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 # CHECK WHICH PARTS SHOULD BE CHANGED
#================================================= #=================================================
change_domain=0 #REMOVEME? change_domain=0
if [ "$old_domain" != "$new_domain" ] #REMOVEME? if [ "$old_domain" != "$new_domain" ]
then then
change_domain=1 #REMOVEME? change_domain=1
fi fi
change_path=0 #REMOVEME? change_path=0
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -75,16 +75,18 @@ ynh_systemd_action --service_name=$app-worker --action="stop" --log_path="/var/l
#================================================= #=================================================
ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 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 # Change the domain for NGINX
if [ $change_domain -eq 1 ] if [ $change_domain -eq 1 ]
then then
# Delete file checksum for the old conf file location # Delete file checksum for the old conf file location
ynh_delete_file_checksum --file="$nginx_conf_path" #REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path"
mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf #REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf
# Store file checksum for the new config file location # 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 fi
#================================================= #=================================================
@ -102,9 +104,9 @@ ynh_systemd_action --service_name=$app-worker --action="start" --log_path="/var/
#================================================= #=================================================
# RELOAD NGINX # 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 # END OF SCRIPT

View file

@ -12,47 +12,47 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
} }
# Exit if an error occurs during the execution of the script # 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 # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
domain=$YNH_APP_ARG_DOMAIN #REMOVEME? domain=$YNH_APP_ARG_DOMAIN
path_url="/" path="/"
admin=$YNH_APP_ARG_ADMIN #REMOVEME? admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC #REMOVEME? is_public=$YNH_APP_ARG_IS_PUBLIC
allow_multimedia_write=$YNH_APP_ARG_ALLOW_MULTIMEDIA_WRITE #REMOVEME? allow_multimedia_write=$YNH_APP_ARG_ALLOW_MULTIMEDIA_WRITE
app=$YNH_APP_INSTANCE_NAME #REMOVEME? app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS # 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 #REMOVEME? install_dir=/opt/yunohost/$app
test ! -e "$final_path" || ynh_die --message="This path already contains a folder" #REMOVEME? test ! -e "$install_dir" || ynh_die --message="This path already contains a folder"
ynh_app_setting_set --app=$app --key=final_path --value="$final_path" #REMOVEME? ynh_app_setting_set --app=$app --key=install_dir --value="$install_dir"
data_path=/home/yunohost.app/$app data_path=/home/yunohost.app/$app
test ! -e "$data_path" || ynh_die --message="This path already contains a folder" test ! -e "$data_path" || ynh_die --message="This path already contains a folder"
ynh_app_setting_set --app=$app --key=data_path --value="$data_path" #REMOVEME? ynh_app_setting_set --app=$app --key=data_path --value="$data_path"
# Register (book) web path # 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 # 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 #REMOVEME? ynh_app_setting_set --app=$app --key=domain --value=$domain
ynh_app_setting_set --app=$app --key=path --value=$path_url #REMOVEME? ynh_app_setting_set --app=$app --key=path --value=$path
ynh_app_setting_set --app=$app --key=admin --value=$admin #REMOVEME? ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=allow_multimedia_write --value=$allow_multimedia_write ynh_app_setting_set --app=$app --key=allow_multimedia_write --value=$allow_multimedia_write
#================================================= #=================================================
@ -63,31 +63,31 @@ ynh_app_setting_set --app=$app --key=allow_multimedia_write --value=$allow_multi
ynh_script_progression --message="Finding available ports..." --weight=1 ynh_script_progression --message="Finding available ports..." --weight=1
# Find an available port # Find an available port
port=$(ynh_find_port --port=3000) #REMOVEME? port=$(ynh_find_port --port=3000)
ynh_app_setting_set --app=$app --key=port --value=$port #REMOVEME? ynh_app_setting_set --app=$app --key=port --value=$port
backend_port=$(ynh_find_port --port=8001) #REMOVEME? backend_port=$(ynh_find_port --port=8001)
ynh_app_setting_set --app=$app --key=backend_port --value=$backend_port #REMOVEME? ynh_app_setting_set --app=$app --key=backend_port --value=$backend_port
similarity_port=$(ynh_find_port --port=$(expr $backend_port + 1)) #REMOVEME? similarity_port=$(ynh_find_port --port=$(expr $backend_port + 1))
ynh_app_setting_set --app=$app --key=similarity_port --value=$similarity_port #REMOVEME? ynh_app_setting_set --app=$app --key=similarity_port --value=$similarity_port
#================================================= #=================================================
# INSTALL DEPENDENCIES # INSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Installing dependencies..." --weight=5 #REMOVEME? ynh_script_progression --message="Installing dependencies..." --weight=5
ynh_install_app_dependencies $pkg_dependencies #REMOVEME? 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_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#================================================= #=================================================
# CREATE A POSTGRESQL DATABASE # 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) #REMOVEME? db_name=$(ynh_sanitize_dbid --db_name=$app)
db_user=$db_name #REMOVEME? db_user=$db_name
ynh_psql_test_if_first_run #REMOVEME? ynh_psql_test_if_first_run
ynh_app_setting_set --app=$app --key=db_name --value=$db_name #REMOVEME? 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? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
@ -107,10 +107,10 @@ ynh_add_nginx_config backend_port
#================================================= #=================================================
# CREATE DEDICATED USER # 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 # 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
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
@ -153,12 +153,12 @@ ynh_script_progression --message="Finalizing database..." --weight=1
upgrade_db upgrade_db
pushd "$final_path/backend" pushd "$install_dir/backend"
admin_mail="$(ynh_user_get_info $admin 'mail')" admin_mail="$(ynh_user_get_info $admin 'mail')"
sudo -u $app bash -c " sudo -u $app bash -c "
set -a set -a
export PATH=\"$path_prefix:"'$PATH'"\" export PATH=\"$path_prefix:"'$PATH'"\"
source \"$final_path\"/librephotos.env source \"$install_dir\"/librephotos.env
python3 manage.py createsuperuser --noinput --username \"$admin\" --email \"$admin_mail\" python3 manage.py createsuperuser --noinput --username \"$admin\" --email \"$admin_mail\"
" 2>&1 " 2>&1
for user in $(ynh_user_list); do for user in $(ynh_user_list); do
@ -166,7 +166,7 @@ pushd "$final_path/backend"
sudo -u $app bash -c " sudo -u $app bash -c "
set -a set -a
export PATH=\"$path_prefix:"'$PATH'"\" export PATH=\"$path_prefix:"'$PATH'"\"
source \"$final_path\"/librephotos.env source \"$install_dir\"/librephotos.env
python3 manage.py shell python3 manage.py shell
" <<< " " <<< "
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
@ -234,22 +234,22 @@ ynh_systemd_action --service_name=$app-worker --action="start" --log_path="/var/
#================================================= #=================================================
# SETUP SSOWAT # SETUP SSOWAT
#================================================= #=================================================
ynh_script_progression --message="Configuring permissions..." --weight=1 #REMOVEME? ynh_script_progression --message="Configuring permissions..." --weight=1
# Make app public if necessary # Make app public if necessary
if [ $is_public -eq 1 ] #REMOVEME? if [ $is_public -eq 1 ]
then then
# Everyone can access the app. # Everyone can access the app.
# The "main" permission is automatically created before the install script. # 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 fi
#================================================= #=================================================
# RELOAD NGINX # 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 # END OF SCRIPT

View file

@ -12,16 +12,16 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # 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
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port) #REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name #REMOVEME? db_user=$db_name
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
data_path=$(ynh_app_setting_get --app=$app --key=data_path) #REMOVEME? data_path=$(ynh_app_setting_get --app=$app --key=data_path)
#================================================= #=================================================
# STANDARD REMOVE # STANDARD REMOVE
@ -62,26 +62,26 @@ ynh_remove_systemd_config --service="$app-worker"
#================================================= #=================================================
# REMOVE THE POSTGRESQL DATABASE # 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 # 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 # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing dependencies..." --weight=30 #REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=30
# Remove metapackage and its dependencies # Remove metapackage and its dependencies
ynh_remove_app_dependencies #REMOVEME? ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Removing app main directory..." --weight=2 #REMOVEME? ynh_script_progression --message="Removing app main directory..." --weight=2
# Remove the app directory securely # Remove the app directory securely
ynh_secure_remove --file="$final_path" #REMOVEME? ynh_secure_remove --file="$install_dir"
#================================================= #=================================================
# REMOVE APP DATA DIR # REMOVE APP DATA DIR
@ -128,10 +128,10 @@ ynh_secure_remove --file="/var/log/$app"
#================================================= #=================================================
# REMOVE DEDICATED USER # 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 # Delete a system user
ynh_system_user_delete --username=$app #REMOVEME? ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -14,41 +14,41 @@ source /usr/share/yunohost/helpers
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # 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
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) #REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name #REMOVEME? db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
data_path=$(ynh_app_setting_get --app=$app --key=data_path) #REMOVEME? data_path=$(ynh_app_setting_get --app=$app --key=data_path)
allow_multimedia_write=$(ynh_app_setting_get --app=$app --key=allow_multimedia_write) #REMOVEME? allow_multimedia_write=$(ynh_app_setting_get --app=$app --key=allow_multimedia_write)
port=$(ynh_app_setting_get --app=$app --key=port) #REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
backend_port=$(ynh_app_setting_get --app=$app --key=port) #REMOVEME? backend_port=$(ynh_app_setting_get --app=$app --key=port)
similarity_port=$(ynh_app_setting_get --app=$app --key=similarity_port) #REMOVEME? similarity_port=$(ynh_app_setting_get --app=$app --key=similarity_port)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # 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 \ #REMOVEME? ynh_webpath_available --domain=$domain --path=$path \
|| ynh_die --message="Path not available: ${domain}${path_url}" || ynh_die --message="Path not available: ${domain}${path}"
test ! -d $final_path \ #REMOVEME? test ! -d $install_dir \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $install_dir "
test ! -d $data_path \ test ! -d $data_path \
|| ynh_die --message="There is already a directory: $data_path " || ynh_die --message="There is already a directory: $data_path "
@ -66,7 +66,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --weight=1 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 APP DATA DIR # RESTORE THE APP DATA DIR
@ -77,15 +77,15 @@ ynh_restore_file --origin_path="$data_path" --not_mandatory
mkdir -p $data_path/protected_media/{thumbnails_big,square_thumbnails,square_thumbnails_small,faces} mkdir -p $data_path/protected_media/{thumbnails_big,square_thumbnails,square_thumbnails_small,faces}
mkdir -p $data_path/data/nextcloud_media mkdir -p $data_path/data/nextcloud_media
mkdir -p $data_path/matplotlib mkdir -p $data_path/matplotlib
ln -s $final_path/data_models $data_path/data_models ln -s $install_dir/data_models $data_path/data_models
#================================================= #=================================================
# RECREATE THE DEDICATED USER # 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) # 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
#================================================= #=================================================
# RESTORE VARIOUS FILES # RESTORE VARIOUS FILES
@ -102,11 +102,11 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Reinstalling dependencies..." --weight=60 #REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=60
# Define and install dependencies # Define and install dependencies
ynh_install_app_dependencies $pkg_dependencies #REMOVEME? 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_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg"
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
@ -120,10 +120,10 @@ set_permissions
#================================================= #=================================================
# RESTORE THE POSTGRESQL DATABASE # RESTORE THE POSTGRESQL DATABASE
#================================================= #=================================================
ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=2 #REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=2
ynh_psql_test_if_first_run #REMOVEME? 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_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 ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
#================================================= #=================================================

View file

@ -12,23 +12,23 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # 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
domain=$(ynh_app_setting_get --app=$app --key=domain) #REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) #REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
admin=$(ynh_app_setting_get --app=$app --key=admin) #REMOVEME? admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) #REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
language=$(ynh_app_setting_get --app=$app --key=language) #REMOVEME? language=$(ynh_app_setting_get --app=$app --key=language)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) #REMOVEME? db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name #REMOVEME? db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) #REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
port=$(ynh_app_setting_get --app=$app --key=port) #REMOVEME? port=$(ynh_app_setting_get --app=$app --key=port)
backend_port=$(ynh_app_setting_get --app=$app --key=backend_port) #REMOVEME? backend_port=$(ynh_app_setting_get --app=$app --key=backend_port)
similarity_port=$(ynh_app_setting_get --app=$app --key=similarity_port) #REMOVEME? similarity_port=$(ynh_app_setting_get --app=$app --key=similarity_port)
data_path=$(ynh_app_setting_get --app=$app --key=data_path) #REMOVEME? data_path=$(ynh_app_setting_get --app=$app --key=data_path)
allow_multimedia_write=$(ynh_app_setting_get --app=$app --key=allow_multimedia_write) #REMOVEME? allow_multimedia_write=$(ynh_app_setting_get --app=$app --key=allow_multimedia_write)
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -39,16 +39,16 @@ upgrade_type=$(ynh_check_app_version_changed)
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
#================================================= #=================================================
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=30 #REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=30
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade #REMOVEME? ynh_backup_before_upgrade
ynh_clean_setup () { #REMOVEME? ynh_clean_setup () {
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup #REMOVEME? ynh_restore_upgradebackup
} }
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors #REMOVEME? ynh_abort_if_errors
#================================================= #=================================================
# STANDARD UPGRADE STEPS # STANDARD UPGRADE STEPS
@ -93,18 +93,18 @@ ynh_add_nginx_config backend_port
#================================================= #=================================================
# UPGRADE DEPENDENCIES # 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
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_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 # 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) # 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
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -199,9 +199,9 @@ ynh_systemd_action --service_name=$app-worker --action="start" --log_path="/var/
#================================================= #=================================================
# RELOAD NGINX # 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 # END OF SCRIPT