Docker: Create default users and groups #2262 #2228

Creates accounts to run PhotoPrism under a custom user ID. Also adds
them to the video and render groups, which might help to access hardware
transcoding devices.
This commit is contained in:
Michael Mayer
2022-04-18 14:14:32 +02:00
parent 27b84365da
commit c2baf2ae5a
27 changed files with 210 additions and 213 deletions

26
scripts/dist/create-users.sh vendored Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/sh
PATH="/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/scripts"
# abort if not executed as root
if [ $(id -u) != "0" ]; then
echo "Usage: run ${0##*/} as root" 1>&2
exit 1
fi
echo "Creating default users and groups..."
groupadd -f -r -g 44 video
groupadd -f -r -g 109 render
groupadd -f -g 1000 photoprism
add_user()
{
useradd -u "$1" -g photoprism -G video,render -s /bin/bash -m -d "/home/user-$1" "user-$1" 2>/dev/null
}
for i in $(seq 50 99); do add_user "$i"; done
for i in $(seq 500 549); do add_user "$i"; done
for i in $(seq 1000 1099); do add_user "$i"; done
echo "Done."