initial commit of file from CVS for e-smith-grub on Wed 12 Jul 08:55:23 BST 2023

This commit is contained in:
Brian Read
2023-07-12 08:55:23 +01:00
parent 02dc245d5a
commit 6f93c1b6c7
100 changed files with 1607 additions and 2 deletions

View File

@@ -0,0 +1,26 @@
#!/usr/bin/perl
use strict;
use warnings;
use esmith::ConfigDB;
my $c = esmith::ConfigDB->open_ro or die "Could not open Config DB";
my $sysconfig = $c->get('sysconfig') or die "Missing db entry sysconfig";
my $locale = $sysconfig->prop('Language') || "en_US.UTF-8";
my $orilang=$ENV{LANG};
# here we force the environement as it is empty if launched by server-manager
if ( ! defined $ENV{LANG}|| $ENV{LANG}eq "" || $ENV{LANG} eq "C") {
$ENV{LANG}=$locale;
}
my $grubpath;
if (-e "/sys/firmware/efi") {
$grubpath = "/boot/efi/EFI/centos/grub.cfg";
} else {
$grubpath = "/boot/grub2/grub.cfg";
}
system("/usr/sbin/grub2-mkconfig", "-o", $grubpath) == 0
or die("Unable to update grub2\n");
$ENV{LANG}=$orilang;

View File

@@ -0,0 +1 @@
FILTER=sub { $_[0] =~ /^\s*$/ ? '' : $_[0] }

View File

@@ -0,0 +1 @@
FILTER=sub { $_[0] =~ /^\s*$/ ? '' : $_[0] }

View File

@@ -0,0 +1,4 @@
{
@lines = map { s/GRUB_TERMINAL_OUTPUT="console"/GRUB_TERMINAL_OUTPUT="gfxterm"/; $_ } @lines;
$OUT = "";
}

View File

@@ -0,0 +1,4 @@
{
@lines = map { s/GRUB_DISABLE_RECOVERY="true"/GRUB_DISABLE_RECOVERY="false"/; $_ } @lines;
$OUT = "";
}

View File

@@ -0,0 +1,35 @@
{
# parse fstab to know what fstype is root partition
my $fstype = "ext4";
my @patterns = ( qr/\s\/\s+xfs\s+/, qr/^\/dev\/main\/.*\s+xfs\s+/ );
open (RD, "</etc/fstab")
|| warn "Cannot open input file /etc/fstab: $!\n";
while (<RD>)
{
chop;
$fstype="xfs" if ( $_ ~~ @patterns );
}
close(RD);
if ( $fstype eq "xfs" ) {
# GRUB_CMDLINE_LINUX="rd.lvm.lv=main/root rd.lvm.lv=main/swap rhgb quiet"
# to GRUB_CMDLINE_LINUX="rd.lvm.lv=main/root rd.lvm.lv=main/swap rhgb quiet rootflags=uquota,pquota"
# also remove noquota
@lines = map {
/^GRUB_CMDLINE_LINUX/ && s/noquota//;
/^GRUB_CMDLINE_LINUX/ && ! /rootflags=uquota,pquota/ && s/"$/ rootflags=uquota,pquota"/;
$_
} @lines;
} else {
# if we are using ext[234] or any other fs type let's default to ...
@lines = map {
/^GRUB_CMDLINE_LINUX/ && s/noquota//;
/^GRUB_CMDLINE_LINUX/ && /rootflags=uquota,pquota/ && s/rootflags=uquota,pquota//;
$_
} @lines;
}
"";
}

View File

@@ -0,0 +1,26 @@
{
# grub splash image for koozali, alternative to theme
# ignored if a theme is defined
#GRUB_BACKGROUND="/boot/grub2/smeserver10.png"
my $GrubBackground= $Sysconfig{'GrubBackground'} || '/boot/grub2/smeserver10.png';
# remove if disabled, : you do not want any background
if ($GrubBackground eq 'disabled') {
@lines = map {
s/^GRUB_BACKGROUND.*//;
$_
} @lines;
}
else {
# change if line already there
@lines = map {
/^GRUB_BACKGROUND/ && ! /="$GrubBackground"/ && s/=".*"/="$GrubBackground"/;
$_
} @lines;
# add if line missing
push @lines, 'GRUB_BACKGROUND="$GrubBackground"' unless ( grep /GRUB_BACKGROUND/, @lines );
}
$OUT = "";
}

View File

@@ -0,0 +1,31 @@
{
# grub theme for koozali:
#GRUB_THEME="/boot/grub2/themes/koozali/theme.txt"
#GRUB_GFXMODE="1024x768"
my $GrubTheme = $Sysconfig{'GrubTheme'} || 'koozali';
my $GrubGFXMODE = $Sysconfig{'GrubGFXMODE'} || '1024x768';
# remove if disabled
if ($GrubTheme eq 'disabled') {
@lines = map {
s/^GRUB_GFXMODE.*//;
s/^GRUB_THEME.*//;
$_
} @lines;
}
else {
# change if line already there
@lines = map {
/^GRUB_GFXMODE/ && ! /="$GrubGFXMODE"/ && s/=".*"/="$GrubGFXMODE"/;
/^GRUB_THEME/ && ! /="\/boot\/grub2\/themes\/$GrubTheme\/theme.txt"/ && s/=".*"/="\/boot\/grub2\/themes\/$GrubTheme\/theme.txt"/;
$_
} @lines;
# add if line missing
push @lines, 'GRUB_GFXMODE="'.$GrubGFXMODE.'"' unless ( grep /GRUB_GFXMODE/, @lines );
push @lines, 'GRUB_THEME="/boot/grub2/themes/'.$GrubTheme.'/theme.txt"' unless ( grep /GRUB_THEME/, @lines );
}
"";
}

View File

@@ -0,0 +1,8 @@
{
if (open(GRUB, "/etc/default/grub"))
{
@lines = <GRUB>;
}
close GRUB;
$OUT = "";
}

View File

@@ -0,0 +1,6 @@
{
foreach (@lines)
{
$OUT .= "$_\n";
}
}

View File

@@ -0,0 +1,19 @@
{
return "" unless (defined $EVENT and $EVENT eq "local");
open (VERSION, "/proc/version") or die "Couldn't read /proc/version";
my $version = <VERSION>;
chomp $version;
$version =~ s/^Linux version ([^\s]+) .*/$1/;
close VERSION;
open (KERNEL, "rpm -qf --qf '%{NAME}' /boot/vmlinuz-$version|");
my $default = <KERNEL>;
chomp $default;
close KERNEL;
return "" unless $default;
@lines = map { s/DEFAULTKERNEL=.*/DEFAULTKERNEL=$default/; $_ } @lines;
$OUT = "";
}

View File

@@ -0,0 +1,8 @@
{
if (open(KERNEL, "/etc/sysconfig/kernel"))
{
@lines = <KERNEL>;
}
close KERNEL;
$OUT = "";
}

View File

@@ -0,0 +1,6 @@
{
foreach (@lines)
{
$OUT .= "$_\n";
}
}