Enhancement #1845

Updated by Giacomo Sanchietti over 7 years ago

Add all host record of type @local@ to /etc/hosts.

etc/e-smith/templates/etc/hosts/40hosts_local
<pre>
#
# 40hosts_local 30hosts_local
#
{
use esmith::HostsDB;
my $hdb = esmith::HostsDB->open_ro() || return '# hosts DB is not available';

$OUT = '';

foreach my $host ($hdb->get_all_by_prop('type', 'local'))
{
my $IpAddress = $host->prop('IpAddress') || '';

if ($IpAddress eq '') {
# skip all entries without an IP
next;
}

my $Description = $host->prop('Description') || "";
$OUT .= "# ${Description}\n" if($Description);
$OUT .= sprintf "%-18s %s\n", $IpAddress, $host->key;
}

$OUT;
}
</pre>

Back