forked from gadmin/gsb2023
110 lines
3.0 KiB
Bash
Executable File
110 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
ovarelease="2023a"
|
|
ovafogrelease="2023a"
|
|
ovafile="$HOME/Téléchargements/debian-bullseye-gsb-${ovarelease}.ova"
|
|
ovafilefog="$HOME/Téléchargements/debian-buster-${ovafogrelease}.ova"
|
|
|
|
|
|
usage () {
|
|
echo "$0 - version ${ovarelease}"
|
|
echo "$0 : creation VM et parametrage interfaces"
|
|
echo "usage : $0 <s-infra|r-int|r-ext|s-proxy|s-mon>"
|
|
exit 1
|
|
}
|
|
|
|
create_vm () {
|
|
nom="$1"
|
|
nomova=${ovafile}
|
|
if [[ "${nom}" == "s-fog" ]] ; then
|
|
nomova="${ovafilefog}"
|
|
fi
|
|
if [[ ! -r "${nomova}" ]]; then
|
|
echo "$0 : erreur ouverture fichier ${nomova} ..."
|
|
exit 3
|
|
fi
|
|
vboxmanage import "${nomova}" --vsys 0 --vmname "${nom}"
|
|
}
|
|
|
|
setif () {
|
|
|
|
VBoxManage modifyvm "$1" --nic"${2}" intnet
|
|
VBoxManage modifyvm "$1" --intnet"${2}" "$3"
|
|
VBoxManage modifyvm "$1" --nictype"${2}" 82540EM
|
|
VBoxManage modifyvm "$1" --cableconnected"${2}" on
|
|
VBoxManage modifyvm "$1" --nicpromisc"${2}" allow-all
|
|
}
|
|
|
|
create_if () {
|
|
# enp0s3
|
|
setif "$1" 1 "$2"
|
|
setif "$1" 2 "$3"
|
|
#(enp0s8)
|
|
}
|
|
|
|
|
|
if [[ $# != 1 ]] ; then
|
|
usage
|
|
fi
|
|
|
|
vm="$1"
|
|
|
|
create_vm "${vm}"
|
|
if [[ "${vm}" == "s-infra" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-infra"
|
|
elif [[ "${vm}" == "s-proxy" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-infra"
|
|
elif [[ "${vm}" == "r-int" ]] ; then
|
|
# n-adm, n-link, n-wifi, n-user, n-infra
|
|
create_if "${vm}" "n-adm" "n-infra"
|
|
setif "${vm}" 2 "n-link"
|
|
setif "${vm}" 3 "n-wifi"
|
|
setif "${vm}" 4 "n-user"
|
|
setif "${vm}" 5 "n-infra"
|
|
elif [[ "${vm}" == "r-ext" ]] ; then
|
|
./addint.r-ext
|
|
elif [[ "${vm}" == "s-mon" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-infra"
|
|
elif [[ "${vm}" == "s-appli" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-infra"
|
|
elif [[ "${vm}" == "s-backup" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-infra"
|
|
elif [[ "${vm}" == "s-itil" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-infra"
|
|
elif [[ "${vm}" == "s-nxc" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-infra"
|
|
elif [[ "${vm}" == "s-fog" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-infra"
|
|
setif "${vm}" 3 "n-user"
|
|
elif [[ "${vm}" == "s-DNS-ext" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-dmz"
|
|
elif [[ "${vm}" == "s-web-ext" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-dmz"
|
|
elif [[ "${vm}" == "s-nxc" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-infra"
|
|
elif [[ "${vm}" == "s-lb" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-dmz" "n-dmz-lb"
|
|
elif [[ "${vm}" == "s-web1" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-dmz-lb" "n-dmz-db"
|
|
# setif "${vm}" 3 "n-dmz-lb"
|
|
elif [[ "${vm}" == "s-web2" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-dmz-lb" "n-dmz-db"
|
|
elif [[ "${vm}" == "s-web3" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-dmz-lb" "n-dmz-db"
|
|
# setif "${vm}" 3 "n-dmz-lb"
|
|
elif [[ "${vm}" == "s-lb-bd" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-dmz-db"
|
|
elif [[ "${vm}" == "s-nas" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-dmz-db"
|
|
elif [[ "${vm}" == "r-vp1" ]] ; then
|
|
./addint.r-vp1
|
|
elif [[ "${vm}" == "r-vp2" ]] ; then
|
|
./addint.r-vp2
|
|
elif [[ "${vm}" == "s-agence" ]] ; then
|
|
create_if "${vm}" "n-adm" "n-agence"
|
|
|
|
else
|
|
echo "$0 : vm ${vm} non prevu"
|
|
exit 2
|
|
fi
|