summaryrefslogtreecommitdiff
path: root/fs_webdemo
diff options
context:
space:
mode:
authorivan <ivan>2001-04-26 02:18:15 +0000
committerivan <ivan>2001-04-26 02:18:15 +0000
commitcec839776b1946de882e5bd968732ac472adbce3 (patch)
tree833bfe3c6b7f10ea4bd9019e156cfccb517605b5 /fs_webdemo
parentaa120bd3a40e65fe9751c0128c2ffe57cfad0b89 (diff)
argh
Diffstat (limited to 'fs_webdemo')
-rwxr-xr-xfs_webdemo/registerd.Pg34
1 files changed, 29 insertions, 5 deletions
diff --git a/fs_webdemo/registerd.Pg b/fs_webdemo/registerd.Pg
index 53a118638..996ac8b23 100755
--- a/fs_webdemo/registerd.Pg
+++ b/fs_webdemo/registerd.Pg
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
-# $Id: registerd.Pg,v 1.4 2001-04-26 00:18:36 ivan Exp $
+# $Id: registerd.Pg,v 1.5 2001-04-26 02:18:15 ivan Exp $
use strict;
use vars qw(
@@ -50,7 +50,7 @@ die "not running as root user"
$dbh = DBI->connect( $datasrc, $user, $pass, {
'AutoCommit' => 'true',
} ) or die "DBI->connect error: $DBI::errstr\n";
-$x = $DBI::errstr; #silly; to avoid "used only once" warning
+#$x = $DBI::errstr; #silly; to avoid "used only once" warning
while ( 1 ) {
@@ -85,9 +85,25 @@ while ( 1 ) {
my $username = $row->{'username'};
my $email = $row->{'passwd'};
- system("/usr/bin/createdb --username freeside demo_$username | mail ivan-createdb\@420.am");
-
- system "psql -U freeside demo_$username </usr/local/etc/freeside/demo_template.Pg | mail ivan-psql\@420.am";
+ $pdbh = DBI->connect( 'DBI:Pg:host=localhost;database=demo_template', 'freeside', 'maelcolm' )
+ or do { &myerr("$username: ". $DBI::errstr); next; };
+
+ $psth = $pdbh->prepare("CREATE DATABASE demo_$username")
+ or do { &myerr("$username: ". $pdbh->errstr;); next; };
+ $psth->execute()
+ or do { &myerr("$username: ". $psth->errstr;); next; };
+
+ open(PSQL,"|psql -U freeside demo_$username")
+ or do { &myerr("|psql -U freeside demo_$username: $!"); next; };
+ open(PSQLDATA, "</usr/local/etc/freeside/demo_template.Pg")
+ or do { &myerr("/usr/local/etc/freeside/demo_template.Pg: $!"); next; };
+ while(<PSQLDATA>) {
+ print PSQL $_;
+ }
+ close PSQLDATA
+ or do { &myerr("/usr/local/etc/freeside/demo_template.Pg: $!"); next; };
+ close PSQL
+ or do { &myerr("|psql -U freeside demo_$username: $!"); next; };
mkdir "${freeside_conf}conf.DBI:Pg:host=localhost;dbname=demo_$username", 0755;
system "cp -pr ${freeside_conf}conf.DBI:Pg:host=localhost\\;dbname=demo_template/* ".
@@ -190,3 +206,11 @@ while ( 1 ) {
}
+sub myerr {
+ my $msg = shift;
+ open(MAIL,"|mail ivan-fsdemoerr@420.am");
+ print MAIL $msg, "\n\n";
+ print MAIL $msg, "\n\n";
+ close MAIL;
+};
+