#!/bin/sh # deploy/docker-entrypoint.sh: the Docker image's ENTRYPOINT. It runs as # root only to make /var/lib/pixa usable by pixad: a host directory # bind-mounted there keeps its host owner, often root, and data from an # earlier run may belong to another uid. The server itself always runs # as pixad. set -eu main() { mkdir -p /var/lib/pixa # Only the directory and its top-level entries are checked, so a # normal start does not walk the cache. -depth gives each directory # to pixad after its contents, so a start stopped part way leaves # something at the top for the next start to find; -h changes a # symlink itself, never the file it points to. if [ -n "$(find /var/lib/pixa -maxdepth 1 \( ! -user pixad -o ! -group pixad \))" ]; then find /var/lib/pixa -depth -exec chown -h pixad:pixad {} + fi chmod 750 /var/lib/pixa exec su-exec pixad /usr/local/bin/pixad "$@" } main "$@"