Starhost
11-28-2001, 11:32 AM
Yes people finally I'm going to publish my raq Tweaks to all other raq users. The only thing I want in return is that you keep the copyright notice on top of the files.
NOTE:
Allmost all tweaks require PHP to be setuped as CGI
The tweaks are at your own RISK!
HOWTO 1: Chmodd all dir's so that other users can't access them throw shell.
#!/usr/local/bin/php -q
<?php
// This script is developped by: N. Elsten
// Copyright by Starhost.nl
// Use of this script is at your own risks
// If you have suggestions/commands please mail to: elsten@starhost.nl
$handle=opendir('.');
while (false!==($file = readdir($handle))) {
$begin = $file;
$in = substr("$begin", 0, 4);
if ($file != "." && $file != ".." && $in == "site"){
system("chown httpd /home/sites/$file/web");
system("chmod 771 /home/sites/$file/web");
}
}
closedir($handle);
?>
Copy and paste the PHP script above and save it as: dir.php in the directory /home/sites/ Now chmodd dir.php 755.
Now make sure that the script has root privelidges. Now type on the command line: crontab -e And at the following line:
30 */2 * * * /home/sites/dir.php > /dev/null 2>&1
This will make sure that the script is executed every half hour.
HOWTO 2: Adding a standard wildcard in named using the cobalt GUI to manage bind.
First login as root into your shell and type:
pico -w /usr/lib/perl5/site_perl/5.005/Cobalt/Vsite.pm
(this is the file on a raq3 on other raq's I don't know if it is located at the same place).
Now search for the Vhost things (it looks something like below):
$new_conf .= <<EOF;
<VirtualHost $addr>
ServerName $name
ServerAdmin $serveradmin
DocumentRoot $Htgroup_dir/$group/$Webdir
RewriteEngine on
RewriteCond %{HTTP_HOST} !^$addr(:80)?$my
RewriteCond %{HTTP_HOST} !^$name(:80)?$my
RewriteRule ^/(.*) http://$name/\$1 [L,R]
RewriteOptions inherit
AliasMatch ^/~([^/]+)(/(.*))? $Htgroup_dir/$group/users/\$1/web/\$3
AliasMatch ^/users/([^/]+)(/(.*))? $Htgroup_dir/$group/users/\$1/web/\$3
</VirtualHost>
Replace this by:
$string = $name;
$string =~ s/^.*?\.//;
my $my = '$';
$new_conf .= <<EOF;
<VirtualHost $addr>
ServerName $name
ServerAdmin $serveradmin
DocumentRoot $Htgroup_dir/$group/$Webdir
ServerAlias *.$string
#ServerAlias $string
RewriteEngine on
#RewriteCond %{HTTP_HOST} !^$addr(:80)?$my
#RewriteCond %{HTTP_HOST} !^$name(:80)?$my
#RewriteRule ^/(.*) http://$name/\$1 [L,R]
RewriteOptions inherit
AliasMatch ^/~([^/]+)(/(.*))? $Htgroup_dir/$group/users/\$1/web/\$3
AliasMatch ^/users/([^/]+)(/(.*))? $Htgroup_dir/$group/users/\$1/web/\$3
</VirtualHost>
Save it.
Now all hosts that you will create using the cobalt GUI got a wildcards in apache so that it will catch all subdomains. Now type
pico -w /root/dns.php
And put the following in the file:
#!/usr/local/bin/php -q
<?php
// This script is developped by: N. Elsten
// Copyright by Starhost.nl
// Use of this script is at your own risks
// If you have suggestions/commands please mail to: elsten@starhost.nl
$handle=opendir('/etc/named/');
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != "db.cache" && $file != "records" && $file != "test.php" && $file != "pri.0.0.127.in-addr.arpa" && $file != "pri.35.196.213.in-addr.arpa" && $file != "pri.ns1.starhostdns.com:ns2.starhostdns.com:admin@ns1.starhostdns.com:14400:3600:604800:86400"){
$begin = $file;
$aantal = strlen("$begin");
$in = substr("$begin", 0, 4);
$uit = substr("$begin", -4);
if($in == "pri." AND $uit != "arpa" AND $uit != "lude"){
$bestaat = file_exists("/etc/named/$file.include");
if($bestaat != "1"){
$naam = substr("$begin", 3, "$aantal");
system("touch /etc/named/pri$naam.include");
$string = "*$naam. in cname www$naam.";
$fp = fopen ("/etc/named/pri$naam.include", "a+");
fwrite ($fp, $string);
fclose ($fp);
system("/etc/rc.d/init.d/named restart");
}
}
}
}
closedir($handle);
?>
Don't forget to change ns1.starhostdns.com and ns2.starhostdns.com to your nameservers (if you are using them on this raq). And change pri.35.196.213.in-addr.arpa to pri.yourip.in-addr.arpa
No type on the command line:
crontab -e
And put in it:
0 */1 * * * /root/dns.php > /dev/null 2>&1
This will make sure the script is executed every hour.
HOWTO 3: Change the proftp so that standard users will go to their dir and site administrators will standard go to: /home/sites/www.domain.com/
pico -w /usr/lib/perl5/site_perl/5.005/Cobalt/Ftp.pm
Change the section that looks like this:
<VirtualHost $ip>
DefaultRoot / admin
DefaultRoot ~/../.. $Sites_AdminGroup
DefaultChdir ../../ $Sites_AdminGroup
DefaultRoot ~ !$Sites_AdminGroup
DisplayLogin .ftphelp
$anonConfig</VirtualHost>
TO:
<VirtualHost $ip>
DefaultRoot / admin
DefaultRoot ~/../.. $Sites_AdminGroup
DefaultChdir ../../ $Sites_AdminGroup
DefaultRoot ~ !$Sites_AdminGroup
AllowOverwrite on
DisplayLogin .ftphelp
$anonConfig</VirtualHost>
Now save it and type on the command line:
pico -w /etc/proftpd.conf
Make sure that the above will say:
(I don't now exactly how it was before but know it says:
# This is a basic ProFTPD configuration file (rename it to
# 'proftpd.conf' for actual use. It establishes a single server
# and a single anonymous login. It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.
ServerName "ProFTPD"
ServerType inetd
DeferWelcome off
DefaultServer on
DefaultRoot / admin
DefaultRoot ~/../.. site-adm
DefaultChdir ../../ site-adm
DefaultRoot ~ !site-adm
And further down other mess.
When you are doing this and you got already servers running make sure the lines in the file are:
<VirtualHost 80.84.225.3>
DefaultRoot / admin
DefaultRoot ~/../.. site-adm
DefaultChdir ../../ site-adm
DefaultRoot ~ !site-adm
#DefaultChdir ../../web site-adm
AllowOverwrite on
DisplayLogin .ftphelp
</VirtualHost>
But then with your own ip. Do this for every ip you run sites on.
I hope you liked it. If you got problems please report them here.
NOTE:
Allmost all tweaks require PHP to be setuped as CGI
The tweaks are at your own RISK!
HOWTO 1: Chmodd all dir's so that other users can't access them throw shell.
#!/usr/local/bin/php -q
<?php
// This script is developped by: N. Elsten
// Copyright by Starhost.nl
// Use of this script is at your own risks
// If you have suggestions/commands please mail to: elsten@starhost.nl
$handle=opendir('.');
while (false!==($file = readdir($handle))) {
$begin = $file;
$in = substr("$begin", 0, 4);
if ($file != "." && $file != ".." && $in == "site"){
system("chown httpd /home/sites/$file/web");
system("chmod 771 /home/sites/$file/web");
}
}
closedir($handle);
?>
Copy and paste the PHP script above and save it as: dir.php in the directory /home/sites/ Now chmodd dir.php 755.
Now make sure that the script has root privelidges. Now type on the command line: crontab -e And at the following line:
30 */2 * * * /home/sites/dir.php > /dev/null 2>&1
This will make sure that the script is executed every half hour.
HOWTO 2: Adding a standard wildcard in named using the cobalt GUI to manage bind.
First login as root into your shell and type:
pico -w /usr/lib/perl5/site_perl/5.005/Cobalt/Vsite.pm
(this is the file on a raq3 on other raq's I don't know if it is located at the same place).
Now search for the Vhost things (it looks something like below):
$new_conf .= <<EOF;
<VirtualHost $addr>
ServerName $name
ServerAdmin $serveradmin
DocumentRoot $Htgroup_dir/$group/$Webdir
RewriteEngine on
RewriteCond %{HTTP_HOST} !^$addr(:80)?$my
RewriteCond %{HTTP_HOST} !^$name(:80)?$my
RewriteRule ^/(.*) http://$name/\$1 [L,R]
RewriteOptions inherit
AliasMatch ^/~([^/]+)(/(.*))? $Htgroup_dir/$group/users/\$1/web/\$3
AliasMatch ^/users/([^/]+)(/(.*))? $Htgroup_dir/$group/users/\$1/web/\$3
</VirtualHost>
Replace this by:
$string = $name;
$string =~ s/^.*?\.//;
my $my = '$';
$new_conf .= <<EOF;
<VirtualHost $addr>
ServerName $name
ServerAdmin $serveradmin
DocumentRoot $Htgroup_dir/$group/$Webdir
ServerAlias *.$string
#ServerAlias $string
RewriteEngine on
#RewriteCond %{HTTP_HOST} !^$addr(:80)?$my
#RewriteCond %{HTTP_HOST} !^$name(:80)?$my
#RewriteRule ^/(.*) http://$name/\$1 [L,R]
RewriteOptions inherit
AliasMatch ^/~([^/]+)(/(.*))? $Htgroup_dir/$group/users/\$1/web/\$3
AliasMatch ^/users/([^/]+)(/(.*))? $Htgroup_dir/$group/users/\$1/web/\$3
</VirtualHost>
Save it.
Now all hosts that you will create using the cobalt GUI got a wildcards in apache so that it will catch all subdomains. Now type
pico -w /root/dns.php
And put the following in the file:
#!/usr/local/bin/php -q
<?php
// This script is developped by: N. Elsten
// Copyright by Starhost.nl
// Use of this script is at your own risks
// If you have suggestions/commands please mail to: elsten@starhost.nl
$handle=opendir('/etc/named/');
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != "db.cache" && $file != "records" && $file != "test.php" && $file != "pri.0.0.127.in-addr.arpa" && $file != "pri.35.196.213.in-addr.arpa" && $file != "pri.ns1.starhostdns.com:ns2.starhostdns.com:admin@ns1.starhostdns.com:14400:3600:604800:86400"){
$begin = $file;
$aantal = strlen("$begin");
$in = substr("$begin", 0, 4);
$uit = substr("$begin", -4);
if($in == "pri." AND $uit != "arpa" AND $uit != "lude"){
$bestaat = file_exists("/etc/named/$file.include");
if($bestaat != "1"){
$naam = substr("$begin", 3, "$aantal");
system("touch /etc/named/pri$naam.include");
$string = "*$naam. in cname www$naam.";
$fp = fopen ("/etc/named/pri$naam.include", "a+");
fwrite ($fp, $string);
fclose ($fp);
system("/etc/rc.d/init.d/named restart");
}
}
}
}
closedir($handle);
?>
Don't forget to change ns1.starhostdns.com and ns2.starhostdns.com to your nameservers (if you are using them on this raq). And change pri.35.196.213.in-addr.arpa to pri.yourip.in-addr.arpa
No type on the command line:
crontab -e
And put in it:
0 */1 * * * /root/dns.php > /dev/null 2>&1
This will make sure the script is executed every hour.
HOWTO 3: Change the proftp so that standard users will go to their dir and site administrators will standard go to: /home/sites/www.domain.com/
pico -w /usr/lib/perl5/site_perl/5.005/Cobalt/Ftp.pm
Change the section that looks like this:
<VirtualHost $ip>
DefaultRoot / admin
DefaultRoot ~/../.. $Sites_AdminGroup
DefaultChdir ../../ $Sites_AdminGroup
DefaultRoot ~ !$Sites_AdminGroup
DisplayLogin .ftphelp
$anonConfig</VirtualHost>
TO:
<VirtualHost $ip>
DefaultRoot / admin
DefaultRoot ~/../.. $Sites_AdminGroup
DefaultChdir ../../ $Sites_AdminGroup
DefaultRoot ~ !$Sites_AdminGroup
AllowOverwrite on
DisplayLogin .ftphelp
$anonConfig</VirtualHost>
Now save it and type on the command line:
pico -w /etc/proftpd.conf
Make sure that the above will say:
(I don't now exactly how it was before but know it says:
# This is a basic ProFTPD configuration file (rename it to
# 'proftpd.conf' for actual use. It establishes a single server
# and a single anonymous login. It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.
ServerName "ProFTPD"
ServerType inetd
DeferWelcome off
DefaultServer on
DefaultRoot / admin
DefaultRoot ~/../.. site-adm
DefaultChdir ../../ site-adm
DefaultRoot ~ !site-adm
And further down other mess.
When you are doing this and you got already servers running make sure the lines in the file are:
<VirtualHost 80.84.225.3>
DefaultRoot / admin
DefaultRoot ~/../.. site-adm
DefaultChdir ../../ site-adm
DefaultRoot ~ !site-adm
#DefaultChdir ../../web site-adm
AllowOverwrite on
DisplayLogin .ftphelp
</VirtualHost>
But then with your own ip. Do this for every ip you run sites on.
I hope you liked it. If you got problems please report them here.
