SLBR/image/bin/progress

21 lines
701 B
Bash
Executable File

#!/bin/bash
scoreboard="$(nc -q0 -d {{ HOST_IP }} {{ INFO_PORT }})"
my_ip="$(ip addr | grep 'scope global eth0' | cut -f6 -d ' ')"
total_challenges="$(echo "$scoreboard" | head -n1)"
completed_challenges="$(
echo "$scoreboard" \
| grep "$my_ip" \
| cut -f2- -d ' ' \
| tr -d ' ' \
| tr ',' '\n' \
| sort \
| tr '\n' ',' \
| sed 's/,/, /g' \
| sed 's/^, //' \
| sed 's/, $//'
)"
num_completed="$(echo $completed_challenges | grep -oE '[0-9]' | wc -l)"
echo "There are $total_challenges total challenges"
echo "You have completed the following challenges: $completed_challenges"
echo "You have completed $num_completed of the $total_challenges total challenges"