###############################################################################
## HaCi - IP Address Administration #
## Copyright (C) 2006-2015 by Lars Wildemann #
## Author: Lars Wildemann <HaCi@larsux.de> #
## #
## HaCi is an IP Address / Network Administration Tool with IPv6 Support. #
## It stores its data efficiently in a relational Database and uses a #
## treelike Strukture to illustrate supernets and subnets. #
## #
## This program is free software; you can redistribute it and#or modify #
## it under the terms of the GNU General Public License as published by #
## the Free Software Foundation; either version 2 of the License, or #
## (at your option) any later version. #
## #
## This program is distributed in the hope that it will be useful, #
## but WITHOUT ANY WARRANTY; without even the implied warranty of #
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
## GNU General Public License for more details. #
###############################################################################
OVERVIEW
HaCi is a web frontend for administrating networks. It consist of a (perl) CGI and a (mySQL/postgreSQL) database as backend.
REQUIRERMENTS
All you need is a webserver (e.g.: Apache), a database (e.g.: mySQL) and an OS which supports perl.
- Perl (check with `perl -M<MODULE> -e 1 2>/dev/null && echo "Ok" || echo "Failed"`)
- Cache::Cache
- CGI
- CGI::Ajax
- CGI::Carp
- CGI::Cookie
- CGI::Session
- Class::Accessor
- Class::MakeMethods
- Config::General
- Digest::MD5
- Digest::SHA
- Encode
- Encode::Guess
- File::Temp
- HTML::Entities
- Locale::gettext
- Log::LogLite
- Math::BigInt v1.87
- Net::CIDR
- Net::IPv6Addr
- Net::SNMP
- Storable
- Template
- Time::Local
- DBD::mysql (for mysql support)
- DBD::Pg (for postgresql support)
- Apache::DBI (optional for getting connection persistence when using mod-perl)
- DNS::ZoneParse (optional for importing Zonefiles)
- File::Basename (optional for XMP-RPC API support)
- Frontier::Client (optional for XMP-RPC API support)
- IO::Socket::INET6 (optional for IMAP authentication support)
- Math::BigInt::GMP (optional, but proposed for more performance!)
- Net::DNS (optional for importing Zonefiles)
- Net::LDAP (optional for LDAP authentication)
- Net::Ping (optional for Ping-Plugin)
- Pod::WSDL (optional for SAOP support)
- SOAP::Transport::HTTP (optional for SAOP support)
- SQL::Translator::Diff (optional for automatic database upgrade support)
- SQL::Translator v0.09000 (optional for automatic database upgrade support)
- Text::CSV (optional for ex/importing CSV-Files)
- Text::CSV_XS (optional for faster ex/importing CSV-Files)
- Time::HiRes (optional for XMP-RPC API support)
- JSON (optional for RESTWrapper API support)
- URI::Query (optional for RESTWrapper API support)
- HTTP Server
- SQL Database
You can use the scripts 'bin/checkPerlDependencies.bash', 'bin/checkPerlOptionals.bash' or the testpage "/cgi-bin/test.cgi" to check for dependencies.
INSTALLATION
1)
First, extract the archiv into a directory, from which the HTTP server will process it and check dependencies.
$ cd /var/www
$ wget 'http://downloads.sourceforge.net/project/haci/haci/0.98c/HaCi_0.98c.tar.gz'
$ tar xfzv HaCi_0.98c.tar.gz
$ HaCi/bin/checkPerlDependencies.bash
$ HaCi/bin/checkPerlOptionals.bash
2)
If needed, accommodate the file/directory permissions, so the HTTP server will have no problems.
<installDir>/logs : HTTPServer (rwx)
<installDir>/spool : HTTPServer (rwx)
3)
Modify the HaCi.conf.sample (<installDir>/etc) for your needs.
It can be stored either in '/etc/HaCi.conf' or '<installDir>/etc/HaCi.conf'.
'/etc/HaCi.conf' has precedence.
4)
Configure your database and webserver, for serving your new tool.
e.g.:
- MySQL
---------------------- 8< ---------------------
CREATE USER 'HaCi'@'localhost' IDENTIFIED BY '<GEHEIM!>';
GRANT USAGE ON *.* TO 'HaCi'@'localhost' IDENTIFIED BY '<GEHEIM!>';
CREATE DATABASE `HaCi`;
GRANT ALL PRIVILEGES ON `HaCi`.* TO 'HaCi'@'localhost' WITH GRANT OPTION;
---------------------- 8< ---------------------
- HaCi will automatically initiate/update the database with the latest schema. If you don't want HaCi to do this by itself, you can import the latest schema dump:
$ mysql -u HaCi -p HaCi < docs/HaCi_v0.98c.mysql
- postgresql
- Execute as postgres super user:
$ createuser -PSDR HaCi
$ createdb -O HaCi HaCi
- Add this line to your 'pg_hba.conf'
host HaCi HaCi 127.0.0.1/32 md5
- import the database schema dump with the latest version in order to initialize the database
$ psql HaCi < docs/HaCi_v0.98c.pgsql
- OR update to a new version (i.e.: from 0.98b to 0.98c):
$ psql HaCi < docs/HaCi_v0.98b-v0.98c.pgsql
- postgresql v9.0+: Perhaps you need to set the following variable in your 'postgresql.conf', in order to make ipv6 work:
bytea_output = 'escape'
- Apache (httpd.conf)
---------------------- 8< ---------------------
<VirtualHost *:80>
ServerName haci.domain.tld
DocumentRoot /var/www/HaCi/html
ScriptAlias /cgi-bin/ /var/www/HaCi/cgi-bin/
<Directory /var/www/HaCi/cgi-bin>
# If you want to use Mod-Perl ---
PerlRequire /var/www/HaCi/etc/startup.pl
SetHandler perl-script
PerlHandler Apache::Registry # mod-perl1
PerlResponseHandler ModPerl::Registry # mod-perl2
#--------------------------------
Options +ExecCGI
AllowOverride All
Order allow,deny
allow from all
</Directory>
# Exclude the soap api interface from the mod-perl handler
<Files HaCiAPI.cgi>
SetHandler None
</Files>
# Include XML-RPC API
PerlSwitches -I/var/www/HaCi/modules
<Location /RPC2>
SetHandler perl-script
PerlHandler HaCi::XMLRPC
# disable compressing, because of problems with chunked transfer encodings
SetEnv no-gzip
</Location>
# Simple REST-Wrapper which itself uses the XMLRPC-API
<Location /RESTWrapper>
SetHandler perl-script
PerlHandler HaCi::RESTWrapper
</Location>
</VirtualHost>
---------------------- 8< ---------------------
- lighttpd
- standalone (/etc/lighttpd/lighttpd.conf):
---------------------- 8< ---------------------
server.document-root = "/var/www/HaCi/html"
server.errorlog = "/var/www/HaCi/logs/error.log"
alias.url += ("/cgi-bin/" => "/var/www/HaCi/cgi-bin/")
---------------------- 8< ---------------------
- VHost (/etc/lighttpd/conf-available/20-HaCi.conf):
---------------------- 8< ---------------------
server.modules += ( "mod_simple_vhost" )
simple-vhost.server-root = "/var/www"
simple-vhost.document-root = "/html/"
simple-vhost.default-host = "HaCi"
alias.url += ( "/cgi-bin/" => "/var/www/HaCi/cgi-bin/" )
---------------------- 8< ---------------------
- activate CGI
- Debian:
ln -s /etc/lighttpd/conf-available/10-cgi.conf /etc/lighttpd/conf-enabled/
Edit '/etc/lighttpd/conf-available/10-cgi.conf' and comment the alias-Line out:
# alias.url += ( "/cgi-bin/" => "/usr/lib/cgi-bin/" )
#
- SuSE:
Edit '/etc/lighttpd/modules.conf' and enable following line:
include "conf.d/cgi.conf"
5)
HaCi Daemon (bin/HaCid.pl)
The HaCi daemon is responsible for the recurrent plugins. It runs them in defined intervals.
You can start it with the parameter '-c' therewith it exists after one full run and you can start it by crontab.
The daemon stores its PID in 'spool' and writes its logfile in 'logs'. So it must have write permissions to this directories.
6)
HaCiAPI (documentation can be found in /doc)
- SOAP (deprecated)
HaCi supports a SOAP-Interface for accessing the data not only from the webfrontend but also from a perl/php/... script.
You can find a short description and a demo perl script in the 'docs' directory.
- XMLRPC
There is also a XML-RPC API which can be easily integrated into several programming languages. Documentation can be found in the 'docs' directory.
The following methods can be used:
- search
- getFreeSubnets
- getFreeSubnetsFromSearch
- addNet
- editNet
- delNet
- assignFreeSubnet
- getNetworkDetails
- getSubnets
- REST
There is a very basic REST Wrapper which itself uses the XML-RPC-API.
The main reason for this is to support tools which can only communicate via REST (i.e.: Table-JSON-Plugin in Confluence).
The available methods are the same as in the XML-RPC-API.
Authentication is done via HTTP-Basic-Auth or via "username"- and "password"-Parameters.
7)
Look at 'http://sourceforge.net/projects/haci/' for new releases and
'http://haci.larsux.de' for a wiki and the latest infos about HaCi.
For exporting the last CVS version call
$ cvs -z3 -d:pserver:anonymous@haci.cvs.sourceforge.net:/cvsroot/haci export -D NOW HaCi
8)
FINISH
9) Additional comments
Cleanup Database
'bin/cleanupDatabase.pl'
This tool checks the database for stale and broken entries. Pass '-c' as parameter in order to cleanup found issues. Please make sure to backup your database before.
UPGRADE
1)
Make a database backup
2)
Stop the web server
3)
Rename the HaCi-Document-Root
i.e.:
$ mv /var/www/HaCi /var/www/HaCi_OLD
4)
Get the actual code, extract it and check for new dependencies
$ cd /var/www
$ wget 'http://downloads.sourceforge.net/project/haci/haci/0.98c/HaCi_0.98c.tar.gz'
$ tar xfzv HaCi_0.98c.tar.gz
$ cd HaCi
$ bin/checkPerlDependencies.bash
$ bin/checkPerlOptionals.bash
5)
If needed, accommodate the file/directory permissions, so the HTTP server will have no problems.
<installDir>/logs : HTTPServer (rwx)
<installDir>/spool : HTTPServer (rwx)
6)
Update your database
e.g.:
- MySQL
- HaCi will automatically update the database with the latest schema. If you don't want HaCi to do this by itself, you can do the changes manually
$ less docs/manualDatabaseUpgrades_mysql.txt
- postgresql
- update to a new version (i.e.: from 0.98b to 0.98c):
$ psql HaCi < docs/HaCi_v0.98b-v0.98c.pgsql
7)
Check for new entries in the webserver configuration (Apache example in INSTALLATION step 4)
8)
Check for new configuration items in HaCi.conf and synchronize it with your old config (if it doesn't resides in /etc).
9)
Start the webserver & FINISH
The first HaCi request will take some time, because of housekeeping stuff (see in webserver error logfile for more info)
AUTHOR
Lars Wildemann
haci@larsux.de
# vim:ts=8