-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy path00-default.just
More file actions
448 lines (384 loc) Β· 18 KB
/
Copy path00-default.just
File metadata and controls
448 lines (384 loc) Β· 18 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
# vim: set ft=make :
uid := `id -u`
shell := `grep :$(id -u): /etc/passwd | cut -d: -f7`
sparkdock_path := "/opt/sparkdock"
default_branch := "master"
sparkdock_menubar_plist_path := "${HOME}/Library/LaunchAgents/com.sparkfabrik.sparkdock.menubar.plist"
sparkdock_menubar_process_name := "sparkdock-manager"
# Print system information.
[group('system')]
system-device-info:
#!/usr/bin/env bash
read -r -d '' AYSE << EOM
@@@@@@@@@@@@@@@@@@@@@@@@@*,@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@(#,/#%%&&&&&&&%/,(,*////**@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@&&%&&&@@@@@@@@@@@@@@@@@@%&@&&#/***@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@##%@&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&(*,@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@//&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&#%#,*@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@*&&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&@@&&%&(/&@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@((&&&@@&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&&%#@&@@&%&@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@((%#&&#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&@&&&&&#%%@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@*/###%%&&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%@#%&&@%(%@@@@@@@@@@@@@@@
@@@@@@@@@@@@//&##(#&&&&&@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&%&&(%/##@@##&@@@@@@@@@@@@@
@@@@@@@@@@**#&&&%#%%%&&&&&@@&@@@@@@@@@&@@@@@@&@&@&@&&&&&%%#&%%&&@@%&@@@@@@@@@@@@
@@@@@@@@@(*&&&&#(#%@####((#%%&&&&%&&%&&@@&@&%&@%#%####%%#%#%#@@@@@@@&@@@@@@@@@@@
@@@@@@@*(#&%%&&@@&#%&&@&@&&&(##((#(###&%%##%#&%&&@&%%&&&&&@@@@@@@@@@@@&&@@@@@@@@
@@@@/*//&&&%#&&&@@@@@@@@@@@@@@@@@@@@%###%#&@@@@@@@@@@@@@@@@@@@@@@@@@%@@&@@@@@@@@
@@@(*(#&&@@@@@@@@@@@@@@@@@@@@@@@@@@&#&@@&&%&@@@@@@@@@@@@@@@@@@@@@@@@&@@@@@@@@@@@
@@@*(%&@@@@@@@@@@@@@@&###%@@@@@@@&@@@&@@%***/&@@@@((&@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@*#%@@@@@@@@@@@@@%///(#(/((((#%#/,,,,,,,,,,*//(//*/*((%@@@@@@@@@@@@@@@@@@@@@@@
@@@/#%&@@@@@@@@@@@@&//***/#*/&/&(*//*,,,,**///(%&&%#//(#%&&@@@@@@@@@@@@@@@@@@@@@
@@@/##&@@@@@@@&@@&%#%/*,,,,,,*********,,,/(/*,,(%%%///**/(#&@@@&&&&@@@@@@@@@@@@@
@@@*(#&@@@@@@@@@@&&%%/,,,...,,,,*,,**,,.,*//*********,***(#%@@@@&%##@@@@@@@@@@@@
@@@,/%%&@@@&%@@@@&@&&/,,........,,,,,,,,,****,,,,,..,,,**(%&@@@@@@&@@@@@@@@@@@@@
@@@*/,*(&@@@@@@@@@@@@*,,.......,,**,,,,,,***,,.....,,,***(&@@@@@@@@@@@@@@@@@@@@@
@@@@.,#&&&&@@&%&@@@@#**,,,,,,,*,,,,*,..,,/*/*,,,,.,,,***/#@@@&@@@@@@@@@@@@@@@@@@
@@@@@@@.,/%&&&&&&@@&//***,**/*,,,,,*/**/##/*,,,*,,,***//(#@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@.,,//*****((//*,,,,,,,,,****///***///(#&@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@,*(/***/***///*,**/****//#(*/****//(%@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@&(*,,,,,***/*,.,**//((//**,,*/(#&@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@%/*,,,,,,,,,**,,****,****((%%@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@../*,.,,....,,,,,*/(##//@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ,/********/(%#(@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@,.,/@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
EOM
echo "$AYSE"
system_profiler SPHardwareDataType
# Clear DNS cache on macOS.
[group('system')]
system-clear-dns-cache:
@sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder
@echo "DNS cache cleared successfully!"
# Install and update http-proxy to latest version.
[group('http-proxy')]
http-proxy-install-update:
#!/usr/bin/env bash
set -e
echo "Installing/updating http-proxy system to latest version..."
cd {{ sparkdock_path }}
# Update http-proxy repository if it exists
if [ -d "http-proxy" ]; then
echo "π Updating existing http-proxy repository..."
cd http-proxy
echo "π§ Configuring git permissions..."
uid=$(id -u)
gid=$(id -g)
current_uid=$(stat -f "%u" .)
current_gid=$(stat -f "%g" .)
if [[ "$current_uid" != "$uid" || "$current_gid" != "$gid" ]]; then
sudo chown -R "${uid}:${gid}" .
fi
git config --local --add safe.directory $PWD
# Check if we're on main branch (http-proxy uses main, not master)
current_branch=$(git branch --show-current)
if [[ "${current_branch}" != "main" ]]; then
echo "β Error: Not on main branch (currently on '${current_branch}')"
echo "π‘ Switch to main branch first: git checkout main"
exit 1
fi
# Fetch latest changes to compare
echo "π Fetching latest changes..."
git fetch origin
# Check if we're already up to date
if git diff --quiet HEAD origin/main; then
echo "β
Http-proxy repository already up to date!"
else
# Stash any local changes
if ! git diff --quiet || ! git diff --cached --quiet; then
echo "π¦ Stashing local changes..."
git stash -m "Auto-stash before update $(date)"
fi
echo "β¬οΈ Updating to latest main..."
git reset --hard origin/main
echo "β
Http-proxy repository updated successfully!"
fi
cd {{ sparkdock_path }}
fi
# Run ansible installation/update
echo "π§ Running ansible configuration..."
# Check if running in CI/non-interactive mode (detect based on common CI environment variables)
if [[ -n "$CI" || -n "$GITHUB_ACTIONS" || -n "$NON_INTERACTIVE" ]]; then
echo "π€ Detected non-interactive environment, running without password prompt..."
ansible-playbook -i ansible/inventory.ini ansible/macos.yml -v --tags "http-proxy" -e "ansible_become_password=" --become
else
ansible-playbook -i ansible/inventory.ini ansible/macos.yml -v --tags "http-proxy" --ask-become-pass
fi
# Clean up and restart
echo "π Restarting http-proxy services..."
docker rm -vf http-proxy || true
spark-http-proxy start
echo "β
Http-proxy installation/update completed!"
# Update system packages via Homebrew (not sparkdock)
[group('system')]
system-upgrade:
#!/usr/bin/env bash
echo "Updating system packages..."
brew update && brew upgrade && brew cleanup
echo "System packages updated successfully!"
# Install mkcert for local SSL certificate generation.
[group('system')]
system-install-mkcert:
#!/usr/bin/env bash
echo "Installing mkcert..."
brew install mkcert nss
mkcert -install
echo "mkcert installed successfully!"
# Configure Google Cloud SDK and install required components.
[group('system')]
system-gcloud-reconfigure:
#!/usr/bin/env bash
set -euo pipefail
echo "Configuring Google Cloud SDK..."
# Install gcloud-cli via Homebrew if not already installed
if ! brew list --cask google-cloud-sdk >/dev/null 2>&1; then
echo "Installing Google Cloud SDK via Homebrew..."
brew install --cask google-cloud-sdk
fi
# Get the Homebrew prefix
HOMEBREW_PREFIX=$(brew --prefix)
# Source the gcloud environment
if [[ -f "${HOMEBREW_PREFIX}/share/google-cloud-sdk/path.zsh.inc" ]]; then
echo "Sourcing Google Cloud SDK environment..."
# shellcheck source=/dev/null
source "${HOMEBREW_PREFIX}/share/google-cloud-sdk/path.zsh.inc"
else
echo "β Google Cloud SDK path script not found at ${HOMEBREW_PREFIX}/share/google-cloud-sdk/path.zsh.inc"
exit 1
fi
# Install gke-gcloud-auth-plugin component
echo "Installing gke-gcloud-auth-plugin component..."
gcloud components install gke-gcloud-auth-plugin --quiet
# Verify installation
echo "Verifying gke-gcloud-auth-plugin installation..."
if gke-gcloud-auth-plugin --version >/dev/null 2>&1; then
echo "β
gke-gcloud-auth-plugin installed successfully!"
gke-gcloud-auth-plugin --version
else
echo "β Failed to verify gke-gcloud-auth-plugin installation"
exit 1
fi
# Add Google Cloud SDK paths to zshrc if not already present
ZSHRC_FILE="${HOME}/.zshrc"
echo "Updating ${ZSHRC_FILE} with Google Cloud SDK configuration..."
# Create zshrc if it doesn't exist
touch "${ZSHRC_FILE}"
# Check if Google Cloud SDK lines are already in zshrc
if ! grep -q "google-cloud-sdk/path.zsh.inc" "${ZSHRC_FILE}"; then
{
echo ""
echo "# The next line updates PATH for the Google Cloud SDK."
echo "if [ -f '${HOMEBREW_PREFIX}/share/google-cloud-sdk/path.zsh.inc' ]; then . '${HOMEBREW_PREFIX}/share/google-cloud-sdk/path.zsh.inc'; fi"
echo ""
echo "# The next line enables shell command completion for gcloud."
echo "if [ -f '${HOMEBREW_PREFIX}/share/google-cloud-sdk/completion.zsh.inc' ]; then . '${HOMEBREW_PREFIX}/share/google-cloud-sdk/completion.zsh.inc'; fi"
} >> "${ZSHRC_FILE}"
echo "β
Added Google Cloud SDK configuration to ${ZSHRC_FILE}"
else
echo "β
Google Cloud SDK configuration already present in ${ZSHRC_FILE}"
fi
echo "π Google Cloud SDK reconfiguration completed successfully!"
echo "π‘ You may need to restart your terminal or run 'source ~/.zshrc' to use the updated PATH"
# System cleanup to free up disk space (Homebrew and Docker).
[group('system')]
system-cleanup:
#!/usr/bin/env bash
echo "========== System Cleanup Operations =========="
echo "This command will perform the following actions:"
echo " 1. Homebrew cleanup:"
echo " - Remove old versions of installed formulae"
echo " - Delete cached downloads and outdated packages"
echo ""
echo " 2. Docker cleanup:"
echo " - Remove all stopped containers"
echo " - Remove all dangling images"
echo " - Remove all unused networks"
echo " - Remove all build cache not being used"
echo ""
echo "This will free up disk space, but you won't be able to"
echo "recover the removed data afterward."
echo "=============================================="
echo ""
read -p "Do you want to continue with system cleanup? (y/n) " -n 1 -r
echo # Move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo "Running cleanup operations..."
brew cleanup && docker system prune -f
echo "β
System cleanup completed successfully!"
else
echo "System cleanup cancelled."
fi
# List all running Docker containers with formatted output.
[group('docker')]
docker-ps:
@docker ps --format 'table {{"{{"}}.Names{{"}}"}}\t{{"{{"}}.Status{{"}}"}}\t{{"{{"}}.Ports{{"}}"}}'
# Clean up unused Docker resources to free disk space.
[group('docker')]
docker-prune:
@docker system prune -f
# Restart the Docker daemon to resolve common issues.
[group('docker')]
docker-restart:
@osascript -e 'quit app "Docker"' && open -a Docker
# Install sparkdock ansible tag.
[group('sparkdock')]
sparkdock-install-tags tags:
#!/usr/bin/env bash
echo "Running ansible with following tags: {{tags}}"
cd {{ sparkdock_path }}
ansible-playbook -i ansible/inventory.ini ansible/macos.yml -v --tags "{{tags}}" --ask-become-pass
# Update Sparkdock git repository to latest version, it doesn't run any ansible task.
[group('sparkdock')]
sparkdock-update-repository:
#!/usr/bin/env bash
set -e
echo "Updating Sparkdock repository to latest version..."
cd {{ sparkdock_path }}
# Fix git ownership issues
echo "π§ Configuring git safe directory..."
git config --local --add safe.directory $PWD
# Check if we're on {{ default_branch }} branch.
current_branch=$(git branch --show-current)
if [[ "${current_branch}" != "{{ default_branch }}" ]]; then
echo "β Error: Not on {{ default_branch }} branch (currently on '${current_branch}')"
echo "π‘ Switch to {{ default_branch }} branch first: git checkout {{ default_branch }}"
exit 1
fi
# Fetch latest changes to compare
echo "π Fetching latest changes..."
git fetch origin
# Check if we're already up to date
if git diff --quiet HEAD origin/{{ default_branch }}; then
echo "β
Already up to date!"
echo "π‘ Run 'sjust --list' to see available commands."
exit 0
fi
# Stash any local changes
if ! git diff --quiet || ! git diff --cached --quiet; then
echo "π¦ Stashing local changes..."
git stash -m "Auto-stash before update $(date)"
fi
echo "β¬οΈ Updating to latest {{ default_branch }}..."
git reset --hard origin/{{ default_branch }}
echo "β
Sparkdock updated successfully!"
echo "π You now have access to the latest sjust commands and configurations."
echo "π‘ Run 'sjust --list' to see available commands."
# Run sparkdock system configuration and updates.
[group('sparkdock')]
sparkdock-upgrade:
#!/usr/bin/env bash
{{ sparkdock_path }}/bin/sparkdock.macos
echo "System configuration and updates completed!"
# Rebuild and install the latest Sparkdock menu bar application.
[group('sparkdock')]
sparkdock-menubar-install:
#!/usr/bin/env bash
echo "Rebuilding and installing Sparkdock menu bar application..."
cd {{ sparkdock_path }}
echo "π§ Running ansible with menubar tag to rebuild and install..."
# Check if running in CI/non-interactive mode (detect based on common CI environment variables)
if [[ -n "$CI" || -n "$GITHUB_ACTIONS" || -n "$NON_INTERACTIVE" ]]; then
echo "π€ Detected non-interactive environment, running without password prompt..."
ansible-playbook -i ansible/inventory.ini ansible/macos.yml -v --tags "menubar" -e "ansible_become_password=" --become
else
ansible-playbook -i ansible/inventory.ini ansible/macos.yml -v --tags "menubar" --ask-become-pass
fi
echo "β
Sparkdock menu bar app rebuilt and installed successfully!"
echo "π‘ The app should now be running via LaunchAgent"
# Fix Xcode command line tools and rebuild menubar application.
[group('menubar')]
menubar-reinstall:
#!/usr/bin/env bash
set -euo pipefail
echo "π§ Fixing Xcode command line tools and rebuilding Sparkdock menu bar application..."
echo ""
echo "This will fix common Swift compilation issues by reinstalling Xcode command line tools."
echo "You will be prompted for your password and may need to interact with the installer."
echo ""
# Check if we're in a CI environment
if [[ -n "${CI:-}" || -n "${GITHUB_ACTIONS:-}" || -n "${NON_INTERACTIVE:-}" ]]; then
echo "β This task cannot run in CI/non-interactive environments"
echo "π‘ Run this task manually on your local machine if you encounter compilation issues"
exit 1
fi
# Confirm with user
read -p "π€ Do you want to proceed with removing and reinstalling Xcode command line tools? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "β Operation cancelled"
exit 1
fi
echo "ποΈ Removing existing Xcode command line tools..."
if [[ -d "/Library/Developer/CommandLineTools" ]]; then
sudo rm -rf /Library/Developer/CommandLineTools
echo "β
Existing command line tools removed"
fi
echo "π₯ Installing Xcode command line tools..."
echo "π‘ A dialog will appear - please click 'Install' and wait for completion"
xcode-select --install
# Wait for installation to complete
echo "β³ Waiting for Xcode command line tools installation to complete..."
echo "π‘ This may take several minutes. Please be patient..."
while ! xcode-select -p &> /dev/null; do
echo "β³ Still waiting for installation to complete..."
sleep 10
done
echo "β
Xcode command line tools installation completed!"
echo ""
echo "π§ Now attempting to rebuild and install the menubar application..."
cd {{ sparkdock_path }}
# Try to build the menubar app
if ansible-playbook -i ansible/inventory.ini ansible/macos.yml -v --tags "menubar" --ask-become-pass; then
echo ""
echo "π Success! Sparkdock menu bar app has been rebuilt and installed!"
echo "π‘ The app should now be running via LaunchAgent"
else
echo ""
echo "β Menubar installation still failed after fixing command line tools"
echo "π‘ You may need to:"
echo " - Restart your terminal/shell session"
echo " - Check for other Swift/Xcode related issues"
echo " - Verify Xcode license acceptance: sudo xcodebuild -license accept"
exit 1
fi
# Helper function to validate plist and unload service
_menubar_plist_unload:
#!/usr/bin/env bash
PLIST_PATH="{{sparkdock_menubar_plist_path}}"
if [[ ! -f "${PLIST_PATH}" ]]; then
echo "β LaunchAgent plist not found at ${PLIST_PATH}"
exit 1
fi
# Bootout the service if it's currently loaded (ignore errors)
launchctl bootout gui/$(id -u) "${PLIST_PATH}" 2>/dev/null || true
# Start/restart the Sparkdock menu bar application using LaunchAgent.
[group('sparkdock')]
sparkdock-menubar-start:
#!/usr/bin/env bash
# Kill any running processes first
pkill -f "{{sparkdock_menubar_process_name}}" 2>/dev/null || true
just _menubar_plist_unload
# Load and start the service
PLIST_PATH="{{sparkdock_menubar_plist_path}}"
if ! launchctl bootstrap gui/$(id -u) "${PLIST_PATH}"; then
echo "β Failed to bootstrap menu bar app via LaunchAgent"
exit 1
fi
if ! launchctl enable gui/$(id -u)/com.sparkfabrik.sparkdock.menubar; then
echo "β Failed to enable menu bar app via LaunchAgent"
exit 1
fi
if ! launchctl kickstart gui/$(id -u)/com.sparkfabrik.sparkdock.menubar; then
echo "β Failed to kickstart menu bar app via LaunchAgent"
exit 1
fi
echo "β
Sparkdock menu bar app started successfully"
# Stop the Sparkdock menu bar application using LaunchAgent.
[group('sparkdock')]
sparkdock-menubar-stop:
#!/usr/bin/env bash
just _menubar_plist_unload
# Kill any running processes
pkill -f "{{sparkdock_menubar_process_name}}" 2>/dev/null || true
echo "β
Sparkdock menu bar app stopped successfully"