Enhance bootstrap script for .NET installation and error handling
- Added `wget` to the package installation list for improved script functionality. - Implemented a fallback mechanism using `curl` for .NET installation if the primary script fails, enhancing robustness. - Updated ownership change for the installation directory to ensure proper permissions for the user. - Enhanced logging for error scenarios during .NET installation, providing clearer feedback for troubleshooting. - Added tests to verify the new fallback functionality and ownership changes in the bootstrap script.
This commit is contained in:
@@ -93,7 +93,7 @@ else
|
|||||||
log "light запрошен, но маркера нет — полный apt"
|
log "light запрошен, но маркера нет — полный apt"
|
||||||
fi
|
fi
|
||||||
apt-get update -qq
|
apt-get update -qq
|
||||||
apt-get install -y -qq git python3 python3-venv python3-pip python3-full curl ca-certificates
|
apt-get install -y -qq git python3 python3-venv python3-pip python3-full curl wget ca-certificates
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ensure_data_mount
|
ensure_data_mount
|
||||||
@@ -148,17 +148,39 @@ else
|
|||||||
log "SwarmUI уже в ${SWARM_ROOT} (update off)"
|
log "SwarmUI уже в ${SWARM_ROOT} (update off)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Clone runs as root; Swarm's linux-dotnet-install.sh wget -O into launchtools/
|
||||||
|
# must be writable by SWARM_USER (otherwise: "dotnet-install.sh: Permission denied").
|
||||||
|
chown -R "${SWARM_USER}:${SWARM_USER}" "$SWARM_ROOT"
|
||||||
|
|
||||||
|
install_dotnet_via_curl() {
|
||||||
|
# Fallback when Swarm script fails (no wget, perms, CDN blip).
|
||||||
|
local install_dir="/home/${SWARM_USER}/.dotnet"
|
||||||
|
local script="/tmp/gpu-rent-dotnet-install.sh"
|
||||||
|
log "fallback: curl → ${script}, install → ${install_dir}"
|
||||||
|
curl -fsSL "https://dot.net/v1/dotnet-install.sh" -o "$script"
|
||||||
|
chmod +x "$script"
|
||||||
|
sudo -u "$SWARM_USER" bash "$script" --channel 10.0 --runtime aspnetcore --install-dir "$install_dir"
|
||||||
|
sudo -u "$SWARM_USER" bash "$script" --channel 10.0 --install-dir "$install_dir"
|
||||||
|
sudo -u "$SWARM_USER" bash "$script" --channel 8.0 --runtime aspnetcore --install-dir "$install_dir"
|
||||||
|
sudo -u "$SWARM_USER" bash "$script" --channel 8.0 --install-dir "$install_dir"
|
||||||
|
rm -f "$script"
|
||||||
|
}
|
||||||
|
|
||||||
if [[ ! -x /usr/share/dotnet/dotnet && ! -x "/home/${SWARM_USER}/.dotnet/dotnet" ]]; then
|
if [[ ! -x /usr/share/dotnet/dotnet && ! -x "/home/${SWARM_USER}/.dotnet/dotnet" ]]; then
|
||||||
if [[ -f "${SWARM_ROOT}/launchtools/linux-dotnet-install.sh" ]]; then
|
if [[ -f "${SWARM_ROOT}/launchtools/linux-dotnet-install.sh" ]]; then
|
||||||
log "ставим .NET SDK (скрипт SwarmUI)"
|
log "ставим .NET SDK (скрипт SwarmUI)"
|
||||||
# SwarmUI's linux-dotnet-install.sh does `cd launchtools` and
|
# SwarmUI's linux-dotnet-install.sh does `cd launchtools` and
|
||||||
# `./launchtools/dotnet-install.sh` — must run from repo root.
|
# `./launchtools/dotnet-install.sh` — must run from repo root.
|
||||||
if ! sudo -u "$SWARM_USER" bash -c "cd \"$SWARM_ROOT\" && bash launchtools/linux-dotnet-install.sh"; then
|
if ! sudo -u "$SWARM_USER" bash -c "cd \"$SWARM_ROOT\" && bash launchtools/linux-dotnet-install.sh"; then
|
||||||
log "WARN: linux-dotnet-install.sh завершился с ошибкой"
|
log "WARN: linux-dotnet-install.sh завершился с ошибкой — пробуем curl fallback"
|
||||||
|
install_dotnet_via_curl || log "WARN: curl fallback тоже упал"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
log "нет linux-dotnet-install.sh — curl fallback"
|
||||||
|
install_dotnet_via_curl || true
|
||||||
fi
|
fi
|
||||||
if [[ ! -x /usr/share/dotnet/dotnet && ! -x "/home/${SWARM_USER}/.dotnet/dotnet" ]]; then
|
if [[ ! -x /usr/share/dotnet/dotnet && ! -x "/home/${SWARM_USER}/.dotnet/dotnet" ]]; then
|
||||||
log "ERROR: .NET не установлен ($HOME/.dotnet или /usr/share/dotnet) — SwarmUI не стартует"
|
log "ERROR: .NET не установлен (/home/${SWARM_USER}/.dotnet или /usr/share/dotnet) — SwarmUI не стартует"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
log ".NET ok: $(sudo -u "$SWARM_USER" bash -lc 'command -v dotnet || echo /home/'"$SWARM_USER"'/.dotnet/dotnet')"
|
log ".NET ok: $(sudo -u "$SWARM_USER" bash -lc 'command -v dotnet || echo /home/'"$SWARM_USER"'/.dotnet/dotnet')"
|
||||||
|
|||||||
@@ -19,3 +19,7 @@ def test_bootstrap_script_is_native_swarmui():
|
|||||||
assert "light bootstrap — пропускаем apt-get" in script
|
assert "light bootstrap — пропускаем apt-get" in script
|
||||||
# llm-only re-up can skip apt when data marker exists (not only Swarm boot marker)
|
# llm-only re-up can skip apt when data marker exists (not only Swarm boot marker)
|
||||||
assert 'MARKER_DATA' in script or ".gpu-rent-ready" in script
|
assert 'MARKER_DATA' in script or ".gpu-rent-ready" in script
|
||||||
|
# .NET: chown before Swarm install script; curl fallback if wget/perms fail
|
||||||
|
assert "install_dotnet_via_curl" in script
|
||||||
|
assert "chown -R" in script
|
||||||
|
assert "wget" in script
|
||||||
|
|||||||
Reference in New Issue
Block a user