feat(shell-sync): run_daemon() part 3/3

This commit is contained in:
hoelee committed 2026-07-27 12:17:00 +08:00
1 parent 26c5434ba4
commit e995e26ecf
1 file changed
+40
+40
View File
@@ -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