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

Update to version 2020-06-09, add ARM support

This commit is contained in:
Jules Bertholet 2021-06-10 16:03:39 -04:00
parent eb48dc2d23
commit e9e2814f6c
22 changed files with 167 additions and 118 deletions

View file

@ -11,7 +11,7 @@ If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/in
## Overview
LibrePhotos is a Google Photos-like app. It supports automatic classification of faces, grouping photos by date, location, or objects present, and album creation.
**Shipped version:** 2021-05-31
**Shipped version:** 2021-06-09
## Screenshots

View file

@ -11,7 +11,7 @@ Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install
## Vue d'ensemble
LibrePhotos est un sercice inspiré par Google Photos. Il prend en charge la classification des visages, le groupement des photos par date, la localisation géographique, ou objets présents, et la création d'albums.
**Version incluse :** 2021-05-31
**Version incluse :** 2021-06-09
## Captures d'écran

View file

@ -9,8 +9,10 @@ Requires=postgresql.service
User=__APP__
Group=__APP__
EnvironmentFile=__FINALPATH__/librephotos.env
ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/backend/venv/bin:$PATH exec __FINALPATH__/bin/librephotos-backend"
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
StandardOutput=append:/var/log/__APP__/__APP__-backend.log
StandardError=inherit
[Install]
WantedBy=multi-user.target

View file

@ -1,7 +1,7 @@
SOURCE_URL=https://github.com/LibrePhotos/librephotos/tarball/bd4fabf104ea818a4b8fae61e6e41c08ad89ba16
SOURCE_SUM=6cd32a2d75173c851aed76b8f045f95b67fafac4be9ff499c498c6ceba843eb2
SOURCE_URL=https://github.com/LibrePhotos/librephotos/tarball/67ea61a79dadff8772fa2e7915239840e45a630c
SOURCE_SUM=b166abb70d2fe3870c8fedda2f9bd1fac856ce44312572a34272b99b24f1929d
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=bd4fabf104ea818a4b8fae61e6e41c08ad89ba16
SOURCE_FILENAME=67ea61a79dadff8772fa2e7915239840e45a630c
SOURCE_EXTRACT=true

7
conf/cmake.src Normal file
View file

@ -0,0 +1,7 @@
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

7
conf/cmake_amd64.src Normal file
View file

@ -0,0 +1,7 @@
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

@ -6,8 +6,10 @@ Documentation=https://github.com/LibrePhotos/librephotos
User=__APP__
Group=__APP__
EnvironmentFile=__FINALPATH__/librephotos.env
ExecStart=__FINALPATH__/bin/librephotos-frontend
ExecStart=/usr/bin/env bash -c "PATH=__PATH_PREFIX__:$PATH ./node_modules/.bin/serve build -d -l $httpPort"
WorkingDirectory=__FINALPATH__/frontend
StandardOutput=append:/var/log/__APP__/__APP__-frontend.log
StandardError=inherit
[Install]
WantedBy=multi-user.target

7
conf/im2txt.src Normal file
View file

@ -0,0 +1,7 @@
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

@ -1,7 +0,0 @@
SOURCE_URL=https://s3.eu-central-1.amazonaws.com/ownphotos-deploy/im2txt_data.tar.gz
SOURCE_SUM=2011aa4e7a036458db571fe2583f7b377158ab0b0c3a1dcedefa824dff8b2ee7
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=im2txt_data.tar.gz
SOURCE_EXTRACT=true

View file

@ -1,7 +0,0 @@
SOURCE_URL=https://s3.eu-central-1.amazonaws.com/ownphotos-deploy/im2txt_model.tar.gz
SOURCE_SUM=05015f7819190c1d8d4dea18eebf21fec12c2c5f7eb8b878930faeb465c27d88
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=im2txt_model.tar.gz
SOURCE_EXTRACT=true

View file

