modif mkvm

This commit is contained in:
phil 2023-01-18 23:24:33 +01:00
parent c5c261893c
commit e395c14752

View File

@ -1,21 +1,24 @@
#!/bin/bash #!/bin/bash
mkvmrelease="v1.2"
ovarelease="2023a" ovarelease="2023a"
ovafogrelease="2023a" ovafogrelease="2023a"
ovafile="$HOME/Téléchargements/debian-bullseye-gsb-${ovarelease}.ova" ovafile="$HOME/Téléchargements/debian-bullseye-gsb-${ovarelease}.ova"
ovafilefog="$HOME/Téléchargements/debian-buster-gsb-${ovafogrelease}.ova" ovafilefog="$HOME/Téléchargements/debian-buster-gsb-${ovafogrelease}.ova"
deletemode=0
usage () { usage () {
echo "$0 - version ${ovarelease}" echo "$0 - version ${mkvmrelease} - Ova version ${ovarelease}"
echo "$0 : creation VM et parametrage interfaces" echo "$0 : creation VM et parametrage interfaces"
echo "usage : $0 <s-infra|r-int|r-ext|s-proxy|s-mon>" echo "usage : $0 [-r] <s-infra|r-int|r-ext|s-proxy|s-mon|s-appli|s-backup|s-itil|s-ncx|s-fog>"
echo " option -r : efface vm existante avant creation nouvelle"
exit 1 exit 1
} }
create_vm () { create_vm () {
nom="$1" local nom="$1"
nomova=${ovafile} local nomova="${ovafile}"
if [[ "${nom}" == "s-fog" ]] ; then if [[ "${nom}" == "s-fog" ]] ; then
nomova="${ovafilefog}" nomova="${ovafilefog}"
fi fi
@ -23,6 +26,9 @@ create_vm () {
echo "$0 : erreur ouverture fichier ${nomova} ..." echo "$0 : erreur ouverture fichier ${nomova} ..."
exit 3 exit 3
fi fi
if [[ "${deletemode}" = 1 ]] ; then
VBoxManage unregistervm --delete "${nom}"
fi
vboxmanage import "${nomova}" --vsys 0 --vmname "${nom}" vboxmanage import "${nomova}" --vsys 0 --vmname "${nom}"
} }
@ -38,15 +44,25 @@ setif () {
create_if () { create_if () {
# enp0s3 # enp0s3
setif "$1" 1 "$2" setif "$1" 1 "$2"
setif "$1" 2 "$3"
#(enp0s8) #(enp0s8)
setif "$1" 2 "$3"
#(enp0s9)
if [[ -n "$4" ]] ; then
setif "$1" 3 "$4"
fi
} }
if [[ $# != 1 ]] ; then if [[ $# == 0 ]] ; then
usage usage
fi fi
if [[ $1 == "--help" ]] || [[ $1 == "-h" ]] || [[ $1 == "-V" ]] ; then
usage
fi
if [[ $1 == "-r" ]] ; then
deletemode=1
shift
fi
vm="$1" vm="$1"
create_vm "${vm}" create_vm "${vm}"
@ -56,9 +72,7 @@ elif [[ "${vm}" == "s-proxy" ]] ; then
create_if "${vm}" "n-adm" "n-infra" create_if "${vm}" "n-adm" "n-infra"
elif [[ "${vm}" == "r-int" ]] ; then elif [[ "${vm}" == "r-int" ]] ; then
# n-adm, n-link, n-wifi, n-user, n-infra # n-adm, n-link, n-wifi, n-user, n-infra
create_if "${vm}" "n-adm" "n-infra" create_if "${vm}" "n-adm" "n-link" "n-wifi"
setif "${vm}" 2 "n-link"
setif "${vm}" 3 "n-wifi"
setif "${vm}" 4 "n-user" setif "${vm}" 4 "n-user"
setif "${vm}" 5 "n-infra" setif "${vm}" 5 "n-infra"
elif [[ "${vm}" == "r-ext" ]] ; then elif [[ "${vm}" == "r-ext" ]] ; then
@ -74,9 +88,8 @@ elif [[ "${vm}" == "s-itil" ]] ; then
elif [[ "${vm}" == "s-nxc" ]] ; then elif [[ "${vm}" == "s-nxc" ]] ; then
create_if "${vm}" "n-adm" "n-infra" create_if "${vm}" "n-adm" "n-infra"
elif [[ "${vm}" == "s-fog" ]] ; then elif [[ "${vm}" == "s-fog" ]] ; then
create_if "${vm}" "n-adm" "n-infra" create_if "${vm}" "n-adm" "n-infra" "n-user"
setif "${vm}" 3 "n-user" elif [[ "${vm}" == "s-dns-ext" ]] ; then
elif [[ "${vm}" == "s-DNS-ext" ]] ; then
create_if "${vm}" "n-adm" "n-dmz" create_if "${vm}" "n-adm" "n-dmz"
elif [[ "${vm}" == "s-web-ext" ]] ; then elif [[ "${vm}" == "s-web-ext" ]] ; then
create_if "${vm}" "n-adm" "n-dmz" create_if "${vm}" "n-adm" "n-dmz"
@ -86,12 +99,10 @@ elif [[ "${vm}" == "s-lb" ]] ; then
create_if "${vm}" "n-adm" "n-dmz" "n-dmz-lb" create_if "${vm}" "n-adm" "n-dmz" "n-dmz-lb"
elif [[ "${vm}" == "s-web1" ]] ; then elif [[ "${vm}" == "s-web1" ]] ; then
create_if "${vm}" "n-adm" "n-dmz-lb" "n-dmz-db" create_if "${vm}" "n-adm" "n-dmz-lb" "n-dmz-db"
# setif "${vm}" 3 "n-dmz-lb"
elif [[ "${vm}" == "s-web2" ]] ; then elif [[ "${vm}" == "s-web2" ]] ; then
create_if "${vm}" "n-adm" "n-dmz-lb" "n-dmz-db" create_if "${vm}" "n-adm" "n-dmz-lb" "n-dmz-db"
elif [[ "${vm}" == "s-web3" ]] ; then elif [[ "${vm}" == "s-web3" ]] ; then
create_if "${vm}" "n-adm" "n-dmz-lb" "n-dmz-db" create_if "${vm}" "n-adm" "n-dmz-lb" "n-dmz-db"
# setif "${vm}" 3 "n-dmz-lb"
elif [[ "${vm}" == "s-lb-bd" ]] ; then elif [[ "${vm}" == "s-lb-bd" ]] ; then
create_if "${vm}" "n-adm" "n-dmz-db" create_if "${vm}" "n-adm" "n-dmz-db"
elif [[ "${vm}" == "s-nas" ]] ; then elif [[ "${vm}" == "s-nas" ]] ; then
@ -102,8 +113,7 @@ elif [[ "${vm}" == "r-vp2" ]] ; then
./addint.r-vp2 ./addint.r-vp2
elif [[ "${vm}" == "s-agence" ]] ; then elif [[ "${vm}" == "s-agence" ]] ; then
create_if "${vm}" "n-adm" "n-agence" create_if "${vm}" "n-adm" "n-agence"
else else
echo "$0 : vm ${vm} non prevu" echo "$0 : vm ${vm} non prevue "
exit 2 exit 2
fi fi