forked from gadmin/gsb2023
155 lines
5.2 KiB
PowerShell
155 lines
5.2 KiB
PowerShell
#mkvm pour toutes les vms
|
|
|
|
$mkvmrelease="v1.2"
|
|
$ovarelease="2023a"
|
|
$ovafogrelease="2023a"
|
|
$ovafile="$HOME\Downloads\debian-bullseye-gsb-${ovarelease}.ova"
|
|
$ovafilefog="$HOME\Downloads\debian-buster-gsb-${ovafogrelease}.ova"
|
|
$vboxmanage="C:\Program Files\Oracle\VirtualBox\VBoxManage.exe"
|
|
$deletemode=0
|
|
|
|
#FONCTIONS
|
|
|
|
function create_vm{ param([string]$nomvm)
|
|
#Importation depuis l'ova
|
|
& "$vboxmanage" import "$ovafile" --vsys 0 --vmname "$nomvm"
|
|
Write-Host "Machine $nomvm importée"
|
|
}
|
|
|
|
function create_if{ param([string]$nomvm, [string]$nic, [int]$rang, [string]$reseau)
|
|
#Création d'une interface
|
|
if ($nomvm -and $nic -and $rang -and $reseau) {
|
|
#if ("1" -eq "1") {
|
|
if ($nic -eq "bridge") {
|
|
#Création d'une interface en pont
|
|
& "$vboxmanage" modifyvm "$nomvm" --nic"$rang" bridged
|
|
& "$vboxmanage" modifyvm "$nomvm" --nictype"$rang" 82540EM
|
|
& "$vboxmanage" modifyvm "$nomvm" --cableconnected"$rang" on
|
|
& "$vboxmanage" modifyvm "$nomvm" --nicpromisc"$rang" allow-all
|
|
Write-Host "$nomvm : IF$rang $nic"
|
|
}
|
|
elseif ($nic -eq "int") {
|
|
#Création d'une interface en reseau interne
|
|
& "$vboxmanage" modifyvm "$nomvm" --nic"$rang" intnet
|
|
& "$vboxmanage" modifyvm "$nomvm" --intnet"$rang" "$reseau"
|
|
& "$vboxmanage" modifyvm "$nomvm" --nictype"$rang" 82540EM
|
|
& "$vboxmanage" modifyvm "$nomvm" --cableconnected"$rang" on
|
|
& "$vboxmanage" modifyvm "$nomvm" --nicpromisc"$rang" allow-all
|
|
Write-Host "$nomvm : IF$rang $nic $reseau"
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if ($args[0] -eq "s-adm") {
|
|
|
|
create_vm $args[0]
|
|
create_if $args[0] "bridge" 1 "null"
|
|
create_if $args[0] "int" 2 "n-adm"
|
|
|
|
}
|
|
|
|
elseif ($args[0] -eq "s-infra") {
|
|
|
|
create_vm $args[0]
|
|
create_if $args[0] "int" 1 "n-adm"
|
|
create_if $args[0] "int" 2 "n-infra"
|
|
|
|
#création de la première interface
|
|
& "$vboxmanage" modifyvm "s-infra" --nic1 intnet
|
|
& "$vboxmanage" modifyvm "s-infra" --intnet1 "n-adm"
|
|
& "$vboxmanage" modifyvm "s-infra" --nictype1 82540EM
|
|
& "$vboxmanage" modifyvm "s-infra" --cableconnected1 on
|
|
& "$vboxmanage" modifyvm "s-infra" --nicpromisc1 allow-all
|
|
|
|
#création de la deuxième interface
|
|
& "$vboxmanage" modifyvm "s-infra" --nic2 intnet
|
|
& "$vboxmanage" modifyvm "s-infra" --intnet2 "n-infra"
|
|
& "$vboxmanage" modifyvm "s-infra" --nictype2 82540EM
|
|
& "$vboxmanage" modifyvm "s-infra" --cableconnected2 on
|
|
& "$vboxmanage" modifyvm "s-infra" --nicpromisc2 allow-all
|
|
}
|
|
|
|
elseif ($args[0] -eq "r-int") {
|
|
|
|
create_vm($args[0])
|
|
|
|
#interface 1
|
|
& "$vboxmanage" modifyvm "r-int" --nic1 intnet
|
|
& "$vboxmanage" modifyvm "r-int" --intnet1 "n-adm"
|
|
& "$vboxmanage" modifyvm "r-int" --nictype1 82540EM
|
|
& "$vboxmanage" modifyvm "r-int" --cableconnected1 on
|
|
& "$vboxmanage" modifyvm "r-int" --nicpromisc1 allow-all
|
|
|
|
#interface 2
|
|
& "$vboxmanage" modifyvm "r-int" --nic2 intnet
|
|
& "$vboxmanage" modifyvm "r-int" --intnet2 "n-link"
|
|
& "$vboxmanage" modifyvm "r-int" --nictype2 82540EM
|
|
& "$vboxmanage" modifyvm "r-int" --cableconnected2 on
|
|
& "$vboxmanage" modifyvm "r-int" --nicpromisc2 allow-all
|
|
|
|
#interface 3
|
|
& "$vboxmanage" modifyvm "r-int" --nic3 intnet
|
|
& "$vboxmanage" modifyvm "r-int" --intnet3 "n-wifi"
|
|
& "$vboxmanage" modifyvm "r-int" --nictype3 82540EM
|
|
& "$vboxmanage" modifyvm "r-int" --cableconnected3 on
|
|
& "$vboxmanage" modifyvm "r-int" --nicpromisc3 allow-all
|
|
|
|
#interface 4
|
|
& "$vboxmanage" modifyvm "r-int" --nic4 intnet
|
|
& "$vboxmanage" modifyvm "r-int" --intnet4 "n-user"
|
|
& "$vboxmanage" modifyvm "r-int" --nictype4 82540EM
|
|
& "$vboxmanage" modifyvm "r-int" --cableconnected4 on
|
|
& "$vboxmanage" modifyvm "r-int" --nicpromisc4 allow-all
|
|
|
|
#interface 5
|
|
& "$vboxmanage" modifyvm "r-int" --nic5 intnet
|
|
& "$vboxmanage" modifyvm "r-int" --intnet5 "n-infra"
|
|
& "$vboxmanage" modifyvm "r-int" --nictype5 82540EM
|
|
& "$vboxmanage" modifyvm "r-int" --cableconnected5 on
|
|
& "$vboxmanage" modifyvm "r-int" --nicpromisc5 allow-all
|
|
}
|
|
|
|
elseif ($args[0] -eq "r-ext") {
|
|
|
|
create_vm($args[0])
|
|
|
|
#interface 1
|
|
& "$vboxmanage" modifyvm "r-ext" --nic1 intnet
|
|
& "$vboxmanage" modifyvm "r-ext" --intnet1 "n-adm"
|
|
& "$vboxmanage" modifyvm "r-ext" --nictype1 82540EM
|
|
& "$vboxmanage" modifyvm "r-ext" --cableconnected1 on
|
|
& "$vboxmanage" modifyvm "r-ext" --nicpromisc1 allow-all
|
|
|
|
#interface 2
|
|
& "$vboxmanage" modifyvm "r-ext" --nic2 intnet
|
|
& "$vboxmanage" modifyvm "r-ext" --intnet2 "n-dmz"
|
|
& "$vboxmanage" modifyvm "r-ext" --nictype2 82540EM
|
|
& "$vboxmanage" modifyvm "r-ext" --cableconnected2 on
|
|
& "$vboxmanage" modifyvm "r-ext" --nicpromisc2 allow-all
|
|
|
|
#interface 3
|
|
& "$vboxmanage" modifyvm "r-ext" --nic3 bridged
|
|
& "$vboxmanage" modifyvm "r-ext" --nictype3 82540EM
|
|
& "$vboxmanage" modifyvm "r-ext" --cableconnected3 on
|
|
& "$vboxmanage" modifyvm "r-ext" --nicpromisc3 allow-all
|
|
|
|
#interface 4
|
|
& "$vboxmanage" modifyvm "r-ext" --nic4 intnet
|
|
& "$vboxmanage" modifyvm "r-ext" --intnet4 "n-linkv"
|
|
& "$vboxmanage" modifyvm "r-ext" --nictype4 82540EM
|
|
& "$vboxmanage" modifyvm "r-ext" --cableconnected4 on
|
|
& "$vboxmanage" modifyvm "r-ext" --nicpromisc4 allow-all
|
|
|
|
#interface 5
|
|
& "$vboxmanage" modifyvm "r-ext" --nic5 intnet
|
|
& "$vboxmanage" modifyvm "r-ext" --intnet5 "n-link"
|
|
& "$vboxmanage" modifyvm "r-ext" --nictype5 82540EM
|
|
& "$vboxmanage" modifyvm "r-ext" --cableconnected5 on
|
|
& "$vboxmanage" modifyvm "r-ext" --nicpromisc5 allow-all
|
|
}
|
|
|
|
elseif ($args[0] -eq "test") {
|
|
|
|
fonction1 $args[0] $args[1]
|
|
} |