Refactor VM volume mounting
- Replace bind-mounts on /lmn/media/$USER with separate mounting for Home and Share SMB shares in the VM. - Update vm-run to start virtiofsd with /lmn/media/$USER (/home/$USER on localhome machines). - Use vm-vminfo to generate a JSON file containing user information, including Username, Groups, printer list krb5-ticket and some more - Configure vminfo.service (systemd-timer) to periodically call vm-vminfo. - Ensure krb5-ticket (TGT) is injected into the Windows VM. - Mount SMB-Home and SMB-Share shares as part of the new structure.
This commit is contained in:
parent
48ce882c16
commit
8471e34b0f
12 changed files with 560 additions and 24 deletions
73
misc/vm/vm-prepare-sys.ps1
Normal file
73
misc/vm/vm-prepare-sys.ps1
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
# Installiere alle Mounts aus target.csv
|
||||
# Geprüft wird, ob das Laufwerk bereits vorhanden
|
||||
# 11.05.2025 da
|
||||
|
||||
function Mount-Drive {
|
||||
param (
|
||||
[string]$DriveLetter,
|
||||
[string]$TargetPath
|
||||
)
|
||||
|
||||
try {
|
||||
& "C:\Program Files (x86)\WinFsp\bin\launchctl-x64.exe" start virtiofs viofs$DriveLetter $TargetPath \\.\${DriveLetter}:
|
||||
Write-Verbose "Laufwerk hinzugefügt: $DriveLetter"
|
||||
} catch {
|
||||
Write-Error "Fehler beim Hinzufügen des Laufwerks ${DriveLetter}: $_"
|
||||
}
|
||||
}
|
||||
|
||||
function Import-VMInfo {
|
||||
param (
|
||||
[string]$Path
|
||||
)
|
||||
|
||||
if (Test-Path $Path) {
|
||||
return Get-Content -Path $Path -Raw | ConvertFrom-Json
|
||||
} else {
|
||||
Write-Error "Fehler beim Einlesen der VMInfo Datei ($Path nicht gefunden)."
|
||||
Write-Error "Tipp: Beim Neustart der VM wird diese Datei neu angelegt."
|
||||
Pause
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
# Laufwerk Y: mit weiteren Mountpoint-Infos mounten
|
||||
& "C:\Program Files\Virtio-Win\VioFS\virtiofs.exe" -m Y:
|
||||
#Mount-Drive -DriveLetter "Y" -TargetPath "VM-Data"
|
||||
|
||||
# VMInfo aus JSON File einlesen
|
||||
$VMInfoPath = "Y:\.vminfo.json"
|
||||
# Schleife, die auf das Laufwerk wartet
|
||||
while (-not (Test-Path $VMInfoPath)) {
|
||||
Write-Host "Warte auf $VMInfoPath..."
|
||||
Start-Sleep -Seconds 1
|
||||
}
|
||||
$VMInfo = Import-VMInfo -Path $VMInfoPath
|
||||
|
||||
# Weitere Laufwerke einbinden
|
||||
#foreach ($virtiofs in $VMInfo.VirtioFS) {
|
||||
# $targetDrive = $virtiofs.Drive
|
||||
# if (-not (Get-PSDrive -Name $targetDrive -ErrorAction SilentlyContinue)) {
|
||||
# Mount-Drive -DriveLetter $targetDrive -TargetPath $virtiofs.Target
|
||||
# } else {
|
||||
# Write-Error "Laufwerk bereits vorhanden: $targetDrive"
|
||||
# }
|
||||
#}
|
||||
|
||||
# Drucker installieren
|
||||
foreach ($drucker in $VMInfo.Printers) {
|
||||
# Überprüfen, ob der Drucker bereits vorhanden ist
|
||||
$druckerName = $drucker.Name
|
||||
$druckerVorhanden = Get-Printer | Where-Object { $_.Name -eq $druckerName }
|
||||
|
||||
# Umwandlung in HTTP-URL
|
||||
$httpUrl = $drucker.IppURL -replace "ipp://", "http://" -replace "122.1", "122.1:631"
|
||||
|
||||
if (-not $druckerVorhanden) {
|
||||
# Drucker hinzufügen, wenn er nicht vorhanden ist
|
||||
Add-Printer -PortName $httpUrl -Name $druckerName -DriverName "Microsoft IPP Class Driver"
|
||||
Write-Host "Drucker hinzugefuegt: $druckerName"
|
||||
} else {
|
||||
Write-Host "Drucker bereits vorhanden: $druckerName"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue