capsul-flask/capsulflask/shell_scripts/virsh-list.sh

14 lines
373 B
Bash
Executable File

#!/bin/sh
printf '['
delimiter=""
virsh list --all | tail -n +3 | while read -r line; do
if [ "$line" != "" ]; then
capsul_id="$(echo "$line" | awk '{ print $2 }')"
capsul_state="$(echo "$line" | sed -E 's/^ *[0-9-]+ +[^ ]+ +//')"
printf '%s\n {"id":"%s", "state":"%s"}' "$delimiter" "$capsul_id" "$capsul_state"
delimiter=","
fi
done
printf '\n]\n'