-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync-config.sh
More file actions
executable file
·51 lines (44 loc) · 1.56 KB
/
sync-config.sh
File metadata and controls
executable file
·51 lines (44 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
#
# Sync OpenCode configuration from GitHub
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/mattbaylor/opencode-infisical-setup/main/sync-config.sh | bash
#
# Or with custom config URL:
# CONFIG_URL=https://your-url.com/opencode.json bash sync-config.sh
set -e
CONFIG_URL="${CONFIG_URL:-https://raw.githubusercontent.com/mattbaylor/opencode-infisical-setup/main/config-templates/opencode.json}"
OPENCODE_CONFIG_DIR="${HOME}/.config/opencode"
OPENCODE_CONFIG_FILE="${OPENCODE_CONFIG_DIR}/opencode.json"
echo "=== OpenCode Configuration Sync ==="
echo ""
# Create config directory if it doesn't exist
if [ ! -d "$OPENCODE_CONFIG_DIR" ]; then
echo "Creating OpenCode config directory: $OPENCODE_CONFIG_DIR"
mkdir -p "$OPENCODE_CONFIG_DIR"
fi
# Backup existing config if it exists
if [ -f "$OPENCODE_CONFIG_FILE" ]; then
BACKUP_FILE="${OPENCODE_CONFIG_FILE}.backup.$(date +%Y%m%d_%H%M%S)"
echo "Backing up existing config to: $BACKUP_FILE"
cp "$OPENCODE_CONFIG_FILE" "$BACKUP_FILE"
fi
# Download the config
echo "Downloading config from: $CONFIG_URL"
if ! curl -fsSL "$CONFIG_URL" -o "$OPENCODE_CONFIG_FILE"; then
echo "Failed to download config from $CONFIG_URL"
exit 1
fi
echo ""
echo "OpenCode configuration synced successfully!"
echo "Config location: $OPENCODE_CONFIG_FILE"
echo ""
echo "Next steps:"
echo "1. Edit the config to customize for your environment:"
echo " nano $OPENCODE_CONFIG_FILE"
echo ""
echo "2. Set up any required API keys (see config-templates/README.md)"
echo ""
echo "3. Test OpenCode:"
echo " opencode"