summary refs log tree commit diff
path: root/host/initramfs/etc/getuuids
blob: 62f893581ba83ec87a4ecad7bf87556768b4ae78 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/awk -f
# SPDX-License-Identifier: EUPL-1.2+
# SPDX-FileCopyrightText: 2021, 2023 Alyssa Ross <hi@alyssa.is>

function to_uuid(hex) {
    return substr(hex, 1, 8) "-" substr(hex, 9, 4) "-" substr(hex, 13, 4) "-" \
        substr(hex, 17, 4) "-" substr(hex, 21)
}

BEGIN {
    if (length(ENVIRON["roothash"]) != 64) {
	system("echo 'roothash invalid or missing' >&2")
	exit 1
    }

    print to_uuid(substr(ENVIRON["roothash"], 1, 32))
    print to_uuid(substr(ENVIRON["roothash"], 33, 32))
}