#!/usr/bin/perl
use strict;
use lib '/mit/scripts/deploy/bin';
use onserver;

setup();

undef $/;

open(FILE, "admin/contemp.php");
my $a = <FILE>;
close(FILE);
$a =~ s/localhost/$sqlhost/g;
$a =~ s/dbuser/$sqluser/g;
$a =~ s/dbpass/$sqlpass/g;
$a =~ s/guestbookdb/$sqldb/g;
$a =~ s/useremail/$email/g;
open(FILE, ">admin/config.inc.php");
print FILE $a;
close(FILE);

open(FILE, "instemp.php");
$a = <FILE>;
close(FILE);
$a =~ s/gbuser/$admin_username/g;
$a =~ s/gbpass/$admin_password/g;
open(FILE, ">install.php");
print FILE $a;
close(FILE);

fetch_uri(
    'install.php',
    {},
    {action => 'Create table',
     db => $sqldb,
     host => $sqlhost,
     name => $sqluser,
     pass => $sqlpass});
