Skip to content

Commit

Permalink
Fix to prevent adding multiple time, if already added (on re-running) v…
Browse files Browse the repository at this point in the history
  • Loading branch information
iliajie committed Jul 26, 2020
1 parent 0f84b34 commit e7d0f17
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions lib/Virtualmin/Config/Plugin/Quotas.pm
Original file line number Diff line number Diff line change
Expand Up @@ -100,32 +100,34 @@ sub actions {
print " " x ($xfs ? 26 : 34);
$res = 2;
if ($xfs) {

# Update the grub config file source
my $grubfile = "/etc/default/grub";
my %grub;
&read_env_file($grubfile, \%grub) ||
($res = 0);
&read_env_file($grubfile, \%grub) || ($res = 0);
my $v = $grub{'GRUB_CMDLINE_LINUX'};
if ($v =~ /rootflags=(\S+)/) {
$v =~ s/rootflags=(\S+)/rootflags=$1,uquota,gquota/;
}
else {
$v .= " rootflags=uquota,gquota";
}
$grub{'GRUB_CMDLINE_LINUX'} = $v;
&write_env_file($grubfile, \%grub);

# Generate a new actual config file
my $grub_file = "/boot/grub2/grub.cfg";
# On EFI it's different config file
if (-d "/sys/firmware/efi") {
my %osrelease;
&read_env_file('/etc/os-release', \%osrelease);
my $osid = $osrelease{'ID'} || 'centos';
$grub_file = "/boot/efi/EFI/$osid/grub.cfg";
if ($v !~ /rootflags=.*?([u|g]quota)/) {
if ($v =~ /rootflags=(\S+)/) {
$v =~ s/rootflags=(\S+)/rootflags=$1,uquota,gquota/;
} else {
$v .= " rootflags=uquota,gquota";
}
$grub{'GRUB_CMDLINE_LINUX'} = $v;
&write_env_file($grubfile, \%grub);

# Generate a new actual config file
my $grub_file = "/boot/grub2/grub.cfg";

# On EFI it's different config file
if (-d "/sys/firmware/efi") {
my %osrelease;
&read_env_file('/etc/os-release', \%osrelease);
my $osid = $osrelease{'ID'} || 'centos';
$grub_file = "/boot/efi/EFI/$osid/grub.cfg";
}
&copy_source_dest($grub_file, "$grub_file.orig");
$self->logsystem("grub2-mkconfig -o $grub_file");
}
&copy_source_dest($grub_file, "$grub_file.orig");
$self->logsystem("grub2-mkconfig -o $grub_file");
}
}
else {
Expand Down

0 comments on commit e7d0f17

Please sign in to comment.