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

Upgrade to 0.2021.36~ynh2

This commit is contained in:
yalh76 2022-07-27 04:18:35 +02:00
parent c373ea09b0
commit d40dc9fd99
17 changed files with 176 additions and 185 deletions

View file

@ -1,13 +1,8 @@
# See here for more information
# https://github.com/YunoHost/package_check#syntax-check_process-file
# Move this file from check_process.default to check_process when you have filled it.
;; Test complet ;; Test complet
; Manifest ; Manifest
domain="domain.tld" (DOMAIN) domain="domain.tld"
admin="john" (USER) is_public=1
is_public=1 (PUBLIC|public=1|private=0) admin="john"
allow_multimedia_write=1 allow_multimedia_write=1
; Checks ; Checks
pkg_linter=1 pkg_linter=1
@ -17,7 +12,10 @@
setup_private=1 setup_private=1
setup_public=1 setup_public=1
upgrade=1 upgrade=1
# 0.0.20210329~ynh1
upgrade=1 from_commit=3b5b527e26cb6b530bd51f14c791d1dc15757af4 upgrade=1 from_commit=3b5b527e26cb6b530bd51f14c791d1dc15757af4
# 0.2021.36~ynh1
upgrade=1 from_commit=86a0d1ad46c4fd341cac32103dcaa8b3df832b7e
backup_restore=1 backup_restore=1
multi_instance=0 multi_instance=0
port_already_use=0 port_already_use=0
@ -26,6 +24,3 @@
Email= Email=
Notification=none Notification=none
;;; Upgrade options ;;; Upgrade options
; commit=3b5b527e26cb6b530bd51f14c791d1dc15757af4
name=Upgrade from March 29
manifest_arg=domain=domain.tld&admin=john&is_public=1&allow_multimedia_write=1&

0
doc/.gitkeep Normal file
View file

1
doc/DESCRIPTION.md Normal file
View file

@ -0,0 +1 @@
A photo viewer and manager similar to Google Photos

1
doc/DESCRIPTION_fr.md Normal file
View file

@ -0,0 +1 @@
Un gestionnaire de photos semblable à Google Photos

0
doc/DISCLAIMER.md Normal file
View file

0
doc/DISCLAIMER_fr.md Normal file
View file

0
doc/screenshots/.gitkeep Normal file
View file

View file

