working on support for managing VM state and IP address
This commit is contained in:
@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
virsh list --all | grep running | grep -v ' Id' | grep -v -- '----' | awk '{print $2}' | sort
|
@ -8,15 +8,15 @@ if echo "$ip_address" | grep -vqE '^([0-9]{1,3}\.){3}[0-9]{1,3}$'; then
|
||||
fi
|
||||
|
||||
printf '['
|
||||
DELIMITER=""
|
||||
delimiter=""
|
||||
ssh-keyscan "$ip_address" 2>/dev/null | while read -r line; do
|
||||
if echo "$line" | grep -qE "^$ip_address"' +(ssh|ecdsa)-[0-9A-Za-z+/_=@. -]+$'; then
|
||||
KEY_CONTENT="$(echo "$line" | awk '{ print $2 " " $3 }')"
|
||||
FINGERPRINT_OUTPUT="$(echo "$KEY_CONTENT" | ssh-keygen -l -E sha256 -f - | sed -E 's/^[0-9]+ SHA256:([0-9A-Za-z+/-]+) .+ \(([A-Z0-9]+)\)$/\1 \2/g')"
|
||||
SHA256_HASH="$(echo "$FINGERPRINT_OUTPUT" | awk '{ print $1 }')"
|
||||
KEY_TYPE="$(echo "$FINGERPRINT_OUTPUT" | awk '{ print $2 }')"
|
||||
printf '%s\n {"key_type":"%s", "content":"%s", "sha256":"%s"}' "$DELIMITER" "$KEY_TYPE" "$KEY_CONTENT" "$SHA256_HASH"
|
||||
DELIMITER=","
|
||||
key_content="$(echo "$line" | awk '{ print $2 " " $3 }')"
|
||||
fingerprint_output="$(echo "$key_content" | ssh-keygen -l -E sha256 -f - | sed -E 's/^[0-9]+ SHA256:([0-9A-Za-z+/-]+) .+ \(([A-Z0-9]+)\)$/\1 \2/g')"
|
||||
sha256_hash="$(echo "$fingerprint_output" | awk '{ print $1 }')"
|
||||
key_type="$(echo "$fingerprint_output" | awk '{ print $2 }')"
|
||||
printf '%s\n {"key_type":"%s", "content":"%s", "sha256":"%s"}' "$delimiter" "$key_type" "$key_content" "$sha256_hash"
|
||||
delimiter=","
|
||||
fi
|
||||
done
|
||||
printf '\n]\n'
|
||||
|
13
capsulflask/shell_scripts/virsh-list.sh
Executable file
13
capsulflask/shell_scripts/virsh-list.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
printf '['
|
||||
delimiter=""
|
||||
virsh list --all | while read -r line; do
|
||||
if echo "$line" | grep -qE '(running)|(shut off)'; then
|
||||
capsul_id="$(echo "$line" | awk '{ print $2 }')"
|
||||
capsul_state="$(echo "$line" | sed -E 's/.*((running)|(shut off))\w*/\1/')"
|
||||
printf '%s\n {"id":"%s", "state":"%s"}' "$delimiter" "$capsul_id" "$capsul_state"
|
||||
delimiter=","
|
||||
fi
|
||||
done
|
||||
printf '\n]\n'
|
3
capsulflask/shell_scripts/virsh-net-list.sh
Normal file
3
capsulflask/shell_scripts/virsh-net-list.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
virsh net-list --all | tail -n +3 | awk '{ print $1 }'
|
Reference in New Issue
Block a user