{{- $host := .BuildHost }}
{{- $time := .BuildTime }}
{{- $source := .BuildSource }}
{{- range $fsdevice,$fs := .FileSystems }}
{{- $prefix := tr $fs.Path "/" "" }}{{ $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 }}
