Compare commits

..

3 Commits

Author SHA1 Message Date
Ilia Ross
05752faec0 Fix to separate drive and CPU temperatures collection #2208 2024-06-30 15:54:47 +03:00
Jamie Cameron
1cf3813fb6 Merge branch 'master' of github.com:webmin/webmin 2024-06-27 19:45:29 -07:00
Jamie Cameron
1216ae709b Stop showing and editing dnssec-lookaside https://github.com/webmin/webmin/issues/617 2024-06-27 19:45:21 -07:00
7 changed files with 7 additions and 222 deletions

153
bin/patch
View File

@@ -1,153 +0,0 @@
#!/usr/bin/env perl
# patch - Apply a patch to Webmin core or its modules from GitHub or a local file
use strict;
use warnings;
use 5.010;
use Getopt::Long qw(:config permute pass_through);
use Pod::Usage;
use File::Basename;
use Cwd qw(cwd);
my %opt;
GetOptions(
'help|h' => \$opt{'help'},
'config|c=s' => \$opt{'config'},
);
pod2usage(0) if ($opt{'help'});
# Get Webmin path
my $path = cwd;
my $lib = "web-lib-funcs.pl";
if (!-r "$path/$lib") {
$path = dirname(dirname($0));
if (!-r "$path/$lib") {
$path = $path = Cwd::realpath('..');
}
}
# Init core
my $config_dir = $opt{'config'} || '/etc/webmin';
$ENV{'WEBMIN_CONFIG'} = $config_dir;
push(@INC, $path);
eval 'use WebminCore';
init_config();
# Check if curl is installed
if (!has_command('curl')) {
print "curl is not installed\n";
exit 1;
}
# Check if git is installed
if (!has_command('git')) {
print "git is not installed\n";
exit 1;
}
# Get patch URL or file
my $patch = $ARGV[0];
# Params check
if (!$patch) {
pod2usage(0);
exit 1;
}
# Patch check
if ($patch !~ /^https?:\/\//) {
if (!-r $patch) {
print "Patch file $patch doesn't exist\n";
exit 1;
}
}
elsif ($patch =~ /^https?:\/\/(github|gitlab)\.com/ &&
$patch !~ /\.patch$/ && $patch !~ /\.diff$/) {
$patch .= '.patch';
}
# Parse module name from URL
my $module = "";
if ($patch =~ m{https://(github|gitlab)\.com/[^/]+/([^/]+)/commit/[^/]+}) {
$module = $2;
$module = "" if ($2 eq 'webmin');
# Special handling for some modules
$module = $module =~ /^virtualmin-pro$/ ?
'virtual-server/pro' :
'virtual-server'
if $module =~ /^virtualmin-(gpl|pro)$/;
}
# Check if module exists
if (!-d "$path/$module") {
print "Module $module doesn't exist\n";
exit 1;
}
# Download command or cat patch file
my $cmd;
if ($patch =~ /^https?:\/\//) {
$cmd = "curl -s @{[quotemeta($patch)]}";
chdir "$path/$module";
}
else {
$cmd = "cat @{[quotemeta($patch)]}";
}
# Apply patch using Git
my $output = `$cmd 2>&1 | git apply --reject --verbose --whitespace=fix 2>&1`;
if ($output !~ /applied patch.*?cleanly/i) {
print "Patch failed: $output\n";
exit 1;
}
print "Patch applied successfully to:\n";
print " $1\n" while $output =~ /^Applied patch\s+(\S+)/mg;
system("$config_dir/restart");
=pod
=head1 NAME
patch
=head1 DESCRIPTION
Apply a patch to Webmin core or its modules from GitHub or a local file.
=head1 SYNOPSIS
webmin patch patch-url/file
=head1 OPTIONS
=over
=item --help, -h
Give this help list.
=item --config, -c
Specify the full path to the Webmin configuration directory. Defaults to
C</etc/webmin>
Examples of usage:
Apply a patch from a URL.
- webmin patch https://github.com/webmin/webmin/commit/e6a2bb15b0.patch
- webmin patch https://github.com/virtualmin/virtualmin-gpl/commit/f4433153d
Apply a patch from local file.
- cd /usr/libexec/webmin/virtual-server/pro &&
webmin patch /root/virtualmin-pro/patches/patch-1.patch
=back
=head1 LICENSE AND COPYRIGHT
Copyright 2024 Ilia Ross <ilia@virtualmin.com>

View File

@@ -17,7 +17,6 @@ $access{'defaults'} || &error($text{'trusted_ecannot'});
my $conf = &get_config();
my $options = &find("options", $conf);
my $mems = $options->{'members'};
my @dlv = &find("dnssec-lookaside", $mems);
my $tkeys = &find("trusted-keys", $conf);
$tkeys ||= { 'members' => [ ] };
@@ -38,33 +37,6 @@ if (&supports_dnssec_client() == 2) {
$text{'default'}, undef);
}
# Trusted DLVs (obsolete)
if (@dlv) {
my @dtable = ( );
my $i = 0;
foreach my $d (@dlv, { 'values' => [ '.' ] }) {
my $dlv = $d->{'values'}->[0];
$dlv = "" if ($dlv eq ".");
push(@dtable, [
&ui_opt_textbox("anchor_$i", $d->{'values'}->[2],
30, $text{'trusted_none'}),
&ui_opt_textbox("dlv_$i", $dlv, 20,
$text{'trusted_root'}) ]);
$i++;
}
print &ui_table_row($text{'trusted_dlvs'},
&ui_radio("dlv_auto",
@dlv == 0 ? 2 :
@dlv == 1 && $dlv[0]->{'values'}->[0] eq 'auto' ? 1 : 0,
[ [ 1, $text{'trusted_dlvs1'} ],
[ 2, $text{'trusted_dlvs2'} ],
[ 0, $text{'trusted_dlvs0'} ] ])."<br>\n".
&ui_columns_table([ $text{'trusted_anchor'},
$text{'trusted_dlv'} ],
undef,
\@dtable), 3);
}
# Trusted keys
if (@{$tkeys->{'members'}}) {
my @ktable = ( );

View File

@@ -24,46 +24,6 @@ if (&supports_dnssec_client() == 2) {
&save_choice("dnssec-validation", $options, 1);
}
# Save DLV zones
if (defined($in{'dlv_auto'})) {
my @dlvs = ( );
if ($in{'dlv_auto'} == 1) {
# Automatic mode
push(@dlvs, { 'name' => 'dnssec-lookaside',
'values' => [ 'auto' ] });
}
elsif ($in{'dlv_auto'} == 0) {
# Listed zones
my $dlv;
for(my $i=0; defined($in{"anchor_$i"}); $i++) {
if (!$in{"anchor_${i}_def"}) {
$in{"anchor_$i"} =~ /^[a-z0-9\.\-\_]+$/ ||
&error(&text('trusted_eanchor', $i+1));
$in{"anchor_$i"} .= "."
if ($in{"anchor_$i"} !~ /\.$/);
if ($in{"dlv_${i}_def"}) {
$dlv = ".";
}
else {
$in{"dlv_$i"} =~ /^[a-z0-9\.\-\_]+$/ ||
&error(&text('trusted_edlv', $i+1));
$dlv = $in{"dlv_$i"};
$dlv .= "." if ($dlv !~ /\.$/);
}
push(@dlvs, { 'name' => 'dnssec-lookaside',
'values' => [
$dlv, "trust-anchor",
$in{"anchor_$i"} ] });
}
}
}
elsif ($in{'dlv_auto'} == 2) {
# None
@dlvs = ( );
}
&save_directive($options, "dnssec-lookaside", \@dlvs, 1);
}
# Save trusted keys
if (defined($in{'zone_0'})) {
my @keys = ( );

View File

@@ -74,7 +74,7 @@ if (&foreign_installed("package-updates") && $config{'collect_pkgs'}) {
}
# CPU and drive temps
if (!$config{'collect_notemp'} && defined(&proc::get_current_cpu_data)) {
if (!$config{'collect_notemp2'} && defined(&proc::get_current_cpu_data)) {
my ($cpu, $fans) = &proc::get_current_cpu_data();
$info->{'cputemps'} = $cpu if (ref($cpu) && @{$cpu} >= 1);
$info->{'cpufans'} = $fans if (ref($fans) && @{$fans} >= 1);

View File

@@ -18,6 +18,7 @@ else {
# Save collection options
$system_status::config{'collect_pkgs'} = $in{'pkgs'};
$system_status::config{'collect_notemp2'} = !$in{'temp2'};
$system_status::config{'collect_notemp'} = !$in{'temp'};
$system_status::config{'collect_units'} = $in{'units'};

View File

@@ -19,6 +19,10 @@ print &ui_table_row($text{'status_interval'},
print &ui_table_row($text{'status_pkgs'},
&ui_yesno_radio("pkgs", $system_status::config{'collect_pkgs'}));
# Collect CPU temerature?
print &ui_table_row($text{'status_temp2'},
&ui_yesno_radio("temp2", !$system_status::config{'collect_notemp2'}));
# Collect drive temps?
print &ui_table_row($text{'status_temp'},
&ui_yesno_radio("temp", !$system_status::config{'collect_notemp'}));

View File

@@ -1061,6 +1061,7 @@ status_interval0=Every
status_mins=minutes
status_pkgs=Collect available package updates?
status_temp=Collect drive temperatures?
status_temp2=Collect CPU temperatures and fans speed?
status_units=Units for temperatures
status_celsius=Celsius
status_fahrenheit=Fahrenheit