About this list Date view Thread view Subject view Author view Attachment view

From: Geoffrey D. Bennett (g_at_netcraft.com.au)
Date: Thu 06 Jun 2002 - 09:22:10 BST


Hi there,

I'm using vserver to provide multiple vservers for multiple companies,
and it makes sense (to me) to put the vservers into subdirectories
named by the company name. Eg:

/vservers/foo/auth, foo/mail, foo/www, bar/auth, bar/mail, bar/www,
etc...

The only troubles I have encountered with this are:
- I didn't think to mkdir /var/run/vservers/foo before "vserver
  foo/auth start" the first time (therefore the .ctx lock file wasn't
  created)
- vps doesn't look in subdirectories beneath /var/run/vservers

If anyone else intends to try a similar vserver layout, the below
patch to vps may be useful.

Regards,
Geoffrey.

--- /usr/sbin/vps Thu May 2 14:46:49 2002
+++ vps Thu Jun 6 00:40:27 2002
@@ -7,11 +7,14 @@
 # version 1.0
 
 # 1.1 Added error messages
+# 2002-06-06 g_at_netcraft.com.au Added support for subdirectories in $lockdir
+
+use DirHandle;
 
 $lockdir = "/var/run/vservers";
 
 $pid_length = 5;
-get_server_names();
+get_server_names($lockdir, "");
 $context=get_context("self");
 
 if ($context == -1) {
@@ -87,16 +90,20 @@
 
 sub get_server_names
 {
- opendir LOCKDIR, "$lockdir";
- while ($file=readdir(LOCKDIR)) {
- if (-f "$lockdir/$file") {
- open FILE, "$lockdir/$file";
+ my($dir_name, $prefix) = @_;
+ my($dir) = new DirHandle($dir_name);
+
+ while ($file=$dir->read()) {
+ if (-f "$dir_name/$file") {
+ open FILE, "$dir_name/$file";
           $file =~ s/(.+)\.ctx/$1/;
           while (<FILE>) {
              if (/S_CONTEXT=(\d+)/) {
- $name{$1} = $file;
+ $name{$1} = "$prefix$file";
              }
           }
+ } elsif ($file !~ /^\./ and -d _) {
+ get_server_names("$dir_name/$file", "$file/");
        }
     }
 }

-- 
Geoffrey D. Bennett, RHCE, RHCX               geoffrey_at_netcraft.com.au
Senior Systems Engineer           http://www.netcraft.com.au/geoffrey/
NetCraft Australia Pty Ltd           http://www.netcraft.com.au/linux/


About this list Date view Thread view Subject view Author view Attachment view
[Next/Previous Months] [Main vserver Project Homepage] [Howto Subscribe/Unsubscribe] [Paul Sladen's vserver stuff]
Generated on Wed 06 Nov 2002 - 07:03:41 GMT by hypermail 2.1.3