Changeset 417 for trunk/cgi-bin/extras


Ignore:
Timestamp:
06/30/10 17:48:03 (14 years ago)
Author:
Kris Deugau
Message:

/trunk

Rearrangements and tweaks toward releaseability:

  • Add Makefile to install halfway-sanely
  • Add .spec file
  • Shuffle "use IPDB;" and "use MyIPDB;" lines so that we can automagically insert a suitable "use lib..." line during 'make install'
  • Check copyright statements
  • Clear up some defaults, and place a number of "constants" in IPDB/MyIPDB rather than having them hardcoded all over the place (Still need to think of a sane way to do this for ipdb.psql's alloctype preseeding)
  • Tweak $VERSION identifier in IPDB.pm so it can be defined in the Makefile
  • Clean up some dangling bits from repository history conversion, remove unneeded "use ..." statements
  • Tweak rWHOIS export script to use more globals and "constants" from (My)IPDB.pm, and more Perl internals than system()-equivalents. Add a few fixme comments for longer-term flexibility improvements.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/extras/db2rwhois.pl

    r380 r417  
    1010# Last update by $Author$
    1111###
    12 # Copyright (C) 2004-2007 - Kris Deugau
     12# Copyright (C) 2004-2010 - Kris Deugau
    1313
    1414use strict;
     
    1616use DBI;
    1717use NetAddr::IP;
     18use File::Path 'rmtree';
     19use POSIX qw(strftime);
     20
     21# don't remove!  required for GNU/FHS-ish install from tarball
     22##uselib##
     23
    1824use MyIPDB;
    19 use File::Path 'rmtree';
    20 
    21 $ENV{"PATH"} = "/bin;/usr/bin";
     25
     26#$ENV{"PATH"} = "/bin;/usr/bin";
    2227
    2328my $rwhoisDataPath = "/etc/rwhoisd";
     
    9196  print "$masterblocks[$i] $ctime $mtime\n";
    9297
    93   my $date;
    94   chomp ($date = `/bin/date +"%Y-%m-%d"`);
     98  my $date = strftime("%Y-%m-%d", localtime);
    9599
    96100  my $rwnet = "net-".$masterblocks[$i]->addr."-".$masterblocks[$i]->masklen;
     
    111115    mkdir "$netdatadir/data/referral";
    112116
    113     my $serial;
    114     chomp ($serial = `/bin/date '+%Y%m%d'000000000`);
    115 
     117    my $serial = strftime("%Y%m%d%H%M%S000", localtime);
     118
     119##fixme: SOA should be different every time data changes, therefore need to rewrite this ~~ every export :(
    116120    print "  Creating SOA...\n";
    117121    open SOAFILE, ">$netdatadir/soa";
     
    147151
    148152    print "  Copying template files...\n";
     153##fixme: find a way to do this without a shell (or functional equivalent)
    149154    qx { /bin/cp $rwhoisDataPath/skel/attribute_defs/* $netdatadir/attribute_defs/ };
    150155
     156##fixme: not sure if this is even necessary, since it's not referenced anywhere I can recall...
    151157    print "  Creating org data...\n";
    152     open ORGDATAFILE, ">$netdatadir/data/org/friendlyisp.txt";
     158    open ORGDATAFILE, ">$netdatadir/data/org/ourorg.txt";
    153159    print ORGDATAFILE qq(ID: NETBLK-ISP.$masterblocks[$i]
    154160Auth-Area: $masterblocks[$i]
    155 Org-Name: Friendly ISP
    156 Street-Address: 123 4th Street
    157 City: Anytown
    158 State: ON
    159 Postal-Code: H0H 0H0
    160 Country-Code: CA
    161 Phone: 000-555-1234
     161Org-Name: $IPDB::org_name
     162Street-Address: $IPDB::org_street
     163City: $IPDB::org_city
     164State: $IPDB::org_prov_state
     165Postal-Code: $IPDB::org_pocode
     166Country-Code: $IPDB::org_country
     167Phone: $IPDB::org_phone
    162168Created: 20040308
    163169Updated: 20040308
     
    189195        "IP-Network: $masterblocks[$i]\n".
    190196        "IP-Network-Block: ".$masterblocks[$i]->range."\n".
    191         "Org-Name: Friendly ISP\n".
    192         "Street-Address: 123 4th Street\n".
    193         "City: Anytown\n".
    194         "StateProv: Ontario\n".
    195         "Postal-Code: H0H 0H0\n".
    196         "Country-Code: CA\n".
    197         "Tech-Contact: ISP-ARIN-HANDLE\n".
     197        "Org-Name: $IPDB::org_name\n".
     198        "Street-Address: $IPDB::org_street\n".
     199        "City: $IPDB::org_city\n".
     200        "StateProv: $IPDB::org_prov_state\n".
     201        "Postal-Code: $IPDB::org_pocode\n".
     202        "Country-Code: $IPDB::org_country\n".
     203        "Tech-Contact: $IPDB::org_techhandle\n".
    198204        "Created: $ctime\n".
    199205        "Updated: $mtime\n".
     
    226232
    227233# Fill in a generic entry for nameless allocations
    228 if ($desc =~ /^\s*$/) { $desc = 'Friendly ISP'; }
     234if ($desc =~ /^\s*$/) { $desc = $IPDB::org_name; }
    229235
    230236    # Fix up datestamps.  We don't *really* need sub-microsecond resolution on our exports...
     
    257263        "IP-Network: $net\n".
    258264        "IP-Network-Block: ".$net->range."\n".
    259         "Org-Name: Friendly ISP\n".
    260         "Street-Address: 123 4th Street\n".
    261         "City: Anytown\n".
    262         "StateProv: Ontario\n".
    263         "Postal-Code: H0H 0H0\n".
    264         "Country-Code: CA\n".
    265         "Tech-Contact: ISP-ARIN-HANDLE\n".
     265        "Org-Name: $IPDB::org_name\n".
     266        "Street-Address: $IPDB::org_street\n".
     267        "City: $IPDB::org_city\n".
     268        "StateProv: $IPDB::org_prov_state\n".
     269        "Postal-Code: $IPDB::org_pocode\n".
     270        "Country-Code: $IPDB::org_country\n".
     271        "Tech-Contact: $IPDB::org_techhandle\n".
    266272        "Created: $ctime\n".
    267273        "Updated: $mtime\n".
     
    281287        "IP-Network: $net\n".
    282288        "IP-Network-Block: ".$net->range."\n".
    283         "Org-Name: ".($name ? $name : 'Friendly ISP')."\n".
    284         "Street-Address: ".($street ? $street : '123 4th Street')."\n".
    285         "City: ".($city ? $city : 'Anytown')."\n".
    286         "StateProv: ".($prov ? $prov : 'Ontario')."\n".
    287         "Postal-Code: ".($pocode ? $pocode : 'H0H 0H0')."\n".
    288         "Country-Code: ".($country ? $country : 'CA')."\n".
    289         "Tech-Contact: ".($tech ? $tech : 'ISP-ARIN-HANDLE')."\n".
     289        "Org-Name: ".($name ? $name : $IPDB::org_name)."\n".
     290        "Street-Address: ".($street ? $street : $IPDB::org_street)."\n".
     291        "City: ".($city ? $city : $IPDB::org_city)."\n".
     292        "StateProv: ".($prov ? $prov : $IPDB::org_prov_state)."\n".
     293        "Postal-Code: ".($pocode ? $pocode : $IPDB::org_pocode)."\n".
     294        "Country-Code: ".($country ? $country : $IPDB::org_country)."\n".
     295        "Tech-Contact: ".($tech ? $tech : $IPDB::org_techhandle)."\n".
    290296        "Created: $ctime\n".
    291297        "Updated: $mtime\n".
Note: See TracChangeset for help on using the changeset viewer.