Debian Codegraph @

dracut/modules.d/50kiwi-verity/kiwi-veritytab-setup.sh

raw
1 #!/bin/sh
2 # This file is part of kiwi.
3 #
4 # kiwi is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # kiwi is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with kiwi. If not, see <http://www.gnu.org/licenses/>
16 #
17 # shellcheck disable=SC1091
18 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
19
20 if [ ! -e "/etc/veritytab" ];then
21 return
22 fi
23
24 read -r name data_device hash_device root_hash options < /etc/veritytab
25
26 if [ "$(echo "${data_device}" | cut -f1 -d=)" = "UUID" ];then
27 data_device=/dev/disk/by-uuid/$(echo "${data_device}" | cut -f2 -d=)
28 fi
29 if [ "$(echo "${hash_device}" | cut -f1 -d=)" = "UUID" ];then
30 hash_device=/dev/disk/by-uuid/$(echo "${hash_device}" | cut -f2 -d=)
31 fi
32
33 # Read kernel command line verity options and merge the options
34 kiwi_verity_options=$(getarg rd.kiwi.verity_options=)
35 if [ -n "${kiwi_verity_options}" ]; then
36 if [ -n "${options}" ]; then
37 options="${options},${kiwi_verity_options}"
38 else
39 options="${kiwi_verity_options}"
40 fi
41 fi
42
43 veritysetup="veritysetup open "
44 veritysetup="${veritysetup} ${data_device} ${name} ${hash_device} ${root_hash}"
45
46 for option in $(echo "${options}" | tr , " ");do
47 veritysetup="${veritysetup} --${option}"
48 done
49
50 eval "${veritysetup}"