#!/usr/bin/perl my $httpdsites = '/etc/apache2/sites-enabled/'; my $vhtpl = " NameVirtualHost *:80 UseCanonicalName off ServerName *.{domain} ServerAdmin {admin} DocumentRoot \"/data/htdocs/{domain}/%-3+/\" AllowOverride All ServerName {domain} ServerAdmin {admin} DocumentRoot \"/data/htdocs/{domain}\" AllowOverride All "; my $httpdhandler = '/etc/init.d/apache2'; if($#ARGV < 0) { print "Usage : $0 []\n"; exit 0; } my $domain = shift @ARGV; my $admin = shift @ARGV; die('No domain provided !') unless($domain); die('Domain name has bad format !') unless($domain =~ /([a-z0-9_-]\.)+([a-z]+)/i); $admin = 'webmaster@'.$domain unless($admin); $vhtpl =~ s/\{domain\}/$domain/g; $vhtpl =~ s/\{admin\}/$admin/g; $vhtpl =~ s/^\s+|\s+$//g; open(my $fh, '>'.$httpdsites.'.conf') or die('Unable to open output file.'); print $fh $vhtpl; close $fh; `$httpdhandler restart`; 0;