From: cvs2git Date: Thu, 20 Mar 2003 03:41:04 +0000 (+0000) Subject: This commit was manufactured by cvs2svn to create branch X-Git-Tag: freeside_1_4_1beta8~23 X-Git-Url: http://git.freeside.biz/gitweb/?a=commitdiff_plain;h=9ba9f5252cceb2385c914127062e1ca3954b6d60;hp=31dabd9708065a2ae24880b2fe27e997b81878b6;p=freeside.git This commit was manufactured by cvs2svn to create branch 'FREESIDE_1_4_BRANCH'. --- diff --git a/FS/FS/part_export/apache.pm b/FS/FS/part_export/apache.pm new file mode 100644 index 000000000..b72c9bdb0 --- /dev/null +++ b/FS/FS/part_export/apache.pm @@ -0,0 +1,7 @@ +package FS::part_export::bind; + +use vars qw(@ISA); +use FS::part_export::null; + +@ISA = qw(FS::part_export::null); + diff --git a/FS/t/part_export-apache.t b/FS/t/part_export-apache.t new file mode 100644 index 000000000..b9995080f --- /dev/null +++ b/FS/t/part_export-apache.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::part_export::apache; +$loaded=1; +print "ok 1\n"; diff --git a/bin/apache.export b/bin/apache.export new file mode 100755 index 000000000..6142c92b4 --- /dev/null +++ b/bin/apache.export @@ -0,0 +1,65 @@ +#!/usr/bin/perl -w + +use strict; +#use File::Path; +use File::Rsync; +use Net::SSH qw(ssh); +use FS::UID qw(adminsuidsetup datasrc); +use FS::Record qw(qsearch qsearchs); +use FS::part_export; +use FS::cust_svc; +use FS::svc_www; + +my $user = shift or die &usage; +adminsuidsetup $user; + +#needs the export number in there somewhere too...? +my $spooldir = "/usr/local/etc/freeside/export.". datasrc. "/apache"; +mkdir $spooldir, 0700 unless -d $spooldir; + +my @exports = qsearch('part_export', { 'exporttype' => 'apache' } ); + +my $rsync = File::Rsync->new({ + rsh => 'ssh', +# dry_run => 1, +}); + +foreach my $export ( @exports ) { + + my $machine = $export->machine; + my $file = "$spooldir/$machine.conf"; + + open(HTTPD_CONF,">$file") or die "can't open $file: $!"; + + my $template = $export->option('template'); + + my @svc_www = $export->svc_x; + + foreach my $svc_www ( @svc_www ) { + use vars qw($zone $username); + $zone = $svc_www->domain_record->zone; + $username = $svc_www->svc_acct->username; + print HTTPD_CONF eval(qq("$template")); + } + + my $user = $export->option('user'); + my $httpd_conf = $export->option('httpd_conf') + + $rsync->exec( { + src => $file, + dest => "$user\@$machine:$httpd_conf", + } ) or die "rsync to $machine failed: ". join(" / ", $rsync->err); + # warn $rsync->out; + + ssh("root\@$machine", 'ndc reload'); + +} + +close NAMED_CONF; + +# ----- + +sub usage { + die "Usage:\n export.export user\n"; +} +