Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·7531 lines (6740 loc) · 278 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·7531 lines (6740 loc) · 278 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
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
set -euo pipefail
# Keep installer output visible even when a subcommand redirects stdout/stderr.
exec 3>&1
# =============================================================================
# COMPONENT VERSION AND IMAGE DEFAULTS — EDIT HERE
# =============================================================================
# These are the installer defaults, grouped by installation source so a release
# can advance one component without silently changing the others. A matching
# command-line option or component environment variable still takes precedence.
#
# Pip-installed add-ons are deliberately single-sourced in
# package-index/python-packages.toml. MN_DEFAULT_AGENT_PACKAGE_INDEX_VERSION
# selects that indexed inventory; do not duplicate its individual package pins
# here.
# MirrorNeuron releases by installation source.
# Core is a GAR Docker image.
MN_DEFAULT_CORE_VERSION="${MN_DEFAULT_CORE_VERSION:-v1.3.59}"
# SDK, CLI, and API are pip packages.
MN_DEFAULT_PYTHON_SDK_VERSION="${MN_DEFAULT_PYTHON_SDK_VERSION:-v1.3.58}"
MN_DEFAULT_CLI_VERSION="${MN_DEFAULT_CLI_VERSION:-v1.3.53}"
MN_DEFAULT_API_VERSION="${MN_DEFAULT_API_VERSION:-v1.3.53}"
# Web UI is a GAR npm package (the installer strips the leading `v`).
MN_DEFAULT_WEB_UI_VERSION="${MN_DEFAULT_WEB_UI_VERSION:-v1.3.59}"
# Additional pip packages are selected from the versioned package index.
MN_DEFAULT_AGENT_PACKAGE_INDEX_VERSION="${MN_DEFAULT_AGENT_PACKAGE_INDEX_VERSION:-v1.3.59}"
# Membrane v2 context engine is a GAR Docker image.
MN_DEFAULT_MEMBRANE_CONTEXT_ENGINE_VERSION="${MN_DEFAULT_MEMBRANE_CONTEXT_ENGINE_VERSION:-v1.3.59}"
# Google Artifact Registry coordinates.
MN_DEFAULT_CORE_GAR_PROJECT="${MN_DEFAULT_CORE_GAR_PROJECT:-mirrorneuron-public-packages}"
MN_DEFAULT_CORE_GAR_LOCATION="${MN_DEFAULT_CORE_GAR_LOCATION:-us-central1}"
MN_DEFAULT_CORE_GAR_DOCKER_REPOSITORY="${MN_DEFAULT_CORE_GAR_DOCKER_REPOSITORY:-mirrorneuron-runtime}"
MN_DEFAULT_CORE_GAR_DOCKER_IMAGE_NAME="${MN_DEFAULT_CORE_GAR_DOCKER_IMAGE_NAME:-mirror-neuron-core}"
MN_DEFAULT_MEMBRANE_GAR_IMAGE="${MN_DEFAULT_MEMBRANE_GAR_IMAGE:-us-central1-docker.pkg.dev/mirrorneuron-public-packages/mirrorneuron-runtime/membrane-context-engine}"
MN_DEFAULT_PIP_INDEX_URL="${MN_DEFAULT_PIP_INDEX_URL:-https://us-central1-python.pkg.dev/mirrorneuron-public-packages/agent-skills/simple/}"
MN_DEFAULT_PYTHON_GAR_LOCATION="${MN_DEFAULT_PYTHON_GAR_LOCATION:-us-central1}"
MN_DEFAULT_PYTHON_GAR_REPOSITORY="${MN_DEFAULT_PYTHON_GAR_REPOSITORY:-agent-skills}"
MN_DEFAULT_WEB_UI_GAR_NPM_REPOSITORY="${MN_DEFAULT_WEB_UI_GAR_NPM_REPOSITORY:-mirrorneuron-npm}"
MN_DEFAULT_WEB_UI_NPM_REGISTRY="${MN_DEFAULT_WEB_UI_NPM_REGISTRY:-https://us-central1-npm.pkg.dev/mirrorneuron-public-packages/mirrorneuron-npm/}"
# Docker images started directly by the installer or generated Compose config.
MN_DEFAULT_REDIS_IMAGE="${MN_DEFAULT_REDIS_IMAGE:-redis:8}"
MN_DEFAULT_WEB_UI_IMAGE="${MN_DEFAULT_WEB_UI_IMAGE:-node:22-alpine}"
# These upstream images intentionally retain their existing mutable `latest`
# policy. Replace `latest` with a release tag or digest here to pin them.
MN_DEFAULT_SYNCTHING_IMAGE="${MN_DEFAULT_SYNCTHING_IMAGE:-syncthing/syncthing:latest}"
MN_DEFAULT_OPENSHELL_SANDBOX_IMAGE="${MN_DEFAULT_OPENSHELL_SANDBOX_IMAGE:-ghcr.io/nvidia/openshell/sandbox:latest}"
MN_DEFAULT_OPENSHELL_SUPERVISOR_IMAGE="${MN_DEFAULT_OPENSHELL_SUPERVISOR_IMAGE:-ghcr.io/nvidia/openshell/supervisor:latest}"
MN_DEFAULT_OPENSHELL_VERSION="${MN_DEFAULT_OPENSHELL_VERSION:-v0.0.47}"
MN_DEFAULT_OPENSHELL_GATEWAY_IMAGE="${MN_DEFAULT_OPENSHELL_GATEWAY_IMAGE:-ghcr.io/nvidia/openshell/gateway:0.0.47}"
# Docker Model Runner's NVIDIA source build.
MN_DEFAULT_DOCKER_MODEL_PLUGIN_PACKAGE="${MN_DEFAULT_DOCKER_MODEL_PLUGIN_PACKAGE:-docker-model-plugin}"
# Empty preserves the OS package repository’s selected version. Set an exact
# package version here when the Ubuntu Docker repository is pinned.
MN_DEFAULT_DOCKER_MODEL_PLUGIN_VERSION="${MN_DEFAULT_DOCKER_MODEL_PLUGIN_VERSION:-}"
MN_DEFAULT_NVIDIA_LLAMA_CPP_BUILD="${MN_DEFAULT_NVIDIA_LLAMA_CPP_BUILD:-b10524}"
MN_DEFAULT_NVIDIA_LLAMA_CPP_IMAGE="${MN_DEFAULT_NVIDIA_LLAMA_CPP_IMAGE:-ghcr.io/ggml-org/llama.cpp:server-cuda13-b10524}"
MN_DEFAULT_NVIDIA_MODEL_RUNNER_IMAGE="${MN_DEFAULT_NVIDIA_MODEL_RUNNER_IMAGE:-docker/model-runner:local-cuda-b10524}"
MN_DEFAULT_NVIDIA_MODEL_RUNNER_BUILD_VERSION="${MN_DEFAULT_NVIDIA_MODEL_RUNNER_BUILD_VERSION:-v1.2.6-local-b10524}"
# Python toolchain. Leave MN_DEFAULT_UV_VERSION empty to preserve the upstream
# installer’s current-release behavior; set it to a uv release to pin it.
MN_DEFAULT_MANAGED_PYTHON_VERSION="${MN_DEFAULT_MANAGED_PYTHON_VERSION:-3.11}"
MN_MANAGED_PYTHON_VERSION="${MN_MANAGED_PYTHON_VERSION:-$MN_DEFAULT_MANAGED_PYTHON_VERSION}"
MN_DEFAULT_UV_VERSION="${MN_DEFAULT_UV_VERSION:-}"
# Model artifacts referenced by generated Compose configuration.
MN_DEFAULT_LLM_MODEL_RUNNER_MODEL="${MN_DEFAULT_LLM_MODEL_RUNNER_MODEL:-gemma4:e2b}"
MN_INSTALL_MODE="${MN_INSTALL_MODE:-binary}"
MN_INSTALL_MODE_EXPLICIT="N"
MN_INSTALL_HELP_REQUESTED="N"
MN_INSTALL_VERBOSE="${MN_INSTALL_VERBOSE:-N}"
MN_INSTALL_RESET="N"
MN_INSTALL_DETECT_ONLY="N"
MN_INSTALL_START_DOCKER="N"
MN_BUILD_MEMBRANE="N"
MN_BUILD_MEMBRANE_DIR=""
MN_MEMBRANE_BUILD_PREPARED="N"
# The installer release has its own tag. It selects the versioned support
# snapshot while the component pins above select each published artifact.
MN_DEFAULT_INSTALL_VERSION="${MN_DEFAULT_INSTALL_VERSION:-v1.3.59}"
MN_INSTALL_VERSION="${MN_INSTALL_VERSION:-}"
MN_INSTALL_SCRIPT_NAME="$(basename "$0")"
MN_INSTALL_ARGS=()
function print_unified_usage() {
cat >&3 <<EOF
Usage: ./$MN_INSTALL_SCRIPT_NAME [--mode github|local|binary] [options]
Unified MirrorNeuron installer.
Modes:
github Install from GitHub repositories.
local Install from local sibling repositories in a mirror-neuron-set checkout.
binary Install released artifacts/packages. This is the default.
Common options:
--start-docker Start existing Docker only; do not install MirrorNeuron or Docker.
--detect-only Print installed/running status and version as JSON; make no changes.
--version TAG Install this release version, for example v1.2.31.
--yes, -y Run non-interactively with defaults and flags. This is the default.
--interactive Ask each install question before proceeding.
--reset Permanently clear existing runtime data before installing.
Always requires typing YES; --yes does not bypass it.
-v, --verbose Show installation details and command paths.
--no-reinstall Keep an existing install instead of overwriting it.
--web-ui / --no-web-ui Enable or skip Web UI setup.
--redis / --no-redis Enable or skip Redis Docker setup.
--context-engine / --no-context-engine
Enable or skip Membrane context engine setup.
--build-membrane Local mode: build Membrane source instead of pulling GAR.
Ignored in github/binary modes. Source: MN_MEMBRANE_DIR
or the sibling Membrane checkout.
--openshell / --no-openshell Enable or skip OpenShell gateway setup.
--syncthing / --no-syncthing Enable or skip Syncthing shared-storage replication.
--start / --no-start Start or skip starting MirrorNeuron after install.
--python PATH Same as MN_PYTHON. Must be Python 3.11.x.
--no-managed-python Do not use uv to install a private Python runtime.
--python-components LIST Install only these Python components where supported.
--core-version TAG Binary mode: pin the MirrorNeuron core release.
--python-sdk-version TAG Binary mode: pin mirrorneuron-python-sdk.
--cli-version TAG Binary mode: pin mirrorneuron-cli.
--api-version TAG Binary mode: pin mirrorneuron-api.
--web-ui-version TAG Binary mode: pin mirrorneuron-web-ui.
--gar-project PROJECT Binary mode Google Artifact Registry project override.
--gar-location LOCATION Binary mode GAR location. Default: us-central1.
--gar-repository NAME Binary mode GAR Python repository override.
--python-index-url URL Binary mode pip index URL override.
--python-extra-index-url URL Binary mode dependency fallback index URL.
-h, --help Show this help.
Examples:
./$MN_INSTALL_SCRIPT_NAME --start-docker
./$MN_INSTALL_SCRIPT_NAME --detect-only
./$MN_INSTALL_SCRIPT_NAME --no-web-ui
./$MN_INSTALL_SCRIPT_NAME --interactive
./$MN_INSTALL_SCRIPT_NAME --reset
./$MN_INSTALL_SCRIPT_NAME --mode github
./$MN_INSTALL_SCRIPT_NAME --mode local --no-web-ui --no-skills
./$MN_INSTALL_SCRIPT_NAME --version v1.2.31
./$MN_INSTALL_SCRIPT_NAME --mode github --version v1.2.31
./$MN_INSTALL_SCRIPT_NAME --core-version v1.2.31 --python-sdk-version v1.2.31 --cli-version v1.2.31 --api-version v1.2.31 --web-ui-version v1.2.31
EOF
}
# =============================================================================
# DOCKER STARTUP ONLY
# =============================================================================
function mn_start_docker() {
local host_os endpoint context attempts
attempts="${MN_DOCKER_START_ATTEMPTS:-60}"
if ! [[ "$attempts" =~ ^[1-9][0-9]*$ ]]; then
printf 'error: MN_DOCKER_START_ATTEMPTS must be a positive integer.\n' >&3
return 1
fi
if ! command -v docker >/dev/null 2>&1; then
printf 'error: Docker CLI is not installed or is not on PATH.\nNext: install Docker for your OS and rerun install.sh --start-docker.\n' >&3
return 1
fi
if docker info >/dev/null 2>&1; then
printf '✓ Docker is already running.\n' >&3
return 0
fi
context="$(docker context show 2>/dev/null || true)"
if [ -n "${DOCKER_CONTEXT:-}" ]; then
endpoint="$(docker context inspect --format '{{.Endpoints.docker.Host}}' 2>/dev/null || true)"
else
endpoint="${DOCKER_HOST:-$(docker context inspect --format '{{.Endpoints.docker.Host}}' 2>/dev/null || true)}"
fi
case "$endpoint" in
ssh://*|tcp://*|http://*|https://*)
printf 'error: The selected Docker endpoint is remote or uses TCP.\nNext: start that daemon on its host or select a local Docker context, then retry.\n' >&3
return 1 ;;
esac
host_os="$(uname -s)"
printf '==> Starting Docker\n' >&3
case "$host_os" in
Darwin)
if ! open -a Docker; then
printf 'error: Could not launch Docker Desktop.\nNext: open the installed Docker Desktop application, then retry.\n' >&3
return 1
fi
;;
Linux)
case "$context:$endpoint" in
desktop-linux:*|*:*/.docker/desktop/docker.sock)
mn_start_docker_service user docker-desktop || return 1 ;;
rootless:*|*:*/run/user/*/docker.sock)
mn_start_docker_service user docker || return 1 ;;
*) mn_start_docker_service system docker || return 1 ;;
esac
;;
MINGW*|MSYS*|CYGWIN*)
if ! docker desktop start; then
printf 'error: Could not start Docker Desktop.\nNext: open Docker Desktop manually, then retry.\n' >&3
return 1
fi
;;
*)
printf 'error: Automatic Docker startup is unsupported on this OS.\nNext: start Docker manually, then retry.\n' >&3
return 1 ;;
esac
printf '==> Waiting for Docker to become ready\n' >&3
while [ "$attempts" -gt 0 ]; do
if docker info >/dev/null 2>&1; then
printf '✓ Docker is running.\n' >&3
return 0
fi
attempts=$((attempts - 1))
[ "$attempts" -eq 0 ] || sleep 2
done
printf 'error: Docker did not become accessible before the startup timeout.\nNext: check Docker startup, socket permissions, and the selected context with docker info, then retry.\n' >&3
return 1
}
function mn_start_docker_service() {
local scope="$1" service_name="$2"
local -a command_args=() privilege=()
if [ "$scope" = user ]; then
command_args=(systemctl --user start "$service_name")
elif command -v systemctl >/dev/null 2>&1 && [ -d /run/systemd/system ]; then
command_args=(systemctl start "$service_name")
elif command -v service >/dev/null 2>&1; then
command_args=(service "$service_name" start)
else
printf 'error: No supported Docker service manager is available.\nNext: start Docker using your OS service manager, then retry.\n' >&3
return 1
fi
if [ "$scope" = system ] && [ "$(id -u)" -ne 0 ]; then
if ! command -v sudo >/dev/null 2>&1; then
printf 'error: Starting the Docker system service requires sudo.\nNext: ask an administrator to start the Docker service, then retry.\n' >&3
return 1
fi
privilege=(sudo -n)
fi
if ! ${privilege[@]+"${privilege[@]}"} "${command_args[@]}" </dev/null; then
printf 'error: Could not start the Docker service.\nNext: run the following command with the required permissions, then retry:\n ' >&3
[ "$scope" != system ] || printf 'sudo ' >&3
printf '%s ' "${command_args[@]}" >&3
printf '\n' >&3
return 1
fi
}
# =============================================================================
# READ-ONLY RUNTIME DETECTION
# =============================================================================
function mn_detect_version_is_valid() {
local version="$1"
local version_regex='^v(0|[1-9][0-9]*)[.](0|[1-9][0-9]*)[.](0|[1-9][0-9]*)([-+][0-9A-Za-z.-]+)?$'
[[ "$version" =~ $version_regex ]]
}
function mn_detect_version_from_metadata() {
local metadata_file="$1"
local version=""
[ -r "$metadata_file" ] || return 1
version="$(sed -n 's/^[[:space:]]*"core_release_tag"[[:space:]]*:[[:space:]]*"\([^"]*\)"[[:space:]]*,\{0,1\}[[:space:]]*$/\1/p' "$metadata_file" | head -n 1)"
mn_detect_version_is_valid "$version" || return 1
printf '%s' "$version"
}
function mn_detect_version_from_docker() {
local image=""
local version=""
image="$(docker container inspect --format '{{.Config.Image}}' mirror-neuron-core 2>/dev/null || true)"
if [ -n "$image" ]; then
version="$(docker image inspect --format '{{ index .Config.Labels "org.opencontainers.image.version" }}' "$image" 2>/dev/null || true)"
fi
if [ -z "$version" ]; then
version="$(docker image inspect --format '{{ index .Config.Labels "org.opencontainers.image.version" }}' mirror-neuron-core:latest 2>/dev/null || true)"
fi
mn_detect_version_is_valid "$version" || return 1
printf '%s' "$version"
}
function mn_detect_version_from_cli() {
local cli="$1"
local output=""
local version=""
[ -x "$cli" ] || return 1
output="$(MN_DISABLE_UPDATE_CHECK=1 "$cli" --version 2>/dev/null || true)"
version="$(printf '%s\n' "$output" | sed -n 's/.*\(v\{0,1\}[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\([-+][0-9A-Za-z.-][0-9A-Za-z.-]*\)\{0,1\}\).*/\1/p' | head -n 1)"
[ -n "$version" ] || return 1
case "$version" in
v*) ;;
*) version="v${version}" ;;
esac
mn_detect_version_is_valid "$version" || return 1
printf '%s' "$version"
}
function mn_detect_runtime_is_ready() {
local cli="$1"
local report=""
[ -x "$cli" ] || return 1
if report="$(MN_CLI_OUTPUT=plain MN_DISABLE_UPDATE_CHECK=1 "$cli" runtime status --json 2>/dev/null)"; then
return 0
fi
if printf '%s' "$report" | grep -q 'MN_NODE_IDENTITY_INVALID'; then
MN_DETECT_IDENTITY_INVALID="Y"
fi
return 1
}
function mn_detect_runtime() {
local install_dir="${MN_HOME:-${HOME}/.mn}"
local metadata_file="${install_dir}/install_metadata.json"
local installed="false"
local running="false"
local runtime_ready="false"
local status="not_installed"
local version=""
local docker_installed="false"
local docker_running="false"
local docker_ready="N"
local core_container_exists="N"
local cli=""
local MN_DETECT_IDENTITY_INVALID="N"
if command -v docker >/dev/null 2>&1; then
docker_installed="true"
if docker info >/dev/null 2>&1; then
docker_running="true"
docker_ready="Y"
if docker container inspect mirror-neuron-core >/dev/null 2>&1; then
core_container_exists="Y"
fi
fi
fi
if [ -f "$metadata_file" ] || [ -f "${install_dir}/docker-compose.yml" ] || \
[ -x "${install_dir}/bin/mn" ] || [ -x "${install_dir}/venv/bin/mn" ] || \
[ "$core_container_exists" = "Y" ]; then
installed="true"
fi
if [ -x "${install_dir}/bin/mn" ]; then
cli="${install_dir}/bin/mn"
elif [ -x "${install_dir}/venv/bin/mn" ]; then
cli="${install_dir}/venv/bin/mn"
fi
if [ "$installed" = "true" ] && [ -n "$cli" ] && mn_detect_runtime_is_ready "$cli"; then
runtime_ready="true"
fi
if [ "$installed" = "true" ]; then
if [ "$docker_ready" != "Y" ]; then
running="null"
status="docker_not_running"
elif [ "$(docker container inspect --format '{{.State.Running}}' mirror-neuron-core 2>/dev/null || true)" = "true" ]; then
running="true"
status="running"
else
status="stopped"
fi
fi
if [ "$MN_DETECT_IDENTITY_INVALID" = "Y" ] && [ "$docker_ready" = "Y" ]; then
status="identity_invalid"
fi
version="$(mn_detect_version_from_metadata "$metadata_file" || true)"
if [ -z "$version" ] && [ "$docker_ready" = "Y" ]; then
version="$(mn_detect_version_from_docker || true)"
fi
if [ -z "$version" ]; then
[ -z "$cli" ] || version="$(mn_detect_version_from_cli "$cli" || true)"
fi
if [ -n "$version" ]; then
printf '{"installed":%s,"running":%s,"runtime_ready":%s,"status":"%s","version":"%s","docker_installed":%s,"docker_running":%s}\n' \
"$installed" "$running" "$runtime_ready" "$status" "$version" "$docker_installed" "$docker_running"
else
printf '{"installed":%s,"running":%s,"runtime_ready":%s,"status":"%s","version":null,"docker_installed":%s,"docker_running":%s}\n' \
"$installed" "$running" "$runtime_ready" "$status" "$docker_installed" "$docker_running"
fi
}
function mn_validate_version_tag_or_exit() {
local tag="$1"
local semver_tag_regex='^v(0|[1-9][0-9]*)[.](0|[1-9][0-9]*)[.](0|[1-9][0-9]*)(-(alpha|beta|rc)[.](0|[1-9][0-9]*))?$'
if [[ ! "$tag" =~ $semver_tag_regex ]]; then
echo "install.sh: invalid release version '$tag'. Expected vMAJOR.MINOR.PATCH or vMAJOR.MINOR.PATCH-rc.N." >&3
exit 1
fi
}
function mn_package_version_from_tag() {
local tag="$1"
local version="${tag#v}"
version="${version/-alpha./a}"
version="${version/-beta./b}"
version="${version/-rc./rc}"
printf '%s' "$version"
}
function mn_web_ui_package_version_from_tag() {
local tag="$1"
printf '%s' "${tag#v}"
}
function mn_default_membrane_engine_tag() {
printf '%s' "$MN_DEFAULT_MEMBRANE_CONTEXT_ENGINE_VERSION"
}
function mn_run_uv_installer() {
local installer="$1"
local target_dir="$2"
if [ -n "$MN_DEFAULT_UV_VERSION" ]; then
UV_UNMANAGED_INSTALL="$target_dir" UV_VERSION="$MN_DEFAULT_UV_VERSION" sh "$installer"
else
UV_UNMANAGED_INSTALL="$target_dir" sh "$installer"
fi
}
function mn_install_support_asset_path() {
local relative_path="$1"
if [ -n "${MN_INSTALL_VERSION:-}" ]; then
printf 'install_support/%s/%s' "$MN_INSTALL_VERSION" "$relative_path"
else
printf '%s' "$relative_path"
fi
}
function mn_is_linux_nvidia_host() {
[ "$(uname -s)" = "Linux" ] || return 1
command -v nvidia-smi >/dev/null 2>&1 || return 1
local gpu_list
gpu_list="$(nvidia-smi -L 2>/dev/null || true)"
[ -n "$gpu_list" ]
}
function mn_is_ubuntu_linux_host() {
[ "$(uname -s)" = "Linux" ] || return 1
[ -r /etc/os-release ] || return 1
local distro_id distro_like
distro_id="$(. /etc/os-release; printf '%s' "${ID:-}")"
distro_like="$(. /etc/os-release; printf '%s' "${ID_LIKE:-}")"
case " ${distro_id} ${distro_like} " in
*" ubuntu "*) return 0 ;;
*) return 1 ;;
esac
}
function mn_is_docker_desktop_host() {
local host_os docker_os
host_os="$(uname -s)"
case "$host_os" in
Darwin|MINGW*|MSYS*|CYGWIN*) return 0 ;;
esac
docker_os="$(docker info --format '{{.OperatingSystem}}' 2>/dev/null | tr '[:upper:]' '[:lower:]' || true)"
case "$docker_os" in
*"docker desktop"*|*"windows"*) return 0 ;;
*) return 1 ;;
esac
}
function mn_print_docker_model_runner_install_hint() {
if mn_is_docker_desktop_host; then
printf 'Next: docker desktop enable model-runner\n' >&3
elif mn_is_ubuntu_linux_host; then
printf 'Next: run these commands, then rerun install.sh:\n' >&3
printf ' sudo apt-get update\n' >&3
printf ' sudo apt-get install docker-model-plugin -y\n' >&3
else
printf "Next: install the Docker Model Runner plugin for this platform, then run 'docker model start-runner'.\n" >&3
fi
}
function mn_install_ubuntu_docker_model_plugin() {
local package_name package_version
local -a privilege=()
package_name="${MN_DOCKER_MODEL_PLUGIN_PACKAGE:-$MN_DEFAULT_DOCKER_MODEL_PLUGIN_PACKAGE}"
package_version="${MN_DOCKER_MODEL_PLUGIN_VERSION:-$MN_DEFAULT_DOCKER_MODEL_PLUGIN_VERSION}"
if [ -n "$package_version" ]; then
package_name="${package_name}=${package_version}"
fi
if ! command -v apt-get >/dev/null 2>&1; then
print_error "'apt-get' is required to install docker-model-plugin on Ubuntu."
mn_print_docker_model_runner_install_hint
exit 1
fi
if [ "$(id -u)" -ne 0 ]; then
if ! command -v sudo >/dev/null 2>&1; then
print_error "'sudo' is required to install docker-model-plugin on Ubuntu."
mn_print_docker_model_runner_install_hint
exit 1
fi
if [ "${NON_INTERACTIVE:-Y}" = "Y" ]; then
if ! sudo -n true >/dev/null 2>&1; then
print_error "Installing docker-model-plugin requires sudo access."
mn_print_docker_model_runner_install_hint
exit 1
fi
privilege=(sudo -n)
else
privilege=(sudo)
fi
fi
print_step "Installing Docker Model Runner plugin for Ubuntu"
if ! ${privilege[@]+"${privilege[@]}"} apt-get update; then
print_error "Could not refresh Ubuntu package metadata."
mn_print_docker_model_runner_install_hint
exit 1
fi
if ! ${privilege[@]+"${privilege[@]}"} apt-get install "$package_name" -y; then
print_error "Could not install docker-model-plugin."
mn_print_docker_model_runner_install_hint
exit 1
fi
}
function mn_prepare_docker_model_runner_cli() {
if mn_is_docker_desktop_host; then
if docker model status >/dev/null 2>&1; then
return 0
fi
print_step "Enabling Docker Model Runner in Docker Desktop"
if ! docker desktop enable model-runner >/dev/null 2>&1; then
print_warning "Docker Desktop did not enable Model Runner automatically."
fi
return 0
fi
if mn_is_ubuntu_linux_host && ! docker model --help >/dev/null 2>&1; then
mn_install_ubuntu_docker_model_plugin
fi
}
function mn_docker_model_runner_endpoint_ready() {
command -v curl >/dev/null 2>&1 || return 1
curl --fail --silent --show-error --max-time 5 \
"http://127.0.0.1:12434/engines/v1/models" >/dev/null 2>&1 || \
curl --fail --silent --show-error --max-time 5 \
"http://127.0.0.1:12434/v1/models" >/dev/null 2>&1
}
function mn_wait_for_docker_model_runner() {
local attempts="${MN_DOCKER_MODEL_RUNNER_START_ATTEMPTS:-30}"
while [ "$attempts" -gt 0 ]; do
if mn_docker_model_runner_endpoint_ready; then
return 0
fi
sleep 1
attempts=$((attempts - 1))
done
return 1
}
function mn_nvidia_llamacpp_runner_image() {
printf '%s' "${MN_DOCKER_MODEL_RUNNER_NVIDIA_IMAGE:-$MN_DEFAULT_NVIDIA_MODEL_RUNNER_IMAGE}"
}
function mn_nvidia_llamacpp_runner_is_current() {
local image
image="$(docker container inspect -f '{{.Config.Image}}' docker-model-runner 2>/dev/null || true)"
[ "$image" = "$(mn_nvidia_llamacpp_runner_image)" ]
}
function mn_ensure_nvidia_llamacpp_runner() {
local runner_image build_dir llama_server_image llama_server_build runner_build_version
runner_image="$(mn_nvidia_llamacpp_runner_image)"
llama_server_image="${MN_NVIDIA_LLAMA_CPP_IMAGE:-$MN_DEFAULT_NVIDIA_LLAMA_CPP_IMAGE}"
llama_server_build="${MN_NVIDIA_LLAMA_CPP_BUILD:-$MN_DEFAULT_NVIDIA_LLAMA_CPP_BUILD}"
runner_build_version="${MN_NVIDIA_MODEL_RUNNER_BUILD_VERSION:-$MN_DEFAULT_NVIDIA_MODEL_RUNNER_BUILD_VERSION}"
if mn_nvidia_llamacpp_runner_is_current; then
if mn_docker_model_runner_endpoint_ready; then
return 0
fi
print_step "Starting the NVIDIA llama.cpp Docker Model Runner"
docker start docker-model-runner >/dev/null 2>&1 || true
if mn_wait_for_docker_model_runner; then
return 0
fi
print_warning "The installed NVIDIA llama.cpp Docker Model Runner did not start; rebuilding it."
fi
if ! command -v git >/dev/null 2>&1; then
print_error "git is required to build the NVIDIA llama.cpp Docker Model Runner."
exit 1
fi
build_dir="$(mktemp -d "${TMPDIR:-/tmp}/mn-dmr-llamacpp.XXXXXX")"
print_step "Updating Docker Model Runner to llama.cpp ${llama_server_build} for NVIDIA"
if ! git clone --depth 1 https://github.com/docker/model-runner.git "$build_dir"; then
rm -rf "$build_dir"
print_error "Could not fetch the Docker Model Runner source needed for the NVIDIA llama.cpp update."
exit 1
fi
if ! docker pull "$llama_server_image"; then
rm -rf "$build_dir"
print_error "Could not pull llama.cpp CUDA build ${llama_server_build}."
exit 1
fi
if ! (
cd "$build_dir"
mn_run_docker_build --target final-llamacpp \
--build-arg VERSION="$runner_build_version" \
--build-arg LLAMA_SERVER_VERSION="$llama_server_build" \
--build-arg LLAMA_SERVER_VARIANT=cuda \
--build-arg LLAMA_UPSTREAM_IMAGE="$llama_server_image" \
-t "$runner_image" .
); then
rm -rf "$build_dir"
print_error "Could not build the NVIDIA llama.cpp Docker Model Runner."
exit 1
fi
rm -rf "$build_dir"
# This replaces only the controller container; its named model volume is
# retained, so existing model artifacts survive the runtime upgrade.
docker rm -f docker-model-runner >/dev/null 2>&1 || true
if ! docker run -d \
--name docker-model-runner \
--restart unless-stopped \
--runtime nvidia \
--gpus all \
--device /dev/dri:/dev/dri \
--network bridge \
-p 127.0.0.1:12434:12434 \
-p 172.17.0.1:12434:12434 \
-v docker-model-runner-models:/models:z \
-e MODEL_RUNNER_PORT=12434 \
-e MODEL_RUNNER_ENVIRONMENT=moby \
-e MODEL_RUNNER_SOCK=/var/run/model-runner/model-runner.sock \
-e LLAMA_SERVER_PATH=/app \
-e LD_LIBRARY_PATH=/app \
-e HOME=/home/modelrunner \
-e MODELS_PATH=/models \
-e NVIDIA_VISIBLE_DEVICES=all \
-e NVIDIA_DRIVER_CAPABILITIES=compute,utility \
--label com.docker.desktop.service=model-runner \
--label com.docker.model-runner.role=controller \
"$runner_image" >/dev/null; then
print_error "Could not start the NVIDIA llama.cpp Docker Model Runner."
exit 1
fi
if ! mn_wait_for_docker_model_runner; then
print_error "The NVIDIA llama.cpp Docker Model Runner did not become ready."
exit 1
fi
print_success "Docker Model Runner is using llama.cpp CUDA build ${llama_server_build}."
}
function mn_resolve_docker_host_socket() {
local context_host=""
case "${DOCKER_HOST:-}" in
unix://*)
printf '%s\n' "${DOCKER_HOST#unix://}"
return 0
;;
esac
if command -v docker >/dev/null 2>&1; then
context_host="$(docker context inspect --format '{{.Endpoints.docker.Host}}' 2>/dev/null | head -n 1 || true)"
case "$context_host" in
unix://*)
printf '%s\n' "${context_host#unix://}"
return 0
;;
esac
fi
if [ "$(uname -s)" = "Darwin" ]; then
printf '%s/.docker/run/docker.sock\n' "$HOME"
else
printf '/var/run/docker.sock\n'
fi
}
# Public GAR pulls must not invoke the caller's credential helpers. Resolve
# the daemon before isolating Docker's config so Docker Desktop keeps its socket.
function mn_pull_public_gar_image() (
local image="$1"
local docker_config docker_host
case "$image" in
us-central1-docker.pkg.dev/mirrorneuron-public-packages/*) ;;
*) docker pull "$image"; return $? ;;
esac
if [ -n "${DOCKER_CONTEXT:-}" ]; then
docker_host="$(docker context inspect --format '{{.Endpoints.docker.Host}}')" || return 1
else
docker_host="${DOCKER_HOST:-$(docker context inspect --format '{{.Endpoints.docker.Host}}' 2>/dev/null | head -n 1 || true)}"
fi
docker_host="${docker_host:-unix://${DOCKER_HOST_SOCKET:-$(mn_resolve_docker_host_socket)}}"
docker_config="$(mktemp -d "${TMPDIR:-/tmp}/mn-public-gar-docker-config.XXXXXX")" || return 1
trap 'rm -rf "$docker_config"' EXIT
unset DOCKER_CONTEXT DOCKER_AUTH_CONFIG
DOCKER_CONFIG="$docker_config" DOCKER_HOST="$docker_host" docker pull "$image"
)
function mn_report_docker_daemon_failure() {
if docker info >/dev/null 2>&1; then
return 0
fi
print_error "Docker stopped responding during installation."
if [ "$(uname -s)" = "Darwin" ]; then
print_error "Restart Docker Desktop and rerun install.sh; the installer is safe to retry."
print_error "If Docker reports a containerd/bbolt assertion, collect diagnostics before resetting Docker data."
else
print_error "Restart the Docker daemon and rerun install.sh; the installer is safe to retry."
fi
}
function mn_run_docker_build() {
local status
if docker build "$@"; then
return 0
else
status=$?
fi
mn_report_docker_daemon_failure
return "$status"
}
function mn_prepare_installer_paths() {
MN_EXISTING_INSTALL="N"
if [ -d "$INSTALL_DIR" ] || [ -f "$BIN_DIR/mn" ]; then
MN_EXISTING_INSTALL="Y"
fi
# Keep downloads, logs and package caches away from macOS protected folders.
mkdir -p "$INSTALL_DIR/tmp" "$INSTALL_DIR/cache"
export TMPDIR="$INSTALL_DIR/tmp"
export PIP_CACHE_DIR="$INSTALL_DIR/cache/pip"
export UV_PYTHON_BIN_DIR="$INSTALL_DIR/bin"
}
function mn_shell_quote() {
local value="$1" syntax="${2:-posix}" character
case "$value" in
''|*[!a-zA-Z0-9_./-]*)
printf "'"
while [ -n "$value" ]; do
character="${value:0:1}"
value="${value:1}"
if [ "$syntax" = "fish" ] && { [ "$character" = "\\" ] || [ "$character" = "'" ]; }; then
printf '\\%s' "$character"
elif [ "$character" = "'" ]; then
printf '%s' "'\\''"
else
printf '%s' "$character"
fi
done
printf "'"
;;
*) printf '%s' "$value" ;;
esac
}
function mn_shell_environment_content() {
local runtime_home="$1" syntax="$2" destination="$3" home_value
home_value="$(mn_shell_quote "$runtime_home" "$syntax")"
if [ "$destination" = "profile" ] && [ "$runtime_home" = "$HOME/.mn" ]; then
home_value='"$HOME/.mn"'
fi
if [ "$syntax" = "fish" ]; then
printf 'set -gx MN_HOME %s\n' "$home_value"
cat <<'EOF'
if not contains -- "$MN_HOME/bin" $PATH
set -gx PATH "$MN_HOME/bin" $PATH
end
EOF
else
printf 'export MN_HOME=%s\n' "$home_value"
cat <<'EOF'
case ":${PATH:-}:" in
*":$MN_HOME/bin:"*) ;;
*) export PATH="$MN_HOME/bin:$PATH" ;;
esac
EOF
fi
}
# Resolve the login shell, not Bash running this script (including curl | bash).
function mn_login_shell() {
local login_shell="${SHELL:-}" user_name
if [ -z "$login_shell" ]; then
user_name="$(id -un)"
if command -v getent >/dev/null 2>&1; then
login_shell="$(getent passwd "$user_name" 2>/dev/null | awk -F: 'NR == 1 {print $7}' || true)"
elif command -v dscl >/dev/null 2>&1; then
login_shell="$(dscl . -read "/Users/$user_name" UserShell 2>/dev/null | awk 'NR == 1 {print $2}' || true)"
fi
if [ -z "$login_shell" ] && [ -r /etc/passwd ]; then
login_shell="$(awk -F: -v user="$user_name" '$1 == user {print $7; exit}' /etc/passwd || true)"
fi
fi
printf '%s' "${login_shell##*/}"
}
# Replace only our marked block. Preserve dotfile symlinks and permissions, and
# publish the complete file atomically without running any user startup code.
function mn_update_shell_profile() (
local profile="$1" runtime_home="$2" syntax="$3" target hops=0 temporary=""
while [ -L "$profile" ]; do
hops=$((hops + 1))
[ "$hops" -le 40 ] || return 1
target="$(readlink "$profile")" || return 1
case "$target" in
/*) profile="$target" ;;
*) profile="$(dirname "$profile")/$target" ;;
esac
done
if [ -e "$profile" ]; then
[ -f "$profile" ] && [ -r "$profile" ] && [ -w "$profile" ] || return 1
fi
mkdir -p "$(dirname "$profile")" || return 1
temporary="$(mktemp "${profile}.mn.XXXXXX")" || return 1
trap 'rm -f "$temporary"' EXIT
if [ -f "$profile" ]; then
cp -p "$profile" "$temporary" || return 1
awk '
$0 == "# >>> MirrorNeuron shell environment >>>" { managed = 1; next }
$0 == "# <<< MirrorNeuron shell environment <<<" { managed = 0; next }
managed { next }
# Older installers wrote this heading and two adjacent exports.
$0 == "# MN and OTTERDESK" { legacy = 1; next }
legacy && /^export (MN_HOME=|PATH="\$MN_HOME\/bin:\$PATH"$)/ { next }
{ legacy = 0; print }
END { if (managed) exit 1 }
' "$profile" > "$temporary" || return 1
fi
{
printf '# >>> MirrorNeuron shell environment >>>\n'
mn_shell_environment_content "$runtime_home" "$syntax" profile
printf '# <<< MirrorNeuron shell environment <<<\n'
} >> "$temporary" || return 1
# Leave an unchanged profile (including its inode) alone on reinstall.
if [ -f "$profile" ] && cmp -s "$profile" "$temporary"; then return 0; fi
mv -f "$temporary" "$profile" || return 1
)
function mn_write_shell_environment() {
local runtime_home login_shell syntax="posix" profile login_profile updated="Y"
local -a profiles=()
mkdir -p "$INSTALL_DIR"
runtime_home="$(cd "$INSTALL_DIR" && pwd)"
mn_shell_environment_content "$runtime_home" posix env > "$INSTALL_DIR/env"
export MN_HOME="$runtime_home"
case ":$PATH:" in
*":$runtime_home/bin:"*) ;;
*) export PATH="$runtime_home/bin:$PATH" ;;
esac
MN_SHELL_PROFILE_RELOAD_REQUIRED="Y"
MN_SHELL_PROFILE_PATH="$runtime_home/env"
MN_SHELL_PROFILE_SYNTAX="posix"
MN_SHELL_PROFILE_SOURCE_COMMAND="."
login_shell="$(mn_login_shell)"
case "$login_shell" in
bash)
# Bash reads only the first existing login file, plus .bashrc for
# non-login terminals. Do not create .bash_profile over .profile.
login_profile="$HOME/.bash_profile"
for profile in "$HOME/.bash_profile" "$HOME/.bash_login" "$HOME/.profile"; do
if [ -e "$profile" ] || [ -L "$profile" ]; then login_profile="$profile"; break; fi
done
profiles=("$HOME/.bashrc" "$login_profile")
MN_SHELL_PROFILE_SOURCE_COMMAND="source"
;;
zsh)
profiles=("${ZDOTDIR:-$HOME}/.zshrc" "${ZDOTDIR:-$HOME}/.zprofile")
MN_SHELL_PROFILE_SOURCE_COMMAND="source"
;;
fish)
syntax="fish"
MN_SHELL_PROFILE_SYNTAX="fish"
profiles=("${XDG_CONFIG_HOME:-$HOME/.config}/fish/conf.d/mirrorneuron.fish")
mn_shell_environment_content "$runtime_home" fish env > "$INSTALL_DIR/env.fish"
MN_SHELL_PROFILE_PATH="$runtime_home/env.fish"
MN_SHELL_PROFILE_SOURCE_COMMAND="source"
;;
sh|dash|ash|ksh|ksh93) profiles=("$HOME/.profile") ;;
*)
print_warning "Could not configure startup for shell '${login_shell:-unknown}'. Add MN_HOME and its bin directory to your shell profile."
updated="N"
;;
esac
for profile in ${profiles[@]+"${profiles[@]}"}; do
if ! mn_update_shell_profile "$profile" "$runtime_home" "$syntax"; then
print_warning "Could not update shell profile: $profile. Check its permissions and rerun the installer."
updated="N"
fi
done
if [ "$updated" = "Y" ]; then
print_success "Shell startup configured. Open a new terminal to use mn directly."
fi
printf 'For this terminal: %s %s\n' "$MN_SHELL_PROFILE_SOURCE_COMMAND" "$(mn_shell_quote "$MN_SHELL_PROFILE_PATH" "$syntax")" >&3
}
function mn_print_next_shell_command() {
local command_text="$1"
if [ "${MN_SHELL_PROFILE_RELOAD_REQUIRED:-N}" = "Y" ]; then
printf 'Next: %s %s && %s\n' "${MN_SHELL_PROFILE_SOURCE_COMMAND:-source}" "$(mn_shell_quote "$MN_SHELL_PROFILE_PATH" "${MN_SHELL_PROFILE_SYNTAX:-posix}")" "$command_text" >&3
else
printf 'Next: %s\n' "$command_text" >&3
fi
}
# Presentation only: report the resolved selections after interactive prompts.
function mn_print_install_summary() {
local components="Core"
[ "${INSTALL_PYTHON_SDK:-Y}" = "Y" ] && components="${components}, SDK"
[ "${INSTALL_CLI:-Y}" = "Y" ] && components="${components}, CLI"
[ "${INSTALL_API:-Y}" = "Y" ] && components="${components}, API"
[ "${INSTALL_WEB_UI:-N}" = "Y" ] && components="${components}, Web UI"
[ "${INSTALL_REDIS:-N}" = "Y" ] && components="${components}, Redis"
[ "${INSTALL_CONTEXT_ENGINE:-N}" = "Y" ] && components="${components}, Membrane"
[ "${INSTALL_OPENSHELL:-N}" = "Y" ] && components="${components}, OpenShell"
[ "${INSTALL_AGENTS:-N}" = "Y" ] && components="${components}, Agents"
[ "${INSTALL_SKILLS:-N}" = "Y" ] && components="${components}, Skills"
case "${MN_SYNCTHING_ENABLED:-0}" in
''|0|[Ff][Aa][Ll][Ss][Ee]|[Nn][Oo]|[Nn]|[Oo][Ff][Ff]|[Dd][Ii][Ss][Aa][Bb][Ll][Ee][Dd]) ;;
*) components="${components}, Syncthing" ;;
esac
printf '\n %sInstall%s %s\n' "$DIM" "$RESET" "$components" >&3
printf ' %sHome%s %s\n' "$DIM" "$RESET" "$INSTALL_DIR" >&3
if [ "$START_NOW" = "Y" ]; then
printf ' %sStartup%s Automatic\n' "$DIM" "$RESET" >&3
else
printf ' %sStartup%s Manual (selected Docker services may still start)\n' "$DIM" "$RESET" >&3
fi
printf '\n' >&3
}
function mn_print_cli_verification_prompt() {
[ "${INSTALL_CLI:-N}" = "Y" ] || return 0
mn_print_next_shell_command "mn --help"
}
function mn_run_runtime_compose() {
local log_dir="${TMPDIR:-/tmp}/mirror_neuron_install"
local log_file="${log_dir}/docker-compose.$$.log"
local status
if [ "$MN_INSTALL_VERBOSE" = "Y" ]; then
runtime_compose "$@"
return
fi
mkdir -p "$log_dir"
if runtime_compose "$@" >"$log_file" 2>&1; then
rm -f "$log_file"
return 0
else
status=$?
fi
print_error "Docker Compose failed. Details: $log_file"
printf ' Re-run with --verbose to show Compose output directly.\n' >&3
return "$status"
}
MN_RUNTIME_START_LOG=""
function mn_run_runtime_start_command() {
local log_dir="${TMPDIR:-/tmp}/mirror_neuron_install"
local log_file="${log_dir}/runtime-start.$$.log"
local status
# Never hide command output while leaving it attached to interactive input.
# A future CLI prompt must be visible instead of appearing as an installer hang.
if [ "$MN_INSTALL_VERBOSE" = "Y" ] || [ -t 0 ]; then
MN_DISABLE_UPDATE_CHECK=1 "$@"
return
fi
mkdir -p "$log_dir"