* The previous behavior required root privileges on start, now this is optional (when run in rootless mode with --user). The user has to ensure the correct ownership is set for existing data in that case. * Furthermore, it is now possible to choose to keep root privileges by setting KEEP_PRIVILEGES to something non-empty. * This also renames abc user to changedetection (nicer).pull/722/head
parent
12d26c6667
commit
a48b75d4ac
@ -1,11 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
PUID=${PUID:-911}
|
||||
PGID=${PGID:-911}
|
||||
set -eu
|
||||
|
||||
groupmod -o -g "$PGID" abc
|
||||
usermod -o -u "$PUID" abc
|
||||
# If the first argument looks like a flag, assume we want to run changedetection
|
||||
if [ "${1:0:1}" = '-' ]; then
|
||||
set -- python ./changedetection.py -d /datastore "$@"
|
||||
fi
|
||||
|
||||
chown -R abc:abc /datastore
|
||||
# If we're running as root, by default make sure process uid/gid
|
||||
# and datadir permissions are correct. This can be skipped by setting
|
||||
# KEEP_PRIVILEGES to something non-empty.
|
||||
if [ "$(id -u)" = '0' -a -n "${KEEP_PRIVILEGES:-}" ]; then
|
||||
PUID=${PUID:-911}
|
||||
PGID=${PGID:-911}
|
||||
|
||||
exec gosu abc:abc python ./changedetection.py -d /datastore
|
||||
groupmod -o -g "$PGID" changedetection
|
||||
usermod -o -u "$PUID" changedetection
|
||||
|
||||
# Look for files in datadir not owned by the correct user and chown them
|
||||
find "/datastore" \! -user changedetection -exec chown changedetection '{}' +
|
||||
|
||||
# Restart this script as an unprivileged user
|
||||
exec gosu changedetection:changedetection "$BASH_SOURCE" "$@"
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
|
Loading…
Reference in new issue