#!/usr/bin/perl -w
#
# list content of a autofs-table in a RUBI compatible form
# used by rubi-glaernisch-astro
#
# 12.3.04 Beat Rubischon <rubischon@phys.ethz.ch>
#
use strict;

# -------------------------
# walk through autofs table
# -------------------------
my %fs;

open AUTOFS, "ypcat auto.astro|";

while (<AUTOFS>) {
    chomp;
    /^([^:]*):(.*)$/o;

    if (defined $fs{$1}) {
	$fs{$1}.=" ".$2;
    } else {
	$fs{$1}=$2;
    }
}

close AUTOFS;

# --------------------
# List host / fs pairs
# --------------------
foreach (sort keys %fs) {
    print "$_";

    foreach (sort split(/ /, $fs{$_})) {
	print " $_";
    }

    print "\n";
}
