-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·95 lines (74 loc) · 3.57 KB
/
configure
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
# script to check for dependencies and prepare a .env file as configuration
echo "Checking dependencies..." >&2
let deps_available=0
printf "\tgrub: " >&2
which grub-probe >/dev/null 2>/dev/null
(( deps_available |= $? ))
which grub-mkimage >/dev/null 2>/dev/null
(( deps_available |= $? ))
test $deps_available == "0" && echo "✅ " >&2 || echo "❌ " >&2
printf "\tenvsubst: " >&2
which envsubst >/dev/null 2>/dev/null
dep_envsubst=$?
(( deps_available |= $dep_envsubst ))
test $dep_envsubst == "0" && echo "✅ " >&2 || echo "❌ (check that you have installed the gettext package)" >&2
printf "\tqemu-system-x86_64: " >&2
which qemu-system-x86_64 >/dev/null 2>/dev/null
dep_qemu=$?
(( deps_available |= $dep_qemu ))
test $dep_qemu == "0" && echo "✅ " >&2 || echo "❌ (check that you have the package qemu-system-x86 installed)" >&2
printf "\tedk2-ovmf: " >&2
test -f /usr/share/ovmf/x64/OVMF.fd
dep_ovmf=$?
(( deps_available |= $dep_ovmf ))
test $dep_ovmf == "0" && echo "✅ " >&2 || echo "❌ " >&2
echo >&2 "Note: qemu-desktop is recommended to get proper visual output when running ./test"
echo >&2
if ! [ $deps_available == "0" ]; then
echo >&2 "Not all required dependencies installed! Aborting..."
exit "1"
fi
echo >&2 'Now retrieving environment. Use `./configure > .env` and `source .env`, if you are sure the output is fine.'
echo >&2
#if [ -f ".env" ]; then
# read -n 1 -p "Existing .env configuration found. Use it as a baseline? [Y/n] " >&2 source_env
# case "$source_env" in
# n|N) ;;
# *) source ".env" ;;
# esac
#fi
#echo >&2
echo "#!/usr/bin/env bash"
echo "# configured values to be substituted in the grub.cfg template"
echo
export ENV_GRUB_LOG_LEVEL=0
echo "export ENV_GRUB_LOG_LEVEL=$ENV_GRUB_LOG_LEVEL"
echo >&2 "Setting log level to $ENV_GRUB_LOG_LEVEL. Set to 0 to turn off or 3 or higher for full debug logs."
# set the timeout to wait after failed cryptomount
export ENV_GRUB_RETRY_TIMEOUT=3
echo "export ENV_GRUB_RETRY_TIMEOUT=$ENV_GRUB_RETRY_TIMEOUT"
disk=$(df --output=source /boot | sed -n "2p")
echo "Assuming $disk to be the luks encrypted disk containing /boot" >&2
export ENV_GRUB_CRYPTODISK_UUID=$(sudo grub-probe -t cryptodisk_uuid -d "$disk")
echo "export ENV_GRUB_CRYPTODISK_UUID=$ENV_GRUB_CRYPTODISK_UUID"
export ENV_GRUB_FS_UUID=$(sudo grub-probe -t fs_uuid -d "$disk")
echo "export ENV_GRUB_FS_UUID=$ENV_GRUB_FS_UUID"
export ENV_GRUB_HINT=$(sudo grub-probe -t efi_hints -d "$disk")
echo "export ENV_GRUB_HINT=$ENV_GRUB_HINT"
export ENV_GRUB_CHAINLOAD_PREFIX="/boot/grub"
sudo test -d "$ENV_GRUB_CHAINLOAD_PREFIX" || echo "❌ ERROR - $ENV_GRUB_CHAINLOAD_PREFIX does not exist. Please check and possibly set manually" >&2
echo "export ENV_GRUB_CHAINLOAD_PREFIX=$ENV_GRUB_CHAINLOAD_PREFIX"
export ENV_GRUB_CHAINLOAD_EFI="/x86_64-efi/grub.efi"
sudo test -f "$ENV_GRUB_CHAINLOAD_PREFIX$ENV_GRUB_CHAINLOAD_EFI" || echo >&2 "❌ ERROR - $ENV_GRUB_CHAINLOAD_PREFIX$ENV_GRUB_CHAINLOAD_EFI does not exist. Was grub-install ever run? Please set manually"
echo "export ENV_GRUB_CHAINLOAD_EFI=$ENV_GRUB_CHAINLOAD_EFI"
export ENV_GRUB_MODULES_BASE='search search_fs_uuid chain'
echo "export ENV_GRUB_MODULES_BASE='$ENV_GRUB_MODULES_BASE'"
# todo test actual needed filesystems
export ENV_GRUB_MODULES_FS='lvm ext2'
echo "export ENV_GRUB_MODULES_FS='$ENV_GRUB_MODULES_FS'"
# luks or luks2
export ENV_GRUB_MODULES_LUKS="luks"
echo "export ENV_GRUB_MODULES_LUKS=$ENV_GRUB_MODULES_LUKS"
export ENV_GRUB_MODULES_CRYPTO='cryptodisk gcry_sha256 gcry_sha512 gcry_rijndael'
echo "export ENV_GRUB_MODULES_CRYPTO='$ENV_GRUB_MODULES_CRYPTO'"