Files
warewulf/overlays/wwinit/rootfs/etc/systemd/system/ww4-mounts.ww
2024-02-19 14:28:49 +01:00

42 lines
1.2 KiB
Plaintext

{{- $host := .BuildHost }}
{{- $time := .BuildTime }}
{{- $source := .BuildSource }}
{{- range $fsdevice,$fs := .FileSystems }}
{{- $prefix := tr $fs.Path "-" "\\x2d" }}
{{- $prefix = tr $prefix "/" "-" }}
{{- $prefix = slice $prefix 1 }}
{{ $suffix := "mount"}}
{{- if $fs.Label }}{{ $prefix = $fs.Label }}{{ end }}
{{- if eq $fs.Format "swap"}}{{ $prefix = tr $fsdevice "/dev/disk/by-partlabel/" "dev-disk-by\\x2dpartlabel-"}}{{ $suffix = "swap"}}{{ end }}
{{- $filename := print $prefix "." $suffix }}
{{- file $filename }}
# This file is autogenerated by warewulf
# Host: {{ $host }}
# Time: {{ $time }}
# Source: {{ $source }}
{{- if eq $fs.Format "swap"}}
[Unit]
ConditionPathExists=/warewulf/ignition.json
After=ignition-ww4-disks.service
Before=swap.target
[Swap]
What={{ $fsdevice }}
[Install]
RequiredBy=swap.target
{{- else }}
[Unit]
ConditionPathExists=/warewulf/ignition.json
Before=local-fs.target
After=ignition-ww4-disks.service
[Mount]
Where={{ $fs.Path }}
What={{ $fsdevice }}
Type={{ $fs.Format }}
{{- if $fs.MountOptions }}
Options={{range $index,$opt := $fs.MountOptions }}{{if $index }},{{ end }}{{ $opt }}{{ end }}
{{- end }}
[Install]
RequiredBy=local-fs.target
{{- end }}
{{- end }}