From 4d41e83e9657f6ec7d9741f610fea7a02792b99b Mon Sep 17 00:00:00 2001 From: Altan Orhon Date: Tue, 24 Oct 2023 18:23:11 -0700 Subject: [PATCH 01/19] Build installer --- .build/install.j2.sh | 63 +++++++++++++++++++++++++++++++ .github/workflows/mkinstaller.yml | 35 +++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100755 .build/install.j2.sh create mode 100644 .github/workflows/mkinstaller.yml diff --git a/.build/install.j2.sh b/.build/install.j2.sh new file mode 100755 index 0000000..d5456b3 --- /dev/null +++ b/.build/install.j2.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +# install.sh is generated from .build/install.j2.sh. Do not edit it directly. +# This script is intended to be sourced from the current shell. +# It will clone the hyakvnc repository to ~/.hyakvnc/hyakvnc and create a symlink in it to ~/.local/bin/hyakvnc. +# These locations can be changed by setting the following environment variables: +# - HYAKVNC_DIR: Local directory to store application data (default: `$HOME/.hyakvnc`) +# - HYAKVNC_REPO_DIR: Local directory to store git repository (default: `$HYAKVNC_DIR/hyakvnc`) +# - HYAKVNC_REPO_URL: URL of the git repository to clone (default: {{j2_hyakvnc_repo_url}}) +# - BIN_INSTALL_DIR: Local directory to store executable (default: `$HOME/.local/bin`) + +_add_hyakvnc_to_path() { + [ -z "${_UNEXPANDED_BIN_INSTALL_DIR:-}" ] || [ -z "${_BIN_INSTALL_DIR:-}" ] && return 1 + case "${PATH:-}" in + *"${_BIN_INSTALL_DIR}"*) ;; + *) + if [ -n "${BASH_VERSION:-}" ]; then + echo "export PATH=\"${_UNEXPANDED_BIN_INSTALL_DIR}:\$PATH\"" >>"${HOME:-}/.bashrc" + echo "Added hyakvnc to PATH in ${HOME:-}/.bashrc" 2>&1 + export PATH="${_BIN_INSTALL_DIR}:${PATH:-}" + elif [ -n "${ZSH_VERSION:-}" ]; then + echo "export PATH=\"${_UNEXPANDED_BIN_INSTALL_DIR}:\$PATH\"" >>"${ZDOTDIR:-${HOME:-}}/.zshrc" + echo "Added hyakvnc to PATH in ${ZDOTDIR:-${HOME}}/.zshrc" 2>&1 + export PATH="${_BIN_INSTALL_DIR}:${PATH}" + rehash 2>/dev/null || true + else + echo "Could not add hyakvnc to PATH. Please add ${_BIN_INSTALL_DIR} to your shell PATH manually." 2>&1 + return 1 + fi + ;; + esac +} + +_install_hyakvnc() { + _HYAKVNC_DIR="${_HYAKVNC_DIR:-${HOME}/.hyakvnc}" # %% Local directory to store application data (default: `$HOME/.hyakvnc`) + _HYAKVNC_REPO_DIR="${_HYAKVNC_REPO_DIR:-${_HYAKVNC_DIR}/hyakvnc}" # Local directory to store git repository (default: `$HYAKVNC_DIR/hyakvnc`) + _HYAKVNC_REPO_URL="${_HYAKVNC_REPO_URL:-"{{j2_hyakvnc_repo_url}}"}" + + # shellcheck disable=SC2016 + _UNEXPANDED_BIN_INSTALL_DIR='${HOME}/.local/bin' # Local directory to store executable (default: `$HOME/.local/bin`) + _EXPANDED_BIN_INSTALL_DIR="$(eval echo "${_UNEXPANDED_BIN_INSTALL_DIR}")" # Expand environment variables in path + _BIN_INSTALL_DIR="${_BIN_INSTALL_DIR:-${_EXPANDED_BIN_INSTALL_DIR}}" + + mkdir -p "${_BIN_INSTALL_DIR}" && + rm -rf "${_HYAKVNC_DIR}/hyakvnc-tmp" && + echo "Fetching hyakvnc from ${_HYAKVNC_REPO_URL}" 2>&1 && + git clone --depth 1 --single-branch --quiet "${_HYAKVNC_REPO_URL}" ~/.hyakvnc/hyakvnc-tmp && + rm -rf "${_HYAKVNC_REPO_DIR}" && + mv "${_HYAKVNC_DIR}/hyakvnc-tmp" "${_HYAKVNC_REPO_DIR}" && + ln -sf "${_HYAKVNC_REPO_DIR}/hyakvnc" "${_BIN_INSTALL_DIR}/hyakvnc" && + echo "Installed hyakvnc to ${_BIN_INSTALL_DIR}/hyakvnc linking to hyakvnc in ${_HYAKVNC_REPO_DIR}" 2>&1 || + return 1 +} + +if _install_hyakvnc && _add_hyakvnc_to_path; then + echo "Successfully installed hyakvnc." 2>&1 +else + echo "Failed to install hyakvnc." 2>&1 +fi + +# Unset all variables and functions defined in this script: +unset _HYAKVNC_DIR _HYAKVNC_REPO_DIR _HYAKVNC_REPO_URL _UNEXPANDED_BIN_INSTALL_DIR _EXPANDED_BIN_INSTALL_DIR _BIN_INSTALL_DIR +unset -f _install_hyakvnc _add_hyakvnc_to_path diff --git a/.github/workflows/mkinstaller.yml b/.github/workflows/mkinstaller.yml new file mode 100644 index 0000000..30bdd21 --- /dev/null +++ b/.github/workflows/mkinstaller.yml @@ -0,0 +1,35 @@ +name: Build installer +"on": + push: + +jobs: + build-readme: + runs-on: ubuntu-latest + name: Build install.sh + permissions: write-all + steps: + - name: Install jinja-cli + run: | + python3 -m pip install jinja-cli + - name: Check out code for the container build + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Check if install.j2.sh has changed + id: installer-changed + run: | + if git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- .build/install.j2.sh .github/workflows/mkinstaller.yml; then + gh run cancel ${{ github.run_id }} + gh run watch ${{ github.run_id }} + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create and push install.sh + run: | + jinja -D j2_hyakvnc_repo_url 'https://github.com/${{ github.repository }}' -o install.sh .build/install.sh.j2 + git config --local user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" + git config --local user.name ${{ github.event.sender.login }} + git add install.sh + git commit -am "Update install.sh" + git push + From d375f737b887d7a6ae9eedd55d552cb9d68e2c1d Mon Sep 17 00:00:00 2001 From: maouw <62307612+maouw@users.noreply.github.com> Date: Wed, 25 Oct 2023 01:23:32 +0000 Subject: [PATCH 02/19] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b3f2024..562bff3 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ ssh your-uw-netid@klone.hyak.uw.edu After you've connected to the login node, you can download and install `hyakvnc` by running the following command. Copy and paste it into the terminal window where you are connected to the login node and press enter: ```bash -curl -o ~/.local/bin/hyakvnc --create-dirs -fsSL https://raw.githubusercontent.com/maouw/hyakvnc/main/hyakvnc && chmod +x ~/.local/bin/hyakvnc && [[ ":${PATH}:" != *":$HOME/.local/bin:"* ]] && export PATH="$HOME/.local/bin:$PATH" && [-n "${ZSH_VERSION:-}" ] && rehash +curl -o ~/.local/bin/hyakvnc --create-dirs -fsSL https://raw.githubusercontent.com/maouw/hyakvnc/install-sh/hyakvnc && chmod +x ~/.local/bin/hyakvnc && [[ ":${PATH}:" != *":$HOME/.local/bin:"* ]] && export PATH="$HOME/.local/bin:$PATH" && [-n "${ZSH_VERSION:-}" ] && rehash ``` This will download and install `hyakvnc` to your `~/.local/bin` directory and add it to your `$PATH` so you can run it by typing `hyakvnc` into the terminal window. From 66dc7a0a19b0e1f52faa5acc33d74bf02bb7b05c Mon Sep 17 00:00:00 2001 From: Altan Orhon Date: Tue, 24 Oct 2023 18:24:45 -0700 Subject: [PATCH 03/19] Build installer --- .github/workflows/mkinstaller.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mkinstaller.yml b/.github/workflows/mkinstaller.yml index 30bdd21..de15c06 100644 --- a/.github/workflows/mkinstaller.yml +++ b/.github/workflows/mkinstaller.yml @@ -3,7 +3,7 @@ name: Build installer push: jobs: - build-readme: + build-installer: runs-on: ubuntu-latest name: Build install.sh permissions: write-all From 0c5de421e6a9d515f9293592dae51484c9ff0b24 Mon Sep 17 00:00:00 2001 From: Altan Orhon Date: Tue, 24 Oct 2023 18:27:42 -0700 Subject: [PATCH 04/19] Build installer --- .github/workflows/mkinstaller.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/mkinstaller.yml b/.github/workflows/mkinstaller.yml index de15c06..7435945 100644 --- a/.github/workflows/mkinstaller.yml +++ b/.github/workflows/mkinstaller.yml @@ -26,7 +26,9 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Create and push install.sh run: | - jinja -D j2_hyakvnc_repo_url 'https://github.com/${{ github.repository }}' -o install.sh .build/install.sh.j2 + pushd .build/ + jinja -D j2_hyakvnc_repo_url 'https://github.com/${{ github.repository }}' install.sh.j2 > ../install.sh + popd git config --local user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" git config --local user.name ${{ github.event.sender.login }} git add install.sh From b5d4d3c624588f50cc830417b4db90764886b43c Mon Sep 17 00:00:00 2001 From: Altan Orhon Date: Tue, 24 Oct 2023 18:32:14 -0700 Subject: [PATCH 05/19] Build installer --- .github/workflows/mkinstaller.yml | 35 ++++++++++--------------------- 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/.github/workflows/mkinstaller.yml b/.github/workflows/mkinstaller.yml index 7435945..5e880f1 100644 --- a/.github/workflows/mkinstaller.yml +++ b/.github/workflows/mkinstaller.yml @@ -8,30 +8,17 @@ jobs: name: Build install.sh permissions: write-all steps: - - name: Install jinja-cli + - name: Template, create, and push install.sh run: | - python3 -m pip install jinja-cli - - name: Check out code for the container build - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Check if install.j2.sh has changed - id: installer-changed - run: | - if git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- .build/install.j2.sh .github/workflows/mkinstaller.yml; then - gh run cancel ${{ github.run_id }} - gh run watch ${{ github.run_id }} + if ! git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- .build/install.j2.sh .github/workflows/mkinstaller.yml; then + python3 -m pip install jinja-cli + pushd .build/ + jinja -D j2_hyakvnc_repo_url 'https://github.com/${{ github.repository }}' install.sh.j2 > ../install.sh + popd + git config --local user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" + git config --local user.name ${{ github.event.sender.login }} + git add install.sh + git commit -am "Update install.sh" + git push fi - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Create and push install.sh - run: | - pushd .build/ - jinja -D j2_hyakvnc_repo_url 'https://github.com/${{ github.repository }}' install.sh.j2 > ../install.sh - popd - git config --local user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" - git config --local user.name ${{ github.event.sender.login }} - git add install.sh - git commit -am "Update install.sh" - git push From ac9b94f42cb4518b495e74dacbaa589d4cceb66e Mon Sep 17 00:00:00 2001 From: Altan Orhon Date: Tue, 24 Oct 2023 18:36:03 -0700 Subject: [PATCH 06/19] Simplified workflows --- .github/workflows/mkinstaller.yml | 7 +++++- .github/workflows/mkreadme.yml | 42 ++++++++++--------------------- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/.github/workflows/mkinstaller.yml b/.github/workflows/mkinstaller.yml index 5e880f1..e4e8a3e 100644 --- a/.github/workflows/mkinstaller.yml +++ b/.github/workflows/mkinstaller.yml @@ -8,7 +8,12 @@ jobs: name: Build install.sh permissions: write-all steps: - - name: Template, create, and push install.sh + - name: Check out code for the container build + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Update install.sh if needed + id: update-installer run: | if ! git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- .build/install.j2.sh .github/workflows/mkinstaller.yml; then python3 -m pip install jinja-cli diff --git a/.github/workflows/mkreadme.yml b/.github/workflows/mkreadme.yml index 7d98a26..392a89d 100644 --- a/.github/workflows/mkreadme.yml +++ b/.github/workflows/mkreadme.yml @@ -8,39 +8,23 @@ jobs: name: Build README.md permissions: write-all steps: - - name: Install jinja-cli - run: | - python3 -m pip install jinja-cli - name: Check out code for the container build uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Check if README.md has changed - id: readme-changed + - name: Update README.md if needed + id: update-readme run: | if git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- hyakvnc .build/README.j2.md .github/workflows/mkreadme.yml; then - gh run cancel ${{ github.run_id }} - gh run watch ${{ github.run_id }} + pushd .build/ + sed -E '/^HYAKVNC_.*#\s*%%/!d; s/=.*(#\s*%%)/:/g; s/(^.)/- \1/g' ../hyakvnc > config.inc.md + for x in create status show stop config install; do ../hyakvnc help "$x" | sed -E '1 s/(.*)/\n### \1\n/; 2 s/^$/```text/' | pr -e4 -t && echo '```'; done > usage.inc.md + jinja -D github_repository "${{ github.repository }}" -D github_ref_name "${{ github.ref_name }}" README.j2.md | sed 's/^.*.*$//g' > ../README.md + popd + git config --local user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" + git config --local user.name ${{ github.event.sender.login }} + git add README.md + git commit -am "Update README.md" + git push fi - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Generate configuration descriptions - run: | - pushd .build/ - sed -E '/^HYAKVNC_.*#\s*%%/!d; s/=.*(#\s*%%)/:/g; s/(^.)/- \1/g' ../hyakvnc > config.inc.md - popd - - name: Generate usage descriptions - run: | - pushd .build/ - for x in create status show stop config install; do ../hyakvnc help "$x" | sed -E '1 s/(.*)/\n### \1\n/; 2 s/^$/```text/' | pr -e4 -t && echo '```'; done > usage.inc.md - popd - - name: Create and push README.md - run: | - pushd .build/ - jinja -D github_repository "${{ github.repository }}" -D github_ref_name "${{ github.ref_name }}" README.j2.md | sed 's/^.*.*$//g' > ../README.md - popd - git config --local user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" - git config --local user.name ${{ github.event.sender.login }} - git add README.md - git commit -am "Update README.md" - git push + From 3a517e7388698c1fdfab9298aab2e9e2376d9d7e Mon Sep 17 00:00:00 2001 From: Altan Orhon Date: Tue, 24 Oct 2023 18:37:37 -0700 Subject: [PATCH 07/19] Simplified workflows --- .github/workflows/mkinstaller.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/mkinstaller.yml b/.github/workflows/mkinstaller.yml index e4e8a3e..0d264d6 100644 --- a/.github/workflows/mkinstaller.yml +++ b/.github/workflows/mkinstaller.yml @@ -17,8 +17,7 @@ jobs: run: | if ! git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- .build/install.j2.sh .github/workflows/mkinstaller.yml; then python3 -m pip install jinja-cli - pushd .build/ - jinja -D j2_hyakvnc_repo_url 'https://github.com/${{ github.repository }}' install.sh.j2 > ../install.sh + jinja -D j2_hyakvnc_repo_url 'https://github.com/${{ github.repository }}' .build/install.j2.sh -o install.sh popd git config --local user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" git config --local user.name ${{ github.event.sender.login }} From 925907902fffa584b5ec07dd05692237186d9979 Mon Sep 17 00:00:00 2001 From: maouw <62307612+maouw@users.noreply.github.com> Date: Wed, 25 Oct 2023 01:37:52 +0000 Subject: [PATCH 08/19] Update README.md --- README.md | 327 ------------------------------------------------------ 1 file changed, 327 deletions(-) diff --git a/README.md b/README.md index 562bff3..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,327 +0,0 @@ -# hyakvnc - -hyakvnc -- A tool for launching VNC sessions on Hyak. - -`hyakvnc` is a command-line tool that makes it easy to start a graphical [VNC](https://en.wikipedia.org/wiki/Virtual_Network_Computing) session on the University of Washington [Hyak](https://hyak.uw.edu/) cluster, allowing you to interact with the system in a point-and-click environment, with support for graphical applications such as [Freesurfer](https://surfer.nmr.mgh.harvard.edu/). `hyakvnc` sessions run in [Apptainer](https://apptainer.org) containers, which provide reproducible environments that can run anywhere and be shared with other researchers. - -## Prerequisites - -Before running `hyakvnc`, you'll need the following: - -- A Linux, macOS, or Windows machine -- The OpenSSH client (usually included with Linux and macOS, and available for Windows via [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install) or [Cygwin](https://www.cs.odu.edu/~zeil/cs252/latest/Public/loggingin/cygwin.mmd.html) [note that the Windows 10+ built-in OpenSSH client will not work]) -- A VNC client/viewer ([TurboVNC viewer](https://www.turbovnc.org) is recommended for all platforms) -- HYAK Klone access with compute resources -- A private SSH key on your local machine which has been added to the authorized keys on the login node of the HYAK Klone cluster (see below) -- A HyakVNC-compatible Apptainer container image in a directory on Hyak (usually with the file extension `.sif`) or the URL to one (e.g,., `oras://ghcr.io/maouw/hyakvnc_apptainer/ubuntu22.04_turbovnc:latest`) - -Follow the instructions below to set up your machine correctly: - -### Installing OpenSSH and TurboVNC - -#### Linux - -If you are using Linux, OpenSSH is probably installed already -- if not, you can install it via `apt-get install openssh-client` on Debian/Ubuntu or `yum install openssh-clients` on RHEL/CentOS/Rocky/Fedora. To open a terminal window, search for "Terminal" in your desktop environment's application launcher. - -To install TurboVNC, download the latest version from [here](https://sourceforge.net/projects/turbovnc/files). On Debian/Ubuntu, you will need to download the file ending with `arm64.deb`. On RHEL/CentOS/Rocky/Fedora, you will need to download the file ending with `x86_64.rpm`. Then, install it by running `sudo dpkg -i ` on Debian/Ubuntu or `sudo rpm -i ` on RHEL/CentOS/Rocky/Fedora. - -#### macOS - -If you're on macOS, OpenSSH will already be installed. To open a terminal window, open `/Applications/Utilities/Terminal.app` or search for "Terminal" in Launchpad or Spotlight. - -To install TurboVNC, download the latest version from [here](https://sourceforge.net/projects/turbovnc/files). On an M1 Mac (newer), you will need to download the file ending with `arm64.dmg`. On an Intel Mac (older), you will need the file ending with `x86_64.dmg`. Then, open the `.dmg` file and launch the installer inside. - -#### Windows - -Windows needs a little more setup. You'll need to install a terminal emulator as well as the OpenSSH client. The easiest way to do this is to install [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install) (recommended for Windows versions 10+, comes with the OpenSSH client already installed) or [Cygwin](https://www.cs.odu.edu/~zeil/cs252/latest/Public/loggingin/cygwin.mmd.html) (not recommended, needs additional setup). See the links for instructions on how to install these. You can start a terminal window by searching for "Terminal" in the Start menu. - -To install TurboVNC, download the latest version from [here](https://sourceforge.net/projects/turbovnc/files). You will need the file ending with `x64.exe`. Run the program to install TurboVNC. - -### Setting up SSH keys to connect to Hyak compute nodes - -Before you are allowed to connect to a compute node where your VNC session will be running, you must add your SSH public key to the authorized keys on the login node of the HYAK Klone cluster. - -If you don't, you will receive an error like this when you try to connect: - -```text -Permission denied (publickey,gssapi-keyex,gssapi-with-mic) -``` - -To set this up quickly on Linux, macOS, or Windows (WSL2/Cygwin), open a new terminal window on your machine and enter the following 2 commands before you try again. Replace `your-uw-netid` with your UW NetID: - -```bash -[ ! -r ~/.ssh/id_rsa ] && ssh-keygen -t rsa -b 4096 -N '' -C "your-uw-netid@uw.edu" -f ~/.ssh/id_rsa -ssh-copy-id -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa "your-uw-netid"@klone.hyak.uw.edu -``` - -See https://hyak.uw.edu/docs/setup/intracluster-keys for more information. - -### Finding a HyakVNC-compatible container image - -You'll need to find a HyakVNC-compatible container image to run your VNC session in. The following images are provided by us and can be used with `hyakvnc` by copying and pasting the URL into the `hyakvnc create` command: - -- `oras://ghcr.io/maouw/hyakvnc_apptainer/ubuntu22.04_turbovnc:latest` -- Ubuntu 22.04 with TurboVNC -- `oras://ghcr.io/maouw/ubuntu22.04_freesurfer:latest` -- Ubuntu 22.04 with TurboVNC and Freesurfer - -## Installing `hyakvnc` - -`hyakvnc` should be installed on the login node of the HYAK Klone cluster. - -To connect to the login node, you'll need to enter the following command into a terminal window (replacing `your-uw-netid` with your UW NetID) and provide your password when prompted: - -```bash -ssh your-uw-netid@klone.hyak.uw.edu -``` - -### Quick install - -After you've connected to the login node, you can download and install `hyakvnc` by running the following command. Copy and paste it into the terminal window where you are connected to the login node and press enter: - -```bash -curl -o ~/.local/bin/hyakvnc --create-dirs -fsSL https://raw.githubusercontent.com/maouw/hyakvnc/install-sh/hyakvnc && chmod +x ~/.local/bin/hyakvnc && [[ ":${PATH}:" != *":$HOME/.local/bin:"* ]] && export PATH="$HOME/.local/bin:$PATH" && [-n "${ZSH_VERSION:-}" ] && rehash -``` - -This will download and install `hyakvnc` to your `~/.local/bin` directory and add it to your `$PATH` so you can run it by typing `hyakvnc` into the terminal window. - -### Installing manually - -In a terminal window connected to a login node, enter this command to clone the repository and navigate into the repository directory: - -```bash -git clone https://github.com/maouw/hyakvnc && cd hyakvnc -``` - -Then, run the following command to install `hyakvnc`: - -```bash -./hyakvnc install -``` - -If you prefer, you may continue to use `hyakvnc` from the directory where you cloned it by running `./hyakvnc` from that directory instead of using the command `hyakvnc`. -started - -## Getting started - -### Creating a VNC session - -Start a VNC session with the `hyakvnc create` command followed by arguments to specify the container. In this example, we'll use a basic container for a graphical environment from the HyakVNC GitHub Container Registry: - -```bash -hyakvnc create --container oras://maouw/hyakvnc_apptainer/ubuntu22.04_turbovnc:latest -``` - -It may take a few minutes to download the container if you're running it the first time. If successful, `hyakvnc` should print commands and instructions to connect: - -```text -========== -Copy and paste these instructions into a command line terminal on your local machine to connect to the VNC session. -You may need to install a VNC client if you don't already have one. - -NOTE: If you receive an error that looks like "Permission denied (publickey,gssapi-keyex,gssapi-with-mic)", you don't have an SSH key set up. -See https://hyak.uw.edu/docs/setup/intracluster-keys for more information. -To set this up quickly on Linux, macOS, or Windows (WSL2/Cygwin), open a new terminal window on your machine and enter the following 2 commands before you try again: - -[ ! -r ~/.ssh/id_rsa ] && ssh-keygen -t rsa -b 4096 -N '' -C "your-uw-netid@uw.edu" -f ~/.ssh/id_rsa -ssh-copy-id -o StrictHostKeyChecking=no your-uw-netid@klone.hyak.uw.edu ---------- -LINUX TERMINAL (bash/zsh): -ssh -f -o StrictHostKeyChecking=no -L 5901:/mmfs1/home/your-uw-netid/.hyakvnc/jobs/15042104/vnc/socket.uds -J your-uw-netid@klone.hyak.uw.edu your-uw-netid@g3053 sleep 20 && vncviewer localhost:5901 || xdg-open vnc://localhost:5901 || echo 'No VNC viewer found. Please install one or try entering the connection information manually.' - -MACOS TERMINAL -ssh -f -o StrictHostKeyChecking=no -L 5901:/mmfs1/home/your-uw-netid/.hyakvnc/jobs/15042104/vnc/socket.uds -J your-uw-netid@klone.hyak.uw.edu your-uw-netid@g3053 sleep 20 && open -b com.turbovnc.vncviewer.VncViewer --args localhost:5901 2>/dev/null || open -b com.realvnc.vncviewer --args localhost:5901 2>/dev/null || open -b com.tigervnc.vncviewer --args localhost:5901 2>/dev/null || open vnc://localhost:5901 2>/dev/null || echo 'No VNC viewer found. Please install one or try entering the connection information manually.' - -WINDOWS -ssh -f -o StrictHostKeyChecking=no -L 5901:/mmfs1/home/your-uw-netid/.hyakvnc/jobs/15042104/vnc/socket.uds -J your-uw-netid@klone.hyak.uw.edu your-uw-netid@g3053 sleep 20 && cmd.exe /c cmd /c "$(cmd.exe /c where "C:\Program Files\TurboVNC;C:\Program Files(x86)\TurboVNC:vncviewerw.bat")" localhost:5901 || echo 'No VNC viewer found. Please install one or try entering the connection information manually.' - -========== -``` - -## Usage - -`hyakvnc` is command-line tool that only works on the login node of the Hyak cluster. - -### Create a VNC session on Hyak - -```text -Usage: hyakvnc create [create options...] -c [extra args to pass to apptainer...] - -Description: - Create a VNC session on Hyak. - -Options: - -h, --help Show this help message and exit - -c, --container Path to container image (required) - -A, --account Slurm account to use (default: ) - -p, --partition Slurm partition to use (default: ) - -C, --cpus Number of CPUs to request (default: 4) - -m, --mem Amount of memory to request (default: 4G) - -t, --timelimit Slurm timelimit to use (default: 12:00:00) - -g, --gpus Number of GPUs to request (default: ) - -Extra arguments: - Any extra arguments will be passed to apptainer run. - See 'apptainer run --help' for more information. - -Examples: - # Create a VNC session using the container ~/containers/mycontainer.sif - hyakvnc create -c ~/containers/mycontainer.sif - # Create a VNC session using the URL for a container: - hyakvnc create -c oras://ghcr.io/maouw/hyakvnc_apptainer/ubuntu22.04_turbovnc:latest - # Use the SLURM account escience, the partition gpu-a40, 4 CPUs, 1GB of memory, 1 GPU, and 1 hour of time: - hyakvnc create -c ~/containers/mycontainer.sif -A escience -p gpu-a40 -C 4 -m 1G -t 1:00:00 -g 1 - -``` - -### Show the status of running HyakVNC sessions - -```text -Usage: hyakvnc status [status options...] - -Description: - Check status of VNC session(s) on Hyak. - -Options: - -h, --help Show this help message and exit - -d, --debug Print debug info - -j, --jobid Only check status of provided SLURM job ID (optional) - -Examples: - # Check the status of job no. 12345: - hyakvnc status -j 12345 - # Check the status of all VNC jobs: - hyakvnc status -``` - -### Show connection information for a HyakVNC sesssion - -```text -Usage: hyakvnc show - -Description: - Show connection information for a HyakVNC sesssion. - If no job ID is provided, a menu will be shown to select from running jobs. - -Options: - -h, --help Show this help message and exit - -Examples: - # Show connection information for session running on job 123456: - hyakvnc show 123456 - # Interactively select a job to show connection information for: - hyakvnc show - - # Show connection information for session running on job 123456 for macOS: - hyakvnc show -s mac 123456 -``` - -### Stop a HyakVNC session - -```text -Usage: hyakvnc stop [-a] [...] - -Description: - Stop a provided HyakVNC sesssion and clean up its job directory. - If no job ID is provided, a menu will be shown to select from running jobs. - -Options: - -h, --help Show this help message and exit - -n, --no-cancel Don't cancel the SLURM job - -a, --all Stop all jobs - -Examples: - # Stop a VNC session running on job 123456: - hyakvnc stop 123456 - # Stop a VNC session running on job 123456 and do not cancel the job: - hyakvnc stop --no-cancel 123456 - # Stop all VNC sessions: - hyakvnc stop -a - # Stop all VNC sessions but do not cancel the jobs: - hyakvnc stop -a -n -``` - -### Show the current configuration for hyakvnc - -```text -Usage: hyakvnc config [config options...] - -Description: - Show the current configuration for hyakvnc, as set in the user configuration file at /home/runner/.hyakvnc/hyakvnc-config.env, in the current environment, or the default values set by hyakvnc. - -Options: - -h, --help Show this help message and exit - -Examples: - # Show configuration - hyakvnc config -``` - -### Install the hyakvnc command - -```text -Usage: hyakvnc install [install options...] - -Description: - Install hyakvnc so the "hyakvnc" command can be run from anywhere. - -Options: - -h, --help Show this help message and exit - -i, --install-dir Directory to install hyakvnc to (default: ~/.local/bin) - -s, --shell [bash|zsh] Shell to install hyakvnc for (default: $SHELL or bash) - -Examples: - # Install - hyakvnc install - # Install to ~/bin: - hyakvnc install -i ~/bin -``` - -## Configuration - -The following [environment variables](https://wiki.archlinux.org/title/environment_variables) can be used to override the default settings. Any arguments passed to `hyakvnc create` will override the environment variables. - -You can modify the values of these variables by: - -- Setting and exporting them in your shell session, e.g. `export HYAKVNC_SLURM_MEM='8G'` (which will only affect the current shell session) -- Setting them in your shell's configuration file, e.g. `~/.bashrc` or `~/.zshrc` (which will affect all shell sessions) -- Setting them by prefixing the `hyakvnc` command with the variable assignment, e.g. `HYAKVNC_SLURM_MEM='8G' hyakvnc create ...` (which will only affect the current command) -- Setting them in the file `~/.hyakvnc/hyakvnc-config.env` (which will affect all `hyakvnc` commands) - -When you set an environment variable, it is advisable to surround the value with single quotes (`'`) to prevent your shell from interpreting special characters. There should be no spaces between the variable name, the equals sign, and the value. - -The following variables are available: - -- HYAKVNC_DIR: Local directory to store application data (default: `$HOME/.hyakvnc`) -- HYAKVNC_CHECK_UPDATE_FREQUENCY: How often to check for updates in `[d]`ays or `[m]`inutes (default: `0` for every time. Use `1d` for daily, `10m` for every 10 minutes, etc. `-1` to disable.) -- HYAKVNC_CONFIG_FILE: Configuration file to use (default: `$HYAKVNC_DIR/hyakvnc-config.env`) -- HYAKVNC_LOG_FILE: Log file to use (default: `$HYAKVNC_DIR/hyakvnc.log`) -- HYAKVNC_LOG_LEVEL: Log level to use for interactive output (default: `INFO`) -- HYAKVNC_LOG_FILE_LEVEL: Log level to use for log file output (default: `DEBUG`) -- HYAKVNC_SSH_HOST: Default SSH host to use for connection strings (default: `klone.hyak.uw.edu`) -- HYAKVNC_DEFAULT_TIMEOUT: Seconds to wait for most commands to complete before timing out (default: `30`) -- HYAKVNC_VNC_PASSWORD: Password to use for new VNC sessions (default: `password`) -- HYAKVNC_VNC_DISPLAY: VNC display to use (default: `:1`) -- HYAKVNC_APPTAINER_BIN: Name of apptainer binary (default: `apptainer`) -- HYAKVNC_APPTAINER_CONTAINER: Path to container image to use (default: (none; set by `--container` option)) -- HYAKVNC_APPTAINER_APP_VNCSERVER: Name of app in the container that starts the VNC session (default: `vncserver`) -- HYAKVNC_APPTAINER_APP_VNCKILL: Name of app that cleanly stops the VNC session in the container (default: `vnckill`) -- HYAKVNC_APPTAINER_WRITABLE_TMPFS: Whether to use a writable tmpfs for the container (default: `1`) -- HYAKVNC_APPTAINER_CLEANENV: Whether to use a clean environment for the container (default: `1`) -- HYAKVNC_APPTAINER_ADD_BINDPATHS: Bind paths to add to the container (default: (none)) -- HYAKVNC_APPTAINER_ADD_ENVVARS: Environment variables to add to before invoking apptainer (default: (none)) -- HYAKVNC_APPTAINER_ADD_ARGS: Additional arguments to give apptainer (default: (none)) -- HYAKVNC_SLURM_JOB_PREFIX: Prefix to use for hyakvnc SLURM job names (default: `hyakvnc-`) -- HYAKVNC_SLURM_SUBMIT_TIMEOUT: Seconds after submitting job to wait for the job to start before timing out (default: `120`) -- HYAKVNC_SLURM_OUTPUT_DIR: Directory to store SLURM output files (default: `$HYAKVNC_DIR/slurm-output`) -- HYAKVNC_SLURM_OUTPUT: Where to send SLURM job output (default: `$HYAKVNC_SLURM_OUTPUT_DIR/job-%j.out`) -- HYAKVNC_SLURM_JOB_NAME: What to name the launched SLURM job (default: (set according to container name)) -- HYAKVNC_SLURM_ACCOUNT: Slurm account to use (default: (autodetected)) -- HYAKVNC_SLURM_PARTITION: Slurm partition to use (default: (autodetected)) -- HYAKVNC_SLURM_CLUSTER: Slurm cluster to use (default: (autodetected)) -- HYAKVNC_SLURM_GPUS: Number of GPUs to request (default: (none)) -- HYAKVNC_SLURM_MEM: Amount of memory to request, in [M]egabytes or [G]igabytes (default: `4G`) -- HYAKVNC_SLURM_CPUS: Number of CPUs to request (default: `4`) -- HYAKVNC_SLURM_TIMELIMIT: Time limit for SLURM job (default: `12:00:00`) - -## License - -`hyakvnc` is licensed under [MIT License](LICENSE). From 9adb73a39fea95c27e3f8683bd53b9f4e0a2f63f Mon Sep 17 00:00:00 2001 From: Altan Orhon Date: Tue, 24 Oct 2023 18:38:09 -0700 Subject: [PATCH 09/19] Simplified workflows --- .github/workflows/mkinstaller.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/mkinstaller.yml b/.github/workflows/mkinstaller.yml index 0d264d6..4997b37 100644 --- a/.github/workflows/mkinstaller.yml +++ b/.github/workflows/mkinstaller.yml @@ -18,7 +18,6 @@ jobs: if ! git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- .build/install.j2.sh .github/workflows/mkinstaller.yml; then python3 -m pip install jinja-cli jinja -D j2_hyakvnc_repo_url 'https://github.com/${{ github.repository }}' .build/install.j2.sh -o install.sh - popd git config --local user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" git config --local user.name ${{ github.event.sender.login }} git add install.sh From c385ffed21a50e15ced2be44b37596dd3d59e741 Mon Sep 17 00:00:00 2001 From: maouw <62307612+maouw@users.noreply.github.com> Date: Wed, 25 Oct 2023 01:38:36 +0000 Subject: [PATCH 10/19] Update install.sh --- install.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..7184f18 --- /dev/null +++ b/install.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +# install.sh is generated from .build/install.j2.sh. Do not edit it directly. +# This script is intended to be sourced from the current shell. +# It will clone the hyakvnc repository to ~/.hyakvnc/hyakvnc and create a symlink in it to ~/.local/bin/hyakvnc. +# These locations can be changed by setting the following environment variables: +# - HYAKVNC_DIR: Local directory to store application data (default: `$HOME/.hyakvnc`) +# - HYAKVNC_REPO_DIR: Local directory to store git repository (default: `$HYAKVNC_DIR/hyakvnc`) +# - HYAKVNC_REPO_URL: URL of the git repository to clone (default: https://github.com/maouw/hyakvnc) +# - BIN_INSTALL_DIR: Local directory to store executable (default: `$HOME/.local/bin`) + +_add_hyakvnc_to_path() { + [ -z "${_UNEXPANDED_BIN_INSTALL_DIR:-}" ] || [ -z "${_BIN_INSTALL_DIR:-}" ] && return 1 + case "${PATH:-}" in + *"${_BIN_INSTALL_DIR}"*) ;; + *) + if [ -n "${BASH_VERSION:-}" ]; then + echo "export PATH=\"${_UNEXPANDED_BIN_INSTALL_DIR}:\$PATH\"" >>"${HOME:-}/.bashrc" + echo "Added hyakvnc to PATH in ${HOME:-}/.bashrc" 2>&1 + export PATH="${_BIN_INSTALL_DIR}:${PATH:-}" + elif [ -n "${ZSH_VERSION:-}" ]; then + echo "export PATH=\"${_UNEXPANDED_BIN_INSTALL_DIR}:\$PATH\"" >>"${ZDOTDIR:-${HOME:-}}/.zshrc" + echo "Added hyakvnc to PATH in ${ZDOTDIR:-${HOME}}/.zshrc" 2>&1 + export PATH="${_BIN_INSTALL_DIR}:${PATH}" + rehash 2>/dev/null || true + else + echo "Could not add hyakvnc to PATH. Please add ${_BIN_INSTALL_DIR} to your shell PATH manually." 2>&1 + return 1 + fi + ;; + esac +} + +_install_hyakvnc() { + _HYAKVNC_DIR="${_HYAKVNC_DIR:-${HOME}/.hyakvnc}" # %% Local directory to store application data (default: `$HOME/.hyakvnc`) + _HYAKVNC_REPO_DIR="${_HYAKVNC_REPO_DIR:-${_HYAKVNC_DIR}/hyakvnc}" # Local directory to store git repository (default: `$HYAKVNC_DIR/hyakvnc`) + _HYAKVNC_REPO_URL="${_HYAKVNC_REPO_URL:-"https://github.com/maouw/hyakvnc"}" + + # shellcheck disable=SC2016 + _UNEXPANDED_BIN_INSTALL_DIR='${HOME}/.local/bin' # Local directory to store executable (default: `$HOME/.local/bin`) + _EXPANDED_BIN_INSTALL_DIR="$(eval echo "${_UNEXPANDED_BIN_INSTALL_DIR}")" # Expand environment variables in path + _BIN_INSTALL_DIR="${_BIN_INSTALL_DIR:-${_EXPANDED_BIN_INSTALL_DIR}}" + + mkdir -p "${_BIN_INSTALL_DIR}" && + rm -rf "${_HYAKVNC_DIR}/hyakvnc-tmp" && + echo "Fetching hyakvnc from ${_HYAKVNC_REPO_URL}" 2>&1 && + git clone --depth 1 --single-branch --quiet "${_HYAKVNC_REPO_URL}" ~/.hyakvnc/hyakvnc-tmp && + rm -rf "${_HYAKVNC_REPO_DIR}" && + mv "${_HYAKVNC_DIR}/hyakvnc-tmp" "${_HYAKVNC_REPO_DIR}" && + ln -sf "${_HYAKVNC_REPO_DIR}/hyakvnc" "${_BIN_INSTALL_DIR}/hyakvnc" && + echo "Installed hyakvnc to ${_BIN_INSTALL_DIR}/hyakvnc linking to hyakvnc in ${_HYAKVNC_REPO_DIR}" 2>&1 || + return 1 +} + +if _install_hyakvnc && _add_hyakvnc_to_path; then + echo "Successfully installed hyakvnc." 2>&1 +else + echo "Failed to install hyakvnc." 2>&1 +fi + +# Unset all variables and functions defined in this script: +unset _HYAKVNC_DIR _HYAKVNC_REPO_DIR _HYAKVNC_REPO_URL _UNEXPANDED_BIN_INSTALL_DIR _EXPANDED_BIN_INSTALL_DIR _BIN_INSTALL_DIR +unset -f _install_hyakvnc _add_hyakvnc_to_path From a64618cb6b26f5310311f314b9733e4550ef9e98 Mon Sep 17 00:00:00 2001 From: Altan Orhon Date: Tue, 24 Oct 2023 18:39:08 -0700 Subject: [PATCH 11/19] Simplified workflows --- .github/workflows/mkreadme.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/mkreadme.yml b/.github/workflows/mkreadme.yml index 392a89d..7e93d6d 100644 --- a/.github/workflows/mkreadme.yml +++ b/.github/workflows/mkreadme.yml @@ -16,6 +16,7 @@ jobs: id: update-readme run: | if git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- hyakvnc .build/README.j2.md .github/workflows/mkreadme.yml; then + python3 -m pip install jinja-cli pushd .build/ sed -E '/^HYAKVNC_.*#\s*%%/!d; s/=.*(#\s*%%)/:/g; s/(^.)/- \1/g' ../hyakvnc > config.inc.md for x in create status show stop config install; do ../hyakvnc help "$x" | sed -E '1 s/(.*)/\n### \1\n/; 2 s/^$/```text/' | pr -e4 -t && echo '```'; done > usage.inc.md From 54bdf34d568b5538f7303f5c03102b8473142052 Mon Sep 17 00:00:00 2001 From: Altan Orhon Date: Tue, 24 Oct 2023 18:49:29 -0700 Subject: [PATCH 12/19] Simplified workflows --- .../{mkreadme.yml => build-documentation.yml} | 25 +++++++++++------ .github/workflows/mkinstaller.yml | 27 ------------------- 2 files changed, 17 insertions(+), 35 deletions(-) rename .github/workflows/{mkreadme.yml => build-documentation.yml} (51%) delete mode 100644 .github/workflows/mkinstaller.yml diff --git a/.github/workflows/mkreadme.yml b/.github/workflows/build-documentation.yml similarity index 51% rename from .github/workflows/mkreadme.yml rename to .github/workflows/build-documentation.yml index 7e93d6d..b596d47 100644 --- a/.github/workflows/mkreadme.yml +++ b/.github/workflows/build-documentation.yml @@ -1,21 +1,22 @@ -name: Build documentation +name: Build documentation and installer "on": push: jobs: build-readme: runs-on: ubuntu-latest - name: Build README.md + name: Build documentation and installer permissions: write-all steps: - name: Check out code for the container build uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Update README.md if needed - id: update-readme + - name: Build documentation and installer in one step + id: update-docs-and-installer run: | - if git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- hyakvnc .build/README.j2.md .github/workflows/mkreadme.yml; then + commit_msg="" + if git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- hyakvnc .build/README.j2.md .github/workflows/build-documentation.yml; then python3 -m pip install jinja-cli pushd .build/ sed -E '/^HYAKVNC_.*#\s*%%/!d; s/=.*(#\s*%%)/:/g; s/(^.)/- \1/g' ../hyakvnc > config.inc.md @@ -25,7 +26,15 @@ jobs: git config --local user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" git config --local user.name ${{ github.event.sender.login }} git add README.md - git commit -am "Update README.md" - git push + commit_msg="Rebuilt README.md" fi - + if ! git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- .build/install.j2.sh; then + python3 -m pip install jinja-cli + jinja -D j2_hyakvnc_repo_url 'https://github.com/${{ github.repository }}' .build/install.j2.sh -o install.sh + git config --local user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" + git config --local user.name ${{ github.event.sender.login }} + git add install.sh + [ -n "${commit_msg:-}" ] && commit_msg="${commit_msg} " + commit_msg="${commit_msg:-}Rebuilt install.sh" + fi + [ -n "${commit_msg:-}" ] && git commit -m "${commit_msg}" && git push diff --git a/.github/workflows/mkinstaller.yml b/.github/workflows/mkinstaller.yml deleted file mode 100644 index 4997b37..0000000 --- a/.github/workflows/mkinstaller.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Build installer -"on": - push: - -jobs: - build-installer: - runs-on: ubuntu-latest - name: Build install.sh - permissions: write-all - steps: - - name: Check out code for the container build - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Update install.sh if needed - id: update-installer - run: | - if ! git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- .build/install.j2.sh .github/workflows/mkinstaller.yml; then - python3 -m pip install jinja-cli - jinja -D j2_hyakvnc_repo_url 'https://github.com/${{ github.repository }}' .build/install.j2.sh -o install.sh - git config --local user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" - git config --local user.name ${{ github.event.sender.login }} - git add install.sh - git commit -am "Update install.sh" - git push - fi - From 10b3276c422bf1b3e5e7120f6634bb7d530b7360 Mon Sep 17 00:00:00 2001 From: Altan Orhon Date: Tue, 24 Oct 2023 19:05:52 -0700 Subject: [PATCH 13/19] Simplified workflows --- .github/workflows/build-documentation.yml | 29 +++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-documentation.yml b/.github/workflows/build-documentation.yml index b596d47..1a7f10c 100644 --- a/.github/workflows/build-documentation.yml +++ b/.github/workflows/build-documentation.yml @@ -16,25 +16,28 @@ jobs: id: update-docs-and-installer run: | commit_msg="" - if git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- hyakvnc .build/README.j2.md .github/workflows/build-documentation.yml; then + echo "Checking for changes in hyakvnc, .build/README.j2.md, and .github/workflows/build-documentation.yml" + if ! git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- hyakvnc .build/README.j2.md .build/install.j2.sh .github/workflows/build-documentation.yml; then + echo "Changes detected in hyakvnc, .build/README.j2.md, or .github/workflows/build-documentation.yml" python3 -m pip install jinja-cli pushd .build/ sed -E '/^HYAKVNC_.*#\s*%%/!d; s/=.*(#\s*%%)/:/g; s/(^.)/- \1/g' ../hyakvnc > config.inc.md for x in create status show stop config install; do ../hyakvnc help "$x" | sed -E '1 s/(.*)/\n### \1\n/; 2 s/^$/```text/' | pr -e4 -t && echo '```'; done > usage.inc.md jinja -D github_repository "${{ github.repository }}" -D github_ref_name "${{ github.ref_name }}" README.j2.md | sed 's/^.*.*$//g' > ../README.md + jinja -D j2_hyakvnc_repo_url 'https://github.com/${{ github.repository }}' install.j2.sh -o ../install.sh popd + git config --local user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" git config --local user.name ${{ github.event.sender.login }} - git add README.md - commit_msg="Rebuilt README.md" - fi - if ! git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- .build/install.j2.sh; then - python3 -m pip install jinja-cli - jinja -D j2_hyakvnc_repo_url 'https://github.com/${{ github.repository }}' .build/install.j2.sh -o install.sh - git config --local user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" - git config --local user.name ${{ github.event.sender.login }} - git add install.sh - [ -n "${commit_msg:-}" ] && commit_msg="${commit_msg} " - commit_msg="${commit_msg:-}Rebuilt install.sh" + + if ! git diff --quiet --stat README.md; then + git add README.md && commit_msg="Rebuilt README.md" + fi + + if ! git diff --quiet --stat install.sh; then + new_commit_msg="${commit_msg:-}" + [ -n "${new_commit_msg:-}" ] && new_commit_msg="${new_commit_msg} " + git add install.sh && new_commit_msg="Rebuilt install.sh" && commit_msg="${new_commit_msg:-}" + fi + git commit -am "${commit_msg}" && git push fi - [ -n "${commit_msg:-}" ] && git commit -m "${commit_msg}" && git push From 17a2fedaf95a9328521dd05e841cd6f8896a00d8 Mon Sep 17 00:00:00 2001 From: maouw <62307612+maouw@users.noreply.github.com> Date: Wed, 25 Oct 2023 02:06:07 +0000 Subject: [PATCH 14/19] Rebuilt README.md --- README.md | 327 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 327 insertions(+) diff --git a/README.md b/README.md index e69de29..562bff3 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,327 @@ +# hyakvnc + +hyakvnc -- A tool for launching VNC sessions on Hyak. + +`hyakvnc` is a command-line tool that makes it easy to start a graphical [VNC](https://en.wikipedia.org/wiki/Virtual_Network_Computing) session on the University of Washington [Hyak](https://hyak.uw.edu/) cluster, allowing you to interact with the system in a point-and-click environment, with support for graphical applications such as [Freesurfer](https://surfer.nmr.mgh.harvard.edu/). `hyakvnc` sessions run in [Apptainer](https://apptainer.org) containers, which provide reproducible environments that can run anywhere and be shared with other researchers. + +## Prerequisites + +Before running `hyakvnc`, you'll need the following: + +- A Linux, macOS, or Windows machine +- The OpenSSH client (usually included with Linux and macOS, and available for Windows via [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install) or [Cygwin](https://www.cs.odu.edu/~zeil/cs252/latest/Public/loggingin/cygwin.mmd.html) [note that the Windows 10+ built-in OpenSSH client will not work]) +- A VNC client/viewer ([TurboVNC viewer](https://www.turbovnc.org) is recommended for all platforms) +- HYAK Klone access with compute resources +- A private SSH key on your local machine which has been added to the authorized keys on the login node of the HYAK Klone cluster (see below) +- A HyakVNC-compatible Apptainer container image in a directory on Hyak (usually with the file extension `.sif`) or the URL to one (e.g,., `oras://ghcr.io/maouw/hyakvnc_apptainer/ubuntu22.04_turbovnc:latest`) + +Follow the instructions below to set up your machine correctly: + +### Installing OpenSSH and TurboVNC + +#### Linux + +If you are using Linux, OpenSSH is probably installed already -- if not, you can install it via `apt-get install openssh-client` on Debian/Ubuntu or `yum install openssh-clients` on RHEL/CentOS/Rocky/Fedora. To open a terminal window, search for "Terminal" in your desktop environment's application launcher. + +To install TurboVNC, download the latest version from [here](https://sourceforge.net/projects/turbovnc/files). On Debian/Ubuntu, you will need to download the file ending with `arm64.deb`. On RHEL/CentOS/Rocky/Fedora, you will need to download the file ending with `x86_64.rpm`. Then, install it by running `sudo dpkg -i ` on Debian/Ubuntu or `sudo rpm -i ` on RHEL/CentOS/Rocky/Fedora. + +#### macOS + +If you're on macOS, OpenSSH will already be installed. To open a terminal window, open `/Applications/Utilities/Terminal.app` or search for "Terminal" in Launchpad or Spotlight. + +To install TurboVNC, download the latest version from [here](https://sourceforge.net/projects/turbovnc/files). On an M1 Mac (newer), you will need to download the file ending with `arm64.dmg`. On an Intel Mac (older), you will need the file ending with `x86_64.dmg`. Then, open the `.dmg` file and launch the installer inside. + +#### Windows + +Windows needs a little more setup. You'll need to install a terminal emulator as well as the OpenSSH client. The easiest way to do this is to install [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install) (recommended for Windows versions 10+, comes with the OpenSSH client already installed) or [Cygwin](https://www.cs.odu.edu/~zeil/cs252/latest/Public/loggingin/cygwin.mmd.html) (not recommended, needs additional setup). See the links for instructions on how to install these. You can start a terminal window by searching for "Terminal" in the Start menu. + +To install TurboVNC, download the latest version from [here](https://sourceforge.net/projects/turbovnc/files). You will need the file ending with `x64.exe`. Run the program to install TurboVNC. + +### Setting up SSH keys to connect to Hyak compute nodes + +Before you are allowed to connect to a compute node where your VNC session will be running, you must add your SSH public key to the authorized keys on the login node of the HYAK Klone cluster. + +If you don't, you will receive an error like this when you try to connect: + +```text +Permission denied (publickey,gssapi-keyex,gssapi-with-mic) +``` + +To set this up quickly on Linux, macOS, or Windows (WSL2/Cygwin), open a new terminal window on your machine and enter the following 2 commands before you try again. Replace `your-uw-netid` with your UW NetID: + +```bash +[ ! -r ~/.ssh/id_rsa ] && ssh-keygen -t rsa -b 4096 -N '' -C "your-uw-netid@uw.edu" -f ~/.ssh/id_rsa +ssh-copy-id -o StrictHostKeyChecking=no -i ~/.ssh/id_rsa "your-uw-netid"@klone.hyak.uw.edu +``` + +See https://hyak.uw.edu/docs/setup/intracluster-keys for more information. + +### Finding a HyakVNC-compatible container image + +You'll need to find a HyakVNC-compatible container image to run your VNC session in. The following images are provided by us and can be used with `hyakvnc` by copying and pasting the URL into the `hyakvnc create` command: + +- `oras://ghcr.io/maouw/hyakvnc_apptainer/ubuntu22.04_turbovnc:latest` -- Ubuntu 22.04 with TurboVNC +- `oras://ghcr.io/maouw/ubuntu22.04_freesurfer:latest` -- Ubuntu 22.04 with TurboVNC and Freesurfer + +## Installing `hyakvnc` + +`hyakvnc` should be installed on the login node of the HYAK Klone cluster. + +To connect to the login node, you'll need to enter the following command into a terminal window (replacing `your-uw-netid` with your UW NetID) and provide your password when prompted: + +```bash +ssh your-uw-netid@klone.hyak.uw.edu +``` + +### Quick install + +After you've connected to the login node, you can download and install `hyakvnc` by running the following command. Copy and paste it into the terminal window where you are connected to the login node and press enter: + +```bash +curl -o ~/.local/bin/hyakvnc --create-dirs -fsSL https://raw.githubusercontent.com/maouw/hyakvnc/install-sh/hyakvnc && chmod +x ~/.local/bin/hyakvnc && [[ ":${PATH}:" != *":$HOME/.local/bin:"* ]] && export PATH="$HOME/.local/bin:$PATH" && [-n "${ZSH_VERSION:-}" ] && rehash +``` + +This will download and install `hyakvnc` to your `~/.local/bin` directory and add it to your `$PATH` so you can run it by typing `hyakvnc` into the terminal window. + +### Installing manually + +In a terminal window connected to a login node, enter this command to clone the repository and navigate into the repository directory: + +```bash +git clone https://github.com/maouw/hyakvnc && cd hyakvnc +``` + +Then, run the following command to install `hyakvnc`: + +```bash +./hyakvnc install +``` + +If you prefer, you may continue to use `hyakvnc` from the directory where you cloned it by running `./hyakvnc` from that directory instead of using the command `hyakvnc`. +started + +## Getting started + +### Creating a VNC session + +Start a VNC session with the `hyakvnc create` command followed by arguments to specify the container. In this example, we'll use a basic container for a graphical environment from the HyakVNC GitHub Container Registry: + +```bash +hyakvnc create --container oras://maouw/hyakvnc_apptainer/ubuntu22.04_turbovnc:latest +``` + +It may take a few minutes to download the container if you're running it the first time. If successful, `hyakvnc` should print commands and instructions to connect: + +```text +========== +Copy and paste these instructions into a command line terminal on your local machine to connect to the VNC session. +You may need to install a VNC client if you don't already have one. + +NOTE: If you receive an error that looks like "Permission denied (publickey,gssapi-keyex,gssapi-with-mic)", you don't have an SSH key set up. +See https://hyak.uw.edu/docs/setup/intracluster-keys for more information. +To set this up quickly on Linux, macOS, or Windows (WSL2/Cygwin), open a new terminal window on your machine and enter the following 2 commands before you try again: + +[ ! -r ~/.ssh/id_rsa ] && ssh-keygen -t rsa -b 4096 -N '' -C "your-uw-netid@uw.edu" -f ~/.ssh/id_rsa +ssh-copy-id -o StrictHostKeyChecking=no your-uw-netid@klone.hyak.uw.edu +--------- +LINUX TERMINAL (bash/zsh): +ssh -f -o StrictHostKeyChecking=no -L 5901:/mmfs1/home/your-uw-netid/.hyakvnc/jobs/15042104/vnc/socket.uds -J your-uw-netid@klone.hyak.uw.edu your-uw-netid@g3053 sleep 20 && vncviewer localhost:5901 || xdg-open vnc://localhost:5901 || echo 'No VNC viewer found. Please install one or try entering the connection information manually.' + +MACOS TERMINAL +ssh -f -o StrictHostKeyChecking=no -L 5901:/mmfs1/home/your-uw-netid/.hyakvnc/jobs/15042104/vnc/socket.uds -J your-uw-netid@klone.hyak.uw.edu your-uw-netid@g3053 sleep 20 && open -b com.turbovnc.vncviewer.VncViewer --args localhost:5901 2>/dev/null || open -b com.realvnc.vncviewer --args localhost:5901 2>/dev/null || open -b com.tigervnc.vncviewer --args localhost:5901 2>/dev/null || open vnc://localhost:5901 2>/dev/null || echo 'No VNC viewer found. Please install one or try entering the connection information manually.' + +WINDOWS +ssh -f -o StrictHostKeyChecking=no -L 5901:/mmfs1/home/your-uw-netid/.hyakvnc/jobs/15042104/vnc/socket.uds -J your-uw-netid@klone.hyak.uw.edu your-uw-netid@g3053 sleep 20 && cmd.exe /c cmd /c "$(cmd.exe /c where "C:\Program Files\TurboVNC;C:\Program Files(x86)\TurboVNC:vncviewerw.bat")" localhost:5901 || echo 'No VNC viewer found. Please install one or try entering the connection information manually.' + +========== +``` + +## Usage + +`hyakvnc` is command-line tool that only works on the login node of the Hyak cluster. + +### Create a VNC session on Hyak + +```text +Usage: hyakvnc create [create options...] -c [extra args to pass to apptainer...] + +Description: + Create a VNC session on Hyak. + +Options: + -h, --help Show this help message and exit + -c, --container Path to container image (required) + -A, --account Slurm account to use (default: ) + -p, --partition Slurm partition to use (default: ) + -C, --cpus Number of CPUs to request (default: 4) + -m, --mem Amount of memory to request (default: 4G) + -t, --timelimit Slurm timelimit to use (default: 12:00:00) + -g, --gpus Number of GPUs to request (default: ) + +Extra arguments: + Any extra arguments will be passed to apptainer run. + See 'apptainer run --help' for more information. + +Examples: + # Create a VNC session using the container ~/containers/mycontainer.sif + hyakvnc create -c ~/containers/mycontainer.sif + # Create a VNC session using the URL for a container: + hyakvnc create -c oras://ghcr.io/maouw/hyakvnc_apptainer/ubuntu22.04_turbovnc:latest + # Use the SLURM account escience, the partition gpu-a40, 4 CPUs, 1GB of memory, 1 GPU, and 1 hour of time: + hyakvnc create -c ~/containers/mycontainer.sif -A escience -p gpu-a40 -C 4 -m 1G -t 1:00:00 -g 1 + +``` + +### Show the status of running HyakVNC sessions + +```text +Usage: hyakvnc status [status options...] + +Description: + Check status of VNC session(s) on Hyak. + +Options: + -h, --help Show this help message and exit + -d, --debug Print debug info + -j, --jobid Only check status of provided SLURM job ID (optional) + +Examples: + # Check the status of job no. 12345: + hyakvnc status -j 12345 + # Check the status of all VNC jobs: + hyakvnc status +``` + +### Show connection information for a HyakVNC sesssion + +```text +Usage: hyakvnc show + +Description: + Show connection information for a HyakVNC sesssion. + If no job ID is provided, a menu will be shown to select from running jobs. + +Options: + -h, --help Show this help message and exit + +Examples: + # Show connection information for session running on job 123456: + hyakvnc show 123456 + # Interactively select a job to show connection information for: + hyakvnc show + + # Show connection information for session running on job 123456 for macOS: + hyakvnc show -s mac 123456 +``` + +### Stop a HyakVNC session + +```text +Usage: hyakvnc stop [-a] [...] + +Description: + Stop a provided HyakVNC sesssion and clean up its job directory. + If no job ID is provided, a menu will be shown to select from running jobs. + +Options: + -h, --help Show this help message and exit + -n, --no-cancel Don't cancel the SLURM job + -a, --all Stop all jobs + +Examples: + # Stop a VNC session running on job 123456: + hyakvnc stop 123456 + # Stop a VNC session running on job 123456 and do not cancel the job: + hyakvnc stop --no-cancel 123456 + # Stop all VNC sessions: + hyakvnc stop -a + # Stop all VNC sessions but do not cancel the jobs: + hyakvnc stop -a -n +``` + +### Show the current configuration for hyakvnc + +```text +Usage: hyakvnc config [config options...] + +Description: + Show the current configuration for hyakvnc, as set in the user configuration file at /home/runner/.hyakvnc/hyakvnc-config.env, in the current environment, or the default values set by hyakvnc. + +Options: + -h, --help Show this help message and exit + +Examples: + # Show configuration + hyakvnc config +``` + +### Install the hyakvnc command + +```text +Usage: hyakvnc install [install options...] + +Description: + Install hyakvnc so the "hyakvnc" command can be run from anywhere. + +Options: + -h, --help Show this help message and exit + -i, --install-dir Directory to install hyakvnc to (default: ~/.local/bin) + -s, --shell [bash|zsh] Shell to install hyakvnc for (default: $SHELL or bash) + +Examples: + # Install + hyakvnc install + # Install to ~/bin: + hyakvnc install -i ~/bin +``` + +## Configuration + +The following [environment variables](https://wiki.archlinux.org/title/environment_variables) can be used to override the default settings. Any arguments passed to `hyakvnc create` will override the environment variables. + +You can modify the values of these variables by: + +- Setting and exporting them in your shell session, e.g. `export HYAKVNC_SLURM_MEM='8G'` (which will only affect the current shell session) +- Setting them in your shell's configuration file, e.g. `~/.bashrc` or `~/.zshrc` (which will affect all shell sessions) +- Setting them by prefixing the `hyakvnc` command with the variable assignment, e.g. `HYAKVNC_SLURM_MEM='8G' hyakvnc create ...` (which will only affect the current command) +- Setting them in the file `~/.hyakvnc/hyakvnc-config.env` (which will affect all `hyakvnc` commands) + +When you set an environment variable, it is advisable to surround the value with single quotes (`'`) to prevent your shell from interpreting special characters. There should be no spaces between the variable name, the equals sign, and the value. + +The following variables are available: + +- HYAKVNC_DIR: Local directory to store application data (default: `$HOME/.hyakvnc`) +- HYAKVNC_CHECK_UPDATE_FREQUENCY: How often to check for updates in `[d]`ays or `[m]`inutes (default: `0` for every time. Use `1d` for daily, `10m` for every 10 minutes, etc. `-1` to disable.) +- HYAKVNC_CONFIG_FILE: Configuration file to use (default: `$HYAKVNC_DIR/hyakvnc-config.env`) +- HYAKVNC_LOG_FILE: Log file to use (default: `$HYAKVNC_DIR/hyakvnc.log`) +- HYAKVNC_LOG_LEVEL: Log level to use for interactive output (default: `INFO`) +- HYAKVNC_LOG_FILE_LEVEL: Log level to use for log file output (default: `DEBUG`) +- HYAKVNC_SSH_HOST: Default SSH host to use for connection strings (default: `klone.hyak.uw.edu`) +- HYAKVNC_DEFAULT_TIMEOUT: Seconds to wait for most commands to complete before timing out (default: `30`) +- HYAKVNC_VNC_PASSWORD: Password to use for new VNC sessions (default: `password`) +- HYAKVNC_VNC_DISPLAY: VNC display to use (default: `:1`) +- HYAKVNC_APPTAINER_BIN: Name of apptainer binary (default: `apptainer`) +- HYAKVNC_APPTAINER_CONTAINER: Path to container image to use (default: (none; set by `--container` option)) +- HYAKVNC_APPTAINER_APP_VNCSERVER: Name of app in the container that starts the VNC session (default: `vncserver`) +- HYAKVNC_APPTAINER_APP_VNCKILL: Name of app that cleanly stops the VNC session in the container (default: `vnckill`) +- HYAKVNC_APPTAINER_WRITABLE_TMPFS: Whether to use a writable tmpfs for the container (default: `1`) +- HYAKVNC_APPTAINER_CLEANENV: Whether to use a clean environment for the container (default: `1`) +- HYAKVNC_APPTAINER_ADD_BINDPATHS: Bind paths to add to the container (default: (none)) +- HYAKVNC_APPTAINER_ADD_ENVVARS: Environment variables to add to before invoking apptainer (default: (none)) +- HYAKVNC_APPTAINER_ADD_ARGS: Additional arguments to give apptainer (default: (none)) +- HYAKVNC_SLURM_JOB_PREFIX: Prefix to use for hyakvnc SLURM job names (default: `hyakvnc-`) +- HYAKVNC_SLURM_SUBMIT_TIMEOUT: Seconds after submitting job to wait for the job to start before timing out (default: `120`) +- HYAKVNC_SLURM_OUTPUT_DIR: Directory to store SLURM output files (default: `$HYAKVNC_DIR/slurm-output`) +- HYAKVNC_SLURM_OUTPUT: Where to send SLURM job output (default: `$HYAKVNC_SLURM_OUTPUT_DIR/job-%j.out`) +- HYAKVNC_SLURM_JOB_NAME: What to name the launched SLURM job (default: (set according to container name)) +- HYAKVNC_SLURM_ACCOUNT: Slurm account to use (default: (autodetected)) +- HYAKVNC_SLURM_PARTITION: Slurm partition to use (default: (autodetected)) +- HYAKVNC_SLURM_CLUSTER: Slurm cluster to use (default: (autodetected)) +- HYAKVNC_SLURM_GPUS: Number of GPUs to request (default: (none)) +- HYAKVNC_SLURM_MEM: Amount of memory to request, in [M]egabytes or [G]igabytes (default: `4G`) +- HYAKVNC_SLURM_CPUS: Number of CPUs to request (default: `4`) +- HYAKVNC_SLURM_TIMELIMIT: Time limit for SLURM job (default: `12:00:00`) + +## License + +`hyakvnc` is licensed under [MIT License](LICENSE). From 06130146d47b664f96d64bf33118ff6a58c5a285 Mon Sep 17 00:00:00 2001 From: Altan Orhon Date: Tue, 24 Oct 2023 19:16:40 -0700 Subject: [PATCH 15/19] Updated installer --- .build/install.j2.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.build/install.j2.sh b/.build/install.j2.sh index d5456b3..09d4a74 100755 --- a/.build/install.j2.sh +++ b/.build/install.j2.sh @@ -19,12 +19,14 @@ _add_hyakvnc_to_path() { echo "Added hyakvnc to PATH in ${HOME:-}/.bashrc" 2>&1 export PATH="${_BIN_INSTALL_DIR}:${PATH:-}" elif [ -n "${ZSH_VERSION:-}" ]; then - echo "export PATH=\"${_UNEXPANDED_BIN_INSTALL_DIR}:\$PATH\"" >>"${ZDOTDIR:-${HOME:-}}/.zshrc" - echo "Added hyakvnc to PATH in ${ZDOTDIR:-${HOME}}/.zshrc" 2>&1 - export PATH="${_BIN_INSTALL_DIR}:${PATH}" + echo "export PATH=\"${_UNEXPANDED_BIN_INSTALL_DIR}:\$PATH\"" >>"${ZDOTDIR:-${HOME:-}}/.zshrc" && echo "Added hyakvnc to PATH in ${ZDOTDIR:-${HOME}}/.zshrc" 2>&1 + export PATH="${_BIN_INSTALL_DIR}:${PATH:-}" rehash 2>/dev/null || true + elif [ "${0:-}" = "dash" ] || [ "${0:-}" = "sh" ]; then + echo "export PATH=\"${_UNEXPANDED_BIN_INSTALL_DIR}:\$PATH\"" >>"${HOME}/.profile" && echo "Added hyakvnc to PATH in ${HOME}/.profile" 2>&1 + export PATH="${_BIN_INSTALL_DIR}:${PATH:-}" else - echo "Could not add hyakvnc to PATH. Please add ${_BIN_INSTALL_DIR} to your shell PATH manually." 2>&1 + echo "Could not add hyakvnc to PATH." 2>&1 return 1 fi ;; @@ -52,8 +54,13 @@ _install_hyakvnc() { return 1 } -if _install_hyakvnc && _add_hyakvnc_to_path; then +if _install_hyakvnc; then echo "Successfully installed hyakvnc." 2>&1 + if _add_hyakvnc_to_path; then + echo "Added hyakvnc to PATH." 2>&1 + else + echo "Could not add hyakvnc to PATH." 2>&1 + fi else echo "Failed to install hyakvnc." 2>&1 fi From 02476d71ee33f4b6bc2c3d02620b564e6d58aba8 Mon Sep 17 00:00:00 2001 From: maouw <62307612+maouw@users.noreply.github.com> Date: Wed, 25 Oct 2023 02:17:05 +0000 Subject: [PATCH 16/19] Rebuilt install.sh --- install.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 7184f18..9f5d66f 100644 --- a/install.sh +++ b/install.sh @@ -19,12 +19,14 @@ _add_hyakvnc_to_path() { echo "Added hyakvnc to PATH in ${HOME:-}/.bashrc" 2>&1 export PATH="${_BIN_INSTALL_DIR}:${PATH:-}" elif [ -n "${ZSH_VERSION:-}" ]; then - echo "export PATH=\"${_UNEXPANDED_BIN_INSTALL_DIR}:\$PATH\"" >>"${ZDOTDIR:-${HOME:-}}/.zshrc" - echo "Added hyakvnc to PATH in ${ZDOTDIR:-${HOME}}/.zshrc" 2>&1 - export PATH="${_BIN_INSTALL_DIR}:${PATH}" + echo "export PATH=\"${_UNEXPANDED_BIN_INSTALL_DIR}:\$PATH\"" >>"${ZDOTDIR:-${HOME:-}}/.zshrc" && echo "Added hyakvnc to PATH in ${ZDOTDIR:-${HOME}}/.zshrc" 2>&1 + export PATH="${_BIN_INSTALL_DIR}:${PATH:-}" rehash 2>/dev/null || true + elif [ "${0:-}" = "dash" ] || [ "${0:-}" = "sh" ]; then + echo "export PATH=\"${_UNEXPANDED_BIN_INSTALL_DIR}:\$PATH\"" >>"${HOME}/.profile" && echo "Added hyakvnc to PATH in ${HOME}/.profile" 2>&1 + export PATH="${_BIN_INSTALL_DIR}:${PATH:-}" else - echo "Could not add hyakvnc to PATH. Please add ${_BIN_INSTALL_DIR} to your shell PATH manually." 2>&1 + echo "Could not add hyakvnc to PATH." 2>&1 return 1 fi ;; @@ -52,8 +54,13 @@ _install_hyakvnc() { return 1 } -if _install_hyakvnc && _add_hyakvnc_to_path; then +if _install_hyakvnc; then echo "Successfully installed hyakvnc." 2>&1 + if _add_hyakvnc_to_path; then + echo "Added hyakvnc to PATH." 2>&1 + else + echo "Could not add hyakvnc to PATH." 2>&1 + fi else echo "Failed to install hyakvnc." 2>&1 fi From a116e29235e0d846193f6508c9930791f79bcb1b Mon Sep 17 00:00:00 2001 From: Altan Orhon Date: Tue, 24 Oct 2023 19:31:39 -0700 Subject: [PATCH 17/19] Update README.md for new installer --- .build/README.j2.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.build/README.j2.md b/.build/README.j2.md index ae43b52..50d2833 100644 --- a/.build/README.j2.md +++ b/.build/README.j2.md @@ -4,6 +4,8 @@ hyakvnc -- A tool for launching VNC sessions on Hyak. `hyakvnc` is a command-line tool that makes it easy to start a graphical [VNC](https://en.wikipedia.org/wiki/Virtual_Network_Computing) session on the University of Washington [Hyak](https://hyak.uw.edu/) cluster, allowing you to interact with the system in a point-and-click environment, with support for graphical applications such as [Freesurfer](https://surfer.nmr.mgh.harvard.edu/). `hyakvnc` sessions run in [Apptainer](https://apptainer.org) containers, which provide reproducible environments that can run anywhere and be shared with other researchers. +*If you're already familiar with Hyak and VNC and you just want to install `hyakvnc` immediately, you can skip to the [quick install](#quick-install) section.* + ## Prerequisites Before running `hyakvnc`, you'll need the following: @@ -78,7 +80,7 @@ ssh your-uw-netid@klone.hyak.uw.edu After you've connected to the login node, you can download and install `hyakvnc` by running the following command. Copy and paste it into the terminal window where you are connected to the login node and press enter: ```bash -curl -o ~/.local/bin/hyakvnc --create-dirs -fsSL https://raw.githubusercontent.com/{{github_repository}}/{{github_ref_name}}/hyakvnc && chmod +x ~/.local/bin/hyakvnc && [[ ":${PATH}:" != *":$HOME/.local/bin:"* ]] && export PATH="$HOME/.local/bin:$PATH" && [-n "${ZSH_VERSION:-}" ] && rehash +eval "$(curl -fsSL https://raw.githubusercontent.com//{{github_repository}}/{{github_ref_name}}/install.sh)" ``` This will download and install `hyakvnc` to your `~/.local/bin` directory and add it to your `$PATH` so you can run it by typing `hyakvnc` into the terminal window. @@ -88,7 +90,7 @@ This will download and install `hyakvnc` to your `~/.local/bin` directory and ad In a terminal window connected to a login node, enter this command to clone the repository and navigate into the repository directory: ```bash -git clone https://github.com/{{github_repository}} && cd hyakvnc +git clone --depth 1 --single-branch https://github.com/{{github_repository}} && cd hyakvnc ``` Then, run the following command to install `hyakvnc`: From df0413f5817d97adc85a98d2a388cd2f370eea92 Mon Sep 17 00:00:00 2001 From: maouw <62307612+maouw@users.noreply.github.com> Date: Wed, 25 Oct 2023 02:31:56 +0000 Subject: [PATCH 18/19] Rebuilt README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 562bff3..c3af2e1 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ hyakvnc -- A tool for launching VNC sessions on Hyak. `hyakvnc` is a command-line tool that makes it easy to start a graphical [VNC](https://en.wikipedia.org/wiki/Virtual_Network_Computing) session on the University of Washington [Hyak](https://hyak.uw.edu/) cluster, allowing you to interact with the system in a point-and-click environment, with support for graphical applications such as [Freesurfer](https://surfer.nmr.mgh.harvard.edu/). `hyakvnc` sessions run in [Apptainer](https://apptainer.org) containers, which provide reproducible environments that can run anywhere and be shared with other researchers. +*If you're already familiar with Hyak and VNC and you just want to install `hyakvnc` immediately, you can skip to the [quick install](#quick-install) section.* + ## Prerequisites Before running `hyakvnc`, you'll need the following: @@ -78,7 +80,7 @@ ssh your-uw-netid@klone.hyak.uw.edu After you've connected to the login node, you can download and install `hyakvnc` by running the following command. Copy and paste it into the terminal window where you are connected to the login node and press enter: ```bash -curl -o ~/.local/bin/hyakvnc --create-dirs -fsSL https://raw.githubusercontent.com/maouw/hyakvnc/install-sh/hyakvnc && chmod +x ~/.local/bin/hyakvnc && [[ ":${PATH}:" != *":$HOME/.local/bin:"* ]] && export PATH="$HOME/.local/bin:$PATH" && [-n "${ZSH_VERSION:-}" ] && rehash +eval "$(curl -fsSL https://raw.githubusercontent.com//maouw/hyakvnc/install-sh/install.sh)" ``` This will download and install `hyakvnc` to your `~/.local/bin` directory and add it to your `$PATH` so you can run it by typing `hyakvnc` into the terminal window. @@ -88,7 +90,7 @@ This will download and install `hyakvnc` to your `~/.local/bin` directory and ad In a terminal window connected to a login node, enter this command to clone the repository and navigate into the repository directory: ```bash -git clone https://github.com/maouw/hyakvnc && cd hyakvnc +git clone --depth 1 --single-branch https://github.com/maouw/hyakvnc && cd hyakvnc ``` Then, run the following command to install `hyakvnc`: From be85b97bccfb9eb739f8e3bd37e32e720ccbf965 Mon Sep 17 00:00:00 2001 From: Altan Orhon Date: Wed, 25 Oct 2023 10:05:30 -0700 Subject: [PATCH 19/19] Clarify install.sh execution in comments --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 9f5d66f..da58716 100644 --- a/install.sh +++ b/install.sh @@ -2,7 +2,7 @@ # install.sh is generated from .build/install.j2.sh. Do not edit it directly. # This script is intended to be sourced from the current shell. -# It will clone the hyakvnc repository to ~/.hyakvnc/hyakvnc and create a symlink in it to ~/.local/bin/hyakvnc. +# It will clone the hyakvnc repository from GitHub to ~/.hyakvnc/hyakvnc and create a symlink in it to ~/.local/bin/hyakvnc. # These locations can be changed by setting the following environment variables: # - HYAKVNC_DIR: Local directory to store application data (default: `$HOME/.hyakvnc`) # - HYAKVNC_REPO_DIR: Local directory to store git repository (default: `$HYAKVNC_DIR/hyakvnc`)