added support for uid/gid ... by default transmission will still run as root so as to not break backwards compatibility.

This commit is contained in:
Branden Cash
2016-09-26 23:36:24 -07:00
parent 187be60940
commit 8cb81cc588
6 changed files with 64 additions and 7 deletions

View File

@@ -73,4 +73,7 @@ export TRANSMISSION_WATCH_DIR={{ .Env.TRANSMISSION_WATCH_DIR }}
export TRANSMISSION_WATCH_DIR_ENABLED={{ .Env.TRANSMISSION_WATCH_DIR_ENABLED }}
# Transmission needs to know which VPN provider is used
export OPENVPN_PROVIDER={{ .Env.OPENVPN_PROVIDER }}
export OPENVPN_PROVIDER={{ .Env.OPENVPN_PROVIDER }}
export PUID={{ .Env.PUID }}
export PGID={{ .Env.PGID }}

View File

@@ -19,8 +19,10 @@ if [ ! -e "/dev/random" ]; then
ln -s /dev/urandom /dev/random
fi
. /etc/transmission/userSetup.sh
echo "STARTING TRANSMISSION"
exec /usr/bin/transmission-daemon -g ${TRANSMISSION_HOME} --logfile ${TRANSMISSION_HOME}/transmission.log &
exec sudo -u ${RUN_AS} /usr/bin/transmission-daemon -g ${TRANSMISSION_HOME} --logfile ${TRANSMISSION_HOME}/transmission.log &
if [ "$OPENVPN_PROVIDER" = "PIA" ]
then

33
transmission/userSetup.sh Normal file
View File

@@ -0,0 +1,33 @@
#!/bin/sh
# More/less taken from https://github.com/linuxserver/docker-baseimage-alpine/blob/3eb7146a55b7bff547905e0d3f71a26036448ae6/root/etc/cont-init.d/10-adduser
RUN_AS=root
if [ -n "$PUID" ] && [ ! "$(id -u root)" -eq "$PUID" ]; then
RUN_AS=abc
if [ ! "$(id -u ${RUN_AS})" -eq "$PUID" ]; then usermod -o -u "$PUID" ${RUN_AS} ; fi
if [ ! "$(id -g ${RUN_AS})" -eq "$PGID" ]; then groupmod -o -g "$PGID" ${RUN_AS} ; fi
echo "Setting owner for transmission paths to ${PUID}:${PGID}"
chown -R ${RUN_AS}:${RUN_AS} ${TRANSMISSION_HOME}
chown ${RUN_AS}:${RUN_AS} \
/config \
${TRANSMISSION_DOWNLOAD_DIR} \
${TRANSMISSION_INCOMPLETE_DIR} \
${TRANSMISSION_WATCH_DIR}
fi
echo "
-------------------------------------
Transmission will run as
-------------------------------------
User name: ${RUN_AS}
User uid: $(id -u ${RUN_AS})
User gid: $(id -g ${RUN_AS})
-------------------------------------
"
export PUID
export PGID
export RUN_AS