2022-11-02 15:42:31 +00:00
|
|
|
|
#!/usr/bin/with-contenv bash
|
2023-01-05 10:08:07 +00:00
|
|
|
|
# shellcheck shell=bash
|
2022-11-02 15:42:31 +00:00
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
2023-02-08 15:02:21 +00:00
|
|
|
|
# Handle old theme locations
|
2023-02-09 09:27:14 +01:00
|
|
|
|
mkdir -p {/transmissionic,/combustion-release,/flood-for-transmission,/kettu,/transmission-web-control}
|
2023-02-08 15:02:21 +00:00
|
|
|
|
echo /transmissionic /combustion-release /flood-for-transmission /kettu /transmission-web-control | xargs -n1 ln -s /defaults/index.html
|
|
|
|
|
|
|
2022-11-02 15:42:31 +00:00
|
|
|
|
# permissions
|
2022-11-13 16:33:22 +00:00
|
|
|
|
lsiown abc:abc \
|
2023-02-09 09:27:14 +01:00
|
|
|
|
/config/settings.json
|
2022-11-03 11:28:59 +00:00
|
|
|
|
|
|
|
|
|
|
if [[ "$(stat -c '%U' /downloads)" != "abc" ]]; then
|
2022-12-07 09:44:17 +00:00
|
|
|
|
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
|
2022-11-03 11:28:59 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [[ "$(stat -c '%U' /watch)" != "abc" ]]; then
|
2022-11-13 16:33:22 +00:00
|
|
|
|
lsiown abc:abc /watch
|
2022-11-03 11:28:59 +00:00
|
|
|
|
fi
|