#!/bin/bash

set -eu

get_rhel_version() {
    lsb_release -i -r | grep Release | awk '{print $2}' | awk -F . '{print $1}'
}

if [[ -z "$1" ]]; then
    echo "NOPE" >&2
    exit 1
fi

# This script is typically run via non-login, non-interactive shells (cron/ssh),
# so this needs to be set manually to avoid writing to `$HOME/.cache`
export XDG_CACHE_HOME=/home/sandboxes/gbosdd/.cache

release_root="$1"
cd "$release_root"
source ./activate
cd ./dysh
echo "Syncing venv $VIRTUAL_ENV on $(hostname -f) (RHEL$(get_rhel_version))"
/users/gbosdd/.local/bin/uv sync --all-extras --locked --active --link-mode=symlink
