-
Notifications
You must be signed in to change notification settings - Fork 0
chore: add grok-cli dependency and improve backup services #452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0c4a0c4
0f0ae5c
9866ddc
528c033
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,16 +6,36 @@ set -euo pipefail | |||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| CONFIG_DIR="$HOME/.cli-proxy-api" | ||||||||||||||||||||||||||||||||||||||||
| BACKUP_DIR="s3://cliproxyapi/backup/auths/" | ||||||||||||||||||||||||||||||||||||||||
| MAIN_DIR="s3://cliproxyapi/auths/" | ||||||||||||||||||||||||||||||||||||||||
| AUTH_DIR="$CONFIG_DIR/objectstore/auths" | ||||||||||||||||||||||||||||||||||||||||
| DOTFILES_AUTH_DIR="$HOME/dotfiles/objectstore/auths" | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # First, sync from dotfiles repo to local cache (picks up new auth files from ccs auth) | ||||||||||||||||||||||||||||||||||||||||
| if [ -d "$DOTFILES_AUTH_DIR" ] && [ -n "$(ls -A "$DOTFILES_AUTH_DIR" 2>/dev/null)" ]; then | ||||||||||||||||||||||||||||||||||||||||
| mkdir -p "$AUTH_DIR" | ||||||||||||||||||||||||||||||||||||||||
| rsync -a "$DOTFILES_AUTH_DIR/" "$AUTH_DIR/" | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+14
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This new Useful? React with 👍 / 👎.
|
||||||||||||||||||||||||||||||||||||||||
| echo "✅ Synced from dotfiles repo to local cache" >&2 | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Check if auth directory has files | ||||||||||||||||||||||||||||||||||||||||
| if [ -d "$AUTH_DIR" ] && [ -n "$(ls -A "$AUTH_DIR" 2>/dev/null)" ]; then | ||||||||||||||||||||||||||||||||||||||||
| echo "Backing up auth files to R2 backup directory..." >&2 | ||||||||||||||||||||||||||||||||||||||||
| echo "Syncing auth files to R2..." >&2 | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Sync to main auths/ location (what cliproxyapi reads from) | ||||||||||||||||||||||||||||||||||||||||
| AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \ | ||||||||||||||||||||||||||||||||||||||||
| AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \ | ||||||||||||||||||||||||||||||||||||||||
| aws s3 sync \ | ||||||||||||||||||||||||||||||||||||||||
| --endpoint-url="${OBJECTSTORE_ENDPOINT}" \ | ||||||||||||||||||||||||||||||||||||||||
| --no-progress \ | ||||||||||||||||||||||||||||||||||||||||
| "$AUTH_DIR/" \ | ||||||||||||||||||||||||||||||||||||||||
| "$MAIN_DIR" 2>/dev/null && echo "✅ Synced to auths/" >&2 || echo "⚠️ Sync to auths/ failed" >&2 | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+25
to
+31
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Also sync to backup location for redundancy | ||||||||||||||||||||||||||||||||||||||||
| AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \ | ||||||||||||||||||||||||||||||||||||||||
| AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \ | ||||||||||||||||||||||||||||||||||||||||
| aws s3 sync \ | ||||||||||||||||||||||||||||||||||||||||
| --endpoint-url="${OBJECTSTORE_ENDPOINT}" \ | ||||||||||||||||||||||||||||||||||||||||
| --no-progress \ | ||||||||||||||||||||||||||||||||||||||||
| "$AUTH_DIR/" \ | ||||||||||||||||||||||||||||||||||||||||
| "$BACKUP_DIR" 2>/dev/null || echo "⚠️ Backup failed (continuing anyway)" >&2 | ||||||||||||||||||||||||||||||||||||||||
| "$BACKUP_DIR" 2>/dev/null && echo "✅ Synced to backup/auths/" >&2 || echo "⚠️ Backup sync failed" >&2 | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
34
to
+40
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block has the same issues as the previous one: the
Suggested change
Comment on lines
+25
to
+40
|
||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,22 +1,37 @@ | ||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||||||||||||||||||||
| # Recover auth files from backup if missing | ||||||||||||||||||||||||||||||||||||||
| # Recover auth files from R2 if missing locally | ||||||||||||||||||||||||||||||||||||||
| # Handles race condition where files get deleted during config reload | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| CONFIG_DIR="$HOME/.cli-proxy-api" | ||||||||||||||||||||||||||||||||||||||
| MAIN_DIR="s3://cliproxyapi/auths/" | ||||||||||||||||||||||||||||||||||||||
| BACKUP_DIR="s3://cliproxyapi/backup/auths/" | ||||||||||||||||||||||||||||||||||||||
| AUTH_DIR="$CONFIG_DIR/objectstore/auths" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Check if auth directory is missing or empty | ||||||||||||||||||||||||||||||||||||||
| if [ ! -d "$AUTH_DIR" ] || [ -z "$(ls -A "$AUTH_DIR" 2>/dev/null)" ]; then | ||||||||||||||||||||||||||||||||||||||
| echo "Auth files missing, attempting recovery from R2 backup..." >&2 | ||||||||||||||||||||||||||||||||||||||
| echo "Auth files missing locally, attempting recovery from R2..." >&2 | ||||||||||||||||||||||||||||||||||||||
| mkdir -p "$AUTH_DIR" | ||||||||||||||||||||||||||||||||||||||
| AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \ | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Try main auths/ location first | ||||||||||||||||||||||||||||||||||||||
| if AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \ | ||||||||||||||||||||||||||||||||||||||
| AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \ | ||||||||||||||||||||||||||||||||||||||
| aws s3 sync \ | ||||||||||||||||||||||||||||||||||||||
| --endpoint-url="${OBJECTSTORE_ENDPOINT}" \ | ||||||||||||||||||||||||||||||||||||||
| --no-progress \ | ||||||||||||||||||||||||||||||||||||||
| "$BACKUP_DIR" \ | ||||||||||||||||||||||||||||||||||||||
| "$AUTH_DIR/" 2>/dev/null && echo "✅ Recovered auth files from backup" >&2 || echo "⚠️ Recovery failed (no backup available?)" >&2 | ||||||||||||||||||||||||||||||||||||||
| "$MAIN_DIR" \ | ||||||||||||||||||||||||||||||||||||||
| "$AUTH_DIR/" 2>/dev/null; then | ||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: if AWS_ACCESS_KEY_ID=... aws s3 sync ... && [ -n "$(ls -A "$AUTH_DIR" 2>/dev/null)" ]; thenPrompt for AI agents
Suggested change
Comment on lines
+18
to
+24
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redirecting stderr to
Suggested change
|
||||||||||||||||||||||||||||||||||||||
| echo "✅ Recovered auth files from auths/" >&2 | ||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||
| # Fall back to backup location | ||||||||||||||||||||||||||||||||||||||
| echo "Main location empty, trying backup..." >&2 | ||||||||||||||||||||||||||||||||||||||
| AWS_ACCESS_KEY_ID="${OBJECTSTORE_ACCESS_KEY}" \ | ||||||||||||||||||||||||||||||||||||||
| AWS_SECRET_ACCESS_KEY="${OBJECTSTORE_SECRET_KEY}" \ | ||||||||||||||||||||||||||||||||||||||
| aws s3 sync \ | ||||||||||||||||||||||||||||||||||||||
| --endpoint-url="${OBJECTSTORE_ENDPOINT}" \ | ||||||||||||||||||||||||||||||||||||||
| --no-progress \ | ||||||||||||||||||||||||||||||||||||||
| "$BACKUP_DIR" \ | ||||||||||||||||||||||||||||||||||||||
| "$AUTH_DIR/" 2>/dev/null && echo "✅ Recovered from backup/auths/" >&2 || echo "⚠️ Recovery failed" >&2 | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+29
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block has the same issues as seen in
Suggested change
Comment on lines
+18
to
+35
|
||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||
| fi | |
| fi | |
| # Verify that recovery actually restored at least one auth file | |
| if [ -z "$(ls -A "$AUTH_DIR" 2>/dev/null)" ]; then | |
| echo "❌ Recovery failed: no auth files present in $AUTH_DIR after recovery attempts" >&2 | |
| exit 1 | |
| fi |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,12 +19,7 @@ in | |||||
| ] | ||||||
| }:/opt/homebrew/bin:/usr/local/bin"; | ||||||
| }; | ||||||
| StartCalendarInterval = [ | ||||||
| { | ||||||
| Hour = 0; | ||||||
| Minute = 0; | ||||||
| } | ||||||
| ]; | ||||||
| StartInterval = 10800; | ||||||
| StandardOutPath = "/tmp/dotfiles-updater.log"; | ||||||
| StandardErrorPath = "/tmp/dotfiles-updater.error.log"; | ||||||
| }; | ||||||
|
|
@@ -62,7 +57,7 @@ in | |||||
| Description = "Timer for dotfiles auto-updater"; | ||||||
| }; | ||||||
| Timer = { | ||||||
| OnCalendar = "*-*-* 00:00:00"; | ||||||
| OnCalendar = "*-*-* 00/3:00:00"; | ||||||
|
||||||
| OnCalendar = "*-*-* 00/3:00:00"; | |
| OnUnitActiveSec = "3h"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The backup interval was reduced from 5 minutes (300 seconds) to 3 minutes (180 seconds). This 40% increase in frequency may put additional load on the R2 storage service with more frequent sync operations. Consider whether this increased frequency is necessary, especially since the cliproxyapi service appears to use KeepAlive=true (continuously running), so auth files should rarely be missing. A less aggressive interval might be sufficient.