| 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 | ▶ | no warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | |||||||||||
| 16 | 3 | $Config{'test_data1'} = "global_value"; | |||||||||
| 17 | 3 | $Config{'test_data2'} = "global_value"; | |||||||||
| 18 | 3 | $Config{'test_url1'} = "baneharbinger.com/NCustom/index.html"; | |||||||||
| 19 | 3 | $Config{'base_dir'} = "$ENV{HOME}/.ncustom"; | |||||||||
| 20 | 3 | $Config{'save_dir'} = "$Config{'base_dir'}/save"; | |||||||||
| 21 | 3 | $Config{'tmp_dir'} = "$Config{'base_dir'}/tmp"; | |||||||||
| 22 | 3 | $Config{'get_url'} = \&get_url; | |||||||||
| 23 | 3 | $Config{'src_fqdn'} = "baneharbinger.com"; | |||||||||
| 24 | 3 | $Config{'default_src'} = ["~/", "./", "http://$Config{'src_fqdn'}/NCustom/"] ; | |||||||||
| 25 | |||||||||||
| 26 | 3 | $Config{'internal_fqdn'} = "internal.home"; | |||||||||
| 27 | 3 | $Config{'perimeter_fqdn'} = "perimeter.home"; | |||||||||
| 28 | 3 | $Config{'external_fqdn'} = "example.com"; | |||||||||
| 29 | 3 | $Config{'lanserver'} = "lanserver.$Config{'internal_fqdn'}"; | |||||||||
| 30 | 3 | $Config{'netserver'} = "netserver.$Config{'perimeter_fqdn'}"; | |||||||||
| 31 | |||||||||||
| 32 | 3 | $Config{'country_code'} = "AU" ; | |||||||||
| 33 | 3 | $Config{'state'} = "Victoria" ; | |||||||||
| 34 | 3 | $Config{'city'} = "Melbourne" ; | |||||||||
| 35 | 1 | $Config{'organisation'} = "Home" ; | |||||||||
| 36 | 3 | $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 | 3 | $Config{'users'} = { user1 => 501, user2 => 502, user3 => 503 } ; | |||||||||
| 43 | 1 | $Config{'admin_user'} = "user1" ; | |||||||||
| 44 | 1 | $Config{'low_password'} = [ "{CLEAR}changeme", "{CRYPT}wMgpRr3xnNKbk", "{SSHA}HI89zc2t1e87G/snv4wWMDbTj2ghFySR" ] ; | |||||||||
| 45 | 1 | $Config{'high_password'} = [ "{CLEAR}secret", "{CRYPT}LC4DzvurxORlw", "{SSHA}imWMYrKs2Vo6FcPVkDIivekMw4wo08wD" ] ; | |||||||||
| 46 | |||||||||||
| 47 | 2 | ▶ | sub get_url { | ||||||||
|
Subroutine
get_url: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 48 | 3 | 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 | $url =~ /([^\/]*)$/ ; | |||||||||
| 54 | 2 | my $basename = $1; | |||||||||
| 55 | 2 | my $target = "$target_dir/$basename" ; | |||||||||
| 56 | 2 | my $rc =system("/usr/bin/curl $url --fail -o $target > /dev/null 2>&1 "); | |||||||||
| 57 | 2 | ▶ | if($rc != 0){ unlink($target); } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | 2 | chmod 0750, $target ; | |||||||||
| 59 | 2 | return (! $rc); | |||||||||
| 60 | } | ||||||||||
| 61 | |||||||||||
| 62 | 1 | 1; | |||||||||
| 63 | __END__ | ||||||||||