-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
789 lines (651 loc) · 20 KB
/
install.sh
File metadata and controls
789 lines (651 loc) · 20 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
#!/usr/bin/env bash
set -euo pipefail
INSTALL_DIR="${FLOCK_INSTALL_DIR:-$HOME/.flock}"
FLOCK_REPO="https://github.com/nbitslabs/flock.git"
NON_INTERACTIVE="${NON_INTERACTIVE:-false}"
SKIP_AUTH="${SKIP_AUTH:-false}"
DOMAIN=""
log() {
echo "[flock-install] $1"
}
detect_os() {
case "$(uname -s)" in
Linux*) echo "linux";;
Darwin*) echo "macos";;
*) echo "unknown";;
esac
}
detect_package_manager() {
if command -v apt-get &> /dev/null; then
echo "apt"
elif command -v yum &> /dev/null; then
echo "yum"
elif command -v brew &> /dev/null; then
echo "brew"
else
echo "unknown"
fi
}
update_package_index() {
local pkg_manager
pkg_manager=$(detect_package_manager)
if [[ "$pkg_manager" == "apt" ]]; then
log "Updating package index..."
sudo apt-get update -y
fi
}
install_golang() {
if command -v go &> /dev/null; then
local version
version=$(go version 2>/dev/null | sed -n 's/.*go\([0-9]*\.[0-9]*\).*/\1/p')
local major minor
major="${version%%.*}"
minor="${version#*.}"
if [[ "$major" -ge 1 ]] && [[ "$minor" -ge 22 ]]; then
log "Go ${version} already installed"
return 0
fi
fi
log "Installing Go..."
local go_os
case "$(uname -s)" in
Linux*) go_os="linux";;
Darwin*) go_os="darwin";;
*) go_os="linux";;
esac
local arch
arch=$(uname -m)
case "$arch" in
x86_64) arch="amd64";;
aarch64) arch="arm64";;
arm64) arch="arm64";;
esac
local go_version="1.24.7"
local go_archive="go${go_version}.${go_os}-${arch}.tar.gz"
local go_url="https://go.dev/dl/${go_archive}"
log "Downloading ${go_archive}..."
curl -fSL "$go_url" -o "/tmp/${go_archive}"
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf "/tmp/${go_archive}"
rm "/tmp/${go_archive}"
export PATH="/usr/local/go/bin:$PATH"
log "Go installed successfully"
}
install_git() {
if command -v git &> /dev/null; then
log "Git already installed"
return 0
fi
log "Installing Git..."
local pkg_manager
pkg_manager=$(detect_package_manager)
case "$pkg_manager" in
apt) sudo apt-get install -y git;;
yum) sudo yum install -y git;;
brew) brew install git;;
*) log "ERROR: Cannot install git, unknown package manager"; return 1;;
esac
}
install_github_cli() {
if command -v gh &> /dev/null; then
log "GitHub CLI already installed"
return 0
fi
log "Installing GitHub CLI..."
local os_type
os_type=$(detect_os)
if [[ "$os_type" == "macos" ]]; then
brew install gh
else
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt-get update -y
sudo apt-get install -y gh
fi
}
install_opencode() {
if command -v opencode &> /dev/null; then
log "OpenCode already installed"
return 0
fi
log "Installing OpenCode..."
local oc_os oc_arch
case "$(uname -s)" in
Linux*) oc_os="linux";;
Darwin*) oc_os="darwin";;
esac
case "$(uname -m)" in
x86_64) oc_arch="x64";;
aarch64) oc_arch="arm64";;
arm64) oc_arch="arm64";;
esac
local oc_archive="opencode-${oc_os}-${oc_arch}.tar.gz"
local oc_url="https://github.com/anomalyco/opencode/releases/latest/download/${oc_archive}"
log "Downloading ${oc_archive}..."
curl -fSL "$oc_url" -o "/tmp/${oc_archive}"
tar -xzf "/tmp/${oc_archive}" -C "${INSTALL_DIR}/bin"
rm "/tmp/${oc_archive}"
chmod +x "${INSTALL_DIR}/bin/opencode"
add_to_path
log "OpenCode installed successfully"
}
download_flock() {
log "Downloading Flock..."
if [[ -d "${INSTALL_DIR}/flock/.git" ]]; then
cd "${INSTALL_DIR}/flock"
git fetch origin main
git reset --hard origin/main
log "Flock updated to latest"
else
rm -rf "${INSTALL_DIR}/flock"
git clone --depth 1 "$FLOCK_REPO" "${INSTALL_DIR}/flock"
log "Flock downloaded"
fi
}
build_flock() {
log "Building Flock..."
cd "${INSTALL_DIR}/flock"
go build -o "${INSTALL_DIR}/bin/flock" ./cmd/flock
log "Flock built successfully"
}
create_flock_config() {
log "Creating Flock configuration..."
mkdir -p "${INSTALL_DIR}"
cat > "${INSTALL_DIR}/flock.toml" << EOF
opencode_url = "http://127.0.0.1:4096"
addr = ":7070"
db = "${INSTALL_DIR}/flock.db"
data_dir = "${INSTALL_DIR}"
base_path = "${HOME}/dev"
[agent]
enabled = true
heartbeat_interval_secs = 300
stuck_threshold_secs = 600
max_heartbeats_per_session = 20
wait_for_idle_timeout_secs = 180
[auth]
username = ""
password = ""
EOF
log "Flock config created at ${INSTALL_DIR}/flock.toml"
}
create_opencode_config() {
log "Creating OpenCode configuration..."
mkdir -p "${INSTALL_DIR}/opencode"
cat > "${INSTALL_DIR}/opencode/config.json" << 'EOF'
{
"$schema": "https://opencode.ai/config.json",
"server": {
"port": 4096
},
"permission": {
"*": {
"*": "allow"
}
}
}
EOF
log "OpenCode config created"
}
setup_systemd_services() {
log "Setting up systemd services..."
sudo tee /etc/systemd/system/flock.service > /dev/null << EOF
[Unit]
Description=Flock - Agent Orchestration System
After=network.target
[Service]
Type=simple
User=$USER
WorkingDirectory=${INSTALL_DIR}
Environment="PATH=${INSTALL_DIR}/bin:/usr/local/go/bin:$PATH"
ExecStart=${INSTALL_DIR}/bin/flock -config ${INSTALL_DIR}/flock.toml
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
sudo tee /etc/systemd/system/opencode.service > /dev/null << EOF
[Unit]
Description=OpenCode Server
After=network.target
[Service]
Type=simple
User=$USER
WorkingDirectory=${INSTALL_DIR}
Environment="PATH=${INSTALL_DIR}/bin:/usr/local/go/bin:$PATH"
Environment="OPENCODE_CONFIG=${INSTALL_DIR}/opencode/config.json"
ExecStart=${INSTALL_DIR}/bin/opencode serve
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable flock
sudo systemctl enable opencode
log "Systemd services configured"
}
setup_launchd_services() {
log "Setting up launchd services..."
mkdir -p "${HOME}/Library/LaunchAgents"
cat > "${HOME}/Library/LaunchAgents/com.flock.flock.plist" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.flock.flock</string>
<key>ProgramArguments</key>
<array>
<string>${INSTALL_DIR}/bin/flock</string>
<string>-config</string>
<string>${INSTALL_DIR}/flock.toml</string>
</array>
<key>WorkingDirectory</key>
<string>${INSTALL_DIR}</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>${INSTALL_DIR}/bin:/usr/local/go/bin:/usr/local/bin:/usr/bin:/bin</string>
</dict>
</dict>
</plist>
EOF
cat > "${HOME}/Library/LaunchAgents/com.flock.opencode.plist" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.flock.opencode</string>
<key>ProgramArguments</key>
<array>
<string>${INSTALL_DIR}/bin/opencode</string>
<string>serve</string>
</array>
<key>WorkingDirectory</key>
<string>${INSTALL_DIR}</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>${INSTALL_DIR}/bin:/usr/local/go/bin:/usr/local/bin:/usr/bin:/bin</string>
<key>OPENCODE_CONFIG</key>
<string>${INSTALL_DIR}/opencode/config.json</string>
</dict>
</dict>
</plist>
EOF
log "Launchd services configured"
}
setup_services() {
local os_type
os_type=$(detect_os)
if [[ "$os_type" == "macos" ]]; then
setup_launchd_services
else
setup_systemd_services
fi
}
start_services() {
local os_type
os_type=$(detect_os)
log "Starting services..."
if [[ "$os_type" == "macos" ]]; then
launchctl load "${HOME}/Library/LaunchAgents/com.flock.opencode.plist"
launchctl load "${HOME}/Library/LaunchAgents/com.flock.flock.plist"
else
sudo systemctl start opencode
sudo systemctl start flock
fi
log "Services started"
}
authenticate_github() {
if [[ "$SKIP_AUTH" == "true" ]]; then
log "Skipping GitHub authentication (SKIP_AUTH=true)"
return 0
fi
if gh auth status &> /dev/null; then
log "GitHub CLI already authenticated"
return 0
fi
if [[ "$NON_INTERACTIVE" == "true" ]]; then
log "GitHub CLI requires authentication. Run: gh auth login"
return 0
fi
echo ""
read -p "Would you like to authenticate GitHub CLI now? (Y/n): " gh_auth_choice < /dev/tty
gh_auth_choice="${gh_auth_choice:-Y}"
if [[ "$gh_auth_choice" =~ ^[Yy]$ ]]; then
log "Please authenticate with GitHub CLI..."
gh auth login < /dev/tty
log "GitHub CLI authenticated"
else
log "Skipping GitHub authentication. Run 'gh auth login' later."
fi
}
authenticate_opencode() {
log "OpenCode requires manual authentication (TUI-based)."
log "After installation, run: opencode auth login"
}
setup_flock_auth() {
if [[ "$SKIP_AUTH" == "true" ]]; then
log "Skipping Flock auth setup (SKIP_AUTH=true)"
return 0
fi
if [[ -n "${FLOCK_USERNAME:-}" ]] && [[ -n "${FLOCK_PASSWORD:-}" ]]; then
log "Setting up Flock basic authentication..."
sed -i.bak "s/username = \"\"/username = \"$FLOCK_USERNAME\"/" "${INSTALL_DIR}/flock.toml"
sed -i.bak "s/password = \"\"/password = \"$FLOCK_PASSWORD\"/" "${INSTALL_DIR}/flock.toml"
rm -f "${INSTALL_DIR}/flock.toml.bak"
log "Flock auth configured"
else
log "Flock auth skipped (no credentials provided)"
fi
}
install_nginx() {
if command -v nginx &> /dev/null; then
log "Nginx already installed"
return 0
fi
log "Installing Nginx..."
local pkg_manager
pkg_manager=$(detect_package_manager)
case "$pkg_manager" in
apt)
sudo apt-get install -y nginx
;;
yum)
sudo yum install -y nginx
;;
brew)
brew install nginx
;;
*)
log "Unknown package manager, cannot install nginx"
return 1
;;
esac
log "Nginx installed"
}
setup_reverse_proxy() {
if [[ -z "$DOMAIN" ]]; then
log "No domain specified, skipping reverse proxy setup"
return 0
fi
log "Setting up reverse proxy for domain: $DOMAIN"
install_nginx
log "Creating nginx configuration for $DOMAIN..."
sudo tee "/etc/nginx/sites-available/flock" > /dev/null << EOF
server {
listen 80;
server_name $DOMAIN;
location / {
proxy_pass http://127.0.0.1:7070;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_cache_bypass \$http_upgrade;
proxy_buffering off;
proxy_read_timeout 86400;
}
location /event {
proxy_pass http://127.0.0.1:7070;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_buffering off;
proxy_read_timeout 86400;
}
}
EOF
sudo ln -sf "/etc/nginx/sites-available/flock" "/etc/nginx/sites-enabled/flock"
sudo rm -f "/etc/nginx/sites-enabled/default"
sudo nginx -t
log "Nginx configuration created"
}
install_certbot() {
if command -v certbot &> /dev/null; then
log "Certbot already installed"
return 0
fi
log "Installing Certbot..."
local pkg_manager
pkg_manager=$(detect_package_manager)
case "$pkg_manager" in
apt)
sudo apt-get install -y certbot python3-certbot-nginx
;;
yum)
sudo yum install -y certbot python3-certbot-nginx
;;
brew)
brew install certbot
;;
*)
log "Unknown package manager, cannot install certbot"
return 1
;;
esac
log "Certbot installed"
}
setup_ssl() {
if [[ -z "$DOMAIN" ]]; then
return 0
fi
log "Setting up SSL certificate for $DOMAIN..."
install_certbot
log "Requesting SSL certificate..."
sudo certbot --nginx -d "$DOMAIN" --non-interactive --agree-tos --redirect --register-unsafely-without-email
log "SSL certificate configured"
sudo systemctl restart nginx
sudo systemctl restart flock
}
setup_cronjob() {
log "Setting up cronjob for automatic updates..."
local cron_script="${INSTALL_DIR}/bin/flock-update.sh"
cat > "$cron_script" << 'CRONSCRIPT'
#!/usr/bin/env bash
set -euo pipefail
INSTALL_DIR="${FLOCK_INSTALL_DIR:-$HOME/.flock}"
LOG_FILE="${INSTALL_DIR}/logs/update.log"
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE"
}
log "Starting Flock and OpenCode update..."
if [[ -d "${INSTALL_DIR}/flock/.git" ]]; then
cd "${INSTALL_DIR}/flock"
git fetch origin main
if git diff --quiet origin/main -- .; then
log "Flock already up to date"
else
git reset --hard origin/main
go build -o "${INSTALL_DIR}/bin/flock" ./cmd/flock
log "Flock updated"
fi
fi
if command -v opencode &> /dev/null; then
current_version=$(opencode --version 2>/dev/null || echo "unknown")
opencode --version-check || true
log "OpenCode current version: $current_version"
fi
log "Restarting services..."
if command -v systemctl &> /dev/null; then
sudo systemctl restart opencode
sleep 2
sudo systemctl restart flock
elif command -v launchctl &> /dev/null; then
launchctl unload "${HOME}/Library/LaunchAgents/com.flock.opencode.plist" 2>/dev/null || true
launchctl unload "${HOME}/Library/LaunchAgents/com.flock.flock.plist" 2>/dev/null || true
sleep 1
launchctl load "${HOME}/Library/LaunchAgents/com.flock.opencode.plist"
launchctl load "${HOME}/Library/LaunchAgents/com.flock.flock.plist"
fi
log "Update complete"
CRONSCRIPT
chmod +x "$cron_script"
(crontab -l 2>/dev/null | grep -v "flock-update.sh"; echo "0 3 * * * ${INSTALL_DIR}/bin/flock-update.sh >> ${INSTALL_DIR}/logs/update.log 2>&1") | crontab -
log "Cronjob configured to run daily at 3 AM"
}
add_to_path() {
local shell_rc
case "${SHELL:-bash}" in
*zsh) shell_rc="${HOME}/.zshrc";;
*) shell_rc="${HOME}/.bashrc";;
esac
if ! grep -q "${INSTALL_DIR}/bin" "$shell_rc" 2>/dev/null; then
echo "export PATH=\"${INSTALL_DIR}/bin:\$PATH\"" >> "$shell_rc"
fi
export PATH="${INSTALL_DIR}/bin:$PATH"
}
verify_installation() {
log "Verifying installation..."
command -v flock || { log "ERROR: flock not found in PATH"; return 1; }
command -v opencode || { log "ERROR: opencode not found in PATH"; return 1; }
command -v gh || { log "ERROR: gh not found in PATH"; return 1; }
[[ -f "${INSTALL_DIR}/flock.toml" ]] || { log "ERROR: flock.toml not found"; return 1; }
[[ -f "${INSTALL_DIR}/opencode/config.json" ]] || { log "ERROR: opencode config not found"; return 1; }
log "Installation verified successfully!"
return 0
}
print_summary() {
echo ""
echo "============================================"
echo " Flock Installation Complete!"
echo "============================================"
echo ""
echo "Installation directory: ${INSTALL_DIR}"
echo ""
echo "Services:"
echo " - Flock: ${INSTALL_DIR}/bin/flock"
echo " - OpenCode: ${INSTALL_DIR}/bin/opencode"
echo ""
echo "Configuration:"
echo " - Flock: ${INSTALL_DIR}/flock.toml"
echo " - OpenCode: ${INSTALL_DIR}/opencode/config.json"
echo ""
if [[ -n "$DOMAIN" ]]; then
echo "Reverse Proxy:"
echo " - Domain: https://${DOMAIN}"
echo " - SSL: Enabled (certbot)"
echo " - Nginx: Configured"
echo ""
else
echo "Next steps:"
echo " 1. Add to PATH: export PATH=\"${INSTALL_DIR}/bin:\$PATH\""
echo " 2. Authenticate GitHub: gh auth login"
echo " 3. Authenticate OpenCode: opencode auth login"
echo " 4. Access Flock UI: http://localhost:7070"
echo ""
fi
echo "To start services manually:"
if [[ "$(detect_os)" == "macos" ]]; then
echo " launchctl load ${HOME}/Library/LaunchAgents/com.flock.flock.plist"
else
echo " sudo systemctl start flock"
fi
echo ""
}
prompt_config() {
if [[ "$NON_INTERACTIVE" == "true" ]]; then
return 0
fi
echo ""
echo "============================================"
echo " Flock Installer"
echo "============================================"
echo ""
read -p "Install directory [${INSTALL_DIR}]: " input_install_dir < /dev/tty
if [[ -n "$input_install_dir" ]]; then
INSTALL_DIR="$input_install_dir"
fi
read -p "Domain for reverse proxy (leave blank to skip): " input_domain < /dev/tty
DOMAIN="${input_domain:-}"
echo ""
echo "Configure Flock basic authentication:"
read -p "Username: " input_username < /dev/tty
if [[ -n "$input_username" ]]; then
read -s -p "Password: " input_password < /dev/tty
echo ""
FLOCK_USERNAME="$input_username"
FLOCK_PASSWORD="${input_password:-}"
else
FLOCK_USERNAME=""
FLOCK_PASSWORD=""
log "Flock auth skipped (no username provided)"
fi
echo ""
log "Install directory: ${INSTALL_DIR}"
if [[ -n "$DOMAIN" ]]; then
log "Domain: ${DOMAIN}"
fi
echo ""
}
main() {
log "Starting Flock installation..."
log "OS: $(detect_os)"
while [[ $# -gt 0 ]]; do
case "$1" in
--install-dir)
INSTALL_DIR="$2"
shift 2
;;
--domain)
DOMAIN="$2"
shift 2
;;
--non-interactive)
NON_INTERACTIVE="true"
shift
;;
--skip-auth)
SKIP_AUTH="true"
shift
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
prompt_config
mkdir -p "${INSTALL_DIR}/bin"
mkdir -p "${INSTALL_DIR}/logs"
update_package_index
install_git
install_golang
install_github_cli
install_opencode
download_flock
build_flock
create_flock_config
create_opencode_config
setup_flock_auth
setup_services
start_services
authenticate_github
authenticate_opencode
setup_reverse_proxy
setup_ssl
setup_cronjob
add_to_path
verify_installation
print_summary
log "Installation complete!"
}
main "$@"