diff --git a/rclone/config.yml b/rclone/config.yml index 3ee25cd..0ea923c 100755 --- a/rclone/config.yml +++ b/rclone/config.yml @@ -29,8 +29,8 @@ options: cron: "" delete: false credentials: - username: homeassistant - password: homeassistant + username: null + password: null tls: ssl: false certfile: fullchain.pem diff --git a/rclone/rootfs/etc/cont-init.d/rclone.sh b/rclone/rootfs/etc/cont-init.d/rclone.sh index a729c60..3cae369 100755 --- a/rclone/rootfs/etc/cont-init.d/rclone.sh +++ b/rclone/rootfs/etc/cont-init.d/rclone.sh @@ -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 diff --git a/rclone/rootfs/etc/services.d/web/run b/rclone/rootfs/etc/services.d/web/run index 924ff2c..2ef836e 100755 --- a/rclone/rootfs/etc/services.d/web/run +++ b/rclone/rootfs/etc/services.d/web/run @@ -4,23 +4,25 @@ bashio::log.info "Starting rclone web..." # Configure tls if bashio::config.true 'tls.ssl'; then - ssl_flags=(\ - "--rc-cert" "/ssl/$(bashio::config 'tls.certfile')" \ - "--rc-key" "/ssl/$(bashio::config 'tls.keyfile')" \ - ) + 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[@]}" diff --git a/rclone/rootfs/run_rclone.sh b/rclone/rootfs/run_rclone.sh index f29caa9..24f7d29 100755 --- a/rclone/rootfs/run_rclone.sh +++ b/rclone/rootfs/run_rclone.sh @@ -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"