-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinux.sh
More file actions
739 lines (688 loc) · 33.1 KB
/
Copy pathlinux.sh
File metadata and controls
739 lines (688 loc) · 33.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
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
#!/bin/bash
animate_text() {
local text="$1"
for ((i=0; i<${#text}; i++)); do
echo -n "${text:$i:1}"
sleep 0.002
done
echo
}
animate_text_x2() {
local text="$1"
for ((i=0; i<${#text}; i++)); do
echo -n "${text:$i:1}"
sleep 0.0005
done
echo
}
auto_select_model() {
MEMORY_TYPE="RAM"
AVAILABLE_MEM=$(awk '
$1=="MemAvailable:" {avail=$2/1024/1024}
$1=="MemFree:" {free=$2}
$1=="Buffers:" {buf=$2}
$1=="Cached:" {cached=$2}
$1=="SReclaimable:" {srec=$2}
$1=="Shmem:" {shm=$2}
END{
if (avail > 0) printf "%.2f", avail/1.0;
else printf "%.2f", (free+buf+cached+srec-shm)/1024/1024;
}' /proc/meminfo)
TOTAL_MEM=$(awk '/MemTotal/ {print $2 / 1024 / 1024}' /proc/meminfo)
AVAILABLE_MEM_INT=$(awk -v v="$AVAILABLE_MEM" 'BEGIN{printf "%d", int(v)}')
animate_text " ↳ System analysis:"
animate_text " ↳ ${TOTAL_MEM} GB ${MEMORY_TYPE} total, ${AVAILABLE_MEM} GB ${MEMORY_TYPE} available"
if [ "$AVAILABLE_MEM_INT" -ge 22 ]; then
animate_text " 🜲 Recommending: ⬢ 6 Qwen3 for problem solving & coding"
LLM_HF_REPO="unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF"
LLM_HF_MODEL_NAME="Qwen3-Coder-30B-A3B-Instruct-Q4_K_M.gguf"
NODE_NAME="Qwen3 Coder 30B A3B Instruct Q4"
elif [ "$AVAILABLE_MEM_INT" -ge 15 ]; then
animate_text " 🜲 Recommending: ⬢ 12 Qwen3 14B for high-precision logical analysis"
LLM_HF_REPO="unsloth/Qwen3-14B-GGUF"
LLM_HF_MODEL_NAME="Qwen3-14B-Q4_K_M.gguf"
NODE_NAME="Qwen3 14B Q4"
elif [ "$AVAILABLE_MEM_INT" -ge 7 ]; then
animate_text " 🜲 Recommending: ⬢ 13 Qwen3 8B for balanced capability"
LLM_HF_REPO="unsloth/Qwen3-8B-GGUF"
LLM_HF_MODEL_NAME="Qwen3-8B-Q4_K_M.gguf"
NODE_NAME="Qwen3 8B Q4"
else
animate_text " 🜲 Recommending: ⬢ 22 Qwen3 1.7B optimized for efficiency"
LLM_HF_REPO="unsloth/Qwen3-1.7B-GGUF"
LLM_HF_MODEL_NAME="Qwen3-1.7B-Q4_K_M.gguf"
NODE_NAME="Qwen3 1.7B Q4"
fi
animate_text " ↳ Or pick a model smaller than ${AVAILABLE_MEM} GB"
}
BANNER="
▒█████░ ▒█████░ █████████░ █████████░
▓███████▓ ▓███████▓ █████████░ █████████░
░█████████░ ░█████████░ █████████░ █████████░
▓███████▓ ▓███████▓ █████████░ █████████░
▒█████░ ▒█████░ █████████░ █████████░
█████████░ █████████░
▒█████░ ▒█████░ █████████░ █████████░
▓███████▓ ▓███████▓ █████████░ █████████░
░█████████░ ░█████████░ █████████░ █████████░
▓███████▓ ▓███████▓ █████████░ █████████░
▒█████░ ▒█████░ █████████░ █████████░
"
BANNER_FULLNAME="
▒██ ░█▓░ ▒███ ▒███ ▒█████▒ █▓ ▒▓
████░ ████░ ▒███ ▒███ ▒█▒ ▒▓░▒ ▒██▓░▓██▒▒▓▓ ▓▒▒███▓░█▓ █▓ ▓█ ▒▓░▒
▒▓░ ▒▓░ ▒███ ▒███ ▒████▒ ▒█ ▓█ ██▒ ░ ██░ █▓ ▓█░ ██ ██ ▓▓█ ██ ▒█ ▓█
░▓▓ ░▓▓ ▒███ ▒███ ▒█░ █▓ █▓ ▓█ █▒ ▒█▒█▓ █▓ ░█▒█▒██▒█▓ █▓ █▓
████░ ████░ ▒███ ▒███ ▒█░ ▒█ ▓█ ██ █▓ ▓██░ ██ ███ ▒██▒ ▒█ ▓█
▒██ ░▓▒ ▒███ ▒███ ▒█░ ░▒▓░ █▓ ░░▓▒ ▓█░ ▒░▓▒ █▒ █▒░ ░▓▓░
░░█▓
"
animate_text_x2 "$BANNER"
animate_text " Welcome to ::|| Fortytwo, Noderunner."
echo
MEMORY_TYPE="RAM"
PROJECT_DIR="./FortytwoNode"
PROJECT_DEBUG_DIR="$PROJECT_DIR/debug"
PROJECT_MODEL_CACHE_DIR="$PROJECT_DIR/model_cache"
CAPSULE_EXEC="$PROJECT_DIR/FortytwoCapsule"
CAPSULE_LOGS="$PROJECT_DEBUG_DIR/FortytwoCapsule.logs"
CAPSULE_READY_URL="http://0.0.0.0:42442/ready"
PROTOCOL_EXEC="$PROJECT_DIR/FortytwoProtocol"
ACCOUNT_PRIVATE_KEY_FILE="$PROJECT_DIR/.account_private_key"
UTILS_EXEC="$PROJECT_DIR/FortytwoUtils"
animate_text "Preparing your node environment..."
if [[ ! -d "$PROJECT_DEBUG_DIR" || ! -d "$PROJECT_MODEL_CACHE_DIR" ]]; then
mkdir -p "$PROJECT_DEBUG_DIR" "$PROJECT_MODEL_CACHE_DIR"
echo
else
echo
fi
USER=$(logname)
chown "$USER:$USER" "$PROJECT_DIR"
if ! command -v curl &> /dev/null; then
animate_text " ↳ Curl is not installed. Installing curl..."
apt update && apt install -y curl
echo
fi
animate_text "Ξ Connection check to update endpoints"
curl -s --connect-timeout 3 --max-time 5 -o /dev/null "https://download.swarminference.io/capsule/latest"
CAPSULE_S3_STATUS=$?
curl -s --connect-timeout 3 --max-time 5 -o /dev/null "https://download.swarminference.io/protocol/latest"
PROTOCOL_S3_STATUS=$?
if [ "$CAPSULE_S3_STATUS" -eq 0 ] && [ "$PROTOCOL_S3_STATUS" -eq 0 ]; then
echo " ✓ Connected"
echo
elif [ "$CAPSULE_S3_STATUS" -ne 0 ] && [ "$PROTOCOL_S3_STATUS" -ne 0 ]; then
echo " ✕ ERROR: no connection. Check your internet connection, try using a VPN, and restart the script."
exit 1
else
echo " ✕ ERROR: partial connection failure. Try using a VPN and restart the script."
exit 1
fi
animate_text "▒▓░ Checking for the Latest Components Versions ░▓▒"
echo
animate_text "◰ Setup script — version validation"
INSTALLER_UPDATE_URL="https://raw.githubusercontent.com/Fortytwo-Network/fortytwo-console-app/main/linux.sh"
SCRIPT_PATH="$0"
TEMP_FILE=$(mktemp)
curl -fsSL -o "$TEMP_FILE" "$INSTALLER_UPDATE_URL"
if [ ! -s "$TEMP_FILE" ]; then
echo " ✕ ERROR: Failed to download the update. Check your internet connection and try again."
exit 1
fi
if cmp -s "$SCRIPT_PATH" "$TEMP_FILE"; then
echo " ✓ Up to date"
rm "$TEMP_FILE"
else
echo " ↳ Updating..."
cp "$SCRIPT_PATH" "${SCRIPT_PATH}.bak"
cp "$TEMP_FILE" "$SCRIPT_PATH"
chmod +x "$SCRIPT_PATH"
rm "$TEMP_FILE"
echo " ↺ Restarting script..."
sleep 3
exec "$SCRIPT_PATH" "$@"
echo " ✕ ERROR: exec failed."
exit 1
fi
CAPSULE_VERSION=$(curl -s "https://download.swarminference.io/capsule/latest")
animate_text "⎔ Capsule — version $CAPSULE_VERSION"
DOWNLOAD_CAPSULE_URL="https://download.swarminference.io/capsule/v$CAPSULE_VERSION/FortytwoCapsule-linux-amd64"
if [[ -f "$CAPSULE_EXEC" ]]; then
CURRENT_CAPSULE_VERSION_OUTPUT=$("$CAPSULE_EXEC" --version 2>/dev/null)
if [[ "$CURRENT_CAPSULE_VERSION_OUTPUT" == *"$CAPSULE_VERSION"* ]]; then
animate_text " ✓ Up to date"
else
animate_text " ↳ Updating..."
animate_text " ↳ Downloading CPU capsule..."
curl -L -o "$CAPSULE_EXEC" "$DOWNLOAD_CAPSULE_URL"
chmod +x "$CAPSULE_EXEC"
animate_text " ✓ Successfully updated"
fi
else
animate_text " ↳ Downloading CPU capsule..."
curl -L -o "$CAPSULE_EXEC" "$DOWNLOAD_CAPSULE_URL"
chmod +x "$CAPSULE_EXEC"
animate_text " ✓ Installed to: $CAPSULE_EXEC"
fi
PROTOCOL_VERSION=$(curl -s "https://download.swarminference.io/protocol/latest")
animate_text "⏃ Protocol Node — version $PROTOCOL_VERSION"
DOWNLOAD_PROTOCOL_URL="https://download.swarminference.io/protocol/v$PROTOCOL_VERSION/FortytwoProtocolNode-linux-amd64"
if [[ -f "$PROTOCOL_EXEC" ]]; then
CURRENT_PROTOCOL_VERSION_OUTPUT=$("$PROTOCOL_EXEC" --version 2>/dev/null)
if [[ "$CURRENT_PROTOCOL_VERSION_OUTPUT" == *"$PROTOCOL_VERSION"* ]]; then
animate_text " ✓ Up to date"
else
animate_text " ↳ Updating..."
curl -L -o "$PROTOCOL_EXEC" "$DOWNLOAD_PROTOCOL_URL"
chmod +x "$PROTOCOL_EXEC"
animate_text " ✓ Successfully updated"
fi
else
animate_text " ↳ Downloading..."
curl -L -o "$PROTOCOL_EXEC" "$DOWNLOAD_PROTOCOL_URL"
chmod +x "$PROTOCOL_EXEC"
animate_text " ✓ Installed to: $PROTOCOL_EXEC"
fi
UTILS_VERSION=$(curl -s "https://download.swarminference.io/utilities/latest")
animate_text "⨳ Utils — version $UTILS_VERSION"
DOWNLOAD_UTILS_URL="https://download.swarminference.io/utilities/v$UTILS_VERSION/FortytwoUtilsLinux"
if [[ -f "$UTILS_EXEC" ]]; then
CURRENT_UTILS_VERSION_OUTPUT=$("$UTILS_EXEC" --version 2>/dev/null)
if [[ "$CURRENT_UTILS_VERSION_OUTPUT" == *"$UTILS_VERSION"* ]]; then
animate_text " ✓ Up to date"
else
animate_text " ↳ Updating..."
curl -L -o "$UTILS_EXEC" "$DOWNLOAD_UTILS_URL"
chmod +x "$UTILS_EXEC"
animate_text " ✓ Successfully updated"
fi
else
animate_text " ↳ Downloading..."
curl -L -o "$UTILS_EXEC" "$DOWNLOAD_UTILS_URL"
chmod +x "$UTILS_EXEC"
animate_text " ✓ Installed to: $UTILS_EXEC"
fi
echo
animate_text "▒▓░ Identity Initialization ░▓▒"
if [[ -f "$ACCOUNT_PRIVATE_KEY_FILE" ]]; then
ACCOUNT_PRIVATE_KEY=$(cat "$ACCOUNT_PRIVATE_KEY_FILE")
echo
animate_text " ↳ Private key found at $PROJECT_DIR/.account_private_key."
animate_text " ↳ Initiating the node using an existing identity."
animate_text " ⚠ Keep the private key safe. Do not share with anyone."
echo " ⚠ Recover your node or access your wallet with it."
echo " ⚠ We will not be able to recover it if it is lost."
else
echo
echo -e "╔════════════════════ NETWORK IDENTITY ═══════════════════╗"
echo -e "║ ║"
echo -e "║ Each node requires a secure blockchain identity. ║"
echo -e "║ Select one of the following options: ║"
echo -e "║ ║"
echo -e "║ 1. Create a new identity with an activation code. ║"
echo -e "║ Recommended for new nodes. ║"
echo -e "║ ║"
echo -e "║ 2. Recover an existing identity with recovery phrase. ║"
echo -e "║ Use this if you're restoring a previous node. ║"
echo -e "║ ║"
echo -e "╚═════════════════════════════════════════════════════════╝"
echo
read -r -p "Select option [1-2]: " IDENTITY_OPTION
echo
IDENTITY_OPTION=${IDENTITY_OPTION:-1}
if [[ "$IDENTITY_OPTION" == "2" ]]; then
animate_text "[2] Recovering existing identity"
echo
while true; do
read -r -p "Enter your account recovery phrase (12, 18, or 24 words), then press Enter: " ACCOUNT_SEED_PHRASE
echo
if ! ACCOUNT_PRIVATE_KEY=$("$UTILS_EXEC" --phrase "$ACCOUNT_SEED_PHRASE"); then
echo "˙◠˙ Error: Please check the recovery phrase and try again."
continue
else
animate_text "$ACCOUNT_PRIVATE_KEY" > "$ACCOUNT_PRIVATE_KEY_FILE"
animate_text "˙ᵕ˙ The identity successfully restored!"
animate_text " ↳ Private key saved to $PROJECT_DIR/.account_private_key."
echo " ⚠ Keep the key secure. Do not share with anybody."
echo " ⚠ Restore your node or access your wallet with it."
echo " ⚠ We will not be able to recover it would it be lost."
break
fi
done
else
animate_text "[1] Creating a new identity with an activation code"
echo
"$UTILS_EXEC" --check-drop-service || exit 1
while true; do
read -r -p "Enter your activation code: " INVITE_CODE
echo
if [[ -z "$INVITE_CODE" || ${#INVITE_CODE} -lt 12 ]]; then
echo "˙◠˙ Invalid activation code. Check the code and try again."
echo
continue
fi
break
done
animate_text " ↳ Validating your identity..."
WALLET_UTILS_EXEC_OUTPUT="$("$UTILS_EXEC" --create-wallet "$ACCOUNT_PRIVATE_KEY_FILE" --drop-code "$INVITE_CODE" 2>&1)"
UTILS_EXEC_CODE=$?
if [ "$UTILS_EXEC_CODE" -gt 0 ]; then
echo "$WALLET_UTILS_EXEC_OUTPUT"
echo " ✕ ERROR: Failed to validate activation code. Please check the code and try again."
exit 1
fi
animate_text " ✓ Identity created and saved to $PROJECT_DIR/.account_private_key."
echo " ⚠ Keep the key secure. Do not share with anybody."
echo " ⚠ Restore your node or access your wallet with it."
echo " ⚠ We will not be able to recover it would it be lost."
fi
fi
echo
animate_text "▒▓░ The Unique Strength of Your Node ░▓▒"
animate_text "Choose how your node will contribute its unique strengths to the collective intelligence."
auto_select_model
echo
echo -e "╔═══════════════════════════════════════════════════════════════════════════╗"
echo -e "║ 0 ⌖ AUTO-SELECT - Optimal configuration ║"
echo -e "║ Let the system determine the best model for your hardware. ║"
echo -e "║ Balanced for performance and capabilities. ║"
echo -e "╠═══════════════════════════════════════════════════════════════════════════╣"
echo -e "║ 1 ✶ IMPORT CUSTOM - Advanced configuration ║"
echo -e "╚═══════════════════════════════════════════════════════════════════════════╝"
echo
echo "╔═════════ EXTREME TIER | Models with very high memory requirements"
animate_text_x2 "║ 2 ⬢ SUPERIOR GENERALIST"
echo "║ 65.9 GB ${MEMORY_TYPE} • GPT-oss 120B Q4"
echo "║ Frontier-level multi-step answers across coding, math, science,"
echo "║ general knowledge questions."
echo "║ "
animate_text_x2 "║ 3 ⬢ SUPERIOR GENERALIST"
echo "║ 76.5 GB ${MEMORY_TYPE} • GLM-4.5-Air Q4"
echo "║ Deliberate multi-step reasoning in logic, math, and coding;"
echo "║ excels at clear, long-form breakdowns of complex questions."
echo "║ "
animate_text_x2 "║ 4 ⬢ SUPERIOR GENERALIST"
echo "║ 31.7 GB ${MEMORY_TYPE} • Nemotron-Super-49B-v1.5 Q4"
echo "║ High-precision multi-step reasoning in general domains, math and"
echo "║ coding; produces clear step-by-step solutions to complex problems."
echo "╚═════════ EXTREME TIER END"
echo
echo "╔═════════ HEAVY TIER | Dedicating all Compute to the Node"
animate_text_x2 "║ 5 ⬢ ADVANCED REASONING"
echo "║ 19.5 GB ${MEMORY_TYPE} • Qwen3 30B A3B Thinking 2507 Q4"
echo "║ Long-context reasoning at high efficiency, with steady logic,"
echo "║ math, and coding across large inputs."
echo "║ "
animate_text_x2 "║ 6 ⬢ PROGRAMMING & ALGORITHMS"
echo "║ 19.5 GB ${MEMORY_TYPE} • Qwen3-Coder-30B-A3B-Instruct Q4"
echo "║ Writes robust, well-structured code with step-by-step reasoning;"
echo "║ handles large, multi-file tasks and refactors."
echo "║ "
animate_text_x2 "║ 7 ⬢ ADVANCED GENERALIST"
echo "║ 12.2 GB ${MEMORY_TYPE} • gpt-oss-20b Q4"
echo "║ Fast, capable multi-domain reasoning;"
echo "║ solid for day-to-day coding, math, and research."
echo "║ "
animate_text_x2 "║ 8 ⬢ MATH, SCIENCE & CODING"
echo "║ 20.9 GB ${MEMORY_TYPE} • OpenReasoning Nemotron 32B Q4"
echo "║ Meticulous step-by-step logic in math, science and code;"
echo "║ great for explainable solutions and error analysis."
echo "║ "
animate_text_x2 "║ 9 ⬢ ADVANCED GENERALIST"
echo "║ 20.3 GB ${MEMORY_TYPE} • EXAONE 4.0 32B Q4"
echo "║ Strong science and world knowledge with dependable math and coding;"
echo "║ clear, well-grounded explanations."
echo "║ "
animate_text_x2 "║ 10 ⬢ PROGRAMMING & ALGORITHMS"
echo "║ 20.9 GB ${MEMORY_TYPE} • OlympicCoder 32B Q4"
echo "║ Excels at contest-style algorithms;"
echo "║ produces correct, efficient code with clear step-by-step reasoning."
echo "║ "
animate_text_x2 "║ 11 ⬢ ADVANCED REASONING"
echo "║ 9.6 GB ${MEMORY_TYPE} • Apriel-Nemotron-15b-Thinker Q4"
echo "║ Deliberate, reflective multi-step reasoning across mixed tasks;"
echo "║ steady performance on logic, math, and coding."
echo "╚═════════ HEAVY TIER END"
echo
echo "╔═════════ LIGHT TIER | Operating the Node in Background"
animate_text_x2 "║ 12 ⬢ EVERYDAY GENERALIST"
echo "║ 9.6 GB ${MEMORY_TYPE} • Qwen3 14B Q4"
echo "║ Balanced everyday reasoning with multilingual support;"
echo "║ clear, reliable answers across common topics."
echo "║ "
animate_text_x2 "║ 13 ⬢ EVERYDAY GENERALIST"
echo "║ 5.4 GB ${MEMORY_TYPE} • Qwen3 8B Q4"
echo "║ Smooth daily Q&A with concise reasoning;"
echo "║ dependable on summaries, explanations, and light code."
echo "║ "
animate_text_x2 "║ 14 ⬢ MULTILINGUAL GENERALIST"
echo "║ 7.7 GB ${MEMORY_TYPE} • Gemma-3 4B Q4"
echo "║ Multilingual chat with long-context support;"
echo "║ dependable everyday assistant with clear explanations."
echo "║ "
animate_text_x2 "║ 15 ⬢ PROGRAMMING & ALGORITHMS"
echo "║ 9.3 GB ${MEMORY_TYPE} • DeepCoder 14B Q4"
echo "║ Generates accurate code and understands complex programming logic;"
echo "║ reliable for feature drafts and fixes."
echo "║ "
animate_text_x2 "║ 16 ⬢ PROGRAMMING & ALGORITHMS"
echo "║ 4.8 GB ${MEMORY_TYPE} • OlympicCoder 7B Q4"
echo "║ Balanced coding contest solver;"
echo "║ step-by-step algorithmic reasoning and efficient code."
echo "║ "
animate_text_x2 "║ 17 ⬢ MATH & FORMAL LOGIC"
echo "║ 9.3 GB ${MEMORY_TYPE} • OpenMath-Nemotron 14B Q4"
echo "║ Excels at math questions and structured problem-solving;"
echo "║ clear steps for academic and competition problems."
echo "║ "
animate_text_x2 "║ 18 ⬢ MATH & CODING"
echo "║ 3.8 GB ${MEMORY_TYPE} • AceReason-Nemotron-1.1-7B Q3 Small"
echo "║ Handles math and logic puzzles with minimal resources;"
echo "║ concise, step-by-step solutions."
echo "║ "
animate_text_x2 "║ 19 ⬢ THEOREM PROVER"
echo "║ 5.4 GB ${MEMORY_TYPE} • Kimina Prover Distill 8B Q4"
echo "║ Specialist in formal logic and proof steps;"
echo "║ ideal for theorem-style tasks and verification."
echo "║ "
animate_text_x2 "║ 20 ⬢ RUST PROGRAMMING"
echo "║ 4.9 GB ${MEMORY_TYPE} • Tessa-Rust-T1 7B Q4"
echo "║ Focused on Rust programming; produces idiomatic Rust and"
echo "║ helps with code generation, fixes and refactors."
echo "║ "
animate_text_x2 "║ 21 ⬢ MEDICAL EXPERT"
echo "║ 5.4 GB ${MEMORY_TYPE} • II-Medical-8B Q5"
echo "║ Works through clinical Q&A step by step;"
echo "║ useful for study and drafting (non-diagnostic)."
echo "║ "
animate_text_x2 "║ 22 ⬢ LOW MEMORY MODEL"
echo "║ 1.3 GB ${MEMORY_TYPE} • Qwen3 1.7B Q4"
echo "║ Ultra-efficient for basic instructions and quick answers;"
echo "║ suitable for nodes with tight memory."
echo "║ "
animate_text_x2 "║ 23 ⬢ MATH EQUATIONS & REASONING"
echo "║ 1.2 GB ${MEMORY_TYPE} • Palmyra-Mini-Thinking-B 1.78B Q5"
echo "║ Ultra-optimized for low memory; Another specialized variant;"
echo "║ that excels at mathematical equations and reasoning."
echo "║ "
echo "╚═════════ LIGHT TIER END"
echo
echo "[0] Auto, [1] Import, [2-23] Specialized Model"
read -r -p "Select your node's specialization option: " NODE_CLASS
case $NODE_CLASS in
0)
animate_text "⌖ Analyzing system for optimal configuration:"
auto_select_model
;;
1)
echo
echo "══════════════════ CUSTOM MODEL IMPORT ════════════════════"
echo " Intended for users familiar with language models."
echo
read -r -p "Enter HuggingFace repository (e.g., Qwen/Qwen2.5-3B-Instruct-GGUF): " LLM_HF_REPO
read -r -p "Enter model filename (e.g., qwen2.5-3b-instruct-q4_k_m.gguf): " LLM_HF_MODEL_NAME
NODE_NAME="✶ CUSTOM IMPORT: HuggingFace ${LLM_HF_REPO##*/}"
;;
2)
LLM_HF_REPO="unsloth/gpt-oss-120b-GGUF"
LLM_HF_MODEL_NAME="Q4_K_M/gpt-oss-120b-Q4_K_M-00001-of-00002.gguf"
NODE_NAME="⬢ SUPERIOR GENERALIST: gpt-oss-120b Q4"
;;
3)
LLM_HF_REPO="unsloth/GLM-4.5-Air-GGUF"
LLM_HF_MODEL_NAME="Q4_K_M/GLM-4.5-Air-Q4_K_M-00001-of-00002.gguf"
NODE_NAME="⬢ SUPERIOR GENERALIST: GLM-4.5-Air Q4"
;;
4)
LLM_HF_REPO="unsloth/Llama-3_3-Nemotron-Super-49B-v1_5-GGUF"
LLM_HF_MODEL_NAME="Llama-3_3-Nemotron-Super-49B-v1_5-Q4_K_M.gguf"
NODE_NAME="⬢ SUPERIOR GENERALIST: Nemotron-Super-49B-v1.5 Q4"
;;
5)
LLM_HF_REPO="unsloth/Qwen3-30B-A3B-Thinking-2507-GGUF"
LLM_HF_MODEL_NAME="Qwen3-30B-A3B-Thinking-2507-Q4_K_M.gguf"
NODE_NAME="⬢ ADVANCED REASONING: Qwen3 30B A3B Thinking 2507 Q4"
;;
6)
LLM_HF_REPO="unsloth/Qwen3-Coder-30B-A3B-Instruct-GGUF"
LLM_HF_MODEL_NAME="Qwen3-Coder-30B-A3B-Instruct-Q4_K_M.gguf"
NODE_NAME="⬢ PROGRAMMING & ALGORITHMS: Qwen3-Coder-30B-A3B-Instruct Q4"
;;
7)
LLM_HF_REPO="unsloth/gpt-oss-20b-GGUF"
LLM_HF_MODEL_NAME="gpt-oss-20b-Q4_K_M.gguf"
NODE_NAME="⬢ ADVANCED GENERALIST: gpt-oss-20b Q4"
;;
8)
LLM_HF_REPO="unsloth/OpenReasoning-Nemotron-32B-GGUF"
LLM_HF_MODEL_NAME="OpenReasoning-Nemotron-32B-Q4_K_M.gguf"
NODE_NAME="⬢ MATH, SCIENCE & CODING: OpenReasoning Nemotron 32B Q4"
;;
9)
LLM_HF_REPO="LGAI-EXAONE/EXAONE-4.0-32B-GGUF"
LLM_HF_MODEL_NAME="LGAI-EXAONE_EXAONE-4.0-32B-Q4_K_M.gguf"
NODE_NAME="⬢ ADVANCED GENERALIST: EXAONE 4.0 32B Q4"
;;
10)
LLM_HF_REPO="bartowski/open-r1_OlympicCoder-32B-GGUF"
LLM_HF_MODEL_NAME="open-r1_OlympicCoder-32B-Q4_K_M.gguf"
NODE_NAME="⬢ PROGRAMMING & ALGORITHMS: OlympicCoder 32B Q4"
;;
11)
LLM_HF_REPO="bartowski/ServiceNow-AI_Apriel-Nemotron-15b-Thinker-GGUF"
LLM_HF_MODEL_NAME="ServiceNow-AI_Apriel-Nemotron-15b-Thinker-Q4_K_M.gguf"
NODE_NAME="⬢ ADVANCED REASONING: Apriel-Nemotron-15b-Thinker Q4"
;;
12)
LLM_HF_REPO="unsloth/Qwen3-14B-GGUF"
LLM_HF_MODEL_NAME="Qwen3-14B-Q4_K_M.gguf"
NODE_NAME="⬢ EVERYDAY GENERALIST: Qwen3 14B Q4"
;;
13)
LLM_HF_REPO="unsloth/Qwen3-8B-GGUF"
LLM_HF_MODEL_NAME="Qwen3-8B-Q4_K_M.gguf"
NODE_NAME="⬢ EVERYDAY GENERALIST: Qwen3 8B Q4"
;;
14)
LLM_HF_REPO="unsloth/gemma-3-12b-it-GGUF"
LLM_HF_MODEL_NAME="gemma-3-12b-it-Q4_K_M.gguf"
NODE_NAME="⬢ MULTILINGUAL GENERALIST: Gemma-3 4B Q4"
;;
15)
LLM_HF_REPO="bartowski/agentica-org_DeepCoder-14B-Preview-GGUF"
LLM_HF_MODEL_NAME="agentica-org_DeepCoder-14B-Preview-Q4_K_M.gguf"
NODE_NAME="⬢ PROGRAMMING & ALGORITHMS: DeepCoder 14B Q4"
;;
16)
LLM_HF_REPO="bartowski/open-r1_OlympicCoder-7B-GGUF"
LLM_HF_MODEL_NAME="open-r1_OlympicCoder-7B-Q4_K_M.gguf"
NODE_NAME="⬢ PROGRAMMING & ALGORITHMS: OlympicCoder 7B Q4"
;;
17)
LLM_HF_REPO="bartowski/nvidia_OpenMath-Nemotron-14B-GGUF"
LLM_HF_MODEL_NAME="nvidia_OpenMath-Nemotron-14B-Q4_K_M.gguf"
NODE_NAME="⬢ MATH & FORMAL LOGIC: OpenMath-Nemotron 14B Q4"
;;
18)
LLM_HF_REPO="bartowski/nvidia_AceReason-Nemotron-1.1-7B-GGUF"
LLM_HF_MODEL_NAME="nvidia_AceReason-Nemotron-1.1-7B-Q3_K_S.gguf"
NODE_NAME="⬢ MATH & CODING: AceReason-Nemotron-1.1-7B Q3 Small"
;;
19)
LLM_HF_REPO="mradermacher/Kimina-Prover-Distill-8B-GGUF"
LLM_HF_MODEL_NAME="Kimina-Prover-Distill-8B.Q4_K_M.gguf"
NODE_NAME="⬢ THEOREM PROVER: Kimina Prover Distill 8B Q4"
;;
20)
LLM_HF_REPO="bartowski/Tesslate_Tessa-Rust-T1-7B-GGUF"
LLM_HF_MODEL_NAME="Tesslate_Tessa-Rust-T1-7B-Q4_K_M.gguf"
NODE_NAME="⬢ RUST PROGRAMMING: Tessa-Rust-T1 7B Q4"
;;
21)
LLM_HF_REPO="Intelligent-Internet/II-Medical-8B-1706-GGUF"
LLM_HF_MODEL_NAME="II-Medical-8B-1706.Q4_K_M.gguf"
NODE_NAME="⬢ MEDICAL EXPERT: II-Medical-8B Q5"
;;
22)
LLM_HF_REPO="unsloth/Qwen3-1.7B-GGUF"
LLM_HF_MODEL_NAME="Qwen3-1.7B-Q4_K_M.gguf"
NODE_NAME="⬢ LOW MEMORY MODEL: Qwen3 1.7B Q4"
;;
23)
LLM_HF_REPO="prithivMLmods/palmyra-mini-thinking-AIO-GGUF"
LLM_HF_MODEL_NAME="palmyra-mini-thinking-b.Q5_K_M.gguf"
NODE_NAME="⬢ MATH EQUATIONS & REASONING: Palmyra-Mini-Thinking-B 1.78B Q5"
;;
*)
animate_text "No selection made. Continuing with [0] ⌖ AUTO-SELECT..."
auto_select_model
;;
esac
echo
echo "You chose:"
animate_text "${NODE_NAME}"
echo
animate_text " ↳ Downloading the model and preparing the environment may take several minutes..."
"$UTILS_EXEC" --hf-repo "$LLM_HF_REPO" --hf-model-name "$LLM_HF_MODEL_NAME" --model-cache "$PROJECT_MODEL_CACHE_DIR"
echo
animate_text "Setup completed. Ready to launch."
# clear
animate_text_x2 "$BANNER_FULLNAME"
startup() {
animate_text "⎔ Starting Capsule..."
# arguments to capsule
CMD_ARGS=(--llm-hf-repo "$LLM_HF_REPO" --llm-hf-model-name "$LLM_HF_MODEL_NAME" --model-cache "$PROJECT_MODEL_CACHE_DIR")
# Force CPU / bypass GPU runtime checks (export so child process sees them)
export SWARM_FORCE_CPU=1
export SWARM_DISABLE_CUDA=1
export SWARM_DISABLE_TENSORRT=1
export SWARM_NO_GPU=1
export CUDA_VISIBLE_DEVICES=""
export NVIDIA_VISIBLE_DEVICES=none
# ensure CAPSULE_EXEC exists and is not empty/corrupt
if [[ ! -f "$CAPSULE_EXEC" || ! -s "$CAPSULE_EXEC" ]]; then
animate_text " ↳ Capsule binary missing or empty — attempting to (re)download..."
rm -f "$CAPSULE_EXEC"
LATEST=$(curl -s https://download.swarminference.io/capsule/latest || true)
if [[ -z "$LATEST" ]]; then
animate_text " ✕ Failed to fetch latest capsule version from swarminference."
animate_text " ↳ Try alternate URL or check network."
return 1
fi
DOWNLOAD_CAPSULE_URL="https://download.swarminference.io/capsule/v${LATEST}/FortytwoCapsule-linux-amd64"
curl -L -o "$CAPSULE_EXEC" "$DOWNLOAD_CAPSULE_URL" || { animate_text " ✕ Download failed"; return 1; }
chmod +x "$CAPSULE_EXEC"
fi
# extra sanity: check file is ELF x86-64
file "$CAPSULE_EXEC" | grep -q "ELF 64-bit" || {
animate_text " ✕ Capsule binary is not a valid ELF 64-bit executable."
animate_text " ↳ Removing and re-downloading..."
rm -f "$CAPSULE_EXEC"
LATEST=$(curl -s https://download.swarminference.io/capsule/latest || true)
DOWNLOAD_CAPSULE_URL="https://download.swarminference.io/capsule/v${LATEST}/FortytwoCapsule-linux-amd64"
curl -L -o "$CAPSULE_EXEC" "$DOWNLOAD_CAPSULE_URL" || { animate_text " ✕ Download failed"; return 1; }
chmod +x "$CAPSULE_EXEC"
}
# Run capsule in background with environment already exported; use setsid so it detaches from tty
setsid "$CAPSULE_EXEC" "${CMD_ARGS[@]}" > "$CAPSULE_LOGS" 2>&1 < /dev/null &
CAPSULE_PID=$!
# small wait, then check if process started
sleep 1
if ! kill -0 "$CAPSULE_PID" 2>/dev/null; then
animate_text " ✕ Capsule process failed to start (PID: $CAPSULE_PID). Checking logs and kernel messages..."
echo "---- last lines of capsule log ----"
tail -n 40 "$CAPSULE_LOGS" 2>/dev/null || true
echo "---- dmesg (last 20 lines) ----"
dmesg | tail -n 20
return 1
fi
animate_text "Be patient, it may take some time."
# wait for ready endpoint with timeout
SECONDS_WAITED=0
TIMEOUT=300 # 5 minutes
while true; do
STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" "$CAPSULE_READY_URL" || echo "")
if [[ "$STATUS_CODE" == "200" ]]; then
animate_text "Capsule is ready."
break
fi
# detect if process died and capture reason
if ! kill -0 "$CAPSULE_PID" 2>/dev/null; then
wait "$CAPSULE_PID" 2>/dev/null
CAPSULE_EXIT_CODE=$?
animate_text "Capsule process exited (PID: $CAPSULE_PID) with code: $CAPSULE_EXIT_CODE"
echo "---- last lines of capsule log ----"
tail -n 80 "$CAPSULE_LOGS" 2>/dev/null || true
echo "---- dmesg (last 30 lines) ----"
dmesg | tail -n 30
# if illegal instruction detected, attempt to re-download different build
if dmesg | tail -n 30 | grep -qi "Illegal instruction\|invalid opcode"; then
animate_text " ↳ Kernel reports Illegal instruction / invalid opcode. Binary may be incompatible with CPU."
animate_text " ↳ Try re-downloading or use older capsule build."
fi
return 1
fi
sleep 2
SECONDS_WAITED=$((SECONDS_WAITED+2))
if [ "$SECONDS_WAITED" -ge "$TIMEOUT" ]; then
animate_text " ✕ Timeout waiting for capsule ready endpoint."
echo "---- last lines of capsule log ----"
tail -n 80 "$CAPSULE_LOGS" 2>/dev/null || true
return 1
fi
done
animate_text "⏃ Starting Protocol..."
echo
animate_text "Joining ::||"
echo
"$PROTOCOL_EXEC" --account-private-key "$ACCOUNT_PRIVATE_KEY" &
PROTOCOL_PID=$!
return 0
}
cleanup() {
echo
capsule_stopped=$(kill -0 "$CAPSULE_PID" 2>/dev/null && kill "$CAPSULE_PID" 2>/dev/null && echo true || echo false)
[ "$capsule_stopped" = true ] && animate_text "⎔ Stopping capsule..."
protocol_stopped=$(kill -0 "$PROTOCOL_PID" 2>/dev/null && kill "$PROTOCOL_PID" 2>/dev/null && echo true || echo false)
[ "$protocol_stopped" = true ] && animate_text "⏃ Stopping protocol..."
if [ "$capsule_stopped" = true ] || [ "$protocol_stopped" = true ]; then
animate_text "Processes stopped"
animate_text "Bye, Noderunner"
fi
exit 0
}
startup
trap cleanup SIGINT SIGTERM SIGHUP EXIT
while true; do
IS_ALIVE="true"
if ! ps -p "$CAPSULE_PID" > /dev/null; then
wait "$CAPSULE_PID"
CAPSULE_EXIT_CODE=$?
animate_text "Capsule has stopped with exit code: $CAPSULE_EXIT_CODE"
IS_ALIVE="false"
fi
if ! ps -p "$PROTOCOL_PID" > /dev/null; then
wait "$PROTOCOL_PID"
PROTOCOL_EXIT_CODE=$?
animate_text "Node has stopped with exit code: $PROTOCOL_EXIT_CODE"
if [ "$PROTOCOL_EXIT_CODE" -eq 20 ]; then
animate_text "New protocol version is available!"
PROTOCOL_VERSION=$(curl -s "https://download.swarminference.io/protocol/latest")
animate_text "⏃ Protocol Node — version $PROTOCOL_VERSION"
DOWNLOAD_PROTOCOL_URL="https://download.swarminference.io/protocol/v$PROTOCOL_VERSION/FortytwoProtocolNode-linux-amd64"
animate_text " ↳ Updating..."
curl -L -o "$PROTOCOL_EXEC" "$DOWNLOAD_PROTOCOL_URL"
chmod +x "$PROTOCOL_EXEC"
animate_text " ✓ Successfully updated"
fi
IS_ALIVE="false"
fi
if [[ $IS_ALIVE == "false" ]]; then
echo "Capsule or Protocol process has stopped. Restarting..."
kill "$CAPSULE_PID" 2>/dev/null
kill "$PROTOCOL_PID" 2>/dev/null
startup
fi
sleep 5
done