From e995e26ecf7f50404204ee033b6127f6aa9e968d Mon Sep 17 00:00:00 2001 From: hoelee Date: Mon, 27 Jul 2026 12:17:00 +0800 Subject: [PATCH] feat(shell-sync): run_daemon() part 3/3 --- platform/shell-sync/sync.sh | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/platform/shell-sync/sync.sh b/platform/shell-sync/sync.sh index 0f303a37..22bd6165 100644 --- a/platform/shell-sync/sync.sh +++ b/platform/shell-sync/sync.sh @@ -385,3 +385,43 @@ run_daemon() { done } +case "${1:-}" in + sync) + shift + validate_settings + sync_account "${1:-1}" + ;; + sync-all) + validate_settings + sync_all + ;; + authorize) + shift + i="${1:-1}" + src_user="$(get_var "ACCOUNT_${i}_SOURCE_USER")" + src_token="$(get_var "ACCOUNT_${i}_SOURCE_TOKEN")" + src_provider="$(get_var "ACCOUNT_${i}_SOURCE_PROVIDER")" + validate_settings + if ! provider="$(source_oauth_provider "$src_provider")" || [ -z "$src_user" ] || [ -z "$src_token" ]; then + log "Account $i: authorization requires a supported OAuth2 provider, source user, and token path" + exit 1 + fi + log "Manual authorize: $src_user" + exec oauth2_imap --startover --provider "$provider" --application imapsync --token_file "$src_token" "$src_user" + ;; + shell|bash|sh) + exec /bin/bash + ;; + imapsync) + shift + exec imapsync "$@" + ;; + *) + validate_settings + if [ "$ONCE" = "true" ]; then + run_once + else + run_daemon + fi + ;; +esac