This commit is contained in:
Mikan
2026-10-16 12:36:58 +04:00
parent 486a718eab
commit fbff0edf77
6 changed files with 112 additions and 180 deletions

View File

@@ -2,8 +2,6 @@
set -eu
# ------------------------------------------------------------
# Configuration
# ------------------------------------------------------------
@@ -11,36 +9,30 @@ set -eu
HOST_PROJECT_PATH="${HOST_PROJECT_PATH:-}"
SSH_ROLE="${SSH_ROLE:-}"
SSH_PORT="${SSH_PORT:-22}"
NODE_INSTANCE="${NODE_INSTANCE:-gpu-node}"
if [ -z "$HOST_PROJECT_PATH" ]; then
echo "ERROR: HOST_PROJECT_PATH is not set." >&2
exit 1
fi
if [ -z "$SSH_ROLE" ]; then
echo "ERROR: SSH_ROLE is not set." >&2
exit 1
fi
case "$SSH_ROLE" in
main)
EXPECTED_PORT="22"
;;
companion)
EXPECTED_PORT="2222"
;;
*)
echo "ERROR: unknown SSH_ROLE: $SSH_ROLE" >&2
echo "Expected: main or companion" >&2
exit 1
;;
esac
# ------------------------------------------------------------
@@ -61,11 +53,11 @@ cat > /etc/profile.d/gpu-node.sh <<EOF
export HOST_PROJECT_PATH='$HOST_PROJECT_PATH'
export SSH_ROLE='$SSH_ROLE'
export SSH_PORT='$SSH_PORT'
export NODE_INSTANCE='$NODE_INSTANCE'
EOF
chmod 644 /etc/profile.d/gpu-node.sh
# ------------------------------------------------------------
# Export for processes started by sshd
# ------------------------------------------------------------
@@ -73,15 +65,15 @@ chmod 644 /etc/profile.d/gpu-node.sh
export HOST_PROJECT_PATH
export SSH_ROLE
export SSH_PORT
export NODE_INSTANCE
echo "SSH role: $SSH_ROLE"
echo "Node instance: $NODE_INSTANCE"
echo "Host project path: $HOST_PROJECT_PATH"
echo "SSH port: $SSH_PORT"
# ------------------------------------------------------------
# Start SSH
# ------------------------------------------------------------
exec /usr/sbin/sshd -D -e -p "$SSH_PORT"
exec /usr/sbin/sshd -D -e -p "$SSH_PORT"