-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·44 lines (34 loc) · 988 Bytes
/
install.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
#!/bin/bash
usage() {
cat << HELP_USAGE
usage: install.sh <ESP>
ESP : The mount point of the EFI System Partition
Licensed under GPLv3
Copyright (C) 2024 Johann Scott
HELP_USAGE
exit 0
}
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root." 1>&2
exit 1
fi
if [ "$1" = "" ]; then
usage
exit 1
fi
PROJ_DIR=$(realpath $(dirname $0))
cd $PROJ_DIR
cargo build --profile release --out-dir ./out -Z unstable-options
BUILD_ERR_CODE=$?
if [ $BUILD_ERR_CODE -ne 0 ]; then
exit $BUILD_ERR_CODE
fi
echo "Built Wakatiwai bootloader"
ESP_MNT=$1
ESP_DISK_PART=$(findmnt $ESP_MNT -no SOURCE | grep -oE '[0-9]+$')
ESP_DISK_DEV=$(findmnt $ESP_MNT -no SOURCE | sed "s/p$ESP_DISK_PART$//")
sudo mkdir -p "$ESP_MNT/EFI/wakatiwai"
sudo cp ./out/wakatiwai.efi "$ESP_MNT/EFI/wakatiwai/wakatiwai.efi"
echo "Copied bootloader program"
efibootmgr -c -L "Wakatiwai" -l "\EFI\wakatiwai\wakatiwai.efi" -d $ESP_DISK_DEV -p $ESP_DISK_PART
echo "Successfully added boot entry"