forked from gadmin/gsb2023
Merge branch 'main' of https://gitea.lyc-lecastel.fr/gadmin/gsb2023
This commit is contained in:
commit
dbe75506e3
190
scripts/mkvm.ps1
190
scripts/mkvm.ps1
@ -22,11 +22,10 @@ function create_vm{ param([string]$nomvm)
|
|||||||
function create_if{ param([string]$nomvm, [string]$nic, [int]$rang, [string]$reseau)
|
function create_if{ param([string]$nomvm, [string]$nic, [int]$rang, [string]$reseau)
|
||||||
#Création d'une interface
|
#Création d'une interface
|
||||||
if ($nomvm -and $nic -and $rang -and $reseau) {
|
if ($nomvm -and $nic -and $rang -and $reseau) {
|
||||||
#if ("1" -eq "1") {
|
|
||||||
if ($nic -eq "bridge") {
|
if ($nic -eq "bridge") {
|
||||||
#Création d'une interface en pont
|
#Création d'une interface en pont
|
||||||
& "$vboxmanage" modifyvm "$nomvm" --nic"$rang" bridged
|
& "$vboxmanage" modifyvm "$nomvm" --nic"$rang" bridged
|
||||||
& "$vboxmanage" modifyvm "$nomvm" --nictype"$rang" 82540EM
|
& "$vboxmanage" modifyvm "$nomvm" --nictype"$rang" virtio
|
||||||
& "$vboxmanage" modifyvm "$nomvm" --cableconnected"$rang" on
|
& "$vboxmanage" modifyvm "$nomvm" --cableconnected"$rang" on
|
||||||
& "$vboxmanage" modifyvm "$nomvm" --nicpromisc"$rang" allow-all
|
& "$vboxmanage" modifyvm "$nomvm" --nicpromisc"$rang" allow-all
|
||||||
Write-Host "$nomvm : IF$rang $nic"
|
Write-Host "$nomvm : IF$rang $nic"
|
||||||
@ -35,7 +34,7 @@ function create_if{ param([string]$nomvm, [string]$nic, [int]$rang, [string]$res
|
|||||||
#Création d'une interface en reseau interne
|
#Création d'une interface en reseau interne
|
||||||
& "$vboxmanage" modifyvm "$nomvm" --nic"$rang" intnet
|
& "$vboxmanage" modifyvm "$nomvm" --nic"$rang" intnet
|
||||||
& "$vboxmanage" modifyvm "$nomvm" --intnet"$rang" "$reseau"
|
& "$vboxmanage" modifyvm "$nomvm" --intnet"$rang" "$reseau"
|
||||||
& "$vboxmanage" modifyvm "$nomvm" --nictype"$rang" 82540EM
|
& "$vboxmanage" modifyvm "$nomvm" --nictype"$rang" virtio
|
||||||
& "$vboxmanage" modifyvm "$nomvm" --cableconnected"$rang" on
|
& "$vboxmanage" modifyvm "$nomvm" --cableconnected"$rang" on
|
||||||
& "$vboxmanage" modifyvm "$nomvm" --nicpromisc"$rang" allow-all
|
& "$vboxmanage" modifyvm "$nomvm" --nicpromisc"$rang" allow-all
|
||||||
Write-Host "$nomvm : IF$rang $nic $reseau"
|
Write-Host "$nomvm : IF$rang $nic $reseau"
|
||||||
@ -43,6 +42,9 @@ function create_if{ param([string]$nomvm, [string]$nic, [int]$rang, [string]$res
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function usage{
|
||||||
|
Write-Host "usage : mkvm ${myInvocation.ScriptName} <s-adm|s-infra|r-int|r-ext|s-proxy|s-mon|s-agence|s-appli|s-backup|s-itil|s-ncx|s-fog|s-dns-ext|s-web-ext|s-lb|s-lb-bd|s-lb-web1|s-lb-web2|s-lb-web3>"
|
||||||
|
}
|
||||||
|
|
||||||
if ($args[0] -eq "s-adm") {
|
if ($args[0] -eq "s-adm") {
|
||||||
|
|
||||||
@ -52,107 +54,103 @@ if ($args[0] -eq "s-adm") {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif ($args[0] -eq "s-infra") {
|
elseif ($args[0] -eq "r-int") {
|
||||||
|
|
||||||
create_vm $args[0]
|
create_vm $args[0]
|
||||||
create_if $args[0] "int" 1 "n-adm"
|
create_if $args[0] "int" 1 "n-adm"
|
||||||
create_if $args[0] "int" 2 "n-infra"
|
create_if $args[0] "int" 2 "n-link"
|
||||||
|
create_if $args[0] "int" 3 "n-wifi"
|
||||||
#création de la première interface
|
create_if $args[0] "int" 4 "n-user"
|
||||||
& "$vboxmanage" modifyvm "s-infra" --nic1 intnet
|
create_if $args[0] "int" 5 "n-infra"
|
||||||
& "$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") {
|
elseif ($args[0] -eq "r-ext") {
|
||||||
|
|
||||||
create_vm($args[0])
|
create_vm $args[0]
|
||||||
|
create_if $args[0] "int" 1 "n-adm"
|
||||||
#interface 1
|
create_if $args[0] "int" 2 "n-dmz"
|
||||||
& "$vboxmanage" modifyvm "r-ext" --nic1 intnet
|
create_if $args[0] "bridge" 3 "null"
|
||||||
& "$vboxmanage" modifyvm "r-ext" --intnet1 "n-adm"
|
create_if $args[0] "int" 4 "n-linkv"
|
||||||
& "$vboxmanage" modifyvm "r-ext" --nictype1 82540EM
|
create_if $args[0] "int" 5 "n-link"
|
||||||
& "$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") {
|
elseif (((((((($args[0] -eq "s-elk") `
|
||||||
|
-or ($args[0] -eq "s-mon") `
|
||||||
|
-or ($args[0] -eq "s-backup") `
|
||||||
|
-or ($args[0] -eq "s-appli") `
|
||||||
|
-or ($args[0] -eq "s-infra") `
|
||||||
|
-or ($args[0] -eq "s-proxy") `
|
||||||
|
-or ($args[0] -eq "s-itil") `
|
||||||
|
-or ($args[0] -eq "s-nxc") `
|
||||||
|
))))))) {
|
||||||
|
|
||||||
fonction1 $args[0] $args[1]
|
create_vm $args[0]
|
||||||
|
create_if $args[0] "int" 1 "n-adm"
|
||||||
|
create_if $args[0] "int" 2 "n-infra"
|
||||||
|
}
|
||||||
|
|
||||||
|
elseif ($args[0] -eq "s-fog") {
|
||||||
|
|
||||||
|
create_vm $args[0]
|
||||||
|
create_if $args[0] "int" 1 "n-adm"
|
||||||
|
create_if $args[0] "int" 2 "n-infra"
|
||||||
|
create_if $args[0] "int" 3 "n-user"
|
||||||
|
}
|
||||||
|
|
||||||
|
elseif ($args[0] -eq "s-agence") {
|
||||||
|
|
||||||
|
create_vm $args[0]
|
||||||
|
create_if $args[0] "int" 1 "n-adm"
|
||||||
|
create_if $args[0] "int" 2 "n-agence"
|
||||||
|
}
|
||||||
|
|
||||||
|
elseif ($args[0] -eq "s-lb") {
|
||||||
|
|
||||||
|
create_vm $args[0]
|
||||||
|
create_if $args[0] "int" 1 "n-adm"
|
||||||
|
create_if $args[0] "int" 2 "n-dmz"
|
||||||
|
create_if $args[0] "int" 3 "n-dmz-lb"
|
||||||
|
}
|
||||||
|
|
||||||
|
elseif (($args[0] -eq "s-lb-db") -or ($args[0] -eq "s-nas")) {
|
||||||
|
|
||||||
|
create_vm $args[0]
|
||||||
|
create_if $args[0] "int" 1 "n-adm"
|
||||||
|
create_if $args[0] "int" 2 "n-dmz-db"
|
||||||
|
}
|
||||||
|
|
||||||
|
elseif ((($args[0] -eq "s-lb-web1") -or ($args[0] -eq "s-lb-web2") -or ($args[0] -eq "s-lb-web3"))) {
|
||||||
|
|
||||||
|
create_vm $args[0]
|
||||||
|
create_if $args[0] "int" 1 "n-adm"
|
||||||
|
create_if $args[0] "int" 2 "n-dmz-lb"
|
||||||
|
create_if $args[0] "int" 3 "n-dmz-db"
|
||||||
|
}
|
||||||
|
|
||||||
|
elseif (($args[0] -eq "s-dns-ext") -or ($args[0] -eq "s-web-ext")) {
|
||||||
|
|
||||||
|
create_vm $args[0]
|
||||||
|
create_if $args[0] "int" 1 "n-adm"
|
||||||
|
create_if $args[0] "int" 2 "n-infra"
|
||||||
|
create_if $args[0] "int" 3 "n-user"
|
||||||
|
}
|
||||||
|
|
||||||
|
elseif ($args[0] -eq "r-vp1") {
|
||||||
|
|
||||||
|
create_vm $args[0]
|
||||||
|
create_if $args[0] "int" 1 "n-adm"
|
||||||
|
create_if $args[0] "int" 2 "n-linkv"
|
||||||
|
create_if $args[0] "bridge" 3 "null"
|
||||||
|
}
|
||||||
|
|
||||||
|
elseif ($args[0] -eq "r-vp2") {
|
||||||
|
|
||||||
|
create_vm $args[0]
|
||||||
|
create_if $args[0] "int" 1 "n-adm"
|
||||||
|
create_if $args[0] "int" 2 "n-agence"
|
||||||
|
create_if $args[0] "bridge" 3 "null"
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
usage
|
||||||
}
|
}
|
@ -3,3 +3,5 @@
|
|||||||
wget http://r-vp1.gsb.adm:8000/wg0-b.qconf
|
wget http://r-vp1.gsb.adm:8000/wg0-b.qconf
|
||||||
#renomage fichier et mv
|
#renomage fichier et mv
|
||||||
mv ./wg0-b.conf /etc/wireguard/wg0.conf
|
mv ./wg0-b.conf /etc/wireguard/wg0.conf
|
||||||
|
#activation interface wg0
|
||||||
|
systemctl enable wg-quick@wg0 && systemctl start wg-quick@wg0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user