Skip to content

Commit

Permalink
Add ns 127.0.0.1 to resolv.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
swelljoe committed Jul 21, 2017
1 parent 0a7d372 commit 2b92cab
Showing 1 changed file with 45 additions and 38 deletions.
83 changes: 45 additions & 38 deletions lib/Virtualmin/Config/Plugin/Extra.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,56 +8,63 @@ use parent 'Virtualmin::Config::Plugin';
use Time::HiRes qw(sleep);

our $config_directory;
our (%gconfig, %miniserv);
our ( %gconfig, %miniserv );
our $trust_unknown_referers = 1;

sub new {
my $class = shift;
my $class = shift;

# inherit from Plugin
my $self = $class->SUPER::new(
name => 'Extra',
depends => [ 'Apache',
'Webmin', 'Virtualmin' ]
);
# inherit from Plugin
my $self = $class->SUPER::new(
name => 'Extra',
depends => [ 'Apache', 'Webmin', 'Virtualmin' ]
);

return $self;
return $self;
}

# actions method performs whatever configuration is needed for this
# plugin. XXX Needs to make a backup so changes can be reverted.
sub actions {
my $self = shift;

use Cwd;
my $cwd = getcwd();
my $root = $self->root();
chdir($root);
$0 = "$root/virtual-server/config-system.pl";
push(@INC, $root);
eval 'use WebminCore'; ## no critic
init_config();

$self->spin();
sleep 0.2;
eval {
# Attempt to sync clock
if (has_command("ntpdate-debian")) {
system("ntpdate-debian >/dev/null 2>&1 </dev/null &");
}
my $self = shift;

# Turn on caching for downloads by Virtualmin
if (!$gconfig{'cache_size'}) {
$gconfig{'cache_size'} = 50 * 1024 * 1024;
$gconfig{'cache_mods'} = "virtual-server";
write_file("$config_directory/config", \%gconfig);
}
use Cwd;
my $cwd = getcwd();
my $root = $self->root();
chdir($root);
$0 = "$root/virtual-server/config-system.pl";
push( @INC, $root );
eval 'use WebminCore'; ## no critic
init_config();

$self->spin();
sleep 0.2;
eval {
# Attempt to sync clock
if ( has_command("ntpdate-debian") ) {
system("ntpdate-debian >/dev/null 2>&1 </dev/null &");
}

# Turn on caching for downloads by Virtualmin
if ( !$gconfig{'cache_size'} ) {
$gconfig{'cache_size'} = 50 * 1024 * 1024;
$gconfig{'cache_mods'} = "virtual-server";
write_file( "$config_directory/config", \%gconfig );
}

$self->done(1); # OK!
};
if ($@) {
$self->done(0);
}
# Setup localhost to act as resolver

open( my $resolv, '+>>', '/etc/resolv.conf' );
if ( !grep { /nameserver 127.0.0.1/ } <$resolv> ) {
print $resolv 'nameserver 127.0.0.1';
}
close $resolv;

$self->done(1); # OK!
};
if ($@) {
$self->done(0);
}
}

1;

0 comments on commit 2b92cab

Please sign in to comment.