#! /bin/sh /usr/share/dpatch/dpatch-run
## 01_fhs.dpatch by Oliver Gorwits <oliver.gorwits@oucs.ox.ac.uk>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Make paths in NetDisco conform to Debian File Hierarchy Standard

@DPATCH@

diff -urN netdisco-1.0.orig/bin/catalyst_mac_vlan.pl netdisco-1.0/bin/catalyst_mac_vlan.pl
--- netdisco-1.0.orig/bin/catalyst_mac_vlan.pl	2003-05-13 20:20:08.000000000 +0100
+++ netdisco-1.0/bin/catalyst_mac_vlan.pl	2009-09-08 18:57:39.000000000 +0100
@@ -1,4 +1,4 @@
-#!/usr/local/bin/perl -w
+#!/usr/bin/perl -w
 
 use SNMP;
 &SNMP::initMib;
diff -urN netdisco-1.0.orig/bin/parse_mac netdisco-1.0/bin/parse_mac
--- netdisco-1.0.orig/bin/parse_mac	2003-06-10 18:02:27.000000000 +0100
+++ netdisco-1.0/bin/parse_mac	2009-09-08 18:57:39.000000000 +0100
@@ -1,4 +1,4 @@
-#!/usr/local/bin/perl -w
+#!/usr/bin/perl -w
 #
 # parse_mac - Used to chew up output from netsnort or other 
 #       Wardriving programs to make lists of known Wireless 
diff -urN netdisco-1.0.orig/bin/port_control netdisco-1.0/bin/port_control
--- netdisco-1.0.orig/bin/port_control	2003-08-14 19:55:45.000000000 +0100
+++ netdisco-1.0/bin/port_control	2009-09-08 18:57:39.000000000 +0100
@@ -1,4 +1,4 @@
-#!/usr/local/bin/perl -w
+#!/usr/bin/perl -w
 # port_control - Script that used to be called by front-end of netdisco to 
 #                enable and disable ports.
 # Max Baker
diff -urN netdisco-1.0.orig/bin/test_cache.pl netdisco-1.0/bin/test_cache.pl
--- netdisco-1.0.orig/bin/test_cache.pl	2003-05-13 20:20:08.000000000 +0100
+++ netdisco-1.0/bin/test_cache.pl	2009-09-08 18:57:39.000000000 +0100
@@ -1,4 +1,4 @@
-#!/usr/local/bin/perl -w
+#!/usr/bin/perl -w
 
 use lib '/usr/local/netdisco';
 use SNMP::Info;
diff -urN netdisco-1.0.orig/bin/test_dev.pl netdisco-1.0/bin/test_dev.pl
--- netdisco-1.0.orig/bin/test_dev.pl	2003-05-13 20:20:08.000000000 +0100
+++ netdisco-1.0/bin/test_dev.pl	2009-09-08 18:57:39.000000000 +0100
@@ -1,4 +1,4 @@
-#!/usr/local/bin/perl -w
+#!/usr/bin/perl -w
 
 use lib qw(/usr/local/netdisco);
 
diff -urN netdisco-1.0.orig/bin/test_stats.pl netdisco-1.0/bin/test_stats.pl
--- netdisco-1.0.orig/bin/test_stats.pl	2003-05-13 20:20:08.000000000 +0100
+++ netdisco-1.0/bin/test_stats.pl	2009-09-08 18:57:39.000000000 +0100
@@ -1,4 +1,4 @@
-#!/usr/local/bin/perl -w
+#!/usr/bin/perl -w
 
 use lib qw!/usr/local/netdisco/!;
 use SNMP::Info;
diff -urN netdisco-1.0.orig/netdisco netdisco-1.0/netdisco
--- netdisco-1.0.orig/netdisco	2009-06-20 18:45:13.000000000 +0100
+++ netdisco-1.0/netdisco	2009-09-08 18:57:39.000000000 +0100
@@ -19,8 +19,6 @@
 
 use strict;
 use Getopt::Long;
-use FindBin;             # Add this directory for netdisco.pm
-use lib $FindBin::Bin;
 use IO::File;            # For batch_mode()
 use POSIX qw/:errno_h setsid/;  # for Admin Daemon
 use Compress::Zlib;
