mirror of
https://github.com/ViViDboarder/hassio-addon-rclone.git
synced 2024-10-31 18:36:35 +00:00
Make username and password optional
This commit is contained in:
parent
1175215a2d
commit
061d88d8af
@ -29,8 +29,8 @@ options:
|
||||
cron: ""
|
||||
delete: false
|
||||
credentials:
|
||||
username: homeassistant
|
||||
password: homeassistant
|
||||
username: null
|
||||
password: null
|
||||
tls:
|
||||
ssl: false
|
||||
certfile: fullchain.pem
|
||||
|
@ -2,11 +2,19 @@
|
||||
|
||||
bashio::log.info "Configuring rclone..."
|
||||
|
||||
bashio::config.require.username 'credentials.username'
|
||||
bashio::config.require.password 'credentials.password'
|
||||
if bashio::config.true 'tls.ssl'; then
|
||||
bashio::config.require.ssl 'tls' 'tls.certfile' 'tls.keyfile'
|
||||
else
|
||||
bashio::log.warning
|
||||
bashio::log.warning "It's recommended to set tsl settings if exposing to the network and not through the proxy."
|
||||
bashio::log.warning
|
||||
fi
|
||||
|
||||
bashio::config.suggest.true 'tls.ssl'
|
||||
bashio::config.require.ssl 'tls' 'tls.certfile' 'tls.keyfile'
|
||||
if ! bashio::config.has_value 'credentials.username' || ! bashio::config.has_value 'credentials.password'; then
|
||||
bashio::log.warning
|
||||
bashio::log.warning "It's recommended to set credentials.username and credentials.password settings if exposing to the network and not through the proxy."
|
||||
bashio::log.warning
|
||||
fi
|
||||
|
||||
echo "$(bashio::config 'cron') /run_rclone.sh" >> /etc/crontabs/root
|
||||
crontab -l
|
||||
|
@ -4,23 +4,25 @@ bashio::log.info "Starting rclone web..."
|
||||
|
||||
# Configure tls
|
||||
if bashio::config.true 'tls.ssl'; then
|
||||
ssl_flags=(\
|
||||
bashio::config.require.ssl 'tls' 'tls.certfile' 'tls.keyfile'
|
||||
rclone_flags=(\
|
||||
"--rc-cert" "/ssl/$(bashio::config 'tls.certfile')" \
|
||||
"--rc-key" "/ssl/$(bashio::config 'tls.keyfile')" \
|
||||
)
|
||||
fi
|
||||
|
||||
# TODO: Something with UN and PASS
|
||||
# Maybe switch to --rc-no-auth and use proxy
|
||||
username=$(bashio::config 'credentials.username')
|
||||
password=$(bashio::config 'credentials.password')
|
||||
# Optionally set a user and pass
|
||||
if bashio::config.has_value 'credentials.username' && bashio::config.has_value 'credentials.password'; then
|
||||
rclone_flags+=("--rc-user" "$(bashio::config 'credentials.username')")
|
||||
rclone_flags+=("--rc-pass" "$(bashio::config 'credentials.password')")
|
||||
else
|
||||
rclone_flags+=("--rc-no-auth")
|
||||
fi
|
||||
|
||||
exec rclone rcd \
|
||||
--rc-web-gui \
|
||||
--rc-serve \
|
||||
--rc-addr :5572 \
|
||||
--rc-user "$username" \
|
||||
--rc-pass "$password" \
|
||||
--rc-web-gui-update \
|
||||
--rc-web-gui-no-open-browser \
|
||||
"${ssl_flags[@]}"
|
||||
"${rclone_flags[@]}"
|
||||
|
@ -5,9 +5,6 @@ bashio::log.info "Running rclone..."
|
||||
SYNC_COMMAND=$(bashio::config 'sync_command')
|
||||
DESTINATION=$(bashio::config 'destination')
|
||||
|
||||
USERNAME=$(bashio::config 'credentials.username')
|
||||
PASSWORD=$(bashio::config 'credentials.password')
|
||||
|
||||
set +x
|
||||
|
||||
FILTER='{"IncludeRule": ["*.tar"]}'
|
||||
@ -17,4 +14,11 @@ fi
|
||||
|
||||
bashio::log.info "Filter: $FILTER"
|
||||
|
||||
rclone rc --user "$USERNAME" --pass "$PASSWORD" "sync/$SYNC_COMMAND" srcFs=/backup "dstFs=$DESTINATION" _async=true _filter="$FILTER"
|
||||
|
||||
# Maybe add the username and password
|
||||
if bashio::config.has_value 'credentials.username' && bashio::config.has_value 'credentials.password'; then
|
||||
rclone_flags+=("--rc-user" "$(bashio::config 'credentials.username')")
|
||||
rclone_flags+=("--rc-pass" "$(bashio::config 'credentials.password')")
|
||||
fi
|
||||
|
||||
rclone rc "${rclone_flags[@]}" "sync/$SYNC_COMMAND" srcFs=/backup "dstFs=$DESTINATION" _async=true _filter="$FILTER"
|
||||
|
Loading…
Reference in New Issue
Block a user