Use more variables from group_data

This commit is contained in:
Benoit S 2021-09-26 21:25:33 +09:00
parent 14d127fa2c
commit 576d2c8fd5
4 changed files with 104 additions and 50 deletions

View file

@ -17,17 +17,22 @@ apt.packages(
server.user( server.user(
name='Create UNIX user', name='Create UNIX user',
user='photoprism', user=host.data.unix_user,
shell='/bin/false', group=host.data.unix_group,
home=host.data.unix_home,
shell=host.data.unix_shell,
ensure_home=True,
system=True,
comment='photoprism system user',
present=True, present=True,
) )
for items in ['storage', 'originals', 'import']: for items in ['storage', 'originals', 'import']:
files.directory( files.directory(
name='Make required directories /home/photoprism/{}'.format(items), name='Make required directories {}'.format(items),
path='/home/photoprism/{}'.format(items), path=host.data.unix_home+'/{}'.format(items),
user='photoprism', user=host.data.unix_user,
group='photoprism', group=host.data.unix_group,
mode=755 mode=755
) )
@ -53,16 +58,24 @@ files.download(
sha256sum='b937e69e774c530c080c1f6685763ca7db4dc58520a5a2054d111e1504f47688', sha256sum='b937e69e774c530c080c1f6685763ca7db4dc58520a5a2054d111e1504f47688',
) )
if not host.fact.file('/tmp/photoprism.tar'): files.directory(
name='Create undocker cache',
path=host.data.undocker_cache,
user='root',
group='root',
mode=755
)
if not host.fact.file(host.data.undocker_cache+'/photoprism.tar'):
server.shell( server.shell(
name='Download photoprism Docker image', name='Download photoprism Docker image',
chdir='/tmp', chdir=host.data.undocker_cache,
commands=['skopeo copy docker://docker.io/photoprism/photoprism:latest docker-archive:photoprism.tar'], commands=['skopeo copy docker://docker.io/photoprism/photoprism:latest docker-archive:photoprism.tar'],
) )
files.directory( files.directory(
name='Ensure /opt/photoprism exists', name='Create undocker destination',
path='/opt/photoprism', path=host.data.undocker_dst,
user='root', user='root',
group='root', group='root',
mode=755 mode=755
@ -70,20 +83,20 @@ files.directory(
server.shell( server.shell(
name='Undocker the Docker image', name='Undocker the Docker image',
chdir='/opt/photoprism', chdir=host.data.undocker_dst,
commands=['undocker /tmp/photoprism.tar - | tar -xv'], commands=['undocker '+host.data.undocker_cache+'/photoprism.tar - | tar -xv'],
) )
files.template( files.template(
name='Set env file', name='Set env file',
src='templates/env.j2', src='templates/env.j2',
dest='/etc/photoprism.env', dest=host.data.systemd_env,
mode='600', mode='600',
) )
files.put( files.template(
name='Set systemd service file', name='Set systemd service file',
src='files/photoprism.service', src='templates/photoprism.service.j2',
dest='/etc/systemd/system/photoprism.service', dest='/etc/systemd/system/photoprism.service',
mode='644', mode='644',
) )

View file

@ -1,18 +0,0 @@
[Unit]
Description=photoprism
After=network.target
[Service]
Type=simple
User=photoprism
Group=photoprism
StateDirectory=photoprism
EnvironmentFile=/etc/photoprism.env
WorkingDirectory=/photoprism
RootDirectory=/opt/photoprism
BindPaths=/home/photoprism/storage:/photoprism/storage /home/photoprism/originals:/photoprism/originals /home/photoprism/import:/photoprism/import
ExecStart=/photoprism/bin/photoprism start
Restart=on-failure
[Install]
WantedBy=multi-user.target

View file

@ -1,3 +1,4 @@
# From Dockerfile
PHOTOPRISM_ASSETS_PATH="/photoprism/assets" PHOTOPRISM_ASSETS_PATH="/photoprism/assets"
PHOTOPRISM_STORAGE_PATH="/photoprism/storage" PHOTOPRISM_STORAGE_PATH="/photoprism/storage"
PHOTOPRISM_BACKUP_PATH="/var/lib/photoprism" PHOTOPRISM_BACKUP_PATH="/var/lib/photoprism"
@ -5,29 +6,68 @@ PHOTOPRISM_ORIGINALS_PATH="/photoprism/originals"
PHOTOPRISM_IMPORT_PATH="/photoprism/import" PHOTOPRISM_IMPORT_PATH="/photoprism/import"
PHOTOPRISM_LOG_FILENAME="/photoprism/photoprism.log" PHOTOPRISM_LOG_FILENAME="/photoprism/photoprism.log"
PHOTOPRISM_PID_FILENAME="/photoprism/photoprism.pid" PHOTOPRISM_PID_FILENAME="/photoprism/photoprism.pid"
PHOTOPRISM_ADMIN_PASSWORD="{{ host.data.photoprism_admin_password }}"
PHOTOPRISM_ORIGINALS_LIMIT={{ host.data.photoprism_originals_limit }}
PHOTOPRISM_HTTP_COMPRESSION="{{ host.data.photoprism_http_compression }}"
PHOTOPRISM_DEBUG="false" PHOTOPRISM_DEBUG="false"
PHOTOPRISM_PUBLIC="false" PHOTOPRISM_PUBLIC="false"
PHOTOPRISM_READONLY="false" PHOTOPRISM_READONLY="false"
PHOTOPRISM_EXPERIMENTAL="false"
PHOTOPRISM_DISABLE_WEBDAV="false"
PHOTOPRISM_DISABLE_SETTINGS="false"
PHOTOPRISM_DISABLE_TENSORFLOW="false"
PHOTOPRISM_DISABLE_FACES="false"
PHOTOPRISM_DISABLE_CLASSIFICATION="false"
PHOTOPRISM_DARKTABLE_PRESETS="false"
PHOTOPRISM_DETECT_NSFW="false"
PHOTOPRISM_UPLOAD_NSFW="true" PHOTOPRISM_UPLOAD_NSFW="true"
PHOTOPRISM_DATABASE_DRIVER="mysql" PHOTOPRISM_DETECT_NSFW="false"
PHOTOPRISM_DATABASE_SERVER="{{ host.data.photoprism_database_server }}" PHOTOPRISM_EXPERIMENTAL="false"
PHOTOPRISM_DATABASE_NAME="{{ host.data.photoprism_database_name }}"
PHOTOPRISM_DATABASE_USER="{{ host.data.photoprism_database_user }}"
PHOTOPRISM_DATABASE_PASSWORD="{{ host.data.photoprism_database_password }}"
PHOTOPRISM_SITE_URL="http://localhost:2342/" PHOTOPRISM_SITE_URL="http://localhost:2342/"
PHOTOPRISM_SITE_TITLE="PhotoPrism" PHOTOPRISM_SITE_TITLE="PhotoPrism"
PHOTOPRISM_SITE_CAPTION="Browse Your Life" PHOTOPRISM_SITE_CAPTION="Browse Your Life"
PHOTOPRISM_SITE_DESCRIPTION="" PHOTOPRISM_SITE_DESCRIPTION=""
PHOTOPRISM_SITE_AUTHOR="" PHOTOPRISM_SITE_AUTHOR=""
HOME="/photoprism" PHOTOPRISM_HTTP_HOST="0.0.0.0"
PHOTOPRISM_HTTP_PORT=2342
PHOTOPRISM_DATABASE_DRIVER="sqlite"
PHOTOPRISM_DATABASE_SERVER=""
PHOTOPRISM_DATABASE_NAME="photoprism"
PHOTOPRISM_DATABASE_USER="photoprism"
PHOTOPRISM_DATABASE_PASSWORD=""
PHOTOPRISM_DISABLE_WEBDAV="false"
PHOTOPRISM_DISABLE_SETTINGS="false"
PHOTOPRISM_DISABLE_BACKUPS="false"
PHOTOPRISM_DISABLE_EXIFTOOL="false"
PHOTOPRISM_DISABLE_PLACES="false"
PHOTOPRISM_DISABLE_TENSORFLOW="false"
PHOTOPRISM_DISABLE_FACES="false"
PHOTOPRISM_DISABLE_CLASSIFICATION="false"
PHOTOPRISM_DARKTABLE_PRESETS="false"
PHOTOPRISM_THUMB_FILTER="lanczos"
PHOTOPRISM_THUMB_UNCACHED="false"
PHOTOPRISM_THUMB_SIZE=2048
PHOTOPRISM_THUMB_SIZE_UNCACHED=7680
PHOTOPRISM_JPEG_SIZE=7680
PHOTOPRISM_JPEG_QUALITY=92
PHOTOPRISM_WORKERS=0
PHOTOPRISM_WAKEUP_INTERVAL=900
PHOTOPRISM_AUTO_INDEX=300
PHOTOPRISM_AUTO_IMPORT=300
# From docker-compose, those that are really supposed to be configured by user
PHOTOPRISM_ADMIN_PASSWORD="{{ host.data.photoprism_admin_password }}"
PHOTOPRISM_ORIGINALS_LIMIT={{ host.data.photoprism_originals_limit }}
PHOTOPRISM_HTTP_COMPRESSION="{{ host.data.photoprism_http_compression }}"
PHOTOPRISM_DEBUG="{{ host.data.photoprism_debug }}"
PHOTOPRISM_PUBLIC="{{ host.data.photoprism_public }}"
PHOTOPRISM_READONLY="{{ host.data.photoprism_readonly }}"
PHOTOPRISM_EXPERIMENTAL="{{ host.data.photoprism_experimental }}"
PHOTOPRISM_DISABLE_WEBDAV="{{ host.data.photoprism_disable_webdav }}"
PHOTOPRISM_DISABLE_SETTINGS="{{ host.data.photoprism_disable_settings }}"
PHOTOPRISM_DISABLE_TENSORFLOW="{{ host.data.photoprism_disable_tensorflow }}"
PHOTOPRISM_DISABLE_FACES="{{ host.data.photoprism_disable_faces }}"
PHOTOPRISM_DISABLE_CLASSIFICATION="{{ host.data.photoprism_disable_classification }}"
PHOTOPRISM_DARKTABLE_PRESETS="{{ host.data.photoprism_darktable_presets }}"
PHOTOPRISM_DETECT_NSFW="{{ host.data.photoprism_detect_nsfw }}"
PHOTOPRISM_UPLOAD_NSFW="{{ host.data.photoprism_upload_nsfw }}"
PHOTOPRISM_DATABASE_DRIVER="{{ host.data.photoprism_database_driver }}"
PHOTOPRISM_DATABASE_SERVER="{{ host.data.photoprism_database_server }}"
PHOTOPRISM_DATABASE_NAME="{{ host.data.photoprism_database_name }}"
PHOTOPRISM_DATABASE_USER="{{ host.data.photoprism_database_user }}"
PHOTOPRISM_DATABASE_PASSWORD="{{ host.data.photoprism_database_password }}"
PHOTOPRISM_SITE_URL="{{ host.data.photoprism_site_url }}"
PHOTOPRISM_SITE_TITLE="{{ host.data.photoprism_site_title }}"
PHOTOPRISM_SITE_CAPTION="{{ host.data.photoprism_site_caption }}"
PHOTOPRISM_SITE_DESCRIPTION="{{ host.data.photoprism_site_description }}"
PHOTOPRISM_SITE_AUTHOR="{{ host.data.photoprism_site_author }}"
HOME="{{ host.data.photoprism_home }}"

View file

@ -0,0 +1,19 @@
[Unit]
Description=photoprism
After=network.target
[Service]
Type=simple
User={{ host.data.unix_user }}
Group={{ host.data.unix_group }}
StateDirectory={{ host.data.unix_user }}
EnvironmentFile={{ host.data.systemd_env }}
WorkingDirectory=/photoprism
RootDirectory={{ host.data.undocker_dst }}
BindPaths={{ host.data.unix_home }}/storage:/photoprism/storage {{ host.data.unix_home }}/originals:/photoprism/originals {{ host.data.unix_home }}/import:/photoprism/import
BindReadOnlyPaths=/etc/resolv.conf
ExecStart=/photoprism/bin/photoprism start
Restart=on-failure
[Install]
WantedBy=multi-user.target