forked from lstein/Net-ISP-Balance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.PL
96 lines (84 loc) · 2.72 KB
/
Build.PL
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/perl
use strict;
use warnings;
use Module::Build;
use lib './lib';
use Net::ISP::Balance;
my $class = Module::Build->subclass(code=><<'EOF');
use File::Find 'find';
use File::Basename 'basename';
use lib './lib';
use Net::ISP::Balance;
sub ACTION_clean {
my $self = shift;
my $dir = $self->base_dir();
system "cd lsm; make -s clean; cd $dir";
$self->SUPER::ACTION_clean();
}
sub ACTION_install {
my $self = shift;
my $dir = $self->base_dir();
$self->SUPER::ACTION_install();
mkdir '/var/lib/lsm';
my $path = $self->install_destination('script');
my $install_etc = Net::ISP::Balance->install_etc;
unlink("$install_etc/load_balance.pl");
symlink("$path/load_balance.pl"=>"$install_etc/load_balance.pl");
# fix permissions of balance.conf, to encourage root to edit
chmod 0644,"$install_etc/balance.conf";
# and rules files
system "chmod u+w $install_etc/balance/firewall/*";
system "chmod u+w $install_etc/balance/routes/*";
system "chmod u+w $install_etc/balance/pre-run/*";
system "chmod u+w $install_etc/balance/post-run/*";
}
sub process_lsm_files {
my $self = shift;
my $dir = $self->base_dir();
$self->SUPER::ACTION_build();
chomp(my $make = `which make 2>/dev/null`);
chomp(my $nmake = `which nmake 2>/dev/null`);
$make ||= $nmake;
system "cd lsm; $make install; cd $dir";
}
sub process_etc_files {
my $self = shift;
find({no_chdir=>1,
wanted => sub { return unless -f $File::Find::name;
my $bn = basename($_);
return if $bn =~ /~$/ || $bn =~ /^#/;
(my $strip = $File::Find::name) =~ s!^\./etc/!!;
my $install_etc = Net::ISP::Balance->install_etc;
if (-e "$install_etc/$strip") {
print STDERR "skip $install_etc/$strip: already installed\n";
unlink "./blib/$File::Find::name";
return;
}
$self->copy_if_modified(from => $File::Find::name,
to_dir => './blib');
}},
'./etc'
);
}
EOF
my $build = $class->new(
module_name => 'Net::ISP::Balance',
license => 'perl',
dist_version_from => 'lib/Net/ISP/Balance.pm',
dist_abstract => 'Load balance among two or more ISP connections',
dist_author => 'Lincoln Stein <[email protected]>',
configure_requires => { 'Module::Build' => 0 },
requires => {
'perl' => '5.8.0',
'Net::Netmask' => 0,
'Pod::Usage' => 0,
'DB_File' => 0,
},
);
my $install_etc = Net::ISP::Balance->install_etc;
$build->add_build_element('etc');
$build->add_build_element('lsm');
$build->install_path('etc' => $install_etc);
$build->config_data('lsm_path'=>$build->install_destination('script').'/lsm');
$build->create_build_script;
exit 0;