-
Notifications
You must be signed in to change notification settings - Fork 0
/
local-wrapper-tpm.sh
51 lines (42 loc) · 1.72 KB
/
local-wrapper-tpm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Copyright (C) 2022 Toni Blåfield
#
# edge-image-tools is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# edge-image-tools is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with edge-image-tools. If not, see <http://www.gnu.org/licenses/>.
set -e
# Assuming either current user ROOT user or current user has SUDO
userId=$(id -u)
(( userId != 0 )) && echo "Current user not root. This script must be run as root user or with sudo privileges." && exit 1
# Read local variables from separate file
# shellcheck source=/dev/null
source local/local_config
bashBin='/bin/bash'
# Scripts to execute in this local wrapper
scripts=("${PWD}/tpm-device-build.sh" "${PWD}/tpm-attestation-build.sh")
################################################################################
################################ START ####################################
################################################################################
# shellcheck disable=SC2068
for script in ${scripts[@]}; do
chmod -v +x "${script}"
# Test all params are correctly set
${bashBin} "${script}" 'test'
done
# If only testing, dont execute
if [[ ${1} != 'test' ]]; then
# shellcheck disable=SC2068
for script in ${scripts[@]}; do
# If all ok, run the scripts
${bashBin} "${script}"
done
fi