@ -8,8 +8,11 @@ After=network.target
User=__APP__
Group=__APP__
EnvironmentFile=__FINALPATH__/librephotos.env
ExecStart=/usr/bin/env bash -c "PATH=__FINALPATH__/backend/venv/bin:$PATH exec __FINALPATH__/bin/librephotos-image-similarity"
ExecStart=/usr/bin/env bash -c "PATH=__PATH_PREFIX__:$PATH python3 image_similarity/main.py"
WorkingDirectory=__FINALPATH__/backend
StandardOutput=append:/var/log/__APP__/__APP__-image-similarity.log
StandardError=inherit
[Install]
WantedBy=multi-user.target

View file

@ -27,3 +27,4 @@ BACKEND_PORT=__BACKEND_PORT__
IMAGE_SIMILARITY_SERVER_PORT=__SIMILARITY_PORT__
MPLCONFIGDIR=__DATA_PATH__/matplotlib
NODEJS_PATH=__NODEJS_PATH__
DJANGO_SETTINGS_MODULE=ownphotos.settings

View file

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

7
conf/places365.src Normal file
View file

@ -0,0 +1,7 @@
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://s3.eu-central-1.amazonaws.com/ownphotos-deploy/places365_model.tar.gz
SOURCE_SUM=2ded264e09efb6af4bf21c341edc359de60b646b7529d61428882a563b9dfad1
SOURCE_SUM_PRG=sha256sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_FILENAME=places365_model.tar.gz
SOURCE_EXTRACT=true

View file

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

View file

@ -3,13 +3,27 @@ set -a
source /usr/share/yunohost/helpers
app="${0//.\/50-}"
username=$1
user=$1
mail=$2
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
arch="$(dpkg --print-architecture)"
arm64_test=1
pushd $final_path/backend
sudo -u $app $final_path/bin/librephotos-cli shell <<< "
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
backend_path="$final_path/backend"
path_prefix="$backend_path/venv/bin"
if [ "$arch" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then
export CONDA_DIR="$backend_path/conda"
path_prefix="$backend_path/cmake/bin:$CONDA_DIR/condabin:$CONDA_DIR/bin:$path_prefix"
fi
pushd "$backend_path"
sudo -u $app bash -c "
set -a
export PATH=\"$path_prefix:"'$PATH'"\"
source \"$final_path\"/librephotos.env
python3 manage.py shell
" <<< "
from django.contrib.auth import get_user_model
User = get_user_model()
try:
@ -18,6 +32,6 @@ try:
user.is_active = True
user.save()
except User.DoesNotExist:
User.objects.create_user('$username', 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

View file

@ -3,13 +3,27 @@ set -a
source /usr/share/yunohost/helpers
app="${0//.\/50-}"
username=$1
user=$1
purge=$2
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
arch="$(dpkg --print-architecture)"
arm64_test=1
pushd $final_path/backend
sudo -u $app $final_path/bin/librephotos-cli shell <<< "
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
backend_path="$final_path/backend"
path_prefix="$backend_path/venv/bin"
if [ "$arch" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then
export CONDA_DIR="$backend_path/conda"
path_prefix="$backend_path/cmake/bin:$CONDA_DIR/condabin:$CONDA_DIR/bin:$path_prefix"
fi
pushd "$backend_path"
sudo -u $app bash -c "
set -a
export PATH=\"$path_prefix:"'$PATH'"\"
source \"$final_path\"/librephotos.env
python3 manage.py shell
" <<< "
from django.contrib.auth import get_user_model
User = get_user_model()
try:

View file

@ -6,8 +6,16 @@
"en": "A photo viewer and manager similar to Google Photos",
"fr": "Un gestionnaire de photos semblable à Google Photos"
},
"version": "0.0.20210531~ynh1",
"version": "0.0.20210609~ynh1",
"url": "https://github.com/LibrePhotos/librephotos",
"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"
},
"license": "MIT",
"maintainer": {
"name": "Jules Bertholet",
@ -45,7 +53,7 @@
"default": false,
"ask": {
"en": "Allow write access to multimedia directories?",
"fr": "Autorizer la modification des fichiers dans les dossiers multimédia ?"
"fr": "Autoriser la modification des fichiers dans les dossiers multimédia ?"
}
}
]

