2020-07-09 19:02:32 +08:00
|
|
|
|
#!/bin/bash
|
2022-07-13 09:21:24 +08:00
|
|
|
|
#* Copyright (c) 2020-2022 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
|
|
|
|
|
2022-09-02 14:55:26 +08:00
|
|
|
|
|
|
|
|
|
#ACRN parameters Start
|
|
|
|
|
|
|
|
|
|
GENERATED_PARAMS=(cpu_perf_policy=Performance)
|
|
|
|
|
|
|
|
|
|
#ACRN parameters End
|
|
|
|
|
|
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
|
|
|
|
|
2022-05-02 09:29:41 +08:00
|
|
|
|
if ls /boot/vmlinuz*acrn-service-vm* 1> /dev/null 2>&1;then
|
|
|
|
|
service_vm_kernel=$(ls -tr /boot/vmlinuz-*acrn-service-vm* | tail -1)
|
|
|
|
|
else
|
|
|
|
|
service_vm_kernel=$(ls /boot/vmlinuz-* | tail -1)
|
|
|
|
|
fi
|
|
|
|
|
kernelimg="module2 $service_vm_kernel Linux_bzImage"
|
2020-08-12 10:06:19 +08:00
|
|
|
|
|
2022-06-17 13:40:58 +08:00
|
|
|
|
if [ $SCENARIO == hybrid ];then
|
|
|
|
|
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
|
2022-09-02 14:55:26 +08:00
|
|
|
|
multiboot2 $ACRNBIN root=PARTUUID=$partuuid $GENERATED_PARAMS
|
2021-09-26 22:42:40 +08:00
|
|
|
|
$kernelimg
|
2022-06-17 13:40:58 +08:00
|
|
|
|
module2 /boot/zephyr64.elf Zephyr_ElfImage
|
|
|
|
|
module2 /boot/ACPI_VM0.bin ACPI_VM0
|
2020-08-12 10:06:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-26 22:42:40 +08:00
|
|
|
|
EOF
|
2022-06-17 13:40:58 +08:00
|
|
|
|
elif [ $SCENARIO == hybrid_rt ];then
|
|
|
|
|
echo -e "\E[32m Please put bzImage_RT in the /boot/ directory"
|
2021-12-22 10:07:18 +08:00
|
|
|
|
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
|
2022-09-02 14:55:26 +08:00
|
|
|
|
multiboot2 $ACRNBIN root=PARTUUID=$partuuid $GENERATED_PARAMS
|
2021-09-26 22:42:40 +08:00
|
|
|
|
$kernelimg
|
2022-06-17 13:40:58 +08:00
|
|
|
|
module2 /boot/bzImage_RT RT_bzImage
|
2021-09-26 22:42:40 +08:00
|
|
|
|
module2 /boot/ACPI_VM0.bin ACPI_VM0
|
2020-08-12 10:06:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-22 10:07:18 +08:00
|
|
|
|
EOF
|
2022-06-17 13:40:58 +08:00
|
|
|
|
elif [ $SCENARIO == partitioned ];then
|
2021-12-22 10:07:18 +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
|
2022-06-17 13:40:58 +08:00
|
|
|
|
echo 'loading ACRN...'
|
2022-09-02 14:55:26 +08:00
|
|
|
|
multiboot2 $ACRNBIN root=PARTUUID=$partuuid $GENERATED_PARAMS
|
2021-12-22 10:07:18 +08:00
|
|
|
|
$kernelimg
|
|
|
|
|
module2 /boot/ACPI_VM0.bin ACPI_VM0
|
2022-06-17 13:40:58 +08:00
|
|
|
|
module2 /boot/ACPI_VM1.bin ACPI_VM1
|
2021-12-22 10:07:18 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-09-26 22:42:40 +08:00
|
|
|
|
EOF
|
2022-06-17 13:40:58 +08:00
|
|
|
|
else
|
2021-09-26 22:42:40 +08:00
|
|
|
|
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
|
2022-09-02 14:55:26 +08:00
|
|
|
|
multiboot2 $ACRNBIN root=PARTUUID=$partuuid $GENERATED_PARAMS
|
2020-07-09 19:02:32 +08:00
|
|
|
|
$kernelimg
|
2022-06-17 13:40:58 +08:00
|
|
|
|
|
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
|