line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
######################################################################### |
2
|
|
|
|
|
|
|
# We would represent this as CPAN/Config.pm does; # |
3
|
|
|
|
|
|
|
# however we broke it up as some values depend upon others. # |
4
|
|
|
|
|
|
|
# # |
5
|
|
|
|
|
|
|
######################################################################### |
6
|
|
|
|
|
|
|
# Add new # |
7
|
|
|
|
|
|
|
# $Config{'name'} = "value"; # |
8
|
|
|
|
|
|
|
# entries that you can use from all of you NCustom scripts. # |
9
|
|
|
|
|
|
|
# # |
10
|
|
|
|
|
|
|
################################################################# |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package NCustom ; |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
3
|
|
3
|
no warnings; |
|
1
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
175
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$Config{'test_data1'} = "global_value"; |
17
|
|
|
|
|
|
|
$Config{'test_data2'} = "global_value"; |
18
|
|
|
|
|
|
|
$Config{'test_url1'} = "baneharbinger.com/NCustom/index.html"; |
19
|
|
|
|
|
|
|
$Config{'base_dir'} = "$ENV{HOME}/.ncustom"; |
20
|
|
|
|
|
|
|
$Config{'save_dir'} = "$Config{'base_dir'}/save"; |
21
|
|
|
|
|
|
|
$Config{'tmp_dir'} = "$Config{'base_dir'}/tmp"; |
22
|
|
|
|
|
|
|
$Config{'get_url'} = \&get_url; |
23
|
|
|
|
|
|
|
$Config{'src_fqdn'} = "baneharbinger.com"; |
24
|
|
|
|
|
|
|
$Config{'default_src'} = ["~/", "./", "http://$Config{'src_fqdn'}/NCustom/"] ; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$Config{'internal_fqdn'} = "internal.home"; |
27
|
|
|
|
|
|
|
$Config{'perimeter_fqdn'} = "perimeter.home"; |
28
|
|
|
|
|
|
|
$Config{'external_fqdn'} = "example.com"; |
29
|
|
|
|
|
|
|
$Config{'lanserver'} = "lanserver.$Config{'internal_fqdn'}"; |
30
|
|
|
|
|
|
|
$Config{'netserver'} = "netserver.$Config{'perimeter_fqdn'}"; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$Config{'country_code'} = "AU" ; |
33
|
|
|
|
|
|
|
$Config{'state'} = "Victoria" ; |
34
|
|
|
|
|
|
|
$Config{'city'} = "Melbourne" ; |
35
|
1
|
|
|
|
|
37
|
$Config{'organisation'} = "Home" ; |
36
|
|
|
|
|
|
|
$Config{'organisation_unit'} = "Home" ; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# passwords generated with slappasswd |
40
|
|
|
|
|
|
|
# override them in your personal config file |
41
|
|
|
|
|
|
|
# dont change them in this global file (as it is world readable) |
42
|
|
|
|
|
|
|
$Config{'users'} = { user1 => 501, user2 => 502, user3 => 503 } ; |
43
|
|
|
|
|
|
|
$Config{'admin_user'} = "user1" ; |
44
|
|
|
|
|
|
|
$Config{'low_password'} = [ "{CLEAR}changeme", "{CRYPT}wMgpRr3xnNKbk", "{SSHA}HI89zc2t1e87G/snv4wWMDbTj2ghFySR" ] ; |
45
|
|
|
|
|
|
|
$Config{'high_password'} = [ "{CLEAR}secret", "{CRYPT}LC4DzvurxORlw", "{SSHA}imWMYrKs2Vo6FcPVkDIivekMw4wo08wD" ] ; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub get_url { |
48
|
3
|
|
|
2
|
0
|
8
|
my ($url, $target_dir) = @_; |
49
|
|
|
|
|
|
|
# the following should be configured for your system |
50
|
|
|
|
|
|
|
# it can also be configured in ~/.ncustom/NCustom/MyConfig.pm |
51
|
|
|
|
|
|
|
# you may use your favorite utility (curl, wget, pavuk...) |
52
|
|
|
|
|
|
|
# you may want to add arguments, such as proxy, or .netrc |
53
|
3
|
|
|
|
|
1710
|
$url =~ /([^\/]*)$/ ; |
54
|
2
|
|
|
|
|
4
|
my $basename = $1; |
55
|
2
|
|
|
|
|
34
|
my $target = "$target_dir/$basename" ; |
56
|
2
|
|
|
|
|
6
|
my $rc =system("/usr/bin/curl $url --fail -o $target > /dev/null 2>&1 "); |
57
|
2
|
50
|
|
|
|
6
|
if($rc != 0){ unlink($target); } |
|
2
|
|
|
|
|
47137
|
|
58
|
2
|
|
|
|
|
85
|
chmod 0750, $target ; |
59
|
2
|
|
|
|
|
94
|
return (! $rc); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
__END__ |