2022-11-02 15:42:31 +00:00
|
|
|
|
#!/usr/bin/with-contenv 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
|
|
|
|
|
|
chown abc:abc \
|
|
|
|
|
|
/config/settings.json \
|
2022-11-03 11:28:59 +00:00
|
|
|
|
|
|
|
|
|
|
if [[ "$(stat -c '%U' /downloads)" != "abc" ]]; then
|
2022-11-03 11:30:15 +00:00
|
|
|
|
chown abc:abc \
|
|
|
|
|
|
/downloads \
|
|
|
|
|
|
/downloads/complete \
|
|
|
|
|
|
/downloads/incomplete
|
2022-11-03 11:28:59 +00:00
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [[ "$(stat -c '%U' /watch)" != "abc" ]]; then
|
|
|
|
|
|
chown abc:abc /watch
|
|
|
|
|
|
fi
|