@@ -113,7 +111,7 @@
 &header if (grep(/^([aABdeEFgIikKmMOprRTu]|expire-nodes-subnet)$/,keys %args) and !$BatchMode);
 
 # Parse Config File - Check for -C, then in current dir, then in default dir.
-foreach my $c ($args{C},"$FindBin::Bin/netdisco.conf",'/usr/local/netdisco/netdisco.conf') {
+foreach my $c ($args{C},'/etc/netdisco/netdisco.conf') {
     if (defined $c and -r $c){
         $configfile = $c;
         print "Using Config File : $configfile\n" if $DEBUG;
@@ -237,7 +235,7 @@
 
     my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
     my $month = sprintf("%d%02d",$year+1900,$mon+1);
-    &batch_mode("logs/$month/refresh");
+    &batch_mode("$month/refresh");
 
     my $now = localtime();
     print "[Refresh All Devices]  Started at $now. \n";
@@ -1156,7 +1154,7 @@
     
     my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
     my $month = sprintf("%d%02d",$year+1900,$mon+1);
-    &batch_mode("logs/$month/arp",1);
+    &batch_mode("$month/arp",1);
     print "Grabbing Arp Cache from all layer 3 devices (". localtime() . ")...\n";
 
     # Get our old devices, IP->Layer mapping
@@ -2149,7 +2147,7 @@
     $start_time = time;
     my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
     my $month = sprintf("%d%02d",$year+1900,$mon+1);
-    &batch_mode("logs/$month/mac",1);
+    &batch_mode("$month/mac",1);
     print "Grabbing Mac Addresses from all Layer 2 Devices (" . localtime() . ")...\n";
 
     # Get our old devices, IP->Layer mapping
@@ -3163,7 +3161,7 @@
 
     my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
     my $month = sprintf("%d%02d",$year+1900,$mon+1);
-    &batch_mode("logs/$month/netbios",1);
+    &batch_mode("$month/netbios",1);
     
     # Get nodes
     my $days = $CONFIG{nbt_days} || 7;
@@ -3866,7 +3864,7 @@
     # Log backup
     my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
     my $month = sprintf("%d%02d",$year+1900,$mon+1);
-    &batch_mode("logs/$month/nightly",1) unless (defined $no_batch and $no_batch);
+    &batch_mode("$month/nightly",1) unless (defined $no_batch and $no_batch);
     print "nightly() - Starting nightly cleanup and backup routines\n";
 
     print "  Cleaning and clearing data...\n";
@@ -4006,7 +4004,7 @@
 
     my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
     my $month = sprintf("%d%02d",$year+1900,$mon+1);
-    &batch_mode("logs/$month/graph") unless $no_batch;
+    &batch_mode("$month/graph") unless $no_batch;
     print "graph() - Creating Graphs.\n";
 
     tryuse('GraphViz', ver => '2.02', die => 1);
diff -urN netdisco-1.0.orig/netdisco.conf netdisco-1.0/netdisco.conf
--- netdisco-1.0.orig/netdisco.conf	2009-06-11 22:44:23.000000000 +0100
+++ netdisco-1.0/netdisco.conf	2009-09-08 18:57:39.000000000 +0100
@@ -13,10 +13,10 @@
 
 # ---- General Settings ----
 domain          = .mycompany.com
-home            = /usr/local/netdisco
+home            = /usr/lib/netdisco
 #customer        = mycompany
 #customericon    = mycompany.gif,88,31
-topofile        = netdisco-topology.txt
+topofile        = /etc/netdisco/netdisco-topology.txt
 timeout         = 180
 macsuck_timeout = 240
 #macsuck_all_vlans = true
@@ -61,7 +61,7 @@
 
 # ---- Admin Panel Daemon Settings ----
 daemon_bg       = true
-daemon_pid      = netdisco_daemon.pid
+daemon_pid      = /var/run/netdisco_daemon.pid
 daemon_poll     = 2
 
 # ---- Port Control Settings ---
@@ -75,8 +75,8 @@
 
 # Data Archiving and Logging
 compresslogs    = true
-compress        = /usr/bin/gzip -f
-datadir         = data
+compress        = /bin/gzip -f
+datadir         = /var/log/netdisco
 logextension    = txt
 #nmis_dump       = netdisco_nmis
 
@@ -127,24 +127,25 @@
 # snmptimeout in micro-seconds before retry, 1000000 micro-seconds = 1 second
 snmptimeout     = 1000000 
 snmpretries     = 3
+mibhome         = /usr/share/netdisco/mibs
 mibdirs         = \
-    $home/mibs/allied, \
-    $home/mibs/arista, \
-    $home/mibs/aruba, \
-    $home/mibs/asante, \
-    $home/mibs/cabletron, \
-    $home/mibs/cisco, \
-    $home/mibs/cyclades, \
-    $home/mibs/dell, \
-    $home/mibs/enterasys, \
-    $home/mibs/extreme, \
-    $home/mibs/foundry, \
-    $home/mibs/hp, \
-    $home/mibs/juniper, \
-    $home/mibs/netscreen, \
-    $home/mibs/nortel, \
+    $mibhome/allied, \
+    $mibhome/arista, \
+    $mibhome/aruba, \
+    $mibhome/asante, \
+    $mibhome/cabletron, \
+    $mibhome/cisco, \
+    $mibhome/cyclades, \
+    $mibhome/dell, \
+    $mibhome/enterasys, \
+    $mibhome/extreme, \
+    $mibhome/foundry, \
+    $mibhome/hp, \
+    $mibhome/juniper, \
+    $mibhome/netscreen, \
+    $mibhome/nortel, \
     # Do not remove rfc or net-snmp. \
-    $home/mibs/rfc,     $home/mibs/net-snmp
+    $mibhome/rfc,     $mibhome/net-snmp
 
 #bulkwalk_no    = vendor:foundry,model:blah,127.0.0.1/32,myswitch
 #bulkwalk_off   = true
@@ -167,22 +168,23 @@
 # ---- Graph Settings ----
 edge_color      = wheat
 
-graph           = html/netmap.gif
-#graph_png       = html/netmap.png
+outputdir       = /var/lib/netdisco/html
+#graph           = $outputdir/netmap.gif
+graph_png       = $outputdir/netmap.png
 graph_bg        = black
 graph_clusters  = false  # try fdp layout
 graph_color     = white
-#graph_default  = svg
+graph_default   = png
 #graph_dir      = net_dir.gif
 graph_epsilon   = 6
 graph_layout    = twopi  # try neato or fdp too
-graph_map       = html/netmap.map
+graph_map       = $outputdir/netmap.map
 graph_overlap   = scale
 graph_nodesep   = 2
 graph_ranksep   = .3
-#graph_raw      = graph_raw.dot
+#graph_raw      = $outputdir/graph_raw.dot
 graph_splines   = false
-graph_svg       = html/netmap.svg
+graph_svg       = $outputdir/netmap.svg
 graph_timeout   = 90
 graph_x         = 30
 graph_y         = 30
diff -urN netdisco-1.0.orig/netdisco.pm netdisco-1.0/netdisco.pm
--- netdisco-1.0.orig/netdisco.pm	2009-06-11 01:23:40.000000000 +0100
+++ netdisco-1.0/netdisco.pm	2009-09-08 18:57:39.000000000 +0100
@@ -2154,7 +2154,7 @@
     my $cfgitem = shift;
     my $default = shift;
     my $item = $CONFIG{$cfgitem} || $default;
-    my $home = $CONFIG{home} || '/usr/local/netdisco';
+    my $home = $CONFIG{home} || '/usr/lib/netdisco';
     return undef unless defined($item);
     if ($item =~ m,^/,) {
         return $item;
diff -urN netdisco-1.0.orig/netdisco_apache.conf netdisco-1.0/netdisco_apache.conf
--- netdisco-1.0.orig/netdisco_apache.conf	2009-06-03 00:27:02.000000000 +0100
+++ netdisco-1.0/netdisco_apache.conf	2009-09-08 18:57:39.000000000 +0100
@@ -13,18 +13,17 @@
 # Pool Database Connections
 PerlModule Apache::DBI
 
-<Directory /usr/local/netdisco/html>
-	order allow,deny
-	allow from all
-</Directory>
+#<Directory /usr/local/netdisco/html>
+#	order allow,deny
+#	allow from all
+#</Directory>
 
 <Perl>
 # Preload the netdisco module into global server space.
 #   and parse the config file only once.
 { package HTML::Mason::Commands;
-    use lib '/usr/local/netdisco';
     use netdisco qw/:all/;
-    &netdisco::config('/usr/local/netdisco/netdisco.conf');
+    &netdisco::config('/etc/netdisco/netdisco.conf');
 }
 
 # Setup Mason and Session Handler
@@ -35,8 +34,8 @@
 
     my $ah = new HTML::Mason::ApacheHandler(
         args_method            => 'mod_perl',
-        comp_root              => '/usr/local/netdisco/html',
-        data_dir               => '/usr/local/netdisco/mason',
+        comp_root              => '/usr/share/netdisco/html',
+        data_dir               => '/var/lib/netdisco/mason',
         request_class          => 'MasonX::Request::WithApacheSession',
         session_class          => 'Apache::Session::Postgres',
         session_commit         => 1,
diff -urN netdisco-1.0.orig/netdisco_apache_dir.conf netdisco-1.0/netdisco_apache_dir.conf
--- netdisco-1.0.orig/netdisco_apache_dir.conf	2006-03-09 00:05:35.000000000 +0000
+++ netdisco-1.0/netdisco_apache_dir.conf	2009-09-08 18:57:39.000000000 +0100
@@ -1,8 +1,7 @@
 # Apache Configuration for Netdisco
 # This is applied to each virtual server
 
-Alias /netdisco                      "/usr/local/netdisco/html/"
-Alias /netdisco/                     "/usr/local/netdisco/html/"
+Alias /netdisco  "/usr/share/netdisco/html/"
 
 <Location /netdisco>
 	Options +Indexes
diff -urN netdisco-1.0.orig/sql/pg netdisco-1.0/sql/pg
--- netdisco-1.0.orig/sql/pg	2009-01-31 02:06:37.000000000 +0000
+++ netdisco-1.0/sql/pg	2009-09-08 18:57:39.000000000 +0100
@@ -34,11 +34,9 @@
 	    $DefaultDir = $poss;
 	}
     }
-    $Dir        = $ARGS{d} || $DefaultDir;
-    $ConfigFile = $ARGS{c} || "$Dir/netdisco.conf";
+    $Dir        = $ARGS{d} || '/usr/lib/netdisco';
+    $ConfigFile = $ARGS{c} || "/etc/netdisco/netdisco.conf";
     $Psql       = $ARGS{p} || 'psql';
-    eval "use lib '$Dir';";
-    die "use lib '$Dir': $@." if ($@);
 }
 
 my $OS = $^O;
@@ -304,7 +302,7 @@
 
 OPTIONS
    -b                        -- Batch mode, no override protection
-   -d /usr/local/netdisco    -- Path to netdisco.pm
+   -d /usr/lib/netdisco      -- Path to netdisco "Home Directory" (can be ignored)
    -c /path/to/netdisco.conf -- Netdisco Config file to use
    -u pgsql                  -- Database UNIX user
    -p /path/to/psql          -- psql cli executable
@@ -314,3 +312,62 @@
 
 end_usage
 }
+
+__END__
+
+=head1 NAME npg
+
+npg - NetDisco Postgres shell
+
+=head1 SYNOPSIS
+
+ npg [options] [file.sql]
+
+=head1 DESCRIPTION
+
+Specify an SQL file to be run in batch mode, or don't give any arguments to
+launch the psql shell.
+
+=head1 OPTIONS
+
+ -b                        -- Batch mode, no override protection
+ -d /usr/lib/netdisco      -- Path to netdisco "Home Directory" (can be ignored)
+ -c /path/to/netdisco.conf -- Netdisco Config file to use
+ -u pgsql                  -- Database UNIX user
+ -p /path/to/psql          -- psql cli executable
+ -i                        -- Init all tables (Will delete all existing data!)
+ --back                    -- Create Backup of database
+
+=head1 AUTHOR
+
+Max Baker
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright (c) 2006 Max Baker.
+
+Redistribution and use in source and binary forms, with or without 
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+    * Neither the name of the University of California, Santa Cruz nor the 
+      names of its contributors may be used to endorse or promote products 
+      derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=cut
+
