#!/usr/bin/perl

$|=1;

$HOST="irc1.cerf.net";
$HELP="help_US";

($force = 1) if ($ARGV[0] eq "--force");

if ( !-d "/etc/zircon" ) {
    mkdir("/etc/zircon", 0755) or die "mkdir() error: /etc/zircon ($!)";
}

if ( ( !-f "/etc/zircon/rc" ) or ( -f "/etc/zircon/rc" and $force) ) {

    print "Zircon needs to setup information.  We have provided some\n";
    print "reasonable defaults for people living in the USA.\n\n";

    open(RC, "> /etc/zircon/rc") or die "open() error: /etc/zircon/rc ($!)";

    print "What is the default IRC server [$HOST]? ";
    chomp($tmp = <STDIN>);
    ($HOST = $tmp) if ($tmp ne '');

    print "What is the default help service [$HELP]? ";
    chomp($tmp = <STDIN>);
    ($HELP = $tmp) if ($tmp ne '');

    print RC "#\n";
    print RC "# This is the system wide rc file for Zircon\n";
    print RC "#\n";
    print RC "# Configure this before you start.\n";
    print RC "#\n";
    print RC "Server default -host $HOST\n";
    print RC "set helpService \"$HELP\"\n";
} else {
    print
'Zircon is already configured; I\'ll leave the existing configuration
untouched.  Use --force to ignore and overwrite it.
';
}