View file

@ -5,9 +5,10 @@
#=================================================
# dependencies used by the app
pkg_dependencies="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 ufraw-batch"
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 ufraw-batch"
arch="$(dpkg --print-architecture)"
arm64_test=1
#=================================================
# PERSONAL HELPERS
@ -16,9 +17,8 @@ arch="$(dpkg --print-architecture)"
function unpack_source {
ynh_secure_remove "$final_path"
mkdir -p "$final_path/data_models/"{places365,im2txt}
ynh_setup_source --source_id="places365_model" --dest_dir="$final_path/data_models/places365/model/"
ynh_setup_source --source_id="im2txt_model" --dest_dir="$final_path/data_models/im2txt/model/"
ynh_setup_source --source_id="im2txt_data" --dest_dir="$final_path/data_models/im2txt/data/"
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/"
mkdir -p "$data_path"
ln -sf "$final_path/data_models" "$data_path/data_models"
mkdir -p "$data_path/protected_media/"{thumbnails_big,square_thumbnails,square_thumbnails_small,faces}
@ -30,39 +30,43 @@ function unpack_source {
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="linux" --dest_dir="$final_path/linux/"
ynh_setup_source --source_id="dlib" --dest_dir="$final_path/backend/dlib/"
if [ "$arch" = "aarch64" ]; then
if [ "$arch" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then
export CONDA_DIR="$final_path/backend/conda"
mkdir -p "$CONDA_DIR"
ynh_setup_source --source_id="miniforge3" --dest_dir="$CONDA_DIR"
ynh_setup_source --source_id="faiss" --dest_dir="$final_path/backend/faiss/"
if [ "$arch" = "arm64" ]; then
ynh_setup_source --source_id="miniforge3" --dest_dir="$CONDA_DIR"
ynh_setup_source --source_id="cmake" --dest_dir="$final_path/backend/cmake/"
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
ynh_setup_source --source_id="cmake_amd64" --dest_dir="$final_path/backend/cmake/"
fi
ynh_setup_source --source_id="faiss" --dest_dir="$final_path/backend/faiss/"
fi
mkdir -p "$final_path/bin"
mv -f "$final_path/linux/ressources/bin/"* "$final_path/bin"
ynh_secure_remove --file="$final_path/linux"
mkdir -p "/var/log/$app"
}
function set_up_virtualenv {
function set_up_backend {
backend_path="$final_path/backend"
pushd "$backend_path"
chown -R $app:$app "$backend_path"
sudo -u $app python3 -m venv $backend_path/venv
local python_path="$backend_path/venv/bin:$(sudo -u $app bash -c 'echo $PATH')"
path_prefix="$backend_path/venv/bin"
if [ "$arch" = "arm64" ] || [ "$arm64_test" -eq 1 ]; then
path_prefix="$backend_path/cmake/bin:$CONDA_DIR/condabin:$CONDA_DIR/bin:$path_prefix"
fi
local python_path="$path_prefix:$(sudo -u $app bash -c 'echo $PATH')"
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
if [ "$arch" = "aarch64" ]; then
sudo -u $app "$pip" --cache-dir "$cache_dir" install -U torch==1.8.0 torchvision==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html 2>&1 || sudo -u $app "$pip" --cache-dir "$cache_dir" install -U torch==1.8.0 torchvision==0.9.0 -f https://torch.maku.ml/whl/stable.html 2>&1
sudo -u $app env "CONDA_DIR=$CONDA_DIR" bash "${CONDA_DIR}/Miniforge3-4.10.1-4-Linux-aarch64.sh" -b -p "${CONDA_DIR}"
local conda="$CONDA_DIR/condabin/conda"
python_path="$CONDA_DIR/condabin:$CONDA_DIR/bin:$python_path"
if [ "$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}"
sudo -u $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U torch==1.8.0 torchvision==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html 2>&1
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
pushd "$backend_path/faiss"
sudo -u $app cmake -B build .
sudo -u $app make -C build -j faiss
sudo -u $app make -C build -j swigfaiss
sudo -u $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
sudo -u $app env "PATH=$python_path" make -C build -j swigfaiss
cd "build/faiss/python"
sudo -u $app env "PATH=$python_path" python setup.py install
popd
@ -74,7 +78,7 @@ function set_up_virtualenv {
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"
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 || sudo -u $app "$pip" --cache-dir "$cache_dir" install -U torch==1.8.0 torchvision==0.9.0 -f https://download.pytorch.org/whl/torch_stable.html 2>&1
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
fi
pushd "$backend_path/dlib"
sudo -u $app env "PATH=$python_path" python setup.py install 2>&1
@ -82,9 +86,9 @@ function set_up_virtualenv {
sudo -u $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U --requirement "$backend_path/requirements.txt" 2>&1
sudo -u $app env "PATH=$python_path" pip --cache-dir "$cache_dir" install -U --requirement "$backend_path/requirements-ynh.txt" 2>&1
sudo -u $app env "PATH=$python_path" python -m spacy download en_core_web_sm 2>&1
if [ "$arch" = "aarch64" ]; then
unzip "$CONDA_DIR/lib/python3.8/site-packages/"faiss*.egg -d "$CONDA_DIR/lib/python3.8/site-packages/"
fi
#if [ "$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/"
#fi
chown -R root:root "$backend_path"
popd
}
@ -124,27 +128,22 @@ function add_configuations {
fi
ynh_add_config --template="librephotos.env" --destination="$final_path/librephotos.env"
}
for file in $final_path/bin/*; do
ynh_replace_string -m '#!/usr/bin/env bash' -r "#!/usr/bin/env bash\nsource $final_path/librephotos.env" -f $file
echo "$(uniq $file)" > $file
ynh_replace_string -m "source $final_path/librephotos.env" -r "source $final_path/librephotos.env\nexport PATH=\$NODEJS_PATH:\$PATH" -f $file
echo "$(uniq $file)" > $file
ynh_replace_string -m "/usr/lib/librephotos" -r "$final_path" -f $file
ynh_replace_string -m 3000 -r '$httpPort' -f $file
ynh_replace_string -m 8001 -r '$BACKEND_PORT' -f $file
ynh_replace_string -m 8002 -r '$IMAGE_SIMILARITY_SERVER_PORT' -f $file
ynh_replace_string -m "/etc/librephotos" -r $final_path -f $file
ynh_replace_string -m "librephotos-backend.env" -r "librephotos.env" -f $file
ynh_replace_special_string -m 'su - -s $(which bash) librephotos << EOF' -r '' -f $file
ynh_replace_special_string -m 'EOF' -r '' -f $file
ynh_replace_string -m "python3" -r "$backend_path/venv/bin/python3" -f $file
ynh_replace_string -m "gunicorn --workers" -r "$backend_path/venv/bin/gunicorn --workers" -f $file
ynh_replace_string -m "$backend_path/venv/bin/$backend_path/venv/bin/python" -r "$backend_path/venv/bin/python" -f $file
ynh_replace_string -m "$backend_path/venv/bin/$backend_path/venv/bin/gunicorn --workers" -r "$backend_path/venv/bin/gunicorn --workers" -f $file
ynh_replace_string -m 'npm install' -r " " -f $file
ynh_replace_string -m 'npm' -r "yarn" -f $file
done
function upgrade_db {
pushd "$final_path/backend"
chown -R $app:$app "$final_path/backend"
chown -R $app:$app "/var/log/$app"
sudo -u $app bash -c "
set -a
export PATH=\"$path_prefix:"'$PATH'"\"
source \"$final_path\"/librephotos.env
python3 manage.py showmigrations
python3 manage.py migrate
python3 manage.py showmigrations
" 2>&1
popd
set_permissions
}
function set_permissions {

View file

@ -115,11 +115,11 @@ ynh_system_user_create --username=$app --home_dir=$data_path
#=================================================
# SPECIFIC SETUP
#=================================================
# SET UP VIRTUALENV
# SET UP BACKEND
#=================================================
ynh_script_progression --message="Initializing backend Python virtualenv..." --weight=60
ynh_script_progression --message="Setting up backend..." --weight=60
set_up_virtualenv
set_up_backend
#=================================================
# SET UP FRONTEND
@ -151,26 +151,35 @@ add_configuations
#=================================================
ynh_script_progression --message="Finalizing database..." --weight=1
pushd $final_path || ynh_die
chown -R $app:$app $final_path
chown -R $app:$app /var/log/$app
sudo -u $app $final_path/bin/librephotos-upgrade 2>&1
sudo -u $app $final_path/bin/librephotos-createadmin "$admin" "$(ynh_user_get_info $admin 'mail')" $(ynh_string_random -l 64) 2>&1
for username in $(ynh_user_list); do
user_email=$(ynh_user_get_info --username="$username" --key=mail)
sudo -u $app $final_path/bin/librephotos-cli shell <<< "
upgrade_db
pushd "$final_path/backend"
admin_mail="$(ynh_user_get_info $admin 'mail')"
sudo -u $app bash -c "
set -a
export PATH=\"$path_prefix:"'$PATH'"\"
source \"$final_path\"/librephotos.env
python3 manage.py createsuperuser --noinput --username \"$admin\" --email \"$admin_mail\"
" 2>&1
for user in $(ynh_user_list); do
mail=$(ynh_user_get_info --username="$user" --key=mail)
sudo -u $app bash -c "
set -a
export PATH=\"$path_prefix:"'$PATH'"\"
source \"$final_path\"/librephotos.env
python3 manage.py shell
" <<< "
from django.contrib.auth import get_user_model
User = get_user_model()
try:
user = User.objects.get(username='$username')
user.scan_directory='/home/yunohost.multimedia/$username/Picture'
user = User.objects.get(username='$user')
user.scan_directory='/home/yunohost.multimedia/$user/Picture'
user.save()
except User.DoesNotExist:
User.objects.create_user('$username', email='$user_email', scan_directory='/home/yunohost.multimedia/$username/Picture')
User.objects.create_user('$user', email='$mail', scan_directory='/home/yunohost.multimedia/$user/Picture')
" 2>&1
done
chown -R root:root $final_path
popd || ynh_die
popd
#=================================================
# YUNOHOST MULTIMEDIA INTEGRATION

View file

@ -109,11 +109,11 @@ ynh_system_user_create --username=$app --home_dir=$data_path
#=================================================
# SPECIFIC UPGRADE
#=================================================
# SET UP VIRTUALENV
# SET UP BACKEND
#=================================================
ynh_script_progression --message="Upgrading Python virtualenv..." --weight=50
ynh_script_progression --message="Setting up backend..." --weight=50
set_up_virtualenv
set_up_backend
#=================================================
# SET UP FRONTEND
@ -145,12 +145,7 @@ add_configuations
#=================================================
ynh_script_progression --message="Finalizing database..." --weight=1
pushd $final_path || ynh_die
chown -R $app:$app $final_path
chown -R $app:$app /var/log/$app
sudo -u $app $final_path/bin/librephotos-upgrade 2>&1
chown -R root:root $final_path
popd || ynh_die
upgrade_db
#=================================================
# YUNOHOST MULTIMEDIA INTEGRATION