22 lines
543 B
Bash
22 lines
543 B
Bash
#! /bin/bash
|
|
|
|
mayhem_party_rotate() {
|
|
local currently=$(realpath live.yaml | grep -o '[0-9].yaml$' | grep -o '^[0-9]')
|
|
local next=${NEXT:-$((RANDOM%5))}
|
|
while [ -z "$NEXT" ] && [ "$next" == "$currently" ]; do
|
|
next=$((RANDOM%5))
|
|
done
|
|
rm live.yaml
|
|
ln -s players_offset_$next.yaml live.yaml
|
|
pkill -SIGUSR1 -f mayhem-party
|
|
}
|
|
|
|
trap mayhem_party_rotate SIGUSR1
|
|
|
|
if [ "$0" == "$BASH_SOURCE" ]; then
|
|
NEXT=0 mayhem_party_rotate
|
|
while read -p "$(date) > [press enter to rotate]"; do
|
|
mayhem_party_rotate
|
|
done
|
|
fi
|