Skip to content

Commit

Permalink
rewrite the common.sh helper script
Browse files Browse the repository at this point in the history
In the past, the script seemed to be here to help to prepare environment in containers.
However, as the complexity of this template increases, I decided to rewrite the script to prepare uniform environment in any case.
  • Loading branch information
vojtapolasek committed Sep 20, 2024
1 parent 1d6427f commit 09b5b00
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions shared/templates/grub2_bootloader_argument/tests/common.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#!/bin/bash

# We need to mock these files if they do not exist yet
# Because:
# - it is not possible to setup kernel / grub env properly in containerized env
# - even if it would be possible, it takes long time

# this file prepares unified test environment used by other scenarios
# These should be tuned per product to match defaults

{{% if product in ["ol8", "rhel8"] -%}}
mkdir -p /boot/grub2
if [ ! -f /boot/grub2/grubenv ]; then
rm -f /boot/grub2/grubenv
# File size must be exactly 1KiB
{
echo '# GRUB Environment Block'
Expand All @@ -18,10 +15,11 @@ if [ ! -f /boot/grub2/grubenv ]; then
dd if=/dev/zero bs=1K count=1 | tr '\0' '#'
} > /boot/grub2/grubenv
truncate --size=1K /boot/grub2/grubenv
fi
{{% endif %}}


mkdir -p /etc/default
if [ ! -f /etc/default/grub ]; then
rm -f /etc/default/grub
{
echo 'GRUB_CMDLINE_LINUX="rhgb ro ouiet"'
echo 'GRUB_CMDLINE_LINUX_DEFAULT="rhgb ro quiet mock"'
Expand All @@ -31,12 +29,11 @@ if [ ! -f /etc/default/grub ]; then
echo 'GRUB_ENABLE_BLSCFG=true'
echo 'GRUB_TIMEOUT=30'
} > /etc/default/grub
fi

{{% if product in ["fedora", "ol8", "ol9", "rhel8", "rhel9", "rhel10"] -%}}
mkdir -p /boot/loader/entries
shopt -s nullglob
boot_loader_entries=(/boot/loader/entries/*.conf)
if [ "${#boot_loader_entries[@]}" -eq 0 ]; then
rm -f /boot/loader/entries/*.conf
{
echo 'title OS 1'
echo 'version 5.0'
Expand All @@ -46,4 +43,4 @@ if [ "${#boot_loader_entries[@]}" -eq 0 ]; then
echo 'grub_users $grub_users'
echo 'grub_arg --unrestricted'
} > /boot/loader/entries/mock.conf
fi
{{%- endif -%}}

0 comments on commit 09b5b00

Please sign in to comment.