From 79631603c52ce61752206d6e160da8a9c3638529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Petazzoni?= Date: Wed, 15 Jan 2025 19:52:12 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9E=95=EF=B8=8F=20Add=20codeserver=20support?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds a codeserver action, which installs code-server and pre-installs a couple of useful extension. It also installs a systemd user unit in the user account to run it automatically. The 'passwords' action has been tweaked so that it also creates a code-server configuration file to set the password, so that the same password can be used for SSH access and for code-server access. --- prepare-labs/lib/commands.sh | 45 ++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/prepare-labs/lib/commands.sh b/prepare-labs/lib/commands.sh index 50811da9..461d829c 100644 --- a/prepare-labs/lib/commands.sh +++ b/prepare-labs/lib/commands.sh @@ -49,6 +49,41 @@ _cmd_clean() { done } +_cmd codeserver "Install code-server on the clusters" +_cmd_codeserver() { + TAG=$1 + need_tag + + ARCH=${ARCHITECTURE-amd64} + CODESERVER_VERSION=4.96.2 + CODESERVER_URL=https://github.com/coder/code-server/releases/download/v${CODESERVER_VERSION}/code-server-${CODESERVER_VERSION}-linux-${ARCH}.tar.gz + pssh " + set -e + i_am_first_node || exit + if ! [ -x /usr/local/bin/code-server ]; then + curl -fsSL $CODESERVER_URL | sudo tar zx -C /opt + sudo ln -s /opt/code-server-${CODESERVER_VERSION}-linux-${ARCH}/bin/code-server /usr/local/bin/code-server + sudo -u $USER_LOGIN -H code-server --install-extension ms-azuretools.vscode-docker + sudo -u $USER_LOGIN -H code-server --install-extension ms-kubernetes-tools.vscode-kubernetes-tools + sudo -u $USER_LOGIN -H mkdir -p /home/$USER_LOGIN/.local/share/code-server/User + echo '{\"workbench.startupEditor\": \"terminal\"}' | sudo -u $USER_LOGIN tee /home/$USER_LOGIN/.local/share/code-server/User/settings.json + sudo -u $USER_LOGIN mkdir -p /home/$USER_LOGIN/.config/systemd/user + sudo -u $USER_LOGIN tee /home/$USER_LOGIN/.config/systemd/user/code-server.service </dev/null + ' done done info "Done."