-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJustfile
More file actions
387 lines (333 loc) · 13.1 KB
/
Justfile
File metadata and controls
387 lines (333 loc) · 13.1 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
# SPDX-License-Identifier: PMPL-1.0-or-later
# Cloud Sync Tuner - Justfile
# https://github.com/casey/just
set shell := ["bash", "-euo", "pipefail", "-c"]
# Default recipe
import? "contractile.just"
default:
@just --list
# ============================================
# BUILD RECIPES
# ============================================
# Build all components
build: build-tui build-overlay build-tray
@echo "✓ All components built"
# Build Ada TUI
build-tui:
@echo "Building cloud-sync-tuner (Ada)..."
cd src && gnatmake -O2 -gnatn cloud_sync_tuner.adb -o cloud-sync-tuner
# Build overlay daemon (Rust)
build-overlay:
@echo "Building cloud-sync-overlay (Rust)..."
cd overlay-daemon && cargo build --release
# Build tray daemon (Rust)
build-tray:
@echo "Building cloud-sync-tray (Rust)..."
cd tray-daemon && cargo build --release
# Build SELinux policy
build-selinux:
@echo "Building SELinux policy..."
cd selinux && make
# Clean all build artifacts
clean:
rm -f src/cloud-sync-tuner
rm -rf overlay-daemon/target
rm -rf tray-daemon/target
cd selinux && make clean || true
# ============================================
# INSTALL RECIPES
# ============================================
# Install everything
install: build
./install.sh
# Uninstall
uninstall:
./install.sh --uninstall
# Install systemd services only
install-services:
mkdir -p ~/.config/systemd/user
cp systemd/*.service systemd/*.timer ~/.config/systemd/user/
cp overlay-daemon/cloud-sync-overlay.service ~/.config/systemd/user/
cp tray-daemon/cloud-sync-tray.service ~/.config/systemd/user/
systemctl --user daemon-reload
@echo "✓ Services installed"
# Install SELinux policy
install-selinux: build-selinux
cd selinux && sudo make install
# ============================================
# SERVICE MANAGEMENT
# ============================================
# Start all cloud sync services
start:
systemctl --user start rclone-dropbox rclone-gdrive rclone-onedrive
systemctl --user start cloud-sync-overlay cloud-sync-tray
@echo "✓ Services started"
# Stop all services
stop:
systemctl --user stop cloud-sync-tray cloud-sync-overlay
systemctl --user stop rclone-dropbox rclone-gdrive rclone-onedrive
@echo "✓ Services stopped"
# Restart all services
restart: stop start
# Check service status
status:
@cloud-sync-status || true
# View logs
logs:
journalctl --user -f -u "rclone-*" -u cloud-sync-overlay -u cloud-sync-tray
# ============================================
# CONFIGURATION
# ============================================
# Apply writes mode (recommended for Dropbox)
apply-writes:
./src/cloud-sync-tuner writes
@echo "✓ Applied writes mode"
# Apply full mode (aggressive caching)
apply-full:
./src/cloud-sync-tuner full
@echo "✓ Applied full mode"
# Apply Dropbox-safe preset
preset-dropbox:
./src/cloud-sync-tuner --preset dropbox writes
@echo "✓ Applied Dropbox-safe preset"
# Apply Google Drive preset
preset-gdrive:
./src/cloud-sync-tuner --preset gdrive writes
@echo "✓ Applied Google Drive preset"
# Edit configuration
config:
${EDITOR:-nano} ~/.config/cloud-sync-tuner/config.toml
# ============================================
# DEVELOPMENT
# ============================================
# Run TUI in development mode
dev:
cd src && gnatmake -g cloud_sync_tuner.adb -o cloud-sync-tuner && ./cloud-sync-tuner
# Run tests
test: test-ada test-rust
@echo "✓ All tests passed"
# Run Ada tests
test-ada:
@echo "Running Ada tests..."
cd tests && gnatmake test_runner.adb && ./test_runner
# Run Rust tests
test-rust:
cd overlay-daemon && cargo test
cd tray-daemon && cargo test
# Lint code
lint:
cd overlay-daemon && cargo clippy -- -D warnings
cd tray-daemon && cargo clippy -- -D warnings
# Format code
fmt:
cd overlay-daemon && cargo fmt
cd tray-daemon && cargo fmt
# ============================================
# LAMINAR CI RECIPES
# ============================================
# Run full CI pipeline (for laminar)
ci: lint test build
@echo "✓ CI pipeline complete"
# Create release tarball
release version:
@echo "Creating release v{{version}}..."
git tag -a "v{{version}}" -m "Release v{{version}}"
mkdir -p dist
tar czvf "dist/cloud-sync-tuner-{{version}}.tar.gz" \
--transform "s,^,cloud-sync-tuner-{{version}}/," \
--exclude="target" --exclude="*.o" --exclude="*.ali" \
src/ overlay-daemon/ tray-daemon/ selinux/ audit/ \
systemd/ config/ scripts/ man/ justfile install.sh \
README.adoc LICENSE CHANGELOG.md
@echo "✓ Created dist/cloud-sync-tuner-{{version}}.tar.gz"
# ============================================
# COOKBOOKS
# ============================================
# Cookbook: Fix Dropbox rate limiting
cookbook-dropbox-fix: preset-dropbox
@echo "Applying Dropbox rate limiting fix..."
just restart
@echo ""
@echo "Dropbox rate limiting fixed! Changes applied:"
@echo " - VFS cache mode: writes"
@echo " - TPS limit: 4 (Dropbox safe)"
@echo " - TPS burst: 1"
@echo " - Chunk size: 32MB"
# Cookbook: Setup offline folders
cookbook-offline-setup:
@echo "Setting up offline folder sync..."
mkdir -p ~/Offline/{Dropbox,GoogleDrive,OneDrive}
./src/cloud-sync-tuner --pin dropbox:Documents writes
just restart
@echo ""
@echo "Offline sync configured!"
@echo "Pinned folders will sync to ~/Offline/"
# Cookbook: Maximum performance
cookbook-max-performance:
@echo "Applying maximum performance settings..."
./src/cloud-sync-tuner \
--cache-size 50G \
--transfers 8 \
--checkers 16 \
--buffer 64M \
full
just restart
@echo ""
@echo "Maximum performance mode enabled!"
@echo "Warning: This uses more disk space and API calls"
# Cookbook: Minimal resources
cookbook-minimal:
@echo "Applying minimal resource settings..."
./src/cloud-sync-tuner \
--cache-size 2G \
--transfers 2 \
--checkers 4 \
--buffer 8M \
writes
just restart
@echo ""
@echo "Minimal resource mode enabled"
# Cookbook: Enable enterprise compliance
cookbook-enterprise: install-selinux
@echo "Enabling enterprise compliance..."
sudo install -m 644 audit/cloud-sync-tuner.rules /etc/audit/rules.d/
sudo augenrules --load
@echo ""
@echo "Enterprise compliance enabled:"
@echo " - SELinux policy installed"
@echo " - Audit rules active"
@echo " - File access logging enabled"
# ============================================
# HELP
# ============================================
# Show help
help:
@echo "Cloud Sync Tuner - rclone mount configuration"
@echo ""
@echo "Quick Start:"
@echo " just build Build all components"
@echo " just install Install to ~/.local"
@echo " just start Start services"
@echo ""
@echo "Cookbooks (common tasks):"
@echo " just cookbook-dropbox-fix Fix Dropbox rate limiting"
@echo " just cookbook-offline-setup Setup offline folders"
@echo " just cookbook-max-performance Maximum caching"
@echo " just cookbook-enterprise Enable SELinux + audit"
@echo ""
@echo "Run 'just --list' for all recipes"
# Run panic-attacker pre-commit scan
assail:
@command -v panic-attack >/dev/null 2>&1 && panic-attack assail . || echo "panic-attack not found — install from https://github.com/hyperpolymath/panic-attacker"
# ═══════════════════════════════════════════════════════════════════════════════
# ONBOARDING & DIAGNOSTICS
# ═══════════════════════════════════════════════════════════════════════════════
# Check all required toolchain dependencies and report health
doctor:
#!/usr/bin/env bash
echo "═══════════════════════════════════════════════════"
echo " Cloud Sync Tuner Doctor — Toolchain Health Check"
echo "═══════════════════════════════════════════════════"
echo ""
PASS=0; FAIL=0; WARN=0
check() {
local name="$1" cmd="$2" min="$3"
if command -v "$cmd" >/dev/null 2>&1; then
VER=$("$cmd" --version 2>&1 | head -1)
echo " [OK] $name — $VER"
PASS=$((PASS + 1))
else
echo " [FAIL] $name — not found (need $min+)"
FAIL=$((FAIL + 1))
fi
}
check "just" just "1.25"
check "git" git "2.40"
check "Zig" zig "0.13"
# Optional tools
if command -v panic-attack >/dev/null 2>&1; then
echo " [OK] panic-attack — available"
PASS=$((PASS + 1))
else
echo " [WARN] panic-attack — not found (pre-commit scanner)"
WARN=$((WARN + 1))
fi
echo ""
echo " Result: $PASS passed, $FAIL failed, $WARN warnings"
if [ "$FAIL" -gt 0 ]; then
echo " Run 'just heal' to attempt automatic repair."
exit 1
fi
echo " All required tools present."
# Attempt to automatically install missing tools
heal:
#!/usr/bin/env bash
echo "═══════════════════════════════════════════════════"
echo " Cloud Sync Tuner Heal — Automatic Tool Installation"
echo "═══════════════════════════════════════════════════"
echo ""
if ! command -v just >/dev/null 2>&1; then
echo "Installing just..."
cargo install just 2>/dev/null || echo "Install just from https://just.systems"
fi
echo ""
echo "Heal complete. Run 'just doctor' to verify."
# Guided tour of the project structure and key concepts
tour:
#!/usr/bin/env bash
echo "═══════════════════════════════════════════════════"
echo " Cloud Sync Tuner — Guided Tour"
echo "═══════════════════════════════════════════════════"
echo ""
echo '// SPDX-License-Identifier: MPL-2.0-or-later'
echo ""
echo "Key directories:"
echo " src/ Source code"
echo " ffi/ Foreign function interface (Zig)"
echo " src/abi/ Idris2 ABI definitions"
echo " docs/ Documentation"
echo " tests/ Test suite"
echo " .github/workflows/ CI/CD workflows"
echo " contractiles/ Must/Trust/Dust contracts"
echo " .machine_readable/ Machine-readable metadata"
echo " examples/ Usage examples"
echo ""
echo "Quick commands:"
echo " just doctor Check toolchain health"
echo " just heal Fix missing tools"
echo " just help-me Common workflows"
echo " just default List all recipes"
echo ""
echo "Read more: README.adoc, EXPLAINME.adoc"
# Show help for common workflows
help-me:
#!/usr/bin/env bash
echo "═══════════════════════════════════════════════════"
echo " Cloud Sync Tuner — Common Workflows"
echo "═══════════════════════════════════════════════════"
echo ""
echo "FIRST TIME SETUP:"
echo " just doctor Check toolchain"
echo " just heal Fix missing tools"
echo ""
echo "PRE-COMMIT:"
echo " just assail Run panic-attacker scan"
echo ""
echo "LEARN:"
echo " just tour Guided project tour"
echo " just default List all recipes"
# Print the current CRG grade (reads from READINESS.md '**Current Grade:** X' line)
crg-grade:
@grade=$$(grep -oP '(?<=\*\*Current Grade:\*\* )[A-FX]' READINESS.md 2>/dev/null | head -1); \
[ -z "$$grade" ] && grade="X"; \
echo "$$grade"
# Generate a shields.io badge markdown for the current CRG grade
# Looks for '**Current Grade:** X' in READINESS.md; falls back to X
crg-badge:
@grade=$$(grep -oP '(?<=\*\*Current Grade:\*\* )[A-FX]' READINESS.md 2>/dev/null | head -1); \
[ -z "$$grade" ] && grade="X"; \
case "$$grade" in \
A) color="brightgreen" ;; B) color="green" ;; C) color="yellow" ;; \
D) color="orange" ;; E) color="red" ;; F) color="critical" ;; \
*) color="lightgrey" ;; esac; \
echo "[](https://github.com/hyperpolymath/standards/tree/main/component-readiness-grades)"