Web Hosting Talk







View Full Version : As promised before, my Raq (3) tweaks.


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.

Starhost
11-28-2001, 06:22 PM
What do you guys think of my hacks? Are they useful for you? If not please tell me why. If you use them please mail me :-)

Then I know they are useful :-)

nexzt
02-04-2002, 10:49 PM
Good, any programmer that knows a unix system or knows how the cobalt system works can do these them selfs, kinda like the been there done that wrote a control panel already. I made up a package of scripts very much like those but it has gone through numbers of upgrades and now each server thinks on its own and searches for things to do.. i.e users databases folders everything you could name. :)

Starhost
02-05-2002, 05:57 AM
That's really nice :D.

But I don't care anylonger, I finnally got rid of that %$*&&)(& Raq3. Now running freeBSD and I have to say I really like it :-D

shortfork
02-05-2002, 09:12 AM
Originally posted by Starhost
That's really nice :D.

But I don't care anylonger, I finnally got rid of that %$*&&)(& Raq3. Now running freeBSD and I have to say I really like it :-D And this response is relevant... because....?

Shortness:confused:

ljprevo
02-05-2002, 10:31 AM
I tried the:
HOWTO 1: Chmodd all dir's so that other users can't access them throw shell.

on a Raq4i and it would not work. My users can still go past their
own sites in shell.

Could you re-look through your script or point me in the right direction as to what I an doing wrong.

Thanks.

Starhost
02-05-2002, 10:41 AM
Are you sure?

Because it worked on my raq 3.

Can you see what the permissions are of /home/sites/domain/web ?

Which user / group and what permissions?
Further more, is apache running as httpd user, or as another user?

soontohost
02-06-2002, 03:35 AM
nexzt.....Would you be willing to post any of your "fixes"?

DaWiseMouse
02-07-2002, 05:41 AM
I think the key word here is that he said these were his tweaks for RaQ3, so its not a surprise a RaQ4 is having issues, my guess is that it may require some modification to work for the Raq4 as well, I do say they do look mighty usefull though and may very well try to do the tweaking to get this to work on a Raq4.. more to follow.. Mouse