#!/usr/bin/perl -w
use strict;

use WRT54G;
use Util;
use Net::Telnet;

$|++;

my %config = Util::parse_config('wrt54g.cfg');

my $router = WRT54G->new(%config);

print("Pushing busybox ...");
my $remote_busybox = $router->send_file(filename => $config{mips_busybox_binary},
					subdir   => "dist/bin"
				       );
print(" done\n");

print("Pushing install script ...");
my $remote_install = $router->send_file(filename => "install.sh");
print(" done\n");

print("Executing install script ...");
$router->exec_command("/bin/sh $remote_install");
print(" done\n");

print("Decompressing distribution ...");
system("$config{ttcp_binary} -t -p 10 $router->{ip_addr} < dist.tgz");
print(" done\n\n");

print("Basic Linux distribution created.\n",
      "To connect to your WRT54G, run this command:\n\n",
      "$config{telnet_binary} $config{ip_addr}\n"
     );

