mirror of
https://github.com/linuxserver/docker-transmission.git
synced 2025-10-26 06:36:05 +01:00
63 lines
2.4 KiB
Plaintext
Executable File
63 lines
2.4 KiB
Plaintext
Executable File
#!/usr/bin/with-contenv bash
|
||
# shellcheck shell=bash
|
||
|
||
# make folders
|
||
mkdir -p \
|
||
/downloads/{complete,incomplete} /watch
|
||
|
||
# copy config
|
||
if [[ ! -f /config/settings.json ]]; then
|
||
cp /defaults/settings.json /config/settings.json
|
||
fi
|
||
|
||
if [[ -n "$USER" ]] && [[ -n "$PASS" ]]; then
|
||
sed -i '/rpc-authentication-required/c\ "rpc-authentication-required": true,' /config/settings.json
|
||
sed -i "/rpc-username/c\ \"rpc-username\": \"$USER\"," /config/settings.json
|
||
sed -i "/rpc-password/c\ \"rpc-password\": \"$PASS\"," /config/settings.json
|
||
else
|
||
sed -i '/rpc-authentication-required/c\ "rpc-authentication-required": false,' /config/settings.json
|
||
sed -i "/rpc-username/c\ \"rpc-username\": \"$USER\"," /config/settings.json
|
||
sed -i "/rpc-password/c\ \"rpc-password\": \"$PASS\"," /config/settings.json
|
||
fi
|
||
|
||
if [[ -n "$WHITELIST" ]]; then
|
||
sed -i '/rpc-whitelist-enabled/c\ "rpc-whitelist-enabled": true,' /config/settings.json
|
||
sed -i "/\"rpc-whitelist\"/c\ \"rpc-whitelist\": \"$WHITELIST\"," /config/settings.json
|
||
else
|
||
sed -i '/rpc-whitelist-enabled/c\ "rpc-whitelist-enabled": false,' /config/settings.json
|
||
sed -i "/\"rpc-whitelist\"/c\ \"rpc-whitelist\": \"$WHITELIST\"," /config/settings.json
|
||
fi
|
||
|
||
if [[ -n "$HOST_WHITELIST" ]]; then
|
||
sed -i '/rpc-host-whitelist-enabled/c\ "rpc-host-whitelist-enabled": true,' /config/settings.json
|
||
sed -i "/\"rpc-host-whitelist\"/c\ \"rpc-host-whitelist\": \"$HOST_WHITELIST\"," /config/settings.json
|
||
else
|
||
sed -i '/rpc-host-whitelist-enabled/c\ "rpc-host-whitelist-enabled": false,' /config/settings.json
|
||
sed -i "/\"rpc-host-whitelist\"/c\ \"rpc-host-whitelist\": \"$HOST_WHITELIST\"," /config/settings.json
|
||
fi
|
||
|
||
if [[ -n "${PEERPORT}" ]]; then
|
||
sed -i "/\"peer-port\"/c\ \"peer-port\": ${PEERPORT}," /config/settings.json
|
||
sed -i '/peer-port-random-on-start/c\ "peer-port-random-on-start": false,' /config/settings.json
|
||
fi
|
||
|
||
# permissions
|
||
lsiown abc:abc \
|
||
/config/settings.json \
|
||
|
||
if [[ "$(stat -c '%U' /downloads)" != "abc" ]]; then
|
||
lsiown abc:abc /downloads
|
||
fi
|
||
|
||
if [[ "$(stat -c '%U' /downloads/complete)" != "abc" ]]; then
|
||
lsiown abc:abc /downloads/complete
|
||
fi
|
||
|
||
if [[ "$(stat -c '%U' /downloads/incomplete)" != "abc" ]]; then
|
||
lsiown abc:abc /downloads/incomplete
|
||
fi
|
||
|
||
if [[ "$(stat -c '%U' /watch)" != "abc" ]]; then
|
||
lsiown abc:abc /watch
|
||
fi
|