7 use FS::UID qw(adminsuidsetup datasrc);
8 use FS::Record qw(qsearch qsearchs);
13 my $user = shift or die &usage;
16 #needs the export number in there somewhere too...?
17 my $spooldir = "/usr/local/etc/freeside/export.". datasrc. "/apache";
18 mkdir $spooldir, 0700 unless -d $spooldir;
20 my @exports = qsearch('part_export', { 'exporttype' => 'apache' } );
22 my $rsync = File::Rsync->new({
27 foreach my $export ( @exports ) {
29 my $machine = $export->machine;
30 my $file = "$spooldir/$machine.conf";
32 open(HTTPD_CONF,">$file") or die "can't open $file: $!";
34 my $template = $export->option('template');
36 my @svc_www = $export->svc_x;
38 foreach my $svc_www ( @svc_www ) {
39 use vars qw($zone $username);
40 $zone = $svc_www->domain_record->zone;
41 $username = $svc_www->svc_acct->username;
42 print HTTPD_CONF eval(qq("$template")). "\n\n";
45 my $user = $export->option('user');
46 my $httpd_conf = $export->option('httpd_conf');
50 dest => "$user\@$machine:$httpd_conf",
51 } ) or die "rsync to $machine failed: ". join(" / ", $rsync->err);
54 my $restart = $export->option('restart') || 'apachectl graceful';
56 ssh("root\@$machine", $restart);
65 die "Usage:\n apache.export user\n";