You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

215 lines
2.9 KiB

#!/usr/bin/env bash
set -eu
synopsis() {
cat << EOF
Usage : $(basename $0) [-h]
EOF
}
help() {
cat << EOF
$(basename $0) Affiche les configurations des systèmes.
$(synopsis)
-h : affiche cette aide
-r : attendre la touche "Entrée" pour terminer
EOF
}
usage() {
synopsis
exit 1
}
args() {
local opt
while getopts "h" opt; do
case $opt in
h) help; exit 0;;
?) usage;;
esac
done
shift $(($OPTIND - 1))
}
i1() {
printf "%10s %8s %s\n" "GUEST" "IDENT" "GUEST_SYS"
for i in $guests; do
a=$(vdn-config $i IDENT)
b=$(vdn-config $i GUEST_SYS)
printf "%10s %8s %s\n" $i $a $b
done
echo
}
i2() {
printf "%10s %8s %s\n" "GUEST" "MEMORY" "HDA"
sm=0
for i in $guests; do
m=$(vdn-config $i MEMORY)
d=$(vdn-config $i HDA)
printf "%10s %8s %s\n" $i $m $d
sm=$(($sm+$m))
done
echo
echo "TOTAL MEMORY = $sm"
echo
}
i3() {
printf "%10s %8s %s\n" "GUEST" "NETWORKS"
for i in $guests; do
b=$(vdn-config $i NETWORKS)
printf "%10s %8s %s\n" $i "$b"
done
echo
}
i4() {
nets="NET_G"
for i in $(seq 1 9); do
nets="$nets NET_$i"
done
printf "%10s %s\n" NETWORKS " GUESTS(ETH)"
for i in $nets; do
l=""
for s in $guests; do
setGuestVars $s
grep -q '^[^#]*NETWORKS=.*'$i $GUEST_CONF && {
l="$l $s"
}
done
l2=""
for j in $l; do
a=$(vdn-config $j NETWORKS)
b=$(echo "$a" | sed -re 's/^(.*)'$i'.*$/\1/')
c=$(echo "$b" | sed -re 's/[^ ]//g')
d=$(echo "$c" | wc -c)
d=$(($d-1))
#echo "$i $j(eth$d)"
l2="$l2 $j(eth$d)"
done
[ -n "$l2" ] && {
printf "%10s %s\n" $i "$l2"
}
done
echo
}
i5() {
printf "%10s %s\n" "GUEST" "REDIRS"
for i in $guests; do
a="$(vdn-config $i REDIRS)"
printf "%10s %s\n" $i "$a"
done
echo
}
i6() {
nothing=1
}
i7() {
printf "%10s %12s %s\n" "GUEST" "AUFS_SIZE" "AUFS_FILE"
for i in $guests; do
a="$(vdn-config $i AUFS_SIZE)"
b="$(vdn-config $i AUFS_FILE)"
printf "%10s %12s %s\n" $i "$a" "$b"
done
echo
}
i8() {
printf "%10s %12s %s\n" "GUEST" "SWAP_SIZE" "SWAP_FILE"
for i in $guests; do
a="$(vdn-config $i SWAP_SIZE)"
b="$(vdn-config $i SWAP_FILE)"
printf "%10s %12s %s\n" $i "$a" "$b"
done
echo
}
i9() {
printf "%10s %s\n" "GUEST" "SAVE_EXCLUDE"
for i in $guests; do
a="$(vdn-config $i SAVE_EXCLUDE)"
printf "%10s %s\n" $i "$a"
done
echo
}
i10() {
printf "%10s %s\n" "GUEST" "EXTRA_SERVICES"
for i in $guests; do
a="$(vdn-config $i EXTRA_SERVICES)"
printf "%10s %s\n" $i "$a"
done
echo
}
i11() {
printf "%10s %s\n" "GUEST" "EXCLUDE_SERVICES"
for i in $guests; do
a="$(vdn-config $i EXCLUDE_SERVICES)"
printf "%10s %s\n" $i "$a"
done
echo
}
# Programme principal
VDN_PATH=$(readlink -f $(dirname $0)/..); . $VDN_PATH/bin/functions.sh
args "$@"
#IDENT=0; computeNetworks
guests="$(find $NETWORK_DIR -follow -name "*.conf" | sed -re 's/^.*\/([^/]+).conf$/\1/')"
i1
i2
i3
i4
i5
vdn-graph # -a
i6
i7
i8
i9
i10
i11