Respect configured JELLYFIN_USER in Debian's postinst

In my setup I configured a different user. But updates keep "stealing" file permissions for my `$PROGRAMDATA $CONFIGDATA $LOGDATA $CACHEDATA` directories.
This commit is contained in:
Tobias Krönke 2021-05-06 18:56:13 +02:00 committed by GitHub
parent 4b31c007e3
commit 8eee32c8c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

12
debian/postinst vendored
View File

@ -9,6 +9,8 @@ if [[ -f $DEFAULT_FILE ]]; then
. $DEFAULT_FILE . $DEFAULT_FILE
fi fi
JELLYFIN_USER=${JELLYFIN_USER:-jellyfin}
# Data directories for program data (cache, db), configs, and logs # Data directories for program data (cache, db), configs, and logs
PROGRAMDATA=${JELLYFIN_DATA_DIRECTORY-/var/lib/$NAME} PROGRAMDATA=${JELLYFIN_DATA_DIRECTORY-/var/lib/$NAME}
CONFIGDATA=${JELLYFIN_CONFIG_DIRECTORY-/etc/$NAME} CONFIGDATA=${JELLYFIN_CONFIG_DIRECTORY-/etc/$NAME}
@ -18,12 +20,12 @@ CACHEDATA=${JELLYFIN_CACHE_DIRECTORY-/var/cache/$NAME}
case "$1" in case "$1" in
configure) configure)
# create jellyfin group if it does not exist # create jellyfin group if it does not exist
if [[ -z "$(getent group jellyfin)" ]]; then if [[ -z "$(getent group ${JELLYFIN_USER})" ]]; then
addgroup --quiet --system jellyfin > /dev/null 2>&1 addgroup --quiet --system ${JELLYFIN_USER} > /dev/null 2>&1
fi fi
# create jellyfin user if it does not exist # create jellyfin user if it does not exist
if [[ -z "$(getent passwd jellyfin)" ]]; then if [[ -z "$(getent passwd ${JELLYFIN_USER})" ]]; then
adduser --system --ingroup jellyfin --shell /bin/false jellyfin --no-create-home --home ${PROGRAMDATA} \ adduser --system --ingroup ${JELLYFIN_USER} --shell /bin/false ${JELLYFIN_USER} --no-create-home --home ${PROGRAMDATA} \
--gecos "Jellyfin default user" > /dev/null 2>&1 --gecos "Jellyfin default user" > /dev/null 2>&1
fi fi
# ensure $PROGRAMDATA exists # ensure $PROGRAMDATA exists
@ -43,7 +45,7 @@ case "$1" in
mkdir $CACHEDATA mkdir $CACHEDATA
fi fi
# Ensure permissions are correct on all config directories # Ensure permissions are correct on all config directories
chown -R jellyfin $PROGRAMDATA $CONFIGDATA $LOGDATA $CACHEDATA chown -R ${JELLYFIN_USER} $PROGRAMDATA $CONFIGDATA $LOGDATA $CACHEDATA
chgrp adm $PROGRAMDATA $CONFIGDATA $LOGDATA $CACHEDATA chgrp adm $PROGRAMDATA $CONFIGDATA $LOGDATA $CACHEDATA
chmod 0750 $PROGRAMDATA $CONFIGDATA $LOGDATA $CACHEDATA chmod 0750 $PROGRAMDATA $CONFIGDATA $LOGDATA $CACHEDATA