On Sun, 21 Feb 1999, Sean Proske wrote:
> Another project I'd like to take on would be to create a shell script and/or
> a web interface for adding additional virtual domains (I'd actually like to
> incorporate this into my hosting account creation script). Would you mind
Well, on the NON-mj end (as in changing sendmail, vut, DNS, etc) -- I've
included a perl script that can be used. It needs to be modified a little
for your personal usage, but it essentially does the changes. BTW,
example.com should be changed to YOUR main domain -- thus it makes it easy
to have 100 additioanl domains and whenever you change
mail.yourmaindomain.com you just change it once and not 100 times.
----
#!/usr/bin/perl
require 5.004_04;
package mkdom;
$VERSION = '981205.01';
$prog_name = 'mkdom';
require "getopts.pl";
&Getopts("r") || die("Error detected.\n");
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
if (++$mon < 10) { $mon = "0$mon"; }
if (+$mday < 10) { $mday = "0$mday"; }
$date_dns = "19$year$mon$mday";
if (defined($opt_r)) {
&restart_vut;
&restart_sendmail;
&restart_dns;
exit 0;
}
print "What is the domain name? ";
chop($domain = <STDIN>);
print "Who is the vut recipient? (email address) ";
chop($recipient = <STDIN>);
$rev = "01";
&edit_sendmail;
&edit_dns;
if (defined($recipient)) {
&edit_vut;
&restart_vut;
}
&restart_sendmail;
&restart_dns;
sub edit_sendmail {
open(EMAIL,">>/etc/mail/sendmail.cw");
print EMAIL <<"EMAIL-END";
$domain
mail.$domain
www.$domain
EMAIL-END
close(EMAIL);
};
sub edit_dns {
open(DNS,">/var/named/db.$domain");
print DNS <<"DNS-END";
$domain. IN SOA ns.example.com. hostmaster.example.com. (
$date_dns$rev ; Serial
10800 ; Refresh after 3 hours
3600 ; Retry after 1 hour
604800 ; Expire after 1 week
86400 ) ; Minimum TTL of 1 day
DNS-END
print DNS " IN A 127.0.0.1";
print DNS <<"DNS-END";
IN NS ns.example.com.
IN NS ns2.example.com.
IN MX 20 mx4.example.com.
IN MX 20 mx3.example.com.
IN MX 10 mx2.example.com.
IN MX 1 mx.example.com.
\$ORIGIN $domain.
mail IN CNAME mail.example.com.
www IN CNAME $domain.
DNS-END
close(DNS);
open(DNS2,">>/etc/named.conf");
print DNS2 <<"DNS2-END";
zone "$domain" {
type master;
file "db.$domain";
};
DNS2-END
close(DNS2);
open(DNS3,">>/etc/named.conf.slave");
print DNS3 <<"DNS3-END";
zone "$domain" {
type slave;
file "db.$domain";
masters {127.0.0.1; };
};
DNS3-END
};
sub edit_vut {
open(VUT,">>/etc/virtusertable");
print VUT <<"VUT-END";
\@$domain $recipient
VUT-END
close(VUT);
};
sub restart_vut {
unlink("/etc/virtusertable.db");
$vut_cwd = "makemap -v btree /etc/virtusertable < /etc/virtusertable";
system $vut_cwd;
};
sub restart_dns {
open(named,"/var/run/named.pid");
$named_pid = <named>;
close(named);
$named_cwd = "kill -1 $named_pid";
system $named_cwd;
print "DNS (named) restarted - $named_pid";
};
sub restart_sendmail {
open(sendmail,"/var/run/sendmail.pid");
$sendmail_pid = <sendmail>;
close(sendmail);
$sendmail_cwd = "kill -1 $sendmail_pid";
system $sendmail_cwd;
print "sendmail restarted - $sendmail_pid";
};
--
Brock Rozen brozen@torah.org
Director of Technical Services (410)358-9800
Project Genesis http://www.torah.org/
References:
|
|