/[pxelator]/lib/PXElator/network.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /lib/PXElator/network.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 83 - (show annotations)
Fri Jul 31 17:12:52 2009 UTC (14 years, 8 months ago) by dpavlin
File size: 570 byte(s)
split ifconfig out and return resonable status

1 package network;
2
3 use warnings;
4 use strict;
5
6 use File::Slurp;
7
8 use server;
9
10 sub ifconfig {
11 my $dev = shift;
12 `/sbin/ifconfig $dev`
13 }
14
15 sub tap {
16
17 my $interfaces = read_file '/etc/network/interfaces';
18
19 if ( $interfaces !~ m{tap0.*$server::ip}s ) {
20
21 system "sudo apt-get install vde2";
22
23 $interfaces .= qq{
24
25 iface tap0 inet static
26 address $server::ip
27 netmask $server::netmask
28 vde2-switch -
29
30 };
31
32 write_file '/etc/network/interfaces', $interfaces;
33
34 }
35
36 ifconfig('tap0') =~ m{UP} && return 'up';
37 system("sudo ifup tap0") == 0 && return 'started';
38 }
39
40 1;

  ViewVC Help
Powered by ViewVC 1.1.26