2020-07-09 19:02:32 +08:00
|
|
|
|
#!/bin/bash
|
2020-08-12 10:06:19 +08:00
|
|
|
|
#* Copyright (c) 2020 Intel Corporation SPDX-License-Identifier: BSD-3-Clause
|
2020-07-09 19:02:32 +08:00
|
|
|
|
# postinst script for acrn-hypervisor
|
2020-08-12 10:06:19 +08:00
|
|
|
|
# please NOTE !!! scenario_info/board_info changed by python scripts, so do not add content there!!!
|
|
|
|
|
# please NOTE !!! scenario_info/board_info please add in release.json if needed !!!
|
2020-07-09 19:02:32 +08:00
|
|
|
|
set -e
|
|
|
|
|
|
2021-09-26 22:42:40 +08:00
|
|
|
|
#Build info Start
|
2020-07-09 19:02:32 +08:00
|
|
|
|
|
2021-09-26 22:42:40 +08:00
|
|
|
|
SCENARIO=(shared)
|
2020-07-09 19:02:32 +08:00
|
|
|
|
|
2021-09-26 22:42:40 +08:00
|
|
|
|
BOARD=(nuc11tnbi5)
|
2020-07-09 19:02:32 +08:00
|
|
|
|
|
2021-09-26 22:42:40 +08:00
|
|
|
|
#Build info End
|
2020-07-09 19:02:32 +08:00
|
|
|
|
|
2021-09-26 22:42:40 +08:00
|
|
|
|
ACRNBIN="/boot/acrn.${SCENARIO}.${BOARD}.bin"
|
|
|
|
|
type=$(lsblk -l |awk '$NF == "/" {print $1}')
|
2020-08-12 10:06:19 +08:00
|
|
|
|
|
2021-09-26 22:42:40 +08:00
|
|
|
|
pattern='^/dev/.* UUID="([^"]+)".* PARTUUID="([^"]+)"'
|
|
|
|
|
while IFS= read -r line; do
|
|
|
|
|
if [[ $line =~ $pattern ]]; then
|
|
|
|
|
uuid="${BASH_REMATCH[1]}"
|
|
|
|
|
partuuid="${BASH_REMATCH[2]}"
|
2020-08-12 10:06:19 +08:00
|
|
|
|
fi
|
2021-09-26 22:42:40 +08:00
|
|
|
|
done < <(blkid |grep ext4 |grep ${type})
|
2020-08-12 10:06:19 +08:00
|
|
|
|
|
2021-09-26 22:42:40 +08:00
|
|
|
|
filename="/etc/grub.d/40_custom"
|
2020-08-12 10:06:19 +08:00
|
|
|
|
|
2021-09-26 22:42:40 +08:00
|
|
|
|
kernelimg=$(grep module ${filename} | tail -1 || true)
|
2020-08-12 10:06:19 +08:00
|
|
|
|
|
2021-09-26 22:42:40 +08:00
|
|
|
|
if [ $SCENARIO == shared ];then
|
|
|
|
|
cat>"${filename}"<<EOF
|
|
|
|
|
#!/bin/sh
|
|
|
|
|
exec tail -n +3 \$0
|
|
|
|
|
menuentry 'ACRN multiboot2 ' --id ACRN_deb_multiboot2 {
|
|
|
|
|
load_video
|
|
|
|
|
insmod gzio
|
|
|
|
|
insmod part_gpt
|
|
|
|
|
insmod ext2
|
|
|
|
|
search --no-floppy --fs-uuid --set $uuid
|
|
|
|
|
multiboot2 $ACRNBIN root=PARTUUID=$partuuid
|
|
|
|
|
$kernelimg
|
2020-08-12 10:06:19 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-26 22:42:40 +08:00
|
|
|
|
EOF
|
|
|
|
|
elif [ $SCENARIO == hybrid ];then
|
2021-12-22 10:07:18 +08:00
|
|
|
|
echo -e "\E[32m Please put zephyr64.elf in the /boot/ directory"
|
|
|
|
|
tput sgr0
|
2021-09-26 22:42:40 +08:00
|
|
|
|
cat>"${filename}"<<EOF
|
|
|
|
|
#!/bin/sh
|
|
|
|
|
exec tail -n +3 \$0
|
|
|
|
|
menuentry 'ACRN multiboot2 ' --id ACRN_deb_multiboot2 {
|
|
|
|
|
load_video
|
|
|
|
|
insmod gzio
|
|
|
|
|
insmod part_gpt
|
|
|
|
|
insmod ext2
|
|
|
|
|
search --no-floppy --fs-uuid --set $uuid
|
|
|
|
|
multiboot2 $ACRNBIN root=PARTUUID=$partuuid
|
|
|
|
|
$kernelimg
|
|
|
|
|
module2 /boot/zephyr64.elf Zephyr_ElfImage
|
|
|
|
|
module2 /boot/ACPI_VM0.bin ACPI_VM0
|
2020-08-12 10:06:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-22 10:07:18 +08:00
|
|
|
|
EOF
|
|
|
|
|
elif [ $SCENARIO == hybrid_rt ];then
|
|
|
|
|
echo -e "\E[32m Please put bzImage_RT in the /boot/ directory"
|
|
|
|
|
tput sgr0
|
|
|
|
|
cat>"${filename}"<<EOF
|
|
|
|
|
#!/bin/sh
|
|
|
|
|
exec tail -n +3 \$0
|
|
|
|
|
menuentry 'ACRN multiboot2 ' --id ACRN_deb_multiboot2 {
|
|
|
|
|
load_video
|
|
|
|
|
insmod gzio
|
|
|
|
|
insmod part_gpt
|
|
|
|
|
insmod ext2
|
|
|
|
|
search --no-floppy --fs-uuid --set $uuid
|
|
|
|
|
multiboot2 $ACRNBIN root=PARTUUID=$partuuid
|
|
|
|
|
$kernelimg
|
|
|
|
|
module2 /boot/bzImage_RT RT_bzImage
|
|
|
|
|
module2 /boot/ACPI_VM0.bin ACPI_VM0
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-26 22:42:40 +08:00
|
|
|
|
EOF
|
|
|
|
|
elif [ $SCENARIO == partitioned ];then
|
|
|
|
|
cat>"${filename}"<<EOF
|
2020-07-09 19:02:32 +08:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
exec tail -n +3 \$0
|
|
|
|
|
menuentry 'ACRN multiboot2 ' --id ACRN_deb_multiboot2 {
|
|
|
|
|
load_video
|
|
|
|
|
insmod gzio
|
|
|
|
|
insmod part_gpt
|
|
|
|
|
insmod ext2
|
|
|
|
|
search --no-floppy --fs-uuid --set $uuid
|
2021-09-26 22:42:40 +08:00
|
|
|
|
echo 'loading ACRN...'
|
|
|
|
|
multiboot2 $ACRNBIN root=PARTUUID=$partuuid
|
2020-07-09 19:02:32 +08:00
|
|
|
|
$kernelimg
|
2021-09-26 22:42:40 +08:00
|
|
|
|
module2 /boot/ACPI_VM0.bin ACPI_VM0
|
|
|
|
|
module2 /boot/ACPI_VM1.bin ACPI_VM1
|
2020-07-09 19:02:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EOF
|
2021-09-26 22:42:40 +08:00
|
|
|
|
fi
|
2020-07-09 19:02:32 +08:00
|
|
|
|
|
|
|
|
|
filename='/etc/default/grub'
|
2021-09-26 22:42:40 +08:00
|
|
|
|
sed -i '/GRUB_DEFAULT=/d' ${filename}
|
|
|
|
|
sed -i '/GRUB_TIMEOUT=/d' ${filename}
|
|
|
|
|
sed -i '/GRUB_HIDDEN_TIMEOUT=/d' ${filename}
|
|
|
|
|
sed -i '/GRUB_CMDLINE_LINUX_DEFAULT=/d' ${filename}
|
|
|
|
|
sed -i '/GRUB_CMDLINE_LINUX=/d' ${filename}
|
|
|
|
|
sed -i '/GRUB_TERMINAL=/d' ${filename}
|
|
|
|
|
sed -i '/GRUB_SERIAL_COMMAND=/d' ${filename}
|
|
|
|
|
sed -i '$a GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"' ${filename}
|
|
|
|
|
sed -i '$a GRUB_TERMINAL="console serial"' ${filename}
|
|
|
|
|
sed -i '$a GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"' ${filename}
|
|
|
|
|
sed -i '$a GRUB_CMDLINE_LINUX="console=tty0 console=ttyS0,115200n8"' ${filename}
|
2020-07-09 19:02:32 +08:00
|
|
|
|
sed -i '$a GRUB_DEFAULT=ACRN_deb_multiboot2' ${filename}
|
|
|
|
|
sed -i '$a GRUB_TIMEOUT=20' ${filename}
|
|
|
|
|
|
|
|
|
|
sync
|
|
|
|
|
update-grub
|
|
|
|
|
|
|
|
|
|
exit 0
|