From 6cca18c895ed9686abff65a114b3ef2a23430e1b Mon Sep 17 00:00:00 2001 From: Benoit S Date: Mon, 27 Sep 2021 20:56:18 +0900 Subject: [PATCH] Add system-run wrapper --- README.md | 10 +++++++++- deploy.py | 8 ++++++++ templates/systemd-run.sh.j2 | 15 +++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 templates/systemd-run.sh.j2 diff --git a/README.md b/README.md index 0dd983e..cf18def 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Pyinfra that deploy PhotoPrism un-dockerized on a Debian 11 LXD container. If required, you can mount external volumes. Example: ``` -lxc config device add _disk disk source=/dev/vdf path=/mnt/pictures readonly=true raw.mount.options=noload +# lxc config device add _disk disk source=/dev/vdf path=/mnt/pictures readonly=true raw.mount.options=noload ``` Then add it to `group_data/production.py`: @@ -28,3 +28,11 @@ Then add it to `group_data/production.py`: ``` photoprism_originals_src='/mnt/pictures' ``` + +# Run photoprism command + +A systemd-run wrapper is installed and you can use it via `/usr/local/bin/photoprism`. + +``` +# /usr/local/bin/photoprism config +``` diff --git a/deploy.py b/deploy.py index 3a58b87..a74a177 100644 --- a/deploy.py +++ b/deploy.py @@ -120,3 +120,11 @@ systemd.service( restarted=True, enabled=True, ) + +files.template( + name='Set systemd-run wrapper', + src='templates/systemd-run.sh.j2', + dest='/usr/local/bin/photoprism', + mode='755', +) + diff --git a/templates/systemd-run.sh.j2 b/templates/systemd-run.sh.j2 new file mode 100644 index 0000000..b44c5f5 --- /dev/null +++ b/templates/systemd-run.sh.j2 @@ -0,0 +1,15 @@ +#!/bin/env bash +set -euo pipefail + +systemd-run \ + --pty \ + --description='photoprism binary call' \ + --property=User={{ host.data.unix_user }} \ + --property=Group={{ host.data.unix_group }} \ + --property=StateDirectory={{ host.data.unix_user }} \ + --property=EnvironmentFile={{ host.data.systemd_env }} \ + --property=WorkingDirectory=/photoprism \ + --property=RootDirectory={{ host.data.undocker_dst }} \ + --property='BindPaths={{ host.data.photoprism_storage_src }}:/photoprism/storage {{ host.data.photoprism_originals_src }}:/photoprism/originals {{ host.data.photoprism_import_src }}:/photoprism/import' \ + --property='BindReadOnlyPaths=/etc/resolv.conf /proc' \ + /photoprism/bin/photoprism $1