ipasserelle-sondages/root/etc/e-smith/events/actions/ipasserelle-survey-init-dom...

52 lines
1.4 KiB
Perl

#!/usr/bin/perl -w
use strict;
use warnings;
use esmith::DomainsDB;
use esmith::ConfigDB;
my $d = esmith::DomainsDB->open or die "Couldn't open DomainsDB\n";
my $c = esmith::ConfigDB->open_ro() or die "Couldn't open ConfigDB\n";
my $domain = $c->get('DomainName')->value;
my $vhost;
$vhost = $d->get("rdv.$domain");
if (!$vhost){
$d->new_record("rdv.$domain",{
type => 'domain',
Content => 'Primary',
Description => "OpenSondage",
Nameservers => 'internet',
TemplatePath => 'WebAppVirtualHost',
DocumentRoot => '/usr/share/opensondage',
Removable => 'yes',
Authentication => 'LemonLDAP'
});
unless ( system("/sbin/e-smith/signal-event", "domain-create", "rdv.$domain") == 0 ){
die "Failed to create domain rdv.$domain\n";
}
}
$vhost = $d->get("sondages.$domain");
if (!$vhost){
$d->new_record("sondages.$domain",{
type => 'domain',
Content => 'Primary',
Description => "LimeSurvey",
Nameservers => 'internet',
TemplatePath => 'WebAppVirtualHost',
DocumentRoot => '/usr/share/limesurvey',
Removable => 'yes',
Authentication => 'LemonLDAP'
});
unless ( system("/sbin/e-smith/signal-event", "domain-create", "sondages.$domain") == 0 ){
die "Failed to create domain sondages.$domain\n";
}
}