@ -6,19 +6,18 @@ app="${0//.\/50-}"
user=$1 user=$1
mail=$2 mail=$2
arch="$(dpkg --print-architecture)"
arm64_test=0 arm64_test=0
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
backend_path="$final_path/backend" backend_path="$final_path/backend"
path_prefix="$backend_path/venv/bin" path_prefix="$backend_path/venv/bin"
if [ "$arch" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then if [ "$YNH_ARCH" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then
export CONDA_DIR="$backend_path/conda" export CONDA_DIR="$backend_path/conda"
path_prefix="$backend_path/cmake/bin:$CONDA_DIR/condabin:$CONDA_DIR/bin:$path_prefix" path_prefix="$backend_path/cmake/bin:$CONDA_DIR/condabin:$CONDA_DIR/bin:$path_prefix"
fi fi
pushd "$backend_path" pushd "$backend_path"
sudo -u $app bash -c " ynh_exec_warn_less ynh_exec_as $app bash -c "
set -a set -a
export PATH=\"$path_prefix:"'$PATH'"\" export PATH=\"$path_prefix:"'$PATH'"\"
source \"$final_path\"/librephotos.env source \"$final_path\"/librephotos.env
@ -33,5 +32,5 @@ try:
user.save() user.save()
except User.DoesNotExist: except User.DoesNotExist:
User.objects.create_user('$user', email='$mail', scan_directory='/home/yunohost.multimedia/$user/Picture') User.objects.create_user('$user', email='$mail', scan_directory='/home/yunohost.multimedia/$user/Picture')
" 2>&1 "
popd popd

View file

@ -6,19 +6,18 @@ app="${0//.\/50-}"
user=$1 user=$1
purge=$2 purge=$2
arch="$(dpkg --print-architecture)"
arm64_test=0 arm64_test=0
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
backend_path="$final_path/backend" backend_path="$final_path/backend"
path_prefix="$backend_path/venv/bin" path_prefix="$backend_path/venv/bin"
if [ "$arch" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then if [ "$YNH_ARCH" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then
export CONDA_DIR="$backend_path/conda" export CONDA_DIR="$backend_path/conda"
path_prefix="$backend_path/cmake/bin:$CONDA_DIR/condabin:$CONDA_DIR/bin:$path_prefix" path_prefix="$backend_path/cmake/bin:$CONDA_DIR/condabin:$CONDA_DIR/bin:$path_prefix"
fi fi
pushd "$backend_path" pushd "$backend_path"
sudo -u $app bash -c " ynh_exec_warn_less ynh_exec_as $app bash -c "
set -a set -a
export PATH=\"$path_prefix:"'$PATH'"\" export PATH=\"$path_prefix:"'$PATH'"\"
source \"$final_path\"/librephotos.env source \"$final_path\"/librephotos.env
@ -34,5 +33,5 @@ try:
user.delete() user.delete()
except User.DoesNotExist: except User.DoesNotExist:
pass pass
" 2>&1 "
popd popd

View file

@ -6,11 +6,11 @@
"en": "A photo viewer and manager similar to Google Photos", "en": "A photo viewer and manager similar to Google Photos",
"fr": "Un gestionnaire de photos semblable à Google Photos" "fr": "Un gestionnaire de photos semblable à Google Photos"
}, },
"version": "0.2021.36~ynh1", "version": "0.2021.36~ynh2",
"url": "https://github.com/LibrePhotos/librephotos", "url": "https://github.com/LibrePhotos/librephotos",
"upstream": { "upstream": {
"license": "MIT", "license": "MIT",
"website": "https://librephotos.com/", "website": "https://librephotos.com",
"demo": "https://demo2.librephotos.com/ (user: demo, password: demo1234)", "demo": "https://demo2.librephotos.com/ (user: demo, password: demo1234)",
"admindoc": "https://docs.librephotos.com/", "admindoc": "https://docs.librephotos.com/",
"userdoc": "https://github.com/LibrePhotos/librephotos", "userdoc": "https://github.com/LibrePhotos/librephotos",
@ -22,7 +22,7 @@
"email": "jules.berthlet@quoi.xyz" "email": "jules.berthlet@quoi.xyz"
}, },
"requirements": { "requirements": {
"yunohost": ">= 4.2.4" "yunohost": ">= 4.3.0"
}, },
"multi_instance": false, "multi_instance": false,
"services": [ "services": [
@ -31,22 +31,20 @@
"postgresql" "postgresql"
], ],
"arguments": { "arguments": {
"install" : [ "install": [
{ {
"name": "domain", "name": "domain",
"type": "domain", "type": "domain"
"example": "example.com"
},
{
"name": "admin",
"type": "user",
"example": "johndoe"
}, },
{ {
"name": "is_public", "name": "is_public",
"type": "boolean", "type": "boolean",
"default": true "default": true
}, },
{
"name": "admin",
"type": "user"
},
{ {
"name": "allow_multimedia_write", "name": "allow_multimedia_write",
"type": "boolean", "type": "boolean",

View file

@ -7,7 +7,8 @@
# 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" 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)" nodejs_version="14"
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
@ -19,7 +20,7 @@ fi
#================================================= #=================================================
function unpack_source { function unpack_source {
ynh_secure_remove "$final_path" ynh_secure_remove --file="$final_path"
mkdir -p "$final_path/data_models/"{places365,im2txt} mkdir -p "$final_path/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="$final_path/data_models/places365/"
ynh_setup_source --source_id="im2txt" --dest_dir="$final_path/data_models/im2txt/" ynh_setup_source --source_id="im2txt" --dest_dir="$final_path/data_models/im2txt/"
@ -35,14 +36,14 @@ function unpack_source {
ynh_setup_source --source_id="backend" --dest_dir="$final_path/backend/" ynh_setup_source --source_id="backend" --dest_dir="$final_path/backend/"
ynh_setup_source --source_id="frontend" --dest_dir="$final_path/frontend/" ynh_setup_source --source_id="frontend" --dest_dir="$final_path/frontend/"
ynh_setup_source --source_id="dlib" --dest_dir="$final_path/backend/dlib/" ynh_setup_source --source_id="dlib" --dest_dir="$final_path/backend/dlib/"
if [ "$arch" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then if [ "$YNH_ARCH" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then
export CONDA_DIR="$final_path/backend/conda" export CONDA_DIR="$final_path/backend/conda"
mkdir -p "$CONDA_DIR" mkdir -p "$CONDA_DIR"
if [ "$arch" = "arm64" ]; then if [ "$YNH_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="$final_path/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
ynh_setup_source --source_id="cmake_amd64" --dest_dir="$final_path/backend/cmake/" ynh_setup_source --source_id="cmake_amd64" --dest_dir="$final_path/backend/cmake/"
fi fi
#ynh_setup_source --source_id="faiss" --dest_dir="$final_path/backend/faiss/" #ynh_setup_source --source_id="faiss" --dest_dir="$final_path/backend/faiss/"
@ -55,24 +56,24 @@ function set_up_backend {
backend_path="$final_path/backend" backend_path="$final_path/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 ynh_exec_warn_less ynh_exec_as $app python3 -m venv $backend_path/venv
path_prefix="$backend_path/venv/bin" path_prefix="$backend_path/venv/bin"
if [ "$arch" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then if [ "$YNH_ARCH" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then
path_prefix="$backend_path/cmake/bin:$CONDA_DIR/condabin:$CONDA_DIR/bin:$path_prefix" path_prefix="$backend_path/cmake/bin:$CONDA_DIR/condabin:$CONDA_DIR/bin:$path_prefix"
fi fi
local python_path="$path_prefix:$(sudo -u $app bash -c 'echo $PATH')" local python_path="$path_prefix:$(ynh_exec_warn_less ynh_exec_as $app bash -c 'echo $PATH')"
local cache_dir="$backend_path/.cache/pip" local cache_dir="$backend_path/.cache/pip"
sudo -u $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U wheel pip setuptools 2>&1 ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U wheel pip setuptools
if [ "$arch" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then if [ "$YNH_ARCH" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then
sudo -u $app env "CONDA_DIR=$CONDA_DIR" bash "${CONDA_DIR}/Miniforge3-4.10.1-4-Linux-aarch64.sh" -bu -p "${CONDA_DIR}" ynh_exec_warn_less ynh_exec_as $app env "CONDA_DIR=$CONDA_DIR" bash "${CONDA_DIR}/Miniforge3-4.10.1-4-Linux-aarch64.sh" -bu -p "${CONDA_DIR}"
sudo -u $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U torch==1.8.1 torchvision==0.9.1 -f https://torch.maku.ml/whl/stable.html 2>&1 ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U torch==1.8.1 torchvision==0.9.1 -f https://torch.maku.ml/whl/stable.html
sudo -u $app env "PATH=$python_path" conda install -y numpy psycopg2 cython pandas scikit-learn=0.24.1 scikit-image=0.18.1 spacy=2.3.5 gevent=20.12.1 matplotlib=3.3.2 faiss-cpu==1.7.0 ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" conda install -y numpy psycopg2 cython pandas scikit-learn=0.24.1 scikit-image=0.18.1 spacy=2.3.5 gevent=20.12.1 matplotlib=3.3.2 faiss-cpu==1.7.0
#pushd "$backend_path/faiss" #pushd "$backend_path/faiss"
# sudo -u $app env "PATH=$python_path" cmake -B build . -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=ON -DFAISS_OPT_LEVEL=generic # ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" cmake -B build . -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=ON -DFAISS_OPT_LEVEL=generic
# sudo -u $app env "PATH=$python_path" make -C build -j faiss # ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" make -C build -j faiss
# sudo -u $app env "PATH=$python_path" make -C build -j swigfaiss # ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" make -C build -j swigfaiss
# cd "build/faiss/python" # cd "build/faiss/python"
# sudo -u $app env "PATH=$python_path" python setup.py install # ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" python setup.py install
#popd #popd
sed -i "/spacy==2.3.2/d" "$backend_path/requirements.txt" sed -i "/spacy==2.3.2/d" "$backend_path/requirements.txt"
sed -i "/sklearn==0.0/d" "$backend_path/requirements.txt" sed -i "/sklearn==0.0/d" "$backend_path/requirements.txt"
@ -82,15 +83,15 @@ function set_up_backend {
sed -i "s/Pillow==8.1.0/Pillow>=8.1.2/" "$backend_path/requirements.txt" sed -i "s/Pillow==8.1.0/Pillow>=8.1.2/" "$backend_path/requirements.txt"
sed -i "/faiss-cpu==1.7.0/d" "$backend_path/requirements.txt" sed -i "/faiss-cpu==1.7.0/d" "$backend_path/requirements.txt"
else else
sudo -u $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U torch==1.8.0+cpu torchvision==0.9.0+cpu -f https://download.pytorch.org/whl/torch_stable.html 2>&1 ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U torch==1.8.0+cpu torchvision==0.9.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
fi fi
pushd "$backend_path/dlib" pushd "$backend_path/dlib"
sudo -u $app env "PATH=$python_path" python setup.py install 2>&1 ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" python setup.py install
popd popd
sudo -u $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U --requirement "$backend_path/requirements.txt" 2>&1 ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U --requirement "$backend_path/requirements.txt"
sudo -u $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U --requirement "$backend_path/requirements-ynh.txt" 2>&1 ynh_exec_warn_less ynh_exec_as $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U --requirement "$backend_path/requirements-ynh.txt"
#if [ "$arch" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then #if [ "$YNH_ARCH" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then
#sudo -u $app unzip "$CONDA_DIR/lib/python3.8/site-packages/"faiss*.egg -d "$CONDA_DIR/lib/python3.8/site-packages/" #ynh_exec_warn_less ynh_exec_as $app unzip "$CONDA_DIR/lib/python3.8/site-packages/"faiss*.egg -d "$CONDA_DIR/lib/python3.8/site-packages/"
#fi #fi
chown -R root:root "$backend_path" chown -R root:root "$backend_path"
popd popd
@ -98,14 +99,14 @@ function set_up_backend {
function install_dlib { function install_dlib {
pushd "$backend_path/dlib" pushd "$backend_path/dlib"
sudo -u $app "$backend_path/venv/bin/python" setup.py install 2>&1 ynh_exec_warn_less ynh_exec_as $app "$backend_path/venv/bin/python" setup.py install
popd popd
} }
function set_node_vars { function set_node_vars {
ynh_exec_warn_less ynh_install_nodejs --nodejs_version=13 ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version
ynh_use_nodejs ynh_use_nodejs
node_PATH=$nodejs_path:$(sudo -u $app sh -c 'echo $PATH') node_PATH=$nodejs_path:$(ynh_exec_warn_less ynh_exec_as $app sh -c 'echo $PATH')
} }
@ -114,10 +115,10 @@ function set_up_frontend {
frontend_path=$final_path/frontend frontend_path=$final_path/frontend
pushd $final_path/frontend pushd $final_path/frontend
chown -R $app:$app $frontend_path chown -R $app:$app $frontend_path
sudo -u $app touch $frontend_path/.yarnrc ynh_exec_warn_less ynh_exec_as $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 ynh_exec_warn_less ynh_exec_as $app env "PATH=$node_PATH" yarn --cache-folder $frontend_path/yarn-cache --use-yarnrc $frontend_path/.yarnrc install --legacy-peer-deps
sudo -u $app env "PATH=$node_PATH" yarn --cache-folder $frontend_path/yarn-cache --use-yarnrc $frontend_path/.yarnrc run build 2>&1 ynh_exec_warn_less ynh_exec_as $app env "PATH=$node_PATH" yarn --cache-folder $frontend_path/yarn-cache --use-yarnrc $frontend_path/.yarnrc run build
sudo -u $app env "PATH=$node_PATH" yarn --cache-folder $frontend_path/yarn-cache --use-yarnrc $frontend_path/.yarnrc add serve 2>&1 ynh_exec_warn_less ynh_exec_as $app env "PATH=$node_PATH" yarn --cache-folder $frontend_path/yarn-cache --use-yarnrc $frontend_path/.yarnrc add serve
chown -R root:root $frontend_path chown -R root:root $frontend_path
popd popd
} }
@ -137,14 +138,14 @@ function upgrade_db {
pushd "$final_path/backend" pushd "$final_path/backend"
chown -R $app:$app "$final_path/backend" chown -R $app:$app "$final_path/backend"
chown -R $app:$app "/var/log/$app" chown -R $app:$app "/var/log/$app"
sudo -u $app bash -c " ynh_exec_warn_less ynh_exec_as $app bash -c "
set -a set -a
export PATH=\"$path_prefix:"'$PATH'"\" export PATH=\"$path_prefix:"'$PATH'"\"
source \"$final_path\"/librephotos.env source \"$final_path\"/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
" 2>&1 "
popd popd
set_permissions set_permissions
} }

View file

@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting true
} }
# 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 ynh_abort_if_errors
@ -43,6 +43,12 @@ ynh_print_info --message="Declaring files to be backed up..."
ynh_backup --src_path="$final_path" ynh_backup --src_path="$final_path"
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$data_path" --is_big
#================================================= #=================================================
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
@ -71,7 +77,6 @@ ynh_backup --src_path="/etc/systemd/system/$app-worker.service"
#================================================= #=================================================
ynh_backup --src_path="/var/log/$app" ynh_backup --src_path="/var/log/$app"
ynh_backup --src_path="$data_path" --is_big
#================================================= #=================================================
# BACKUP THE POSTGRESQL DATABASE # BACKUP THE POSTGRESQL DATABASE
@ -83,4 +88,5 @@ ynh_psql_dump_db --database="$db_name" > db.sql
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -12,6 +12,7 @@ source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
#================================================= #=================================================
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting ynh_clean_check_starting
} }
@ -24,9 +25,10 @@ ynh_abort_if_errors
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path_url="/" path_url="/"
admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
admin=$YNH_APP_ARG_ADMIN
allow_multimedia_write=$YNH_APP_ARG_ALLOW_MULTIMEDIA_WRITE allow_multimedia_write=$YNH_APP_ARG_ALLOW_MULTIMEDIA_WRITE
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
@ -78,6 +80,14 @@ ynh_script_progression --message="Installing dependencies..." --weight=5
ynh_install_app_dependencies $pkg_dependencies 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" 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
# Create a system user
ynh_system_user_create --username=$app --home_dir=$data_path
#================================================= #=================================================
# CREATE A POSTGRESQL DATABASE # CREATE A POSTGRESQL DATABASE
#================================================= #=================================================
@ -102,15 +112,7 @@ unpack_source
ynh_script_progression --message="Configuring NGINX web server..." --weight=1 ynh_script_progression --message="Configuring NGINX web server..." --weight=1
# Create a dedicated NGINX config # Create a dedicated NGINX config
ynh_add_nginx_config backend_port ynh_add_nginx_config
#=================================================
# CREATE DEDICATED USER
#=================================================
ynh_script_progression --message="Configuring system user..." --weight=1
# Create a system user
ynh_system_user_create --username=$app --home_dir=$data_path
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
@ -155,15 +157,15 @@ upgrade_db
pushd "$final_path/backend" pushd "$final_path/backend"
admin_mail="$(ynh_user_get_info $admin 'mail')" admin_mail="$(ynh_user_get_info $admin 'mail')"
sudo -u $app bash -c " ynh_exec_warn_less ynh_exec_as $app bash -c "
set -a set -a
export PATH=\"$path_prefix:"'$PATH'"\" export PATH=\"$path_prefix:"'$PATH'"\"
source \"$final_path\"/librephotos.env source \"$final_path\"/librephotos.env
python3 manage.py createsuperuser --noinput --username \"$admin\" --email \"$admin_mail\" python3 manage.py createsuperuser --noinput --username \"$admin\" --email \"$admin_mail\"
" 2>&1 "
for user in $(ynh_user_list); do for user in $(ynh_user_list); do
mail=$(ynh_user_get_info --username="$user" --key=mail) mail=$(ynh_user_get_info --username="$user" --key=mail)
sudo -u $app bash -c " ynh_exec_warn_less ynh_exec_as $app bash -c "
set -a set -a
export PATH=\"$path_prefix:"'$PATH'"\" export PATH=\"$path_prefix:"'$PATH'"\"
source \"$final_path\"/librephotos.env source \"$final_path\"/librephotos.env
@ -177,7 +179,7 @@ try:
user.save() user.save()
except User.DoesNotExist: except User.DoesNotExist:
User.objects.create_user('$user', email='$mail', scan_directory='/home/yunohost.multimedia/$user/Picture') User.objects.create_user('$user', email='$mail', scan_directory='/home/yunohost.multimedia/$user/Picture')
" 2>&1 "
done done
popd popd
@ -192,8 +194,6 @@ if [ $allow_multimedia_write -eq 1 ]; then
ynh_multimedia_addaccess $app ynh_multimedia_addaccess $app
fi fi
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SECURE FILES AND DIRECTORIES # SECURE FILES AND DIRECTORIES
#================================================= #=================================================
@ -201,6 +201,8 @@ fi
# Set permissions to app files # Set permissions to app files
set_permissions set_permissions
#=================================================
# GENERIC FINALIZATION
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
@ -254,4 +256,5 @@ ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Installation of $app completed" --last ynh_script_progression --message="Installation of $app completed" --last

View file

@ -29,8 +29,6 @@ data_path=$(ynh_app_setting_get --app=$app --key=data_path)
# REMOVE SERVICE INTEGRATION IN YUNOHOST # REMOVE SERVICE INTEGRATION IN YUNOHOST
#================================================= #=================================================
ynh_script_progression --message="Removing $app services integration..." --weight=1
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app-backend >/dev/null ; then if ynh_exec_warn_less yunohost service status $app-backend >/dev/null ; then
yunohost service remove $app-backend yunohost service remove $app-backend
@ -59,6 +57,14 @@ ynh_remove_systemd_config --service="$app-frontend"
ynh_remove_systemd_config --service="$app-image-similarity" ynh_remove_systemd_config --service="$app-image-similarity"
ynh_remove_systemd_config --service="$app-worker" ynh_remove_systemd_config --service="$app-worker"
#=================================================
# REMOVE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1
# Remove the app-specific logrotate config
ynh_remove_logrotate
#================================================= #=================================================
# REMOVE THE POSTGRESQL DATABASE # REMOVE THE POSTGRESQL DATABASE
#================================================= #=================================================
@ -67,14 +73,6 @@ ynh_script_progression --message="Removing the PostgreSQL database..." --weight=
# 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 ynh_psql_remove_db --db_user=$db_user --db_name=$db_name
#=================================================
# REMOVE DEPENDENCIES
#=================================================
ynh_script_progression --message="Removing dependencies..." --weight=30
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR
#================================================= #=================================================
@ -100,18 +98,12 @@ ynh_script_progression --message="Removing NGINX web server configuration..." --
ynh_remove_nginx_config ynh_remove_nginx_config
#================================================= #=================================================
# REMOVE LOGROTATE CONFIGURATION # REMOVE DEPENDENCIES
#================================================= #=================================================
ynh_script_progression --message="Removing logrotate configuration..." --weight=1 ynh_script_progression --message="Removing dependencies..." --weight=30
# Remove the app-specific logrotate config
ynh_remove_logrotate
#=================================================
# REMOVE NODE
#=================================================
ynh_script_progression --message="Removing Node.js..." --weight=1
# Remove metapackage and its dependencies
ynh_remove_app_dependencies
ynh_remove_nodejs ynh_remove_nodejs
#================================================= #=================================================
@ -136,4 +128,5 @@ ynh_system_user_delete --username=$app
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Removal of $app completed" --last ynh_script_progression --message="Removal of $app completed" --last

View file

@ -39,14 +39,11 @@ port=$(ynh_app_setting_get --app=$app --key=port)
backend_port=$(ynh_app_setting_get --app=$app --key=port) backend_port=$(ynh_app_setting_get --app=$app --key=port)
similarity_port=$(ynh_app_setting_get --app=$app --key=similarity_port) 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 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 \ test ! -d $final_path \
|| ynh_die --message="There is already a directory: $final_path " || ynh_die --message="There is already a directory: $final_path "
@ -56,10 +53,12 @@ test ! -d $data_path \
#================================================= #=================================================
# STANDARD RESTORATION STEPS # STANDARD RESTORATION STEPS
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$data_path
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
@ -69,9 +68,9 @@ ynh_script_progression --message="Restoring the app main directory..." --weight=
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
#================================================= #=================================================
# RESTORE THE APP DATA DIR # RESTORE THE DATA DIRECTORY
#================================================= #=================================================
ynh_script_progression --message="Restoring the app data directory..." --weight=1 ynh_script_progression --message="Restoring the data directory..." --weight=1
ynh_restore_file --origin_path="$data_path" --not_mandatory 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}
@ -80,25 +79,14 @@ mkdir -p $data_path/matplotlib
ln -s $final_path/data_models $data_path/data_models ln -s $final_path/data_models $data_path/data_models
#================================================= #=================================================
# RECREATE THE DEDICATED USER # RESTORE USER RIGHTS
#=================================================
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
#=================================================
# RESTORE VARIOUS FILES
#================================================= #=================================================
ynh_restore_file --origin_path="/var/log/$app" # Restore permissions on app files
set_permissions
#================================================= #=================================================
# RESTORE THE LOGROTATE CONFIGURATION # SPECIFIC RESTORATION
#=================================================
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# REINSTALL DEPENDENCIES # REINSTALL DEPENDENCIES
#================================================= #=================================================
@ -109,11 +97,18 @@ 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" 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 NODE.JS
#================================================= #=================================================
ynh_script_progression --message="Restoring Node.js..." --weight=1
# Restore permissions on app files set_node_vars
set_permissions
#=================================================
# RESTORE THE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the NGINX web server configuration..."
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# SPECIFIC RESTORATION # SPECIFIC RESTORATION
@ -127,11 +122,21 @@ 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
#================================================= #=================================================
# RESTORE NODE.JS # RESTORE VARIOUS FILES
#================================================= #=================================================
ynh_script_progression --message="Restoring Node.js..." --weight=1
set_node_vars ynh_restore_file --origin_path="/var/log/$app"
#=================================================
# YUNOHOST MULTIMEDIA INTEGRATION
#=================================================
ynh_script_progression --message="Adding multimedia directories..." --weight=1
# Build YunoHost multimedia directories
ynh_multimedia_build_main_dir
if [ $allow_multimedia_write -eq 1 ]; then
ynh_multimedia_addaccess $app
fi
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
@ -147,6 +152,13 @@ systemctl enable $app-image-similarity.service --quiet
ynh_restore_file --origin_path="/etc/systemd/system/$app-worker.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-worker.service"
systemctl enable $app-worker.service --quiet systemctl enable $app-worker.service --quiet
#=================================================
# RESTORE THE LOGROTATE CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the logrotate configuration..."
ynh_restore_file --origin_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# INTEGRATE SERVICE IN YUNOHOST # INTEGRATE SERVICE IN YUNOHOST
#================================================= #=================================================
@ -167,17 +179,6 @@ ynh_systemd_action --service_name=$app-frontend --action="start" --log_path="sys
ynh_systemd_action --service_name=$app-image-similarity --action="start" --log_path="/var/log/$app/image_similarity.log" ynh_systemd_action --service_name=$app-image-similarity --action="start" --log_path="/var/log/$app/image_similarity.log"
ynh_systemd_action --service_name=$app-worker --action="start" --log_path="/var/log/$app/$app-worker.log" ynh_systemd_action --service_name=$app-worker --action="start" --log_path="/var/log/$app/$app-worker.log"
#=================================================
# YUNOHOST MULTIMEDIA INTEGRATION
#=================================================
ynh_script_progression --message="Adding multimedia directories..." --weight=1
# Build YunoHost multimedia directories
ynh_multimedia_build_main_dir
if [ $allow_multimedia_write -eq 1 ]; then
ynh_multimedia_addaccess $app
fi
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
@ -190,4 +191,5 @@ ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --last ynh_script_progression --message="Restoration completed for $app" --last

View file

@ -18,9 +18,9 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain) domain=$(ynh_app_setting_get --app=$app --key=domain)
path_url=$(ynh_app_setting_get --app=$app --key=path) path_url=$(ynh_app_setting_get --app=$app --key=path)
language=$(ynh_app_setting_get --app=$app --key=language)
admin=$(ynh_app_setting_get --app=$app --key=admin) admin=$(ynh_app_setting_get --app=$app --key=admin)
final_path=$(ynh_app_setting_get --app=$app --key=final_path) final_path=$(ynh_app_setting_get --app=$app --key=final_path)
language=$(ynh_app_setting_get --app=$app --key=language)
db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd)
@ -33,6 +33,7 @@ allow_multimedia_write=$(ynh_app_setting_get --app=$app --key=allow_multimedia_w
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
#================================================= #=================================================
ynh_script_progression --message="Checking version..."
upgrade_type=$(ynh_check_app_version_changed) upgrade_type=$(ynh_check_app_version_changed)
@ -44,6 +45,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take
# Backup the current version of the app # Backup the current version of the app
ynh_backup_before_upgrade ynh_backup_before_upgrade
ynh_clean_setup () { ynh_clean_setup () {
ynh_clean_check_starting
# Restore it if the upgrade fails # Restore it if the upgrade fails
ynh_restore_upgradebackup ynh_restore_upgradebackup
} }
@ -73,6 +75,14 @@ if [ "$nodejs_version" -eq 10 ]; then
ynh_remove_nodejs ynh_remove_nodejs
fi fi
#=================================================
# CREATE DEDICATED USER
#=================================================
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
#================================================= #=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE # DOWNLOAD, CHECK AND UNPACK SOURCE
#================================================= #=================================================
@ -82,14 +92,6 @@ then
unpack_source unpack_source
fi fi
#=================================================
# NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated NGINX config
ynh_add_nginx_config backend_port
#================================================= #=================================================
# UPGRADE DEPENDENCIES # UPGRADE DEPENDENCIES
#================================================= #=================================================
@ -99,12 +101,12 @@ 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" 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 # NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1
# Create a dedicated user (if not existing) # Create a dedicated NGINX config
ynh_system_user_create --username=$app --home_dir=$data_path ynh_add_nginx_config backend_port
#================================================= #=================================================
# SPECIFIC UPGRADE # SPECIFIC UPGRADE
@ -122,17 +124,6 @@ ynh_script_progression --message="Setting up frontend..." --weight=5
set_up_frontend set_up_frontend
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configurations..." --weight=1
# Create dedicated systemd configs
ynh_add_systemd_config --service=$app-backend --template=backend.service
ynh_add_systemd_config --service=$app-frontend --template=frontend.service
ynh_add_systemd_config --service=$app-image-similarity --template=image-similarity.service
ynh_add_systemd_config --service=$app-worker --template=worker.service
#================================================= #=================================================
# ADD CONFIGURATIONS # ADD CONFIGURATIONS
#================================================= #=================================================
@ -147,6 +138,13 @@ ynh_script_progression --message="Finalizing database..." --weight=1
upgrade_db upgrade_db
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
set_permissions
#================================================= #=================================================
# YUNOHOST MULTIMEDIA INTEGRATION # YUNOHOST MULTIMEDIA INTEGRATION
#================================================= #=================================================
@ -158,15 +156,19 @@ if [ $allow_multimedia_write -eq 1 ]; then
ynh_multimedia_addaccess $app ynh_multimedia_addaccess $app
fi fi
#=================================================
# SETUP SYSTEMD
#=================================================
ynh_script_progression --message="Upgrading systemd configurations..." --weight=1
# Create dedicated systemd configs
ynh_add_systemd_config --service=$app-backend --template=backend.service
ynh_add_systemd_config --service=$app-frontend --template=frontend.service
ynh_add_systemd_config --service=$app-image-similarity --template=image-similarity.service
ynh_add_systemd_config --service=$app-worker --template=worker.service
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#=================================================
# SECURE FILES AND DIRECTORIES
#=================================================
# Set permissions to app files
set_permissions
#================================================= #=================================================
# SETUP LOGROTATE # SETUP LOGROTATE
#================================================= #=================================================
@ -206,4 +208,5 @@ ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --last ynh_script_progression --message="Upgrade of $app completed" --last

View file

@ -2,21 +2,11 @@ diff --git a/image_similarity/main.py b/image_similarity/main.py
index 9ca6660..9a33d98 100644 index 9ca6660..9a33d98 100644
--- a/image_similarity/main.py --- a/image_similarity/main.py
+++ b/image_similarity/main.py +++ b/image_similarity/main.py
@@ -7,6 +7,8 @@ from retrieval_index import RetrievalIndex @@ -58,6 +58,6 @@
from utils import logger if __name__ == "__main__":
logger.info("starting server")
+import os - server = WSGIServer(("0.0.0.0", 8002), app)
+ + server = WSGIServer(("0.0.0.0", int(os.environ['IMAGE_SIMILARITY_SERVER_PORT'])), app)
app = Flask(__name__)
api = Api(app)
@@ -48,7 +50,7 @@ api.add_resource(SearchIndex,'/search/')
if __name__ == '__main__':
logger.info('starting server')
- server = WSGIServer(('0.0.0.0', 8002), app)
+ server = WSGIServer(('0.0.0.0', int(os.environ['IMAGE_SIMILARITY_SERVER_PORT'])), app)
server_thread = gevent.spawn(server.serve_forever) server_thread = gevent.spawn(server.serve_forever)
gevent.joinall([server_thread]) gevent.joinall([server_thread])