mirror of
https://github.com/schoebel/mars
synced 2025-02-19 05:27:01 +00:00
marsadm: use first IP on eth0
This commit is contained in:
parent
004b3bbe6a
commit
42ec65952d
@ -10,9 +10,7 @@ my $mars = "/mars";
|
||||
my $host = `uname -n` or die "cannot determine my network node name\n";
|
||||
chomp $host;
|
||||
my $force = 0;
|
||||
my $ip = `ip a` or die "cannot determine my IP address\n";
|
||||
$ip =~ s/\A.*inet +(?!127\.0\.)([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*?\Z/$1/ms or die "cannot parse my IP address\n";
|
||||
chomp $ip;
|
||||
my $ip = _get_ip();
|
||||
print "my IP is $ip\n";
|
||||
|
||||
umask 0077;
|
||||
@ -321,6 +319,14 @@ sub _writable {
|
||||
chmod($newmode, $path) == 1 or die "cannot chmod '$path'\n";
|
||||
}
|
||||
|
||||
sub _get_ip {
|
||||
chomp (my @info = `/sbin/ip addr show dev eth0`);
|
||||
foreach (@info) {
|
||||
m#\sinet\s(\d+\.\d+\.\d+\.\d+)# && return $1;
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
##################################################################
|
||||
|
||||
# commands
|
||||
|
Loading…
Reference in New Issue
Block a user