nixos-riscv/fpga/run-login.sh

32 lines
510 B
Bash
Raw Normal View History

2024-08-26 17:14:53 +02:00
#!/usr/bin/bash
#set -x
set -e
path="$1"
# First determine if we already have jobs already
n=$(squeue --me -lh | wc -l)
if [ "$n" -gt 1 ]; then
echo "Too many jobs queued already" >&2
exit 1
fi
if [ "$n" == 0 ]; then
# No running jobs, so allocate a new job
echo salloc -N 1 --constraint=dmaqdma --no-shell
fi
while [ "$n" != 1 ]; do
sleep 2
n=$(squeue --me -lh)
done
host=$(squeue -h -o %N)
echo "Switching to $host"
# Continue the execution there
ssh "$host" "$path/run-node.sh" "$path"