Files
mistralrs-package/script/setup/nvm.sh
rob thijssen 38a875d06b
All checks were successful
poll-upstream / check (push) Successful in 1s
feat: add nvm setup script for CI runners
Installs nvm, Node.js LTS, and creates a stable symlink at
~/.nvm/default_bin for the systemd PATH so actions/checkout@v4
can find node without sourcing .bashrc.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-27 13:11:38 +03:00

55 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Set up nvm and a stable default Node.js for a gitea_runner user on a CI runner.
#
# Usage: ./script/setup/nvm.sh <runner-host>
#
# This script:
# 1. Installs nvm for the gitea_runner user (if not already present)
# 2. Installs the current Node.js LTS version
# 3. Creates a stable symlink at ~/.nvm/default_bin pointing to the
# default node binary directory
# 4. Prints the systemd Environment line needed for the runner unit
#
# After running, add the following to the runner's systemd unit
# (/etc/systemd/system/gitea-action-runner.service):
#
# Environment=PATH=/var/lib/gitea_runner/.nvm/default_bin:/usr/local/sbin:/usr/local/bin:/usr/bin
#
# Then: sudo systemctl daemon-reload && sudo systemctl restart gitea-action-runner
set -euo pipefail
runner_host="${1:?usage: $0 <runner-host>}"
runner_user="gitea_runner"
echo "installing nvm on ${runner_host} for ${runner_user}..."
ssh "${runner_host}" "sudo -u ${runner_user} bash -c '
export NVM_DIR=\"\${HOME}/.nvm\"
if [ -s \"\${NVM_DIR}/nvm.sh\" ]; then
echo \"nvm already installed at \${NVM_DIR}\"
else
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
fi
'"
echo "installing Node.js LTS and creating stable symlink..."
ssh "${runner_host}" "sudo -u ${runner_user} bash -c '
export NVM_DIR=\"\${HOME}/.nvm\"
. \"\${NVM_DIR}/nvm.sh\"
nvm install --lts
nvm alias default lts/*
ln -sfn \"\$(dirname \"\$(nvm which default)\")\" \"\${NVM_DIR}/default_bin\"
echo \"node: \$(node --version)\"
echo \"symlink: \$(readlink -f \"\${NVM_DIR}/default_bin\")\"
'"
echo ""
echo "add the following to /etc/systemd/system/gitea-action-runner.service on ${runner_host}:"
echo ""
echo " Environment=PATH=/var/lib/${runner_user}/.nvm/default_bin:/usr/local/sbin:/usr/local/bin:/usr/bin"
echo ""
echo "then run:"
echo " ssh ${runner_host} 'sudo systemctl daemon-reload && sudo systemctl restart gitea-action-runner'"
echo ""
echo "also add 'nvm' to the runner's labels in /etc/act_runner/config.yml"