mirror of
https://github.com/YunoHost-Apps/librephotos_ynh.git
synced 2024-09-03 19:36:12 +02:00
37 lines
1 KiB
Bash
37 lines
1 KiB
Bash
#!/usr/bin/env bash
|
|
set -a
|
|
source /usr/share/yunohost/helpers
|
|
|
|
app="${0//.\/50-}"
|
|
user=$1
|
|
mail=$2
|
|
|
|
arch="$(dpkg --print-architecture)"
|
|
arm64_test=0
|
|
|
|
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:
|
|
user = User.objects.get(username='$user')
|
|
user.scan_directory='/home/yunohost.multimedia/$user/Picture'
|
|
user.is_active = True
|
|
user.save()
|
|
except User.DoesNotExist:
|
|
User.objects.create_user('$user', email='$mail', scan_directory='/home/yunohost.multimedia/$user/Picture')
|
|
" 2>&1
|
|
popd
|