blob: 8c70bde4d78ae5078b171679abfbbb96dfca4f15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#!/usr/bin/perl -T
package VServer;
our $VERSION = '1.0';
use strict;
use warnings;
sub get_context_id($) {
my $vserver = shift;
if ($vserver =~ /^([-a-z0-9._]*)$/) {
$vserver = $1;
};
my $dir = "/etc/vservers/$vserver";
return unless -d $dir;
open(my $context, '<', "$dir/context") || return undef;
my $cid = undef;
while (<$context>) {
if ($_ =~ m/([0-9]*)/) {
$cid = $1;
last;
}
}
close $context;
return $cid;
}
sub get_proc_dir($) {
my $context = shift;
my $dir = "/proc/virtual/$context/";
return $dir if (-d $dir);
return undef;
}
1;
|