, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
OCSInventory-Server-2.8.1/README.md 0000664 0000000 0000000 00000006127 13764364732 0016634 0 ustar 00root root 0000000 0000000
[](https://travis-ci.com/OCSInventory-NG/OCSInventory-Server)
OCS Inventory
Some Links:
Ask question |
Installation |
Website |
OCS Professional
OCS (Open Computers and Software Inventory Next Generation) is an assets management and deployment solution.
Since 2001, OCS Inventory NG has been looking for making software and hardware more powerful.
OCS Inventory NG asks its agents to know the software and hardware composition of every computer or server.
Assets management
Since 2001, OCS Inventory NG has been looking for making software and hardware more powerful. OCS Inventory NG asks its agents to know the software and hardware composition of every computer or server. OCS Inventory also ask to discover network’s elements which can’t receive an agent. Since the version 2.0, OCS Inventory NG take in charge the SNMP scans functionality.
This functionality’s main goal is to complete the data retrieved from the IP Discover scan. These SNMP scans will allow you to add a lot more informations from your network devices : printers, scanner, routers, computer without agents, …
Deployment
OCS Inventory NG includes the packet deployment functionality to be sure that all of the softwares environments which are on the network are the same. From the central management server, you can send the packets which will be downloaded with HTTP/HTTPS and launched by the agent on client’s computer. The OCS deployment is configured to make the packets less impactable on the network. OCS is used as a deployment tool on IT stock of more 100 000 devices.
## Requirements
For the requirements, please follow the OCS Inventory documentation :
http://wiki.ocsinventory-ng.org/01.Prerequisites/Libraries-version/
## Installation
To install OCSInventory server simply run the setup script
```bash
sh setup.sh
```
If you want to install webconsole OCS Reports you need to fork OCSInventory-ocsreports as ocsreports
```bash
git clone https://github.com/OCSInventory-NG/OCSInventory-ocsreports.git ocsreports
```
For more informations, please follow the OCS Inventory documentation :
http://wiki.ocsinventory-ng.org/02.Basic-documentation/Setting-up-a-OCS-Inventory-Server/
## Contributing
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Add your changes: `git add folder/file1.php`
4. Commit your changes: `git commit -m 'Add some feature'`
5. Push to the branch: `git push origin my-new-feature`
6. Submit a pull request !
## License
OCS Inventory is GPLv2 licensed
OCSInventory-Server-2.8.1/binutils/ 0000775 0000000 0000000 00000000000 13764364732 0017200 5 ustar 00root root 0000000 0000000 OCSInventory-Server-2.8.1/binutils/create-release-tarball.sh 0000775 0000000 0000000 00000003425 13764364732 0024043 0 ustar 00root root 0000000 0000000 #!/bin/sh
set -e
# Branch name (first args)
BRANCH=$1
#Â Release name (second args)
RELEASE_NAME=$2
# URL to the ocs server git repository
SRV_REPO=https://github.com/OCSInventory-NG/OCSInventory-Server.git
# URL to the ocs reports git repository
WEB_REPO=https://github.com/OCSInventory-NG/OCSInventory-OCSReports.git
# Composer path
COMPOSER_PATH=/usr/bin/composer
# If no branch is supplied exit
if [ -z $BRANCH ]; then
echo "Please set a source branch (first argument)"
exit 1
fi
if [ -z $RELEASE_NAME ]; then
echo "Please set a release name (second argument)"
exit 1
fi
echo "$COMPOSER_PATH"
# Check if composer bin is available, otherwise exit and display an error
if [ ! -f $COMPOSER_PATH ]; then
echo "Error retreving composer executable. Please verify if composer is intalled or the COMPOSER_PATH configuration at the begining of the file (Currently used COMPOSER_PATH = $COMPOSER_PATH)"
exit 1
fi
# Clone server repository and remove git related files
git clone $SRV_REPO -b $BRANCH
rm -rf OCSInventory-Server/.git
rm -rf OCSInventory-Server/.github
rm -rf OCSInventory-Server/.gitignore
#Â Clone reports repository and remove git related files
cd OCSInventory-Server && git clone $WEB_REPO -b $BRANCH ocsreports
rm -rf ocsreports/.git
rm -rf ocsreports/.github
rm -rf ocsreports/.gitignore
# Reset the default settings so install.php will be correctly loaded
rm ocsreports/dbconfig.inc.php
cd ocsreports/
# Run composer on ocsreports
$COMPOSER_PATH install
# Go back to the base path
cd ../..
#Â Change name to comply with OCS' naming convention
mv OCSInventory-Server OCSNG_UNIX_SERVER-$RELEASE_NAME
tar cfz OCSNG_UNIX_SERVER-$RELEASE_NAME.tar.gz OCSNG_UNIX_SERVER-$RELEASE_NAME
rm -rf OCSNG_UNIX_SERVER-$RELEASE_NAME
# Release created !
echo "Release has been successfully created" OCSInventory-Server-2.8.1/binutils/docker-download.sh 0000775 0000000 0000000 00000001506 13764364732 0022615 0 ustar 00root root 0000000 0000000 #!/bin/sh
# Define constant
VERSION=$1
# Github base url for download releases
ReleaseBaseUrl="https://github.com/OCSInventory-NG/OCSInventory-ocsreports/releases/download/"
# Last release tag
LastReleaseTag="${VERSION}/"
# Archive name
LastReleaseArchive="OCSNG_UNIX_SERVER_${VERSION}"
# Archive extension
ArchiveExtension=".tar.gz"
# File destination
FileDestination="/tmp/ocs"
# Archive link for release
FullArchiveUrl=$ReleaseBaseUrl$LastReleaseTag$LastReleaseArchive$ArchiveExtension
# Get archive
if wget $FullArchiveUrl; then
echo $LastReleaseArchive
else
LastReleaseArchive="OCSNG_UNIX_SERVER-${VERSION}"
FullArchiveUrl=$ReleaseBaseUrl$LastReleaseTag$LastReleaseArchive$ArchiveExtension
wget $FullArchiveUrl
echo $FullArchiveUrl
fi
tar -xzvf $LastReleaseArchive$ArchiveExtension
mv $LastReleaseArchive $FileDestination
OCSInventory-Server-2.8.1/binutils/ipdiscover-util.README 0000664 0000000 0000000 00000001622 13764364732 0023202 0 ustar 00root root 0000000 0000000 ################################################################################
#
# OCS Inventory NG Management Server Setup
#
# Copyleft 2006 OCS Inventory NG Team
# Web: http://www.ocsinventory-ng.org
#
# This code is open source and may be copied and modified as long as the source
# code is always made freely available.
# Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
################################################################################
ipdiscover-util.pl is designed to manage the ipdiscover data stored in the
database.
Update the connection data elements at the beginning of the script to make it
work for you.
The GUI ipdiscover feature is improved since this version. If you want more
(analyze button (per subnet) and ip querying), put it in ocsreports.
The script require Net::IP perl module, nmap and samba.
Read documentation for further details.
OCSInventory-Server-2.8.1/binutils/ipdiscover-util.pl 0000775 0000000 0000000 00000050634 13764364732 0022672 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl
###############################################################################
##OCSINVENTORY-NG
##Copyleft Pascal DANEK 2005
##Web : http://www.ocsinventory-ng.org
##
##This code is open source and may be copied and modified as long as the source
##code is always made freely available.
##Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
################################################################################
#
#
use DBI;
use XML::Simple;
use Net::IP qw(:PROC);
use strict;
use Fcntl qw/:flock/;
#Command line options :
#-analyse : nmap analyse and files for grep, human readable and xml generation
#-net : Treat machine for the specified subnet
#
#
################
#OPTIONS READING
################
#
my $option;
#Specify a subnet
my $net;
#Subnet name
my $filter;
#Analyse and class the computers
my $analyse;
#Net for a given ip
my $iptarget;
my $masktarget;
#If auto flag, running for all the subnet.csv subnet and generate files
my $auto;
#Search for problems with computer election
my $ipd;
my $list;
my $xml;
my $cache;
my $path;
#Default values for database connection
#
my $dbhost = 'localhost';
my $dbuser = 'ocs';
my $dbpwd = 'ocs';
my $db = 'ocsweb';
my $dbp = '3306';
my $dbsocket = '';
#
my %xml;
my $ipdiscover;
#Cleanup the directory
&_cleanup();
for $option (@ARGV){
if($option=~/-a$/){
$analyse = 1;
}elsif($option=~/-auto$/){
$auto = 1;
}elsif($option=~/-cache$/){
$cache = 1;
$analyse = 1;
$xml = 1;
}elsif($option=~/-path=(\S*)$/){
$path = $1;
}elsif($option=~/-ipdiscover=(\d+)$/){
$ipdiscover = 1;
$ipd = $1;
}elsif($option=~/-xml$/){
$xml = 1;
}elsif($option=~/-h=(\S+)/){
$dbhost = $1;
}elsif($option=~/-d=(\S+)/){
$db = $1;
}elsif($option=~/-u=(\S+)/){
$dbuser = $1;
}elsif($option=~/-p=(\S+)/){
$dbpwd = $1;
}elsif($option=~/-P=(\S+)/){
$dbp = $1;
}elsif($option=~/-list$/){
$list = 1;
}elsif($option=~/-s=(\S+)/){
$dbsocket = $1;
}elsif($option=~/-net=(\S+)/){
die "Invalid subnet. Abort...\n" unless $1=~/^(\d{1,3}(?:\.\d{1,3}){3})$/;
$net = 1;
$filter = $1;
}elsif($option=~/-ip=(\S+)/){
die "Invalid address => [IP/MASK]. Abort...\n" unless $1=~/^(\d{1,3}(?:\.\d{1,3}){3})\/(.+)$/;
$iptarget = $1;
$masktarget = $2;
}else{
print < Looks for the ip in a subnet
-net=X.X.X.X -> Specify a network
-a -> Launch the analyze
-ipdiscover=X -> Show all the subnet with up to XX ipdiscover
-xml -> xml output
-list=show all the networks present in the database with "connected"/"discovered" computers
#DATABASE OPTION
-p=xxxx password (default ocs)
-P=xxxx port (default 3306)
-d=xxxx database name (default ocsweb)
-u=xxxx user (default ocs)
-h=xxxx host (default localhost)
-s=xxxx socket (default from default mysql configuration)
EOF
die "Invalid options. Abort..\n";
}
}
if($analyse and !$net){
die "Which subnet do you want to analyse ?\n";
}
if($cache or $auto){
unless(-d "$path/ipd"){
mkdir("$path/ipd")
or die $!;
}
}
#Date of the day
my $date = localtime();
#######################
#Database connection...
########
#
my $request;
my $row;
my $dbparams = {};
$dbparams->{'mysql_socket'} = $dbsocket if $dbsocket;
my $dbh = DBI->connect("DBI:mysql:database=$db;host=$dbhost;port=$dbp", $dbuser, $dbpwd, $dbparams)
or die $!;
#############################
#We get the subnet/name pairs
####
#
my @subnet;
$request = $dbh->prepare("SELECT * FROM subnet");
$request->execute;
while($row = $request->fetchrow_hashref){
push @subnet, [ $row->{'NETID'}, $row->{'NAME'}, $row->{'ID'}, $row->{'MASK'} ];
}
###########
#PROCESSING
###########
#
if($auto){
print "\n\n########################\n";
print "Starting scan of subnets\n";
print "########################\n";
my %subnet;
for(@subnet){
my $name = $_->[1];
my $netn = $_->[0];
$name=~s/ /_/g;
$name=~s/\//\\\//g;
$subnet{$name} = $netn;
print "Retrieving $name (".$subnet{$name}.")\n";
}
my $i;
print "\n\n##################\n";
print "PROCESSING SUBNETS \n";
print "##################\n\n";
for(keys(%subnet)){
print "Processing $_ (".$subnet{$_}."). ".(keys(%subnet)-$i)." networks left.\n";
open OUT, ">$path/ipd/".$subnet{$_}.".ipd" or die $!;
unless(flock(OUT, LOCK_EX|LOCK_NB)){
if($xml){
print "345";
exit(0);
}else{
die "An other analyse is in progress\n";
}
}
system("./ipdiscover-util.pl -net=".$subnet{$_}.($xml?' -xml':'')." -a > $path/ipd/'".$subnet{$_}.".ipd'");
$i++;
}
system ("rm -f ipdiscover-analyze.*");
print "Done.\n";
exit(0);
}
#Host subnet
my $network;
#Subnet mask in binary format
my $binmask;
if($ipdiscover){
my @networks;
#get the subnets
my $result;
die "Invalid value\n" if $ipd<0;
$request = $dbh->prepare('select distinct(ipsubnet) from networks left outer join devices on tvalue=ipsubnet where tvalue is null');
$request->execute;
while($row = $request->fetchrow_hashref){
push @networks, [ $row->{'ipsubnet'}, '0' ];
}
$request->finish;
#If positive value, it includes other subnet
if($ipd){
$request = $dbh->prepare('select count(*) nb,tvalue,name from devices group by tvalue having nb<='.$ipd.' and name="ipdiscover"');
$request->execute;
while($row = $request->fetchrow_hashref){
push @networks, [ $row->{'tvalue'}, $row->{'nb'} ];
}
$request->finish;
}
print <[0];
my $nbipd = $network->[1];
next unless $ip =~ /^\d{1,3}(?:\.\d{1,3}){3}$/;
my $req = $dbh->prepare('select h.deviceid, h.id, h.name, h.quality,h.fidelity,h.lastcome,h.lastdate,osname, n.ipmask, n.ipaddress from hardware h,networks n where n.hardware_id=h.id and n.ipsubnet='.$dbh->quote($ip).' order by lastdate');
$req->execute;
#Get the subnet label
unless($xml){
print "#######\n";
my ($nname, $nuid) = &_getnetname($ip, '');
print "SUBNET = ".$ip."-> $nbipd ipdiscover, ".($req->rows?$req->rows:0)." host(s) connected \n[ $nname ($nuid) ]\n";
print "#\n\n";
printf(" %-25s %-9s %-9s %-25s %-15s %-15s %s\n", "","","","","","","");
print "-----------------------------------------------------------------------------------------------------------------------\n";
while($result = $req->fetchrow_hashref){
my $r = $dbh->prepare('select * from devices where hardware_id='.$dbh->quote($result->{'id'}).' and tvalue='.$dbh->quote($ip).' and name="ipdiscover"');
$r->execute;
printf("#-> %-25s %-9s %-9s %-25s %-15s %15s %s %s\n",$result->{'name'},$result->{'quality'},$result->{'fidelity'},$result->{'lastdate'},$result->{'ipaddress'}, $result->{'ipmask'},$result->{'osname'} ,$r->rows?'*':'');
$r->finish;
}
print "\n\n\n\n";
}else{
$xml{'SUBNET'}[$i]{'IP'} = [ $ip ];
$xml{'SUBNET'}[$i]{'IPDISCOVER'} = [ $nbipd ];
$xml{'SUBNET'}[$i]{'HOSTS'} = [ $req->rows?$req->rows:0 ];
$j = 0;
while($result = $req->fetchrow_hashref){
$xml{'SUBNET'}[$i]{'HOST'}[$j]{'NAME'} = [ $result->{'name'} ];
$xml{'SUBNET'}[$i]{'HOST'}[$j]{'QUALITY'} = [ $result->{'quality'} ];
$xml{'SUBNET'}[$i]{'HOST'}[$j]{'FIDELITY'} = [ $result->{'fidelity'} ];
$xml{'SUBNET'}[$i]{'HOST'}[$j]{'LASTDATE'} = [ $result->{'lastdate'} ];
$xml{'SUBNET'}[$i]{'HOST'}[$j]{'OSNAME'} = [ $result->{'osname'} ];
$xml{'SUBNET'}[$i]{'HOST'}[$j]{'IPMASK'} = [ $result->{'ipmask'} ];
$j++;
}
$i++;
}
}
if($xml){
$output=XML::Simple::XMLout( \%xml, RootName => 'NET', SuppressEmpty => undef);
print $output;
}
exit(0);
}
#############
##IP resolving
##############
##
if($iptarget){
my $netname;
#If necessary, ascii conversion of a binary format
$masktarget = _bintoascii($masktarget) if($masktarget=~/^\d\d$/);
die "Invalid netmask. Abort.\n" unless $masktarget=~/^\d{1,3}(\.\d{1,3}){3}$/;
$network = _network($iptarget, $masktarget);
my $uid;
($netname, $uid)= &_getnetname($network, '-');
my @nmb = `nmblookup -A $iptarget`;
#DNS name
my $dnsname = &_getdns($iptarget);
#Netbios name
my $nmbname;
my $inv;
my $type;
for(@nmb){
$nmbname = $1,last if /\s+(\S+).*<00>/;
}
$request = $dbh->prepare('SELECT * FROM networks WHERE IPADDRESS='.$dbh->quote($iptarget));
$request->execute;
if($request->rows){
$inv = 1;
$type = 'Computer';
}else{
$request = $dbh->prepare('SELECT IP,TYPE FROM netmap, network_devices WHERE MAC=MACADDR AND IP='.$dbh->quote($iptarget));
$request->execute;
if(my $row = $request->fetchrow_hashref){
$inv = 1, $type = $row->{'TYPE'};
}
}
$request = $dbh->prepare('SELECT MAC FROM netmap WHERE IP='.$dbh->quote($iptarget));
$request->execute;
my $exist = 1 if $request->rows;
unless($xml){
print < ".($netname).". ($uid) ($network)\n";
print < 'IP', SuppressEmpty => undef);
print $output;
exit(0);
}
}
#
#Searching non-inventoried mac addresses
#
my %network;
my @hosts;
my $null;
#
# Filter out already flagged MAC addresses - drich
$request = $dbh->prepare('SELECT IP,MASK,MAC,DATE FROM netmap LEFT JOIN networks ON MACADDR=MAC where MACADDR IS NULL AND MAC NOT IN (SELECT MACADDR FROM network_devices)');
$request->execute;
#
#Determine the subnets
#
#
my %network_ipd;
#
while($row = $request->fetchrow_hashref){
my $ip;
my $netmask;
#
if($row->{'MASK'}){
$ip = $row->{'IP'};
$netmask = $row->{'MASK'};
$network = _network($ip, $netmask);
$binmask = _binmask($netmask);
if($net){
next unless $network eq $filter;
}
#Hosts count per subnet
if($list and !$analyse and !$net){
$network_ipd{$network}++;
}else{
$network{$network}++;
push @hosts, [ $row->{'MAC'}, $ip , $row->{'DATE'}];
}
}else{
$null++;
}
}
my $total = 0;
#We want ALL subnets in the database, even those that are not discovered
if($list and !$analyse and !$net){
$request = $dbh->prepare('SELECT IPADDRESS,IPMASK FROM networks');
$request->execute;
while($row = $request->fetchrow_hashref){
my $ip;
my $netmask;
#
if($row->{'IPMASK'}=~/^\d{1,3}(\.\d{1,3}){3}$/ and $row->{'IPADDRESS'}=~/^\d{1,3}(\.\d{1,3}){3}$/){
$ip = $row->{'IPADDRESS'};
$netmask = $row->{'IPMASK'};
$network = _network($ip, $netmask);
$network{$network}++;
}
#Hosts count per subnet
}
#We show the part of non-inventoried computers
my $netnum;
for $netnum (keys(%network)){
$total+=$network{$netnum};
for(keys(%network_ipd)){
$network{$netnum}.= "/".$network_ipd{$_} if($_ eq $netnum);
}
}
}
########
#RESULTS
########
#
print <","","","");
print "-------------------------------------------------------------------\n";
}
#net UID
my $dep;
#net name
my $lib;
#
my $line;
my $netn;
#
my $i;
my $output;
for $netn (keys(%network)){
($lib, $dep) = &_getnetname($netn,'-');
if($xml and !$analyse){
$xml{'NETWORK'}[$i]{'LABEL'} = [ $lib ];
$xml{'NETWORK'}[$i]{'UID'} = [ $dep ];
$xml{'NETWORK'}[$i]{'NETNAME'} = [ $netn ];
$xml{'NETWORK'}[$i]{'NETNUMBER'} = [ $network{$netn} ];
$i++;
}elsif(!$xml){
printf("%-35s %-5s %-20s %-4s\n",$lib,$dep,$netn,$network{$netn});
$total += $network{$netn} unless $list;
}
}
if($xml and !$net){
$output=XML::Simple::XMLout( \%xml, RootName => 'IPDISCOVER', SuppressEmpty => undef);
print $output;
}
if($net){
#
my($n, $i);
#Host names
my @names;
#
unless($xml){
print "\n---------------------------------------------\n";
print "Unknown host(s) on $filter \n";
print "---------------------------------------------\n\n";
}
my $output;
for $n (@hosts){
#Trying a DNS resolution
push @$n, &_getdns($$n[1]);
unless($analyse){
if($xml){
$xml{'HOST'}[$i]{'IP'} = [ $$n[1] ];
$xml{'HOST'}[$i]{'MAC'} = [ $$n[0] ];
$xml{'HOST'}[$i]{'DATE'} = [ $$n[2] ];
$xml{'HOST'}[$i]{'NAME'} = [ $$n[3] ];
$i++;
}else{
printf("=> %-20s %-20s %-20s %s\n",$$n[1],$$n[0],$$n[2],$$n[3]);
}
}
}
if(!$analyse and $xml){
$output=XML::Simple::XMLout( \%xml, RootName => 'NET', SuppressEmpty => undef);
print $output;
}
}
########
#ANALYZE
########
#
#
#
#windows computers
my @PCW;
#Linux computers
my @PCL;
#Mac computers
my @PCM;
#net peripherals
my @PR;
#Phantom computers
my @PH;
#At least one port filtered with one port open or closed
my @PF;
if($analyse){
#directory creation for analyses file
if($cache){
open CACHE, ">$path/ipd/$filter.ipd" or die $!;
unless(flock(CACHE, LOCK_EX|LOCK_NB)){
if($xml){
print "346";
exit(0);
}else{
die "An other analyse is in progress\n";
}
}
}
unless(@hosts){
print "No unknown hosts of this network. Stop.\n\n" unless $xml;
exit(0);
}
#If it's a global analyze, we don't display the results but just generate the files
#Using nmap :
# -> Connection on ports 135(msrpc), 80(web), 22(ssh), 23(telnet)
# -> files ipdiscover-analyze.* generated (3 formats : .nmap(human), .gnmap(pour grep), .xml(xml)
# -> No 'host up' detection
#
my @ips;
push @ips, $$_[1] for(@hosts);
#Check that there is no analyses of this network pending
open NMAP, "+>$path/$filter.gnmap";
unless(flock(NMAP, LOCK_EX|LOCK_NB)){
if($xml){
print "347";
exit(0);
}else{
die "An other analyse is in progress\n";
}
}
#Analyse
system("nmap -R -v @ips -p 135,80,22,23 -oG $path/$filter.gnmap -P0 -O > /dev/null");
#
my @gnmap;
if($net){
@gnmap = ;
close NMAP;
unlink "$path/$filter.gnmap";
#
###########
#
my $ref;
my ($h, $w, $j, $r, $f, $l);
REF:
for $ref (@hosts){
$h = $$ref[1];
for(@gnmap){
next if /^#/; # Skip comments
if(/Host: $h\b/){
if (/Status: Down/){
$PH[$j] = $ref;
$j++;
next REF;
}elsif(/Status: /){ # status up is meaningless to us
next;
}
# Try OS detection first
if(/OS: .*Windows/){
$PCW[$w] = $ref;
$w++;
next REF;
}elsif(/OS: .*Apple Mac/){
$PCM[$l] = $ref;
$l++;
next REF;
}elsif(/OS: .*Linux/ and !/OS: .*embedded/){
$PCL[$l] = $ref;
$l++;
next REF;
}elsif(/OS: /){ # Something else, call it network
$PR[$r] = $ref;
$r++;
next REF;
}
if(/135\/o/){
$PCW[$w] = $ref;
$w++;
next REF;
}elsif( (/22\/c.+23\/c.+80\/o.+135\/c/) or (/22\/c.+23\/o.+80\/c.+135\/c/) or (/22\/c.+23\/o.+80\/o.+135\/c/) or (/22\/o.+23\/o/) ){
$PR[$r] = $ref;
$r++;
next REF;
}elsif(/(22\/f.+23\/f.+80\/f.+135\/c|22\/c.+23\/c.+80\/c.+135\/c)/){
$PH[$j] = $ref;
$j++;
next REF;
}elsif(/(22\/f.+23\/f.+80\/f.+135\/f)/){
$PF[$f] = $ref;
$f++;
next REF;
}else{
$PCL[$l] = $ref;
$l++;
next REF;
}
}
}
}
#Display results
print "\n" if $xml;
print CACHE "\n" if $xml;
&_print(\@PCW, 'WINDOWS COMPUTERS');
&_print(\@PCL, 'LINUX COMPUTERS');
&_print(\@PCM, 'MAC COMPUTERS');
&_print(\@PR, 'NETWORK DEVICES');
&_print(\@PF, 'FILTERED HOSTS');
&_print(\@PH, 'PHANTOM HOSTS');
print "\n" if $xml;
print CACHE "\n" if $xml;
}
}
##################
#DISLAY SUBROUTINE
##################
#
sub _print{
my $ref = shift;
my $lib = shift;
if(@$ref){
my $nb;
unless($xml){
print "#" for(0..(length($lib)+3));
print "\n";
print "# ".$lib." #";
print "\n";
print "#" for(0..(length($lib)+3));
print "\n";
print "#----------------------------------------------------------------------------\n";
printf("#%-20s %-20s %-25s %s\n", "IP address", "MAC address", "DNS/Netbios", "Date");
print "#----------------------------------------------------------------------------\n#\n";
}
$nb = 0;
my $output;
%xml = undef;
for(@$ref){
$$_[3] = &_smbname($$_[1]) if $$_[3] eq "-";
if($xml){
$xml{'IP'} = [ $$_[1] ];
$xml{'MAC'} = [ $$_[0] ];
$xml{'NAME'} = [ $$_[3] ];
$xml{'DATE'} = [ $$_[2] ];
$xml{'TYPE'} = ['WINDOWS'] if $lib =~/windows/i;
$xml{'TYPE'} = ['LINUX'] if $lib =~/linux/i;
$xml{'TYPE'} = ['MAC'] if $lib =~/mac/i;
$xml{'TYPE'} = ['FILTERED'] if $lib =~/filtered/i;
$xml{'TYPE'} = ['NETWORK'] if $lib =~/network/i;
$xml{'TYPE'} = ['PHANTOM'] if $lib =~/phantom/i;
$output=XML::Simple::XMLout( \%xml, RootName => 'HOST', SuppressEmpty => undef);
print $output;
print CACHE $output if $cache;
}else{
printf("#-> %-15s %-20s %-20s %s\n",$$_[1],$$_[0],$$_[3],$$_[2]);
$nb++;
}
}
unless($xml){
print "#\n#==========> $nb host(s)\n#\n\n\n";
}
}
}
#
#########################################
#ROUTINE DE RECUPERATION DES NOMS NETBIOS
#########################################
#
sub _smbname{
my $flag = 0;
my $name;
my $ip = shift;
#If no dns name, we try a netbios resolution
my @smb = `nmblookup -A $ip`;
#On cherche un enregistrment <00> pour l'ip passee en argument
for(@smb){
$name = "-";
/Looking\D+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/ unless $flag;
if(/<00>/){
/^\s+(\S+)/;
$name = $1;
return $name;
}
}
return "-";
}
##############
#CLEAN *.gnmap
##############
#
sub _cleanup{
my($name, @files);
opendir DIR, $path;
while($name = readdir DIR){
push @files, $name if $name=~/\.gnmap$/i;
}
closedir DIR;
for(@files){
open FILE, $_ or next;
unlink "$path/$_" if(flock(FILE, LOCK_EX|LOCK_NB));
}
}
print "|\n|\n---------------------------------------------\n|" unless $xml;
if($list){
print "\n|--> TOTAL = $total valid (ips/netmask) in the database\n" unless $xml;
exit(0);
}
unless($xml){
print "\n|--> TOTAL = $total unknown hosts\n";
print "\n|--> WARNING: $null discovered computers without netmask on all discovered machine\n\n" if $null;
}
#Try to get dns name
sub _getdns{
my $ip = shift;
my $name;
chomp(my @names = `host $ip 2>/dev/null`);
for(@names){
return $1 if /.+pointer (.+)/i;
return $1 if /Name:\s*(\S+)/i;
}
return("-");
}
#Retrieve the name of the subnet if available
sub _getnetname{
my $network = shift;
my $r = shift;
for(@subnet){
if($_->[0] eq $network){
return ($_->[1], $_->[2]);
last;
}
}
return($r, $r);
}
#To retrieve the net ip
sub _network{
my $ip = shift;
my $netmask = shift;
my $binip = &ip_iptobin($ip, 4);
my $binmask = &ip_iptobin($netmask, 4);
my $subnet = $binip & $binmask;
return(&ip_bintoip($subnet, 4)) or die(Error());
}
sub _bintoascii{
my $binmask = shift;
my $binstring = "1" x $binmask;
$binstring .= "0" for(1..(32 - $binmask));
return(&ip_bintoip($binstring, 4)) or die(Error());
}
sub _binmask{
my $ip = shift;
return(&ip_iptobin($ip, 4)) or die(Error());
}
OCSInventory-Server-2.8.1/binutils/ocs-errors 0000664 0000000 0000000 00000006466 13764364732 0021235 0 ustar 00root root 0000000 0000000 ################################################################################
#
# OCS Inventory NG Management Server Setup
#
# Copyleft 2008 OCS Inventory NG Team
# Web: http://www.ocsinventory-ng.org
#
# This code is open source and may be copied and modified as long as the source
# code is always made freely available.
# Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
################################################################################
OCS Inventory NG logs format
--> GDH;Process ID;Event code;DeviceID;IP address;User agent;Phase;(comment)
Codes elements :
ERRORS
------
500--Query forbidden
502--Invalid device ID or hostname
503--Impossible to get a key from the config table
504--Impossible to get the last date inventory
505--Impossible to connect to database
506--Inflation problem
507--XML Parsing error
508--Update message unreadeable
509--Impossible to get the account infos
510--Bad content-type
511--File does not exist
512--Malformed request
513--Bad old deviceid
514--synchronisation problem
515--Script error, rollback transaction.
516--Deviceid locked
517--Cannot handle normal duplicate
518--Cannot retrieve database id
519--A device try to add a new computer whereas it is forbidden by filter inventory rules
520--The request for the group is not valid
521--Invalid database connection mode
522--Inventory Cache handling error (Creation)
523--Inventory Cache handling error (Truncate)
524--No checksum
525--Cannot reuse session
526--Error while checking session
527--Cannot end session (DB Fault)
528--No account infos sent
529--Unknown notify type
530--Cannot update ip address (notify handler)
INVENTORY
---------
100--Inventory accepted
101--Inventory succeed
102--Inventory refused
103--New machine(deviceid)
104--Inventory incoming
105--Inventory refused but other task required
106--Prolog stopped by module
107--Inventory stopped by module
108--Cleaning inventory cache
109--Inventory cache handling success
110--Inventory cache out of date
111--Inventory cache already handled (lock fault)
112--Inventory cache updated
113--Inventory section has changed => write it
114--No prolog connection found
115--Inventory refused (no session)
MANAGEMENT
----------
300--Device replaced
301--Device can be duplicated
302--File transmitted (deploy)
304--Deploy off
305--Files transmitted
306--Group out-of-date
307--Revalidate group cache
308--Group is locked by another process
309--Group cache update problem
310--Trusted computer
311--Session started(prolog)
314--Checking expired sessions
315--Checking is already handled by another process (skipping)
316--Found old sessions (according to OCS_OPT_SESSION_CLEAN_TIME)
317--Session validity undefined : check always succeed
318--Session not found
319--Valid session found
320--End of session
321--Compression used is not zlib
322--Notify event
323--Update ipaddress for device (Notify)
324--No such mac address (notify) New iface ?
325--The computer does not exist
326--A old deviceid is present
IPDISCOVER
----------
1001--Ipdiscover enabled
1002--Ipdiscover disabled
1003--Ipdiscover report error
1004--Ipdiscover incoming
1005--Ipdiscover conflict with group exception
DOWNLOAD
--------
2500--Impossible to get config
2501--Message refers to an unexisting package
2502--Cannot retrieve package history (db error)
2001--Download agent event incoming
OCSInventory-Server-2.8.1/binutils/ocsinventory-injector.README 0000664 0000000 0000000 00000001720 13764364732 0024434 0 ustar 00root root 0000000 0000000 ################################################################################
#
# OCS Inventory NG Management Server Setup
#
# Copyleft 2008 OCS Inventory NG Team
# Web: http://www.ocsinventory-ng.org
#
# This code is open source and may be copied and modified as long as the source
# code is always made freely available.
# Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
################################################################################
ocsinventory-injector.pl is a script designed to send inventory to an OCS server
using .ocs files generated by -local (or /local for windows).
Since 1.02 release, you can use the OCS_OPT_GENERATE_OCS_FILES server parameter
to automatically generate these files to "inject" it to a higher level server.
(in case of multi entity configuration for example).
In that case, you can use a cron if the two servers are connected, or put it
on the higher level server and run it on loopback.
OCSInventory-Server-2.8.1/binutils/ocsinventory-injector.pl 0000775 0000000 0000000 00000010175 13764364732 0024121 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl -w
###############################################################################
##OCS inventory-NG Version 1.02
##Copyleft Pascal DANEK 2005
##Copyleft Goneri Le Bouder 2006
##Web : http://www.ocsinventory-ng.org
##
##This code is open source and may be copied and modified as long as the source
##code is always made freely available.
##Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
################################################################################
#Last modification : $Id: ocsinventory-injector.pl,v 1.3 2008-02-18 07:17:52 hunal Exp $
#Local insertion script
use Fcntl qw/:flock/;
use LWP::UserAgent;
use XML::Simple;
use Compress::Zlib;
use Getopt::Long;
use constant VERSION => 3;
use strict;
my $help;
my $directory;
my $file;
my $url;
my $sslmode;
my $cafile;
my $useragent;
my $remove;
my $verbose;
my $stdin;
my $timeout;
sub loadfile {
$file = shift;
unless ( -r $file ) {
print STDERR "Can't read $file\n";
return;
}
print "Loading $file..." if $verbose;
unless ( open( FILE, "$file" ) && flock( FILE, LOCK_EX | LOCK_NB ) ) {
print STDERR "Failed to access $file : $!";
return;
}
local $/;
my $content = ;
close FILE or die "Can't close file $file: $!";
sendContent($content);
}
sub loaddirectory {
my $directory = shift;
unless ( -r $directory ) {
print STDERR "Can't read $directory: $!\n";
return;
}
opendir( DIR, $directory ) || die "can't opendir $directory: $!";
foreach ( readdir(DIR) ) {
loadfile("$directory/$_") if (/\.ocs$/);
}
closedir DIR;
}
sub loadstdin {
my $content;
undef $/;
$content = ;
sendContent($content);
}
sub sendContent {
my $content = shift;
my $ua = LWP::UserAgent->new(
protocols_allowed => ['http', 'https'],
timeout => $timeout,
ssl_opts => {
verify_hostname => $sslmode,
SSL_ca_file => $cafile
},
);
$ua->agent($useragent);
my $request = HTTP::Request->new( POST => $url );
$request->header(
'Pragma' => 'no-cache',
'Content-type', 'Application/x-compress'
);
$request->content("$content");
my $res = $ua->request($request);
if($res->is_success){
print "OK\n" if $verbose;
print STDERR "Can't remove $file: $!\n"
if ($remove && (!unlink $file));
}else{
if($verbose){
print "ERROR: ";
print $res->status_line(), "\n";
}
}
}
sub usage {
print < \$help,
'd|directory=s' => \$directory,
'f|file=s' => \$file,
'u|url=s' => \$url,
'sslmode=s' => \$sslmode,
'cafile=s' => \$cafile,
'useragent=s' => \$useragent,
'r|remove' => \$remove,
'v|verbose' => \$verbose,
't|timeout' => \$timeout,
'stdin' => \$stdin,
);
# Default values
$url = 'http://localhost/ocsinventory' unless $url;
$useragent = 'OCS-NG_INJECTOR_PL_v'.VERSION unless $useragent;
$directory = '.' unless $directory;
$sslmode = 0 unless $sslmode;
$cafile = "cacert.pem" unless $cafile;
$timeout = 10 unless $timeout;
###
$|=1;
if ($file && -f $file) {
loadfile($file);
}
elsif ($stdin) {
loadstdin();
}
elsif($help){
usage();
}
else{
if ($directory && -d $directory) {
loaddirectory($directory);
}
else{
die("Directory does not exist. Abort.");
}
}
OCSInventory-Server-2.8.1/binutils/ocsinventory-log.README 0000664 0000000 0000000 00000002147 13764364732 0023404 0 ustar 00root root 0000000 0000000 ################################################################################
#
# OCS Inventory NG Management Server Setup
#
# Copyleft 2008 OCS Inventory NG Team
# Web: http://www.ocsinventory-ng.org
#
# This code is open source and may be copied and modified as long as the source
# code is always made freely available.
# Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
################################################################################
ocsinventory-log.pl is a sample that enables you to see your ocs server's
activity.
You have to rotate your logs daily at 00:00, using the "compressed" option to
have a day level visibility (use the provided logrotate)
This kind of scripts may help you to adjust server's settings, especially
FREQUENCY and PROLOG_FREQ parameter.
Theses are the supported parameters :
-f='log file' The log file to read
-a=day_before Look for a 'log_file_name.gz' according to logrotate naming system
-r Summary per hour of the activity
-s General summary for the day
-h="hour_num" See a specific hour
=> -m in minutes
=> -d group by ten minutes
OCSInventory-Server-2.8.1/binutils/ocsinventory-log.pl 0000775 0000000 0000000 00000010366 13764364732 0023067 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl -s
$f = $f || '/var/log/ocsinventory-server/activity.log';
unless($a){
$a = 0;
@lines = `cat $f`;
}
else{
@lines = `$f.$a.gz`;
}
push @heures, sprintf("%02i",$_) for(0..23);
push @minutes, sprintf("%02i",$_) for(0..59);
@lines = grep { /^[^;]+;[^;]+;[^;]+;[^;]+;[^;]+$v;[^;]+;[^;]+$/i } @lines if defined($v);
@prologs = grep { /;(?:102|100);/i } @lines;
@accepts = grep { /;100;/i } @lines;
@incomings = grep { /;104;/i } @lines;
@arrived = grep { /;101;/i } @lines;
@errors = grep { /;515;/i } @lines;
@agents = grep { /deploy.+transmitted/i } @lines;
@new = grep { /;103;/i } @lines;
@dup = grep { /;300;/i } @lines;
@gr_nv = grep { /;306;/i } @lines;
@gr_rv = grep { /;307;/i } @lines;
print "\n\nSynthese - ",scalar(localtime())," - $a jours\n\n",
"Prologs: ", scalar(@prologs),"\n",
"Accepted: ", scalar(@accepts),"\n",
"New: ", scalar(@new),"\n",
"Incomings: ", scalar(@incomings),"\n",
"Auto duplicates: ", scalar(@dup),"\n",
"Transmitted: ", scalar(@arrived),"\n",
"Errors: ", scalar(@errors),"\n",
"Groups out-of-date: ",scalar(@gr_nv),"\n",
"Groups revalidated: ",scalar(@gr_nv),"\n",
"Déploiement: ", scalar(@agents),"\n\n" if $s;
per_hour() if $r;
if(defined($h)){
per_deca("$h") if $d;
per_minutes("$h") if $m;
}
sub per_hour
{
print "\n\nRecapitulatif par heure - ",scalar(localtime())," - $a jours\n\n";
print "\t\t\tPrologs\t\tAccepted\tIncomings\tNew\t\tDuplicates\tTransmitted\tErrors\tgr:ood\t:gr:reval\t\tDeployed\n";
for $heure (@heures){
print "$heure heures :\t";
print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @prologs),"\t";
print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @accepts),"\t";
print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @incomings),"\t";
print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @new),"\t";
print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @dup),"\t";
print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @arrived),"\t";
print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @errors),"\t";
print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @gr_nv),"\t";
print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @gr_rv),"\t";
print "\t",scalar(grep { /$heure(?::\d\d){2}/ } @agents),"\n";
}
}
sub per_minutes
{
$heure = shift;
$heure = sprintf("%02i",$heure);
print scalar(localtime()),"\n\n";
print "\n\nRecapitulatif minute par minute pour $heure heures - ",scalar(localtime())," - $ai jours\n\n";
print "\t\t\t\tPrologs\t\tAccepted\tIncomings\tNew\t\tDuplicates\tTransmitted\tErrors\tgr:ood\t:gr:reval\t\tDeployed\n";
for $minute (@minutes){
print "$heure heure $minute minutes :\t";
print "\t",scalar(grep { /$heure:$minute:\d\d/ } @prologs),"\t";
print "\t",scalar(grep { /$heure:$minute:\d\d/ } @accepts),"\t";
print "\t",scalar(grep { /$heure:$minute:\d\d/ } @incomings),"\t";
print "\t",scalar(grep { /$heure:$minute:\d\d/ } @new),"\t";
print "\t",scalar(grep { /$heure:$minute:\d\d/ } @dup),"\t";
print "\t",scalar(grep { /$heure:$minute:\d\d/ } @arrived),"\t";
print "\t",scalar(grep { /$heure:$minute:\d\d/ } @errors),"\t";
print "\t",scalar(grep { /$heure:$minute:\d\d/ } @gr_nv),"\t";
print "\t",scalar(grep { /$heure:$minute:\d\d/ } @gr_rv),"\t";
print "\t",scalar(grep { /$heure:$minute:\d\d/ } @agents),"\n";
}
}
sub per_deca
{
$heure = shift;
@deca = (0..5);
print scalar(localtime()),"\n\n";
print "\n\nRecapitulatif par dix minutes pour $heure heures - ",scalar(localtime())," - $a jours\n\n";
print "\t\t\t\tPrologs\t\tAccepted\tIncomings\tNew\t\tDuplicates\tTransmitted\tErrors\tgr:ood\t:gr:reval\t\tDeployed\n";
for $minute (@deca){
print "$heure heure ($minute*10) :\t";
print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @prologs),"\t";
print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @accepts),"\t";
print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @incomings),"\t";
print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @new),"\t";
print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @dup),"\t";
print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @arrived),"\t";
print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @errors),"\t";
print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @gr_nv),"\t";
print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @gr_rv),"\t";
print "\t",scalar(grep { /$heure:$minute\d:\d\d/ } @agents),"\n";
}
}
OCSInventory-Server-2.8.1/binutils/ocsinventory-powershell-injector.ps1 0000664 0000000 0000000 00000012574 13764364732 0026375 0 ustar 00root root 0000000 0000000 <#
Copyright 2005-2020 OCSInventory-NG/OCSInventory-server contributors.
See the Contributors file for more details about them.
This file is part of OCSInventory-NG/OCSInventory-server.
OCSInventory-NG/OCSInventory-server 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.
OCSInventory-NG/OCSInventory-server 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.
You should have received a copy of the GNU General Public License
along with OCSInventory-NG/OCSInventory-server. if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
#>
param (
[switch]$help = $false,
[string]$directory,
[string]$file,
[string]$url,
[string]$user,
[string]$pass,
[switch]$ssl = $false,
[switch]$remove = $false,
[switch]$info = $false
)
<#
.SYNOPSIS
Display help
.DESCRIPTION
If -help is set in the command line, return the helper and quit
#>
function Get-InjectorHelper {
Write-Output "
DESCRIPTION:
A command line tools to import .ocs files.
USAGE:
-help : this menu
-directory : load every .ocs files from a directory
-file : load a speficic file
-url : ocsinventory backend URL
-ssl : enable SSL inventory injection
-user : Basic auth username
-pass : User password
-remove : remove successfully injected files
-info : verbose mode
"
}
<#
.SYNOPSIS
Display debug log
.DESCRIPTION
Display debug log only if -info is sent
#>
function Write-InfoLog($str) {
if($info.IsPresent){
$currentTime = Get-Date -Format "MM/dd/yyyy HH:mm:ss"
Write-Output "[OCSInject] $currentTime : $str"
}
}
<#
.SYNOPSIS
Send file to OCS Server
.DESCRIPTION
Take the file, retrieve its content and send it to the OCS Inventory server
#>
function Send-File{
Param(
[parameter(Mandatory=$true)]
[string] $filePath,
[parameter(Mandatory=$true)]
[hashtable] $headers
)
$fileContent = Get-Content($filePath)
$fileName = Split-Path $filePath -leaf
if($ssl.IsPresent -eq $true){
add-type "
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Ssl3, [Net.SecurityProtocolType]::Tls, [Net.SecurityProtocolType]::Tls11, [Net.SecurityProtocolType]::Tls12
$webRequestStatus = Invoke-WebRequest `
-Uri $url `
-ContentType "application/xml" `
-Method POST `
-Body $fileContent `
-UserAgent "OCS_POWERSHELL_INJECTOR_V2.8" `
-Headers $headers
}else{
$webRequestStatus = Invoke-WebRequest `
-Uri $url `
-ContentType "application/xml" `
-Method POST `
-Body $fileContent `
-UserAgent "OCS_POWERSHELL_INJECTOR_V2.8" `
-Headers $headers
}
if($webRequestStatus.StatusCode -eq 200){
Write-InfoLog("Injecting file $fileName => OK")
}else{
Write-InfoLog("Injecting file $fileName => ERROR " + $webRequestStatus.StatusCode)
}
}
Write-InfoLog("Starting injector")
#### Help trigger ####
if($help.IsPresent){
Get-InjectorHelper
Exit
}
#### Test for basic parameters ####
if($url.isPresent -eq $false){
Write-InfoLog("URL Missing, please provide one !")
Exit
}
# Manage Auth
if(-not ([string]::IsNullOrEmpty($user)) -And -not ([string]::IsNullOrEmpty($pass))){
Write-InfoLog("Auth required, setting headers...")
$pair = "$($user):$($pass)"
$encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
$basicAuthValue = "Basic $encodedCreds"
Write-InfoLog("Auth basic : $encodedCreds")
$headers = @{
"Authorization" = $basicAuthValue; "Cache-Control" = "no-cache"
}
}else{
$headers = @{
"Cache-Control" = "no-cache"
}
}
$pathOk = $false
# File inject management
if($file -And (Test-Path -Path $file) -eq $true){
$pathOk = $true
Send-File $file $headers
Exit
}
# Directory inject management
if ($directory -And (Test-Path -Path $directory) -eq $true) {
Write-InfoLog("Injecting files present in the directory=> $directory")
Get-ChildItem $directory -Filter *.ocs |
Foreach-Object {
Send-File $_.FullName $headers
}
$pathOk = $true
Exit
}
# Path not working
if($pathOk -eq $false){
Write-InfoLog("File or Directory provided is wrong or not accessible, please check your arguments")
Exit
}
OCSInventory-Server-2.8.1/binutils/soap-client.README 0000664 0000000 0000000 00000013736 13764364732 0022307 0 ustar 00root root 0000000 0000000 ################################################################################
#
# OCS Inventory NG Management Server Setup
#
# Copyleft 2008 OCS Inventory NG Team
# Web: http://www.ocsinventory-ng.org
#
# This code is open source and may be copied and modified as long as the source
# code is always made freely available.
# Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
################################################################################
soap-client is a sample that enable you to discover the ocs web service.
By default, it calls get_computer_V1 method that takes XML as argument.
You can configure this XML using script parameters.
To use other methods, (see Apache::Ocsinventory::Interface) , call it with
-f=method_name and -params='comma separated args'
# Parameters
# -s='' : server to query
# -u='' : user to authenticate
# -pw='' : user's password
# -params='...,...,...,...' : Method's args
# -proto='http|https' : Transport protocol
#
# get_computers V1 secific parameters (enable you to easily modify XML values)
# -o='' : offset value (to iterate if whome result is upper than OCS_OPT_WEB_SERVICE_RESULTS_LIMIT (see ocsinventory-server.conf)
# -c='' : checksum to compare with
# -w='' : same principle than checksum but for other sections (dico_soft and accountinfos for the moment)
# -t='' : type (META || INVENTORY)) See web service documentation
In addition to CHECKSUM (&), you can also request on :
=> userid list
=> tag list
=> database id list.
You can use these criteria in only one request, and you can put few values for each.
For example:
FIRST <= The name of the search engine (only this one is implemented for the moment)
INVENTORY <= We want inventory date (opposite to META DATA)
1 <= We want only hardware section (if it changed since our last reset_checksum) See below.
3 <= We want the third page of the result
2 <= We want to use the software dictionary and the accountinfos
foo <= We want the computers on those foo logged in
bar <= ...where bar logged in
room109 <= We want the computer which have the "room109 tag"
room110 <= ...or the "room110" tag
spare <= ...or th "spare" tag
35 <= Only the DATABASE ID 35
36 <= ...or 36
LASTDATE <= We want to sort by LASTDATE (defaults to ID), allowed values: ID,LASTDATE,LASTCOME
DESC <= We want to sort DESC (defaults to ASC), allowed values: ASC,DESC
SOAP methods available :
Name : get_computers_V1
Args : XML string
Returns : XML
Description : Main function to deal with ocsinventory computer's data (see above)
Name : reset_checksum_V1
Args : a checksum, a list of Databases IDs
Returns : undef on system error, "0E0" if no computers matched or the number of computers on success
Description : The checksum is a bitmap used to know which inventory section has changed since last come. See Apache::Ocsinventory::Map to know the different values. For example, "hardware" section is the first bit (1). if 1 & checksum are true, you know that hardware changed since the last check.
Name : ocs_config_V1
Args : option name, value
Returns : value (if ok, ==value arg) or XML error (LABEL)
Description : Configure ocs with an external tool
Name : ocs_config_V2
Args : option name, integer value, string value
Returns : XML. In case of success : , in case of error, the same as above.
Description : Handle the new ocs config system (see Apache::Ocsinventory::Server::System::Config)
Name : get_dico_soft_element_V1
Args : a word to look for
Returns : The "formatted" name (also known as category)
Description : Get the ditionnary entry of an extracted software name
Name : get_history_V1
Args : page number
Returns : XML. AAAA-MM-DD HH:MM:SSDEVICEIDDEVICEID ordered by date.
Description : useful to know which computers has been deleted or merges (duplicates). If a "DELETED" has no "EQUIVALENT", it is a deletion.
# Clear computer's history
Name : clear_history_V1
Args : A number of events (the former)
Returns : The number of events deleted
Description : Clear computer's history
Name : get_ipdiscover_devices_V1
Args : Date, Page, ninv flag
Returns : XML. On error : LABEL, on success AAAA-MM-DD HH:MM:SSIPADDRESSMACADDRESSIPMASKhostname......
Description : Enable you to query ipdiscover results. The nInv flags ask to the method to only send the uninventories devices
Name : ipdiscover_tag_V1
Args : macaddress, description, type, user
Returns : XML
Description : Register a macaddress as you can do in GUI. The type and the user must be valid in ocs database.
Name : ipdiscover_untag_V1
Args : macaddress
Returns : XML
Description : Unregister a device
Name : ipdiscover_remove_V1
Args : macaddress
Returns : XML
Description : Delete a device from ipdiscover results
Name : ipdiscover_create_type_V1
Args : type name
Returns : XML
Description : Enable you to create a type remotely
Name : ipdiscover_delete_type_V1
Args : type name
Returns : XML
Description : Remove a type
For further details, see http://www.ocsinventory-ng.org/index.php?mact=News,cntnt01,detail,0&cntnt01articleid=98&cntnt01returnid=80
OCSInventory-Server-2.8.1/binutils/soap-client.pl 0000775 0000000 0000000 00000004312 13764364732 0021756 0 ustar 00root root 0000000 0000000 #!/usr/bin/perl -s
use SOAP::Lite;
use XML::Entities;
# Parameters
# -s='' : server to query
# -u='' : user to authenticate
# -pw='' : user's password
# -params='...,...,...,...' : Method's args
# -proto='http|https' : Transport protocol
#
# get_computers V1 secific parameters (enable you to easily modify XML values)
# -o='' : offset value (to iterate if whome result is upper than OCS_OPT_WEB_SERVICE_RESULTS_LIMIT (see ocsinventory-server.conf)
# -c='' : checksum to compare with
# -w='' : same principle than checksum but for other sections (dico_soft and accountinfos for the moment)
# -t='' : type (META || INVENTORY)) See web service documentation
#
# Checksum decimal values
#'hardware' => 1,
#'bios' => 2,
#'memories' => 4,
#'slots' => 8,
#'registry' => 16,
#'controllers' => 32,
#'monitors' => 64,
#'ports' => 128,
#'storages' => 256,
#'drives' => 512,
#'inputs' => 1024,
#'modems' => 2048,
#'networks' => 4096,
#'printers' => 8192,
#'sounds' => 16384,
#'videos' => 32768,
#'softwares' => 65536
$s = $s||'localhost';
$u = $u||'';
$pw = $pw||'';
$proto = $proto||'http';
@params = split ',', $params;
$f = $f||get_computers_V1;
# You can modify some XML tags
$c = $c||131071;
$t=$t||"META";
$o=$o||0;
$w=defined $w?$w:131071;
if( !defined(@params) && $f eq 'get_computers_V1' ){
@params=(<
FIRST
$t
$c
$o
$w
EOF
}
print "Launching soap request to proxy:\n";
print "$proto://$u".($u?':':'').($u?"$pw\@":'')."$s/ocsinterface\n";
print "Function: <$f>\n";
$i++, print "Function Arg $i: `$_'\n" for @params;
print "\nIn progress... \n\n";
$lite = SOAP::Lite
->uri("$proto://$s/Apache/Ocsinventory/Interface")
->proxy("$proto://$u".($u?':':'').($u?"$pw\@":'')."$s/ocsinterface\n")
->$f(@params);
if($lite->fault){
print "ERROR:\n\n",XML::Entities::decode( 'all', $lite->fault->{faultstring} ),"\nEND\n\n";
}
else{
my $i = 0;
for( $lite->paramsall ){
print "===== RESULT $i ===== \n".XML::Entities::decode( 'all', $_ )."\n";
$i++;
}
}
OCSInventory-Server-2.8.1/cpanfile 0000664 0000000 0000000 00000000660 13764364732 0017055 0 ustar 00root root 0000000 0000000 #requires 'mod_perl2', '> 2.0';
requires 'XML::Simple', '>= 2.12';
requires 'Compress::Zlib', '>= 1.33';
requires 'Apache::DBI', '>= 1.10';
#requires 'DBD::mysql', '>= 4.050';
requires 'Net::IP', '>= 1.20';
requires 'Mojolicious', '>= 8';
requires 'Plack', '>= 1.0047';
requires 'Archive::Zip', '>= 1.4';
requires 'Switch', '>= 2.0';
requires 'YAML', '>= 1.0'; OCSInventory-Server-2.8.1/dtd/ 0000775 0000000 0000000 00000000000 13764364732 0016122 5 ustar 00root root 0000000 0000000 OCSInventory-Server-2.8.1/dtd/Interface/ 0000775 0000000 0000000 00000000000 13764364732 0020022 5 ustar 00root root 0000000 0000000 OCSInventory-Server-2.8.1/dtd/Interface/get_computers_V1-request.dtd 0000664 0000000 0000000 00000000304 13764364732 0025430 0 ustar 00root root 0000000 0000000
OCSInventory-Server-2.8.1/dtd/download_request.dtd 0000664 0000000 0000000 00000000312 13764364732 0022172 0 ustar 00root root 0000000 0000000
OCSInventory-Server-2.8.1/dtd/file_request.dtd 0000664 0000000 0000000 00000000304 13764364732 0021303 0 ustar 00root root 0000000 0000000
OCSInventory-Server-2.8.1/dtd/inventory_reply.dtd 0000664 0000000 0000000 00000000326 13764364732 0022070 0 ustar 00root root 0000000 0000000
OCSInventory-Server-2.8.1/dtd/inventory_request.dtd 0000664 0000000 0000000 00000012745 13764364732 0022435 0 ustar 00root root 0000000 0000000
OCSInventory-Server-2.8.1/dtd/prolog_reply.dtd 0000664 0000000 0000000 00000001521 13764364732 0021333 0 ustar 00root root 0000000 0000000
OCSInventory-Server-2.8.1/dtd/prolog_request.dtd 0000664 0000000 0000000 00000000210 13764364732 0021662 0 ustar 00root root 0000000 0000000
OCSInventory-Server-2.8.1/dtd/snmp_request.dtd 0000664 0000000 0000000 00000006341 13764364732 0021350 0 ustar 00root root 0000000 0000000
OCSInventory-Server-2.8.1/dtd/update_reply.dtd 0000664 0000000 0000000 00000000237 13764364732 0021316 0 ustar 00root root 0000000 0000000
OCSInventory-Server-2.8.1/dtd/update_request.dtd 0000664 0000000 0000000 00000000277 13764364732 0021657 0 ustar 00root root 0000000 0000000
OCSInventory-Server-2.8.1/etc/ 0000775 0000000 0000000 00000000000 13764364732 0016122 5 ustar 00root root 0000000 0000000 OCSInventory-Server-2.8.1/etc/logrotate.d/ 0000775 0000000 0000000 00000000000 13764364732 0020344 5 ustar 00root root 0000000 0000000 OCSInventory-Server-2.8.1/etc/logrotate.d/ocsinventory-server 0000664 0000000 0000000 00000000271 13764364732 0024335 0 ustar 00root root 0000000 0000000 # Rotate OCS Inventory NG Communication server logs daily
# Save 7 days old logs in compressed mode
PATH_TO_LOG_DIRECTORY/*.log {
daily
rotate 7
compress
delaycompress
missingok
}
OCSInventory-Server-2.8.1/etc/ocsinventory/ 0000775 0000000 0000000 00000000000 13764364732 0020664 5 ustar 00root root 0000000 0000000 OCSInventory-Server-2.8.1/etc/ocsinventory/ocsinventory-reports.conf 0000664 0000000 0000000 00000007747 13764364732 0026010 0 ustar 00root root 0000000 0000000 ################################################################################
#
# OCS Inventory NG Administration Server
#
# Copyleft 2008 OCS Inventory NG Team
# Web: http://www.ocsinventory-ng.org
#
# This code is open source and may be copied and modified as long as the source
# code is always made freely available.
# Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
################################################################################
#
# ANY CHANGE ON THIS FILE REQUIRES APACHE RESTART TO TAKE EFFECT
#
################################################################################
# Administration console public pages
#
# Alias used to put Administration Server static page (typically PHP) outside
# Apache document root directory
#
Alias OCSREPORTS_ALIAS PATH_TO_OCSREPORTS_DIR
# By default, users can use console from everywhere
# Apache 2.4
Require all granted
Order deny,allow
Allow from all
Options Indexes FollowSymLinks
DirectoryIndex index.php
AllowOverride Options AuthConfig
# Uncomment following to force use of HTTPS in Administration Server
#SSLRequireSSL
# PHP tuning (not working on all distribution, use php.ini instead)
AddType application/x-httpd-php .php
php_flag file_uploads on
# Some PHP tuning for deployment feature up to 8 MB
# post_max_size must be greater than upload_max_filesize
# because of HTTP headers
php_value post_max_size 101m
php_value upload_max_filesize 100m
# You may have to uncomment following on errors
#php_value max_execution_time -1
#php_value max_input_time -1
# Uncomment following if you need to specify a mysql socket
#php_value mysql.default_socket "path/to/mysql/unix/socket"
#!! Mandatory !! : set magic_quotes_gpc to off (to make ocsreports works correctly)
php_flag magic_quotes_gpc off
# Duplicate for php7 compatibility
AddType application/x-httpd-php .php
php_flag file_uploads on
# Some PHP tuning for deployment feature up to 8 MB
# post_max_size must be greater than upload_max_filesize
# because of HTTP headers
php_value post_max_size 101m
php_value upload_max_filesize 100m
# You may have to uncomment following on errors
#php_value max_execution_time -1
#php_value max_input_time -1
# Uncomment following if you need to specify a mysql socket
#php_value mysql.default_socket "path/to/mysql/unix/socket"
#!! Mandatory !! : set magic_quotes_gpc to off (to make ocsreports works correctly)
php_flag magic_quotes_gpc off
# Uncomment following to allow HTTP body request up to 4 MB
# instead default 512 KB
#LimitRequestBody 4194304
################################################################################
# Deployment packages download area
#
# Alias to put Deployment package files outside Apache document root directory
#
# Apache 2.4
Require all granted
Order deny,allow
Allow from all
Alias PACKAGES_ALIAS PATH_TO_PACKAGES_DIR
################################################################################
# Snmp communities area
#
# Alias to put Snmp custom Mibs files outside Apache document root directory
#
# Apache 2.4
Require all granted
Order deny,allow
Allow from all
Alias SNMP_ALIAS PATH_TO_SNMP_DIR
OCSInventory-Server-2.8.1/etc/ocsinventory/ocsinventory-restapi.conf 0000664 0000000 0000000 00000001171 13764364732 0025742 0 ustar 00root root 0000000 0000000 PerlOptions +Parent
$ENV{PLACK_ENV} = 'production';
$ENV{MOJO_HOME} = 'REST_API_PATH';
$ENV{MOJO_MODE} = 'deployment';
$ENV{OCS_DB_HOST} = 'localhost';
$ENV{OCS_DB_PORT} = '3306';
$ENV{OCS_DB_LOCAL} = 'ocsweb';
$ENV{OCS_DB_USER} = 'ocs';
$ENV{OCS_DB_PWD} = 'ocs';
$ENV{OCS_DB_SSL_ENABLED} = 0;
# $ENV{OCS_DB_SSL_CLIENT_KEY} = '';
# $ENV{OCS_DB_SSL_CLIENT_CERT} = '';
# $ENV{OCS_DB_SSL_CA_CERT} = '';
$ENV{OCS_DB_SSL_MODE} = 'SSL_MODE_PREFERRED';
SetHandler perl-script
PerlResponseHandler Plack::Handler::Apache2
PerlSetVar psgi_app 'REST_API_LOADER_PATH'
OCSInventory-Server-2.8.1/etc/ocsinventory/ocsinventory-server.conf 0000664 0000000 0000000 00000033644 13764364732 0025613 0 ustar 00root root 0000000 0000000 ################################################################################
#
# OCS Inventory NG Communication Server Perl Module Setup
#
# Copyleft 2006 Pascal DANEK
# Web: http://www.ocsinventory-ng.org
#
# This code is open source and may be copied and modified as long as the source
# code is always made freely available.
# Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
################################################################################
# Which version of mod_perl we are using
# For mod_perl <= 1.999_21, replace VERSION_MP by 1
# For mod_perl > 1.999_21, replace VERSION_MP by 2
PerlSetEnv OCS_MODPERL_VERSION VERSION_MP
# Master Database settings
# Replace DATABASE_SERVER by hostname or ip of MySQL server for WRITE
PerlSetEnv OCS_DB_HOST DATABASE_SERVER
# Replace DATABASE_PORT by port where running MySQL server, generally 3306
PerlSetEnv OCS_DB_PORT DATABASE_PORT
# Name of database
PerlSetEnv OCS_DB_NAME ocsweb
PerlSetEnv OCS_DB_LOCAL ocsweb
# User allowed to connect to database
PerlSetEnv OCS_DB_USER ocs
# Password for user
PerlSetVar OCS_DB_PWD ocs
# SSL Configuration
# 0 to disable the SSL support for MySQL/MariaDB
# 1 to enable the SSL support for MySQL/MariaDB
PerlSetEnv OCS_DB_SSL_ENABLED 0
# PerlSetEnv OCS_DB_SSL_CLIENT_KEY /etc/ssl/private/client.key
# PerlSetEnv OCS_DB_SSL_CLIENT_CERT /etc/ssl/certs/client.crt
# PerlSetEnv OCS_DB_SSL_CA_CERT /etc/ssl/certs/ca.crt
# SSL Mode
# - SSL_MODE_PREFERRED (SSL enabled but optional)
# - SSL_MODE_REQUIRED (SSL enabled, mandatory but don't verify server certificate. Ex self signed cert)
# - SSL_MODE_STRICT (SSL enabled, mandatory and server cert must be trusted)
PerlSetEnv OCS_DB_SSL_MODE SSL_MODE_PREFERRED
#Â Slave Database settings
# Replace DATABASE_SERVER by hostname or ip of MySQL server for READ
# Useful if you handle mysql slave databases
# PerlSetEnv OCS_DB_SL_HOST DATABASE_SERVER
# Replace DATABASE_PORT by port where running MySQL server, generally 3306
# PerlSetEnv OCS_DB_SL_PORT_SLAVE DATABASE_PORT
# User allowed to connect to database
# PerlSetEnv OCS_DB_SL_USER ocs
# Name of the database
# PerlSetEnv OCS_DB_SL_NAME ocsweb
# Password for user
# PerlSetVar OCS_DB_SL_PWD ocs
# SSL Configuration for Slave database
# 0 to disable the SSL support for MySQL/MariaDB
# 1 to enable the SSL support for MySQL/MariaDB
# PerlSetEnv OCS_DB_SL_SSL_ENABLED 0
# PerlSetEnv OCS_DB_SL_SSL_CLIENT_KEY /etc/ssl/private/client.key
# PerlSetEnv OCS_DB_SL_SSL_CLIENT_CERT /etc/ssl/certs/client.crt
# PerlSetEnv OCS_DB_SL_SSL_CA_CERT /etc/ssl/certs/ca.crt
# SSL Mode
# - SSL_MODE_PREFERRED (SSL enabled but optional)
# - SSL_MODE_REQUIRED (SSL enabled, mandatory but don't verify server certificate. Ex self signed cert)
# - SSL_MODE_STRICT (SSL enabled, mandatory and server cert must be trusted)
# PerlSetEnv OCS_DB_SL_SSL_MODE SSL_MODE_PREFERRED
# Path to log directory (must be writeable)
PerlSetEnv OCS_OPT_LOGPATH "PATH_TO_LOG_DIRECTORY"
# If you need to specify a mysql socket that the client's built-in
#PerlSetEnv OCS_OPT_DBI_MYSQL_SOCKET "path/to/mysql/unix/socket"
# DBI verbosity
PerlSetEnv OCS_OPT_DBI_PRINT_ERROR 0
# Unicode support
PerlSetEnv OCS_OPT_UNICODE_SUPPORT 1
# If you are using a multi server architecture,
# Put the ip addresses of the slaves on the master
# (This is read as perl regular expressions)
PerlAddVar OCS_OPT_TRUSTED_IP 127.0.0.1
#PerlAddVar OCS_OPT_TRUSTED_IP XXX.XXX.XXX.XXX
# Be careful: you must restart apache to make settings taking effects
# Configure engine to use the settings from this file
PerlSetEnv OCS_OPT_OPTIONS_NOT_OVERLOADED 0
# Try to use other compress algorithm than raw zlib
# GUNZIP and clear XML are supported
PerlSetEnv OCS_OPT_COMPRESS_TRY_OTHERS 1
##############################################################
# ===== OPTIONS BELOW ARE OVERLOADED IF YOU USE OCS GUI =====#
##############################################################
# NOTE: IF YOU WANT TO USE THIS CONFIG FILE INSTEAD, set OCS_OPT_OPTIONS_NOT_OVERLOADED to '1'
# ===== MAIN SETTINGS =====
# Enable engine logs (see LOGPATH setting)
PerlSetEnv OCS_OPT_LOGLEVEL 0
# Specify agent's prolog frequency
PerlSetEnv OCS_OPT_PROLOG_FREQ 12
# Specify if agent take contact on service startup
PerlSetEnv OCS_OPT_INVENTORY_ON_STARTUP 0
# Configure the duplicates detection system
PerlSetEnv OCS_OPT_AUTO_DUPLICATE_LVL 15
# Futur security improvements
PerlSetEnv OCS_OPT_SECURITY_LEVEL 0
# Validity of a computer's lock
PerlSetEnv OCS_OPT_LOCK_REUSE_TIME 600
# Enable the history tracking system (useful for external data synchronisation
PerlSetEnv OCS_OPT_TRACE_DELETED 0
# ===== INVENTORY SETTINGS =====
# Specify the validity of inventory data
PerlSetEnv OCS_OPT_FREQUENCY 0
# Configure engine to update inventory regarding to CHECKSUM agent value (lower DB backend load)
PerlSetEnv OCS_OPT_INVENTORY_DIFF 1
# Make engine consider an inventory as a transaction (lower concurency, better disk usage)
PerlSetEnv OCS_OPT_INVENTORY_TRANSACTION 1
# Configure engine to make a differential update of inventory sections (row level). Lower DB backend load, higher frontend load
PerlSetEnv OCS_OPT_INVENTORY_WRITE_DIFF 1
# Enable some stuff to improve DB queries, especially for GUI multicriteria searching system
PerlSetEnv OCS_OPT_INVENTORY_CACHE_ENABLED 1
# Specify when the engine will clean the inventory cache structures
PerlSetEnv OCS_OPT_INVENTORY_CACHE_REVALIDATE 7
# Enable you to keep trace of every elements encountered in db life
PerlSetEnv OCS_OPT_INVENTORY_CACHE_KEEP 1
# ===== SOFTWARES DEPLOYMENT SETTINGS =====
# Enable this feature
PerlSetEnv OCS_OPT_DOWNLOAD 0
# Package which have a priority superior than this value will not be downloaded
PerlSetEnv OCS_OPT_DOWNLOAD_PERIOD_LENGTH 10
# Time between two download cycles (bandwidth control)
PerlSetEnv OCS_OPT_DOWNLOAD_CYCLE_LATENCY 60
# Time between two fragment downloads (bandwidth control)
PerlSetEnv OCS_OPT_DOWNLOAD_FRAG_LATENCY 60
# Specify if you want to track packages affected to a group on computer's level
PerlSetEnv OCS_OPT_DOWNLOAD_GROUPS_TRACE_EVENTS 1
# Time between two download periods (bandwidth control)
PerlSetEnv OCS_OPT_DOWNLOAD_PERIOD_LATENCY 60
# Agents will send ERR_TIMEOUT event and clean the package it is older than this setting
PerlSetEnv OCS_OPT_DOWNLOAD_TIMEOUT 7
# Agents will send an error event and clean the package if package command does not respond during this setting
PerlSetEnv OCS_OPT_DOWNLOAD_EXECUTION_TIMEOUT 120
# Enable ocs engine to deliver agent's files (deprecated)
PerlSetEnv OCS_OPT_DEPLOY 0
# Enable the softwares deployment capacity (bandwidth control)
# ===== GROUPS SETTINGS =====
# Enable the computer\s groups feature
PerlSetEnv OCS_OPT_ENABLE_GROUPS 1
# Random number computed in the defined range. Designed to avoid computing many groups in the same process
PerlSetEnv OCS_OPT_GROUPS_CACHE_OFFSET 43200
# Specify the validity of computer's groups (default: compute it once a day - see offset)
PerlSetEnv OCS_OPT_GROUPS_CACHE_REVALIDATE 43200
# ===== IPDISCOVER SETTINGS =====
# Specify how much agent per LAN will discovered connected peripherals (0 to disable)
PerlSetEnv OCS_OPT_IPDISCOVER 2
# Specify the minimal difference to replace an ipdiscover agent
PerlSetEnv OCS_OPT_IPDISCOVER_BETTER_THRESHOLD 1
# Time between 2 arp requests (mini: 10 ms)
PerlSetEnv OCS_OPT_IPDISCOVER_LATENCY 100
# Specify when to remove a computer when it has not come until this period
PerlSetEnv OCS_OPT_IPDISCOVER_MAX_ALIVE 14
# Disable the time before a first election (not recommended)
PerlSetEnv OCS_OPT_IPDISCOVER_NO_POSTPONE 0
# Enable groups for ipdiscover (for example, you might want to prevent some groups to be ipdiscover agents)
PerlSetEnv OCS_OPT_IPDISCOVER_USE_GROUPS 1
# ===== INVENTORY FILES MAPPING SETTINGS =====
# Use with ocsinventory-injector, enable the multi entities feature
PerlSetEnv OCS_OPT_GENERATE_OCS_FILES 0
# Generate either compressed file or clear XML text
PerlSetEnv OCS_OPT_OCS_FILES_FORMAT OCS
# Specify if you want to keep trace of all inventory between to synchronisation with the higher level server
PerlSetEnv OCS_OPT_OCS_FILES_OVERWRITE 0
# Path to ocs files directory (must be writeable)
PerlSetEnv OCS_OPT_OCS_FILES_PATH /tmp
# ===== FILTER SETTINGS =====
# Enable prolog filter stack
PerlSetEnv OCS_OPT_PROLOG_FILTER_ON 0
# Enable core filter system to modify some things "on the fly"
PerlSetEnv OCS_OPT_INVENTORY_FILTER_ENABLED 0
# Enable inventory flooding filter. A dedicated ipaddress ia allowed to send a new computer only once in this period
PerlSetEnv OCS_OPT_INVENTORY_FILTER_FLOOD_IP 0
# Period definition for INVENTORY_FILTER_FLOOD_IP
PerlSetEnv OCS_OPT_INVENTORY_FILTER_FLOOD_IP_CACHE_TIME 300
# Enable inventory filter stack
PerlSetEnv OCS_OPT_INVENTORY_FILTER_ON 0
# ===== DATA FILTER =====
#Enable the dat filtering capacity
PerlSetEnv OCS_OPT_DATA_FILTER 0
# Set the table names and the field associated you want to filter
#PerlAddVar OCS_OPT_DATA_TO_FILTER HARDWARE
#PerlAddVar OCS_OPT_DATA_TO_FILTER USERID
# ===== REGISTRY SETTINGS =====
# Enable the registry capacity
PerlSetEnv OCS_OPT_REGISTRY 1
# ===== SNMP SETTINGS =====
# Enable the SNMP capacity
PerlSetEnv OCS_OPT_SNMP 0
# Configure engine to update snmp inventory regarding to snmp_laststate table (lower DB backend load)
PerlSetEnv OCS_OPT_SNMP_INVENTORY_DIFF 1
# Display error message about agent https communication in logfile
PerlSetEnv OCS_OPT_SNMP_PRINT_HTTPS_ERROR 1
# ===== SESSION SETTINGS =====
# Not yet in GUI
# Validity of a session (prolog=>postinventory)
PerlSetEnv OCS_OPT_SESSION_VALIDITY_TIME 600
# Consider a session obsolete if it is older thant this value
PerlSetEnv OCS_OPT_SESSION_CLEAN_TIME 86400
# Accept an inventory only if required by server
#( Refuse "forced" inventory)
PerlSetEnv OCS_OPT_INVENTORY_SESSION_ONLY 0
# ===== TAG =====
# The default behavior of the server is to ignore TAG changes from the
# agent.
PerlSetEnv OCS_OPT_ACCEPT_TAG_UPDATE_FROM_CLIENT 0
# ===== EXTERNAL USERAGENTS =====
#Path for external useragents reference file
#!! WARNING !! : external agents may not be supported by OCS NG Community !
#PerlSetEnv OCS_OPT_EXT_USERAGENTS_FILE_PATH /tmp/yourfile.txt
# ===== PLUGINS =====
PerlSetEnv OCS_PLUGINS_PERL_DIR "PATH_TO_PLUGINS_PERL_DIRECTORY"
PerlSetEnv OCS_PLUGINS_CONF_DIR "PATH_TO_PLUGINS_CONFIG_DIRECTORY"
# ===== DEPRECATED =====
# Set the proxy cache validity in http headers when sending a file
PerlSetEnv OCS_OPT_PROXY_REVALIDATE_DELAY 3600
# Deprecated
PerlSetEnv OCS_OPT_UPDATE 0
############ DO NOT MODIFY BELOW ! #######################
# External modules
PerlModule Apache::DBI
PerlModule Compress::Zlib
PerlModule XML::Simple
# Ocs plugins
PerlModule Apache::Ocsinventory::Plugins
# Ocs
PerlModule Apache::Ocsinventory
PerlModule Apache::Ocsinventory::Server::Constants
PerlModule Apache::Ocsinventory::Server::System
PerlModule Apache::Ocsinventory::Server::Communication
PerlModule Apache::Ocsinventory::Server::Inventory
PerlModule Apache::Ocsinventory::Server::Duplicate
# Capacities
PerlModule Apache::Ocsinventory::Server::Capacities::Registry
PerlModule Apache::Ocsinventory::Server::Capacities::Update
PerlModule Apache::Ocsinventory::Server::Capacities::Ipdiscover
PerlModule Apache::Ocsinventory::Server::Capacities::Download
PerlModule Apache::Ocsinventory::Server::Capacities::Notify
PerlModule Apache::Ocsinventory::Server::Capacities::Snmp
# This module guides you through the module creation
# PerlModule Apache::Ocsinventory::Server::Capacities::Example
# This module adds some rules to filter some request sent to ocs server in the prolog and inventory stages
# PerlModule Apache::Ocsinventory::Server::Capacities::Filter
# This module add availibity to filter data from HARDWARE section (data filtered won't be stored in database)
# PerlModule Apache::Ocsinventory::Server::Capacities::Datafilter
# PerlTaintCheck On
# SSL apache settings
#SSLEngine "SSL_ENABLE"
#SSLCertificateFile "SSL_CERTIFICATE_FILE"
#SSLCertificateKeyFile "SSL_CERTIFICATE_KEY_FILE"
#SSLCACertificateFile "SSL_CERTIFICATE_FILE"
#SSLCACertificatePath "SSL_CERTIFICATE_PATH"
#SSLVerifyClient "SSL_VALIDATE_CLIENT"
# Engine apache settings
# "Virtual" directory for handling OCS Inventory NG agents communications
# Be careful, do not create such directory into your web server root document !
# Apache 2.4
Require all granted
# Apache 2.2
order deny,allow
allow from all
#Â If you protect this area you have to deal with http_auth_* agent's parameters
# AuthType Basic
# AuthName "OCS Inventory agent area"
# AuthUserFile "APACHE_AUTH_USER_FILE"
# require valid-user
SetHandler perl-script
PerlHandler Apache::Ocsinventory
# Web service apache settings
PerlModule Apache::Ocsinventory::SOAP
SetHandler perl-script
PerlHandler "Apache::Ocsinventory::SOAP"
# By default, you can query web service from everywhere with a valid user
# Apache 2.4
Require all granted
Order deny,allow
Allow from all
AuthType Basic
AuthName "OCS Inventory SOAP Area"
# Use htpasswd to create/update soap-user (or another granted user)
AuthUserFile "APACHE_AUTH_USER_FILE"
# Apache 2.4
Require user "SOAP_USER"
require "SOAP_USER"
OCSInventory-Server-2.8.1/setup.sh 0000775 0000000 0000000 00000210256 13764364732 0017054 0 ustar 00root root 0000000 0000000 #!/bin/sh
################################################################################
#
# OCS Inventory NG Management Server Setup
#
# Copyleft 2006 Didier LIROULET
# Web: http://www.ocsinventory-ng.org
#
# This code is open source and may be copied and modified as long as the source
# code is always made freely available.
# Please refer to the General Public Licence http://www.gnu.org/ or Licence.txt
################################################################################
#
# Which host run database server
DB_SERVER_HOST="localhost"
# On which port run database server
DB_SERVER_PORT="3306"
# Database server credentials
DB_SERVER_USER="ocs"
DB_SERVER_PWD="ocs"
# Where is Apache daemon binary (if empty, will try to find it)
APACHE_BIN=""
# Where is Apache configuration file (if empty, will try to find it)
APACHE_CONFIG_FILE=""
# Where is Apache includes configuration directory (if emty, will try to find it)
APACHE_CONFIG_DIRECTORY=""
# Which user is running Apache web server (if empty, will try to find it)
APACHE_USER=""
# Which group is running Apache web server (if empty, will try to find it)
APACHE_GROUP=""
# Where is Apache document root directory (if empty, will try to find it)
APACHE_ROOT_DOCUMENT=""
# Which version of mod_perl is apache using, 1 for <= 1.999_21 and 2 for >= 1.999_22 (if empty, user will be asked for)
APACHE_MOD_PERL_VERSION=""
# Where are located OCS Communication server log files
OCS_COM_SRV_LOG="/var/log/ocsinventory-server"
# Where are located OCS Communication server plugins configuration files
OCS_COM_SRV_PLUGINS_CONFIG_DIR="/etc/ocsinventory-server/plugins"
# Where are located OCS Communication server plugins perl files
OCS_COM_SRV_PLUGINS_PERL_DIR="/etc/ocsinventory-server/perl"
# Where is located perl interpreter
PERL_BIN=`which perl 2>/dev/null`
# Where is located make utility
MAKE=`which make 2>/dev/null`
# Where is located logrotate configuration directory
LOGROTATE_CONF_DIR="/etc/logrotate.d"
# Where is located newsyslog.conf
NEWSYSLOG_CONF_FILE="/etc/newsyslog.conf"
# Where to store setup logs
SETUP_LOG=`pwd`/ocs_server_setup.log
# Communication Server Apache configuration file
COM_SERVER_APACHE_CONF_FILE="ocsinventory-server.conf"
# Rest API configuration file
API_REST_APACHE_CONF_FILE="ocsinventory-restapi.conf"
# Communication Server logrotate configuration file
COM_SERVER_LOGROTATE_CONF_FILE="ocsinventory-server"
# Administration Console Apache configuration file
ADM_SERVER_APACHE_CONF_FILE="ocsinventory-reports.conf"
# Administration console read only files directory
ADM_SERVER_STATIC_DIR="/usr/share/ocsinventory-reports"
ADM_SERVER_STATIC_REPORTS_DIR="ocsreports"
ADM_SERVER_REPORTS_ALIAS="/ocsreports"
# Administration console read/write files dir
ADM_SERVER_VAR_DIR="/var/lib/ocsinventory-reports"
# Administration default packages directory and Apache alias
ADM_SERVER_VAR_PACKAGES_DIR="download"
ADM_SERVER_PACKAGES_ALIAS="/download"
# Administration default snmp directory and Apache alias
ADM_SERVER_VAR_SNMP_DIR="snmp"
ADM_SERVER_SNMP_ALIAS="/snmp"
# Administration console log files dir
ADM_SERVER_VAR_LOGS_DIR="logs"
# Administration console scripts log files dir
ADM_SERVER_VAR_SCRIPTS_LOGS_DIR="scripts"
# Administration console default ipdsicover-util.pl cache dir
ADM_SERVER_VAR_IPD_DIR="ipd"
# OS or linux distribution from automatic detection
UNIX_DISTRIBUTION=""
# Default install directory for rest api
REST_API_DIRECTORY=""
###################### DO NOT MODIFY BELOW #######################
# Check for Apache web server binaries
echo
echo "+----------------------------------------------------------+"
echo "| |"
echo "| Welcome to OCS Inventory NG Management server setup ! |"
echo "| |"
echo "+----------------------------------------------------------+"
echo
# Check for OS or linux distribution
echo "Trying to determine which OS or Linux distribution you use"
if [ -f /etc/redhat-release ]
then
UNIX_DISTRIBUTION="redhat"
elif [ -f /etc/debian_version ]
then
UNIX_DISTRIBUTION="debian"
elif [ -f /etc/SuSE-release ]
then
UNIX_DISTRIBUTION="suse"
fi
# Check for Apache web server binaries
echo "+----------------------------------------------------------+"
echo "| Checking for Apache web server binaries ! |"
echo "+----------------------------------------------------------+"
echo
echo "CAUTION: If upgrading Communication server from OCS Inventory NG 1.0 RC2 and"
echo "previous, please remove any Apache configuration for Communication Server!"
echo
echo -n "Do you wish to continue ([y]/n)?"
read ligne
if [ -z "$ligne" ] || [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
then
echo "Assuming Communication server 1.0 RC2 or previous is not installed"
echo "on this computer."
echo
else
echo "Installation aborted !"
echo
exit 1
fi
echo > $SETUP_LOG
OCS_LOCAL_DATE=`date +%Y-%m-%d-%H-%M-%S`
echo "Starting OCS Inventory NG Management server setup on $OCS_LOCAL_DATE" >> $SETUP_LOG
echo -n "from folder " >> $SETUP_LOG
pwd >> $SETUP_LOG
echo -n "Starting OCS Inventory NG Management server setup from folder "
pwd
echo "Storing log in file $SETUP_LOG" >> $SETUP_LOG
echo "Storing log in file $SETUP_LOG"
echo >> $SETUP_LOG
echo "============================================================" >> $SETUP_LOG
echo "Checking OCS Inventory NG Management Server requirements..." >> $SETUP_LOG
echo "============================================================" >> $SETUP_LOG
echo
echo "+----------------------------------------------------------+"
echo "| Checking for database server properties... |"
echo "+----------------------------------------------------------+"
echo
# Check mysql client distribution version
echo "Checking for database server properties" >> $SETUP_LOG
DB_CLIENT_MAJOR_VERSION=`eval mysql -V | cut -d' ' -f6 | cut -d'.' -f1` >> $SETUP_LOG 2>&1
DB_CLIENT_MINOR_VERSION=`eval mysql -V | cut -d' ' -f6 | cut -d'.' -f2` >> $SETUP_LOG 2>&1
if [ "$DB_CLIENT_MAJOR_VERSION" = "Linux" ]
then
DB_CLIENT_MAJOR_VERSION=`eval mysql -V | cut -d' ' -f4 | cut -d'.' -f1` >> $SETUP_LOG 2>&1
DB_CLIENT_MINOR_VERSION=`eval mysql -V | cut -d' ' -f4 | cut -d'.' -f2` >> $SETUP_LOG 2>&1
fi
echo "Your MySQL client seems to be part of MySQL version $DB_CLIENT_MAJOR_VERSION.$DB_CLIENT_MINOR_VERSION."
echo "MySQL client distribution version $DB_CLIENT_MAJOR_VERSION.$DB_CLIENT_MINOR_VERSION." >> $SETUP_LOG
# Ensure mysql distribution is 4.1 or higher
if [ $DB_CLIENT_MAJOR_VERSION -gt 4 ]
then
res=1
else
if [ $DB_CLIENT_MAJOR_VERSION -eq 4 ]
then
if [ $DB_CLIENT_MINOR_VERSION -eq 1 ]
then
res=1
else
res=0
fi
else
res=0
fi
fi
if [ $res -eq 0 ]
then
# Not 4.1 or higher, ask user to contnue ?
echo "Your computer does not seem to be compliant with MySQL 4.1 or higher."
echo -n "Do you wish to continue (y/[n])?"
read ligne
if [ "$ligne" = "y" ]
then
echo "Ensure your database server is running MySQL 4.1 or higher !"
echo "Ensure also this computer is able to connect to your MySQL server !"
else
echo "Installation aborted !"
exit 1
fi
else
echo "Your computer seems to be running MySQL 4.1 or higher, good ;-)"
echo "Computer seems to be running MySQL 4.1 or higher" >> $SETUP_LOG
fi
echo
# Ask user for database server host
res=0
while [ $res -eq 0 ]
do
echo -n "Which host is running database server [$DB_SERVER_HOST] ?"
read ligne
if [ -z "$ligne" ]
then
res=1
else
DB_SERVER_HOST="$ligne"
res=1
fi
done
echo "OK, database server is running on host $DB_SERVER_HOST ;-)"
echo "Database server is running on host $DB_SERVER_HOST" >> $SETUP_LOG
echo
# Ask user for database server port
res=0
while [ $res -eq 0 ]
do
echo -n "On which port is running database server [$DB_SERVER_PORT] ?"
read ligne
if [ -z "$ligne" ]
then
res=1
else
DB_SERVER_PORT="$ligne"
res=1
fi
done
echo "OK, database server is running on port $DB_SERVER_PORT ;-)"
echo "Database server is running on port $DB_SERVER_PORT" >> $SETUP_LOG
echo
echo
echo "+----------------------------------------------------------+"
echo "| Checking for Apache web server daemon... |"
echo "+----------------------------------------------------------+"
echo
echo "Checking for Apache web server daemon" >> $SETUP_LOG
# Try to find Apache daemon
if [ -z "$APACHE_BIN" ]
then
APACHE_BIN_FOUND=`which httpd 2>/dev/null`
if [ -z "$APACHE_BIN_FOUND" ]
then
APACHE_BIN_FOUND=`which apache2ctl 2>/dev/null`
if [ -z "$APACHE_BIN_FOUND" ]
then
APACHE_BIN_FOUND=`which apachectl 2>/dev/null`
if [ -z "$APACHE_BIN_FOUND" ]
then
APACHE_BIN_FOUND=`which httpd2 2>/dev/null`
fi
fi
fi
fi
echo "Found Apache daemon $APACHE_BIN_FOUND" >> $SETUP_LOG
# Ask user's confirmation
res=0
while [ $res -eq 0 ]
do
echo -n "Where is Apache daemon binary [$APACHE_BIN_FOUND] ?"
read ligne
if [ -z "$ligne" ]
then
APACHE_BIN=$APACHE_BIN_FOUND
else
APACHE_BIN="$ligne"
fi
# Ensure file exists and is executable
if [ -x $APACHE_BIN ]
then
res=1
else
echo "*** ERROR: $APACHE_BIN is not executable !"
res=0
fi
# Ensure file is not a directory
if [ -d $APACHE_BIN ]
then
echo "*** ERROR: $APACHE_BIN is a directory !"
res=0
fi
done
echo "OK, using Apache daemon $APACHE_BIN ;-)"
echo "Using Apache daemon $APACHE_BIN" >> $SETUP_LOG
echo
echo
echo "+----------------------------------------------------------+"
echo "| Checking for Apache main configuration file... |"
echo "+----------------------------------------------------------+"
echo
# Try to find Apache main configuration file
echo "Checking for Apache main configuration file" >> $SETUP_LOG
if [ -z "$APACHE_CONFIG_FILE" ]
then
APACHE_ROOT=`eval $APACHE_BIN -V | grep "HTTPD_ROOT" | cut -d'=' -f2 | tr -d '"'`
echo "Found Apache HTTPD_ROOT $APACHE_ROOT" >> $SETUP_LOG
APACHE_CONFIG=`eval $APACHE_BIN -V | grep "SERVER_CONFIG_FILE" | cut -d'=' -f2 | tr -d '"'`
echo "Found Apache SERVER_CONFIG_FILE $APACHE_CONFIG" >> $SETUP_LOG
if [ -e $APACHE_CONFIG ]
then
APACHE_CONFIG_FILE_FOUND="$APACHE_CONFIG"
else
APACHE_CONFIG_FILE_FOUND="$APACHE_ROOT/$APACHE_CONFIG"
fi
fi
echo "Found Apache main configuration file $APACHE_CONFIG_FILE_FOUND" >> $SETUP_LOG
# Ask user's confirmation
res=0
while [ $res -eq 0 ]
do
echo -n "Where is Apache main configuration file [$APACHE_CONFIG_FILE_FOUND] ?"
read ligne
if [ -z "$ligne" ]
then
APACHE_CONFIG_FILE=$APACHE_CONFIG_FILE_FOUND
else
APACHE_CONFIG_FILE="$ligne"
fi
# Ensure file is not a directory
if [ -d $APACHE_CONFIG_FILE ]
then
echo "*** ERROR: $APACHE_CONFIG_FILE is a directory !"
res=0
fi
# Ensure file exists and is readable
if [ -r $APACHE_CONFIG_FILE ]
then
res=1
else
echo "*** ERROR: $APACHE_CONFIG_FILE is not readable !"
res=0
fi
done
echo "OK, using Apache main configuration file $APACHE_CONFIG_FILE ;-)"
echo "Using Apache main configuration file $APACHE_CONFIG_FILE" >> $SETUP_LOG
echo
echo
echo "+----------------------------------------------------------+"
echo "| Checking for Apache user account... |"
echo "+----------------------------------------------------------+"
echo
# Try to find Apache main configuration file
echo "Checking for Apache user account" >> $SETUP_LOG
if [ -z "$APACHE_USER" ]
then
case $UNIX_DISTRIBUTION in
"debian")
if [ -f /etc/apache2/envvars ]
then
. /etc/apache2/envvars
fi
APACHE_USER_FOUND=$APACHE_RUN_USER
;;
"suse")
if [ -f /etc/apache2/uid.conf ]
then
APACHE_USER_FOUND=`cat /etc/apache2/uid.conf | grep "User" | tail -1 | cut -d' ' -f2`
fi
;;
"redhat")
APACHE_USER_FOUND=`cat $APACHE_CONFIG_FILE | grep "User " | tail -1 | cut -d' ' -f2`
;;
esac
fi
echo "Found Apache user account $APACHE_USER_FOUND" >> $SETUP_LOG
# Ask user's confirmation
res=0
while [ $res -eq 0 ]
do
echo -n "Which user account is running Apache web server [$APACHE_USER_FOUND] ?"
read ligne
if [ -z "$ligne" ]
then
APACHE_USER=$APACHE_USER_FOUND
else
APACHE_USER="$ligne"
fi
# Ensure group exist in /etc/passwd
if [ `cat /etc/passwd | grep $APACHE_USER | wc -l` -eq 0 ]
then
echo "*** ERROR: account $APACHE_USER not found in system table /etc/passwd !"
else
res=1
fi
done
echo "OK, Apache is running under user account $APACHE_USER ;-)"
echo "Using Apache user account $APACHE_USER" >> $SETUP_LOG
echo
echo
echo "+----------------------------------------------------------+"
echo "| Checking for Apache group... |"
echo "+----------------------------------------------------------+"
echo
# Try to find Apache main configuration file
echo "Checking for Apache group" >> $SETUP_LOG
if [ -z "$APACHE_GROUP" ]
then
case $UNIX_DISTRIBUTION in
"debian")
if [ -f /etc/apache2/envvars ]
then
. /etc/apache2/envvars
fi
APACHE_GROUP_FOUND=$APACHE_RUN_USER
;;
"suse")
if [ -f /etc/apache2/uid.conf ]
then
APACHE_GROUP_FOUND=`cat /etc/apache2/uid.conf | grep "Group" | tail -1 | cut -d' ' -f2`
fi
;;
"redhat")
APACHE_GROUP_FOUND=`cat $APACHE_CONFIG_FILE | grep "Group " | tail -1 | cut -d' ' -f2`
;;
esac
if [ -z "$APACHE_GROUP_FOUND" ]
then
# No group found, assume group name is the same as account
echo "No Apache user group found, assuming group name is the same as user account" >> $SETUP_LOG
APACHE_GROUP_FOUND=$APACHE_USER
fi
fi
echo "Found Apache user group $APACHE_GROUP_FOUND" >> $SETUP_LOG
# Ask user's confirmation
res=0
while [ $res -eq 0 ]
do
echo -n "Which user group is running Apache web server [$APACHE_GROUP_FOUND] ?"
read ligne
if [ -z "$ligne" ]
then
APACHE_GROUP=$APACHE_GROUP_FOUND
else
APACHE_GROUP="$ligne"
fi
# Ensure group exist in /etc/group
if [ `cat /etc/group | grep $APACHE_GROUP | wc -l` -eq 0 ]
then
echo "*** ERROR: group $APACHE_GROUP not found in system table /etc/group !"
else
res=1
fi
done
echo "OK, Apache is running under users group $APACHE_GROUP ;-)"
echo "Using Apache user group $APACHE_GROUP" >> $SETUP_LOG
echo
echo
echo "+----------------------------------------------------------+"
echo "| Checking for Apache Include configuration directory... |"
echo "+----------------------------------------------------------+"
echo
# Try to find Apache includes configuration directory
echo "Checking for Apache Include configuration directory" >> $SETUP_LOG
if [ -z "$APACHE_CONFIG_DIRECTORY" ]
then
if [ -d "$APACHE_ROOT/conf.d" ]
then
APACHE_CONFIG_DIRECTORY_FOUND="$APACHE_ROOT/conf.d"
elif [ -d "$APACHE_ROOT/conf-available" ]
then
APACHE_CONFIG_DIRECTORY_FOUND="$APACHE_ROOT/conf-available"
else
APACHE_CONFIG_DIRECTORY_FOUND=""
fi
if [ -d "$APACHE_CONFIG_DIRECTORY_FOUND" ]
then
echo "Found Apache Include configuration directory $APACHE_CONFIG_DIRECTORY_FOUND" >> $SETUP_LOG
fi
fi
# Ask user's confirmation
echo "Setup found Apache Include configuration directory in"
echo "$APACHE_CONFIG_DIRECTORY_FOUND."
echo "Setup will put OCS Inventory NG Apache configuration in this directory."
res=0
while [ $res -eq 0 ]
do
echo -n "Where is Apache Include configuration directory [$APACHE_CONFIG_DIRECTORY_FOUND] ?"
read ligne
if [ -z "$ligne" ]
then
APACHE_CONFIG_DIRECTORY=$APACHE_CONFIG_DIRECTORY_FOUND
else
APACHE_CONFIG_DIRECTORY="$ligne"
fi
# Ensure file is a directory
if [ -d $APACHE_CONFIG_DIRECTORY ]
then
res=1
else
echo "*** ERROR: $APACHE_CONFIG_DIRECTORY is not a directory !"
res=0
fi
# Ensure directory exists and is writable
if [ -w $APACHE_CONFIG_DIRECTORY ]
then
res=1
else
echo "*** ERROR: $APACHE_CONFIG_DIRECTORY is not writable !"
res=0
fi
done
echo "OK, Apache Include configuration directory $APACHE_CONFIG_DIRECTORY found ;-)"
echo "Using Apache Include configuration directory $APACHE_CONFIG_DIRECTORY" >> $SETUP_LOG
echo
echo
echo "+----------------------------------------------------------+"
echo "| Checking for PERL Interpreter... |"
echo "+----------------------------------------------------------+"
echo
echo "Checking for PERL Interpreter" >> $SETUP_LOG
if [ -z "$PERL_BIN" ]
then
echo "PERL Interpreter not found !"
echo "PERL Interpreter not found" >> $SETUP_LOG
echo "OCS Inventory NG is not able to work without PERL Interpreter."
echo "Setup manually PERL first."
echo "Installation aborted !"
echo "installation aborted" >> $SETUP_LOG
exit 1
else
echo "Found PERL interpreter at <$PERL_BIN> ;-)"
echo "Found PERL interpreter at <$PERL_BIN>" >> $SETUP_LOG
fi
# Ask user's confirmation
res=0
while [ $res -eq 0 ]
do
echo -n "Where is PERL interpreter binary [$PERL_BIN] ?"
read ligne
if [ -n "$ligne" ]
then
PERL_BIN="$ligne"
fi
# Ensure file exists and is executable
if [ -x $PERL_BIN ]
then
res=1
else
echo "*** ERROR: $PERL_BIN is not executable !"
res=0
fi
# Ensure file is not a directory
if [ -d $PERL_BIN ]
then
echo "*** ERROR: $PERL_BIN is a directory !"
res=0
fi
done
echo "OK, using PERL interpreter $PERL_BIN ;-)"
echo "Using PERL interpreter $PERL_BIN" >> $SETUP_LOG
echo
echo
echo -n "Do you wish to setup Communication server on this computer ([y]/n)?"
read ligne
if [ -z "$ligne" ] || [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
then
# Setting up Communication server
echo >> $SETUP_LOG
echo "============================================================" >> $SETUP_LOG
echo "Installing Communication server" >> $SETUP_LOG
echo "============================================================" >> $SETUP_LOG
echo
echo
echo "+----------------------------------------------------------+"
echo "| Checking for Make utility... |"
echo "+----------------------------------------------------------+"
echo
echo "Checking for Make utility" >> $SETUP_LOG
if [ -z "$MAKE" ]
then
echo "Make utility not found !"
echo "Make utility not found" >> $SETUP_LOG
echo "Setup is not able to build OCS Inventory NG Perl module."
echo "Unable to build OCS Inventory NG Perl module !" >> $SETUP_LOG
exit 1
else
echo "OK, Make utility found at <$MAKE> ;-)"
echo "Make utility found at <$MAKE>" >> $SETUP_LOG
fi
echo
echo "+----------------------------------------------------------+"
echo "| Checking for Apache mod_perl version... |"
echo "+----------------------------------------------------------+"
echo
echo "Checking for Apache mod_perl version 1.99_22 or higher"
echo "Checking for Apache mod_perl version 1.99_22 or higher" >> $SETUP_LOG
$PERL_BIN -mmod_perl2 -e 'print "mod_perl 1.99_22 or higher is available\n"' >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
# mod_perl 2 not found !
echo "Checking for Apache mod_perl version 1.99_21 or previous"
echo "Checking for Apache mod_perl version 1.99_21 or previous" >> $SETUP_LOG
$PERL_BIN -mmod_perl -e 'print "mod_perl 1.99_21 or previous is available\n"' >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
# mod_perl 1 not found => Ask user
res=0
while [ $res -eq 0 ]
do
echo "Setup is unable to determine your Apache mod_perl version."
echo "Apache must have module mod_perl enabled. As configuration differs from"
echo "mod_perl 1.99_21 or previous AND mod_perl 1.99_22 or higher, Setup must"
echo "know which release Apache is using."
echo "You can find which release you are using by running the following command"
echo " - On RPM enabled OS, rpm -q mod_perl"
echo " - On DPKG enabled OS, dpkg -l libapache*-mod-perl*"
echo "Enter 1 for mod_perl 1.99_21 or previous."
echo "Enter 2 for mod_perl 1.99_22 and higher."
echo -n "Which version of Apache mod_perl the computer is running ([1]/2) ?"
read ligne
if [ -z "$ligne" ]
then
APACHE_MOD_PERL_VERSION=1
else
APACHE_MOD_PERL_VERSION=$ligne
fi
res=1
done
else
echo "Found that mod_perl version 1.99_21 or previous is available."
APACHE_MOD_PERL_VERSION=1
fi
else
echo "Found that mod_perl version 1.99_22 or higher is available."
APACHE_MOD_PERL_VERSION=2
fi
if [ $APACHE_MOD_PERL_VERSION -eq 1 ]
then
echo "OK, Apache is using mod_perl version 1.99_21 or previous ;-)"
echo "Using mod_perl version 1.99_21 or previous" >> $SETUP_LOG
else
echo "OK, Apache is using mod_perl version 1.99_22 or higher ;-)"
echo "Using mod_perl version 1.99_22 or higher" >> $SETUP_LOG
fi
echo
echo "+----------------------------------------------------------+"
echo "| Checking for Communication server log directory... |"
echo "+----------------------------------------------------------+"
echo
echo "Checking for Communication server log directory" >> $SETUP_LOG
# Ask user
res=0
while [ $res -eq 0 ]
do
echo "Communication server can create detailed logs. This logs can be enabled"
echo "by setting integer value of LOGLEVEL to 1 in Administration console"
echo "menu Configuration."
echo -n "Where to put Communication server log directory [$OCS_COM_SRV_LOG] ?"
read ligne
if [ -n "$ligne" ]
then
OCS_COM_SRV_LOG=$ligne
fi
res=1
done
echo "OK, Communication server will put logs into directory $OCS_COM_SRV_LOG ;-)"
echo "Using $OCS_COM_SRV_LOG as Communication server log directory" >> $SETUP_LOG
echo
echo "+----------------------------------------------------------------------------+"
echo "| Checking for Communication server plugins configuration directory... |"
echo "+----------------------------------------------------------------------------+"
echo
echo "Checking for Communication server plugins configuration directory" >> $SETUP_LOG
# Ask user
res=0
while [ $res -eq 0 ]
do
echo "Communication server need a directory for plugins configuration files. "
echo -n "Where to put Communication server plugins configuration files [$OCS_COM_SRV_PLUGINS_CONFIG_DIR] ?"
read ligne
if [ -n "$ligne" ]
then
OCS_COM_SRV_PLUGINS_CONFIG_DIR=$ligne
fi
res=1
done
echo "OK, Communication server will put plugins configuration files into directory $OCS_COM_SRV_PLUGINS_CONFIG_DIR ;-)"
echo "Using $OCS_COM_SRV_PLUGINS_CONFIG_DIR as Communication server plugins configuration directory" >> $SETUP_LOG
echo
echo "+-------------------------------------------------------------------+"
echo "| Checking for Communication server plugins perl directory... |"
echo "+-------------------------------------------------------------------+"
echo
echo "Checking for Communication server perl directory" >> $SETUP_LOG
# Ask user
res=0
while [ $res -eq 0 ]
do
echo "Communication server need a directory for plugins Perl modules files."
echo -n "Where to put Communication server plugins Perl modules files [$OCS_COM_SRV_PLUGINS_PERL_DIR] ?"
read ligne
if [ -n "$ligne" ]
then
OCS_COM_SRV_PLUGINS_PERL_DIR=$ligne
fi
res=1
done
echo "OK, Communication server will put plugins Perl modules files into directory $OCS_COM_SRV_PLUGINS_PERL_DIR ;-)"
echo "Using $OCS_COM_SRV_PLUGINS_PERL_DIR as Communication server plugins perl directory" >> $SETUP_LOG
echo
# jump to communication server directory
echo "Entering Apache sub directory" >> $SETUP_LOG
# Check for required Perl Modules (if missing, please install before)
# - DBI 1.40 or higher
# - Apache::DBI 0.93 or higher
# - DBD::mysql 2.9004 or higher
# - Compress::Zlib 1.33 or higher
# - XML::Simple 2.12 or higher
# - Net::IP 1.21 or higher
# - Archive::Zip
echo
echo "+----------------------------------------------------------+"
echo "| Checking for required Perl Modules... |"
echo "+----------------------------------------------------------+"
echo
REQUIRED_PERL_MODULE_MISSING=0
DBI=0
APACHE_DBI=0
DBD_MYSQL=0
COMPRESS_ZLIB=0
XML_SIMPLE=0
NET_IP=0
ARCHIVE_ZIP=0
echo "Checking for DBI PERL module..."
echo "Checking for DBI PERL module" >> $SETUP_LOG
$PERL_BIN -mDBI -e 'print "PERL module DBI is available\n"' >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: PERL module DBI is not installed !"
REQUIRED_PERL_MODULE_MISSING=1
DBI=1
else
echo "Found that PERL module DBI is available."
fi
echo "Checking for Apache::DBI PERL module..."
echo "Checking for Apache::DBI PERL module" >> $SETUP_LOG
$PERL_BIN -mApache::DBI -e 'print "PERL module Apache::DBI is available\n"' >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: PERL module Apache::DBI is not installed !"
REQUIRED_PERL_MODULE_MISSING=1
APACHE_DBI=1
else
echo "Found that PERL module Apache::DBI is available."
fi
echo "Checking for DBD::mysql PERL module..."
echo "Checking for DBD::mysql PERL module" >> $SETUP_LOG
$PERL_BIN -mDBD::mysql -e 'print "PERL module DBD::mysql is available\n"' >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: PERL module DBD::mysql is not installed !"
REQUIRED_PERL_MODULE_MISSING=1
DBD_MYSQL=1
else
echo "Found that PERL module DBD::mysql is available."
fi
echo "Checking for Compress::Zlib PERL module..."
echo "Checking for Compress::Zlib PERL module" >> $SETUP_LOG
$PERL_BIN -mCompress::Zlib -e 'print "PERL module Compress::Zlib is available\n"' >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: PERL module Compress::Zlib is not installed !"
REQUIRED_PERL_MODULE_MISSING=1
COMPRESS_ZLIB=1
else
echo "Found that PERL module Compress::Zlib is available."
fi
echo "Checking for XML::Simple PERL module..."
echo "Checking for XML::Simple PERL module" >> $SETUP_LOG
$PERL_BIN -mXML::Simple -e 'print "PERL module XML::Simple is available\n"' >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: PERL module XML::Simple is not installed !"
REQUIRED_PERL_MODULE_MISSING=1
XML_SIMPLE=1
else
echo "Found that PERL module XML::Simple is available."
fi
echo "Checking for Net::IP PERL module..."
echo "Checking for Net::IP PERL module" >> $SETUP_LOG
$PERL_BIN -mNet::IP -e 'print "PERL module Net::IP is available\n"' >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: PERL module Net::IP is not installed !"
REQUIRED_PERL_MODULE_MISSING=1
NET_IP=1
else
echo "Found that PERL module Net::IP is available."
fi
# Check for Zip::Archive
echo "Checking for Archive::Zip Perl module..."
echo "Checking for Archive::Zip Perl module" >> $SETUP_LOG
$PERL_BIN -mArchive::Zip -e 'print "PERL module Archive::Zip is available\n"' >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: PERL module Archive::Zip is not installed !"
REQUIRED_PERL_MODULE_MISSING=1
ARCHIVE_ZIP=1
else
echo "Found that PERL module Archive::Zip is available."
fi
if [ $REQUIRED_PERL_MODULE_MISSING -ne 0 ]
then
echo "*** ERROR: There is one or more required PERL modules missing on your computer !"
echo "Please, install missing PERL modules first."
echo " "
echo "OCS setup.sh can install perl module from packages for you"
echo "The script will use the native package from your operating system like apt or rpm"
echo -n "Do you wish to continue (y/[n])?"
read ligne
if [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
then
case $UNIX_DISTRIBUTION in
"redhat")
echo "RedHat based automatic installation"
if [ $DBI -eq 1 ]
then
PACKAGE="$PACKAGE perl-DBI"
fi
if [ $APACHE_DBI -eq 1 ]
then
PACKAGE="$PACKAGE perl-Apache-DBI"
fi
if [ $DBD_MYSQL -eq 1 ]
then
PACKAGE="$PACKAGE perl-DBD-MySQL"
fi
if [ $COMPRESS_ZLIB -eq 1 ]
then
PACKAGE="$PACKAGE perl-Compress-Zlib"
fi
if [ $XML_SIMPLE -eq 1 ]
then
PACKAGE="$PACKAGE perl-XML-Simple"
fi
if [ $NET_IP -eq 1 ]
then
PACKAGE="$PACKAGE perl-Net-IP"
fi
if [ $ARCHIVE_ZIP -eq 1 ]
then
PACKAGE="$PACKAGE perl-Archive-Zip"
fi
yum install $PACKAGE
if [ $? != 0 ]
then
echo "Installation aborted !"
echo "Installation script encounter problems to install packages !"
echo "One or more required PERL modules missing !" >> $SETUP_LOG
echo "Installation aborted" >> $SETUP_LOG
exit 1
fi
echo "All packages have been installed on this computer"
;;
"debian")
echo "Debian based automatic installation"
if [ $DBI -eq 1 ]
then
PACKAGE="$PACKAGE libdbi-perl"
fi
if [ $APACHE_DBI -eq 1 ]
then
PACKAGE="$PACKAGE libapache-dbi-perl"
fi
if [ $DBD_MYSQL -eq 1 ]
then
PACKAGE="$PACKAGE libdbd-mysql-perl"
fi
if [ $COMPRESS_ZLIB -eq 1 ]
then
PACKAGE="$PACKAGE libcompress-zlib-perl"
fi
if [ $XML_SIMPLE -eq 1 ]
then
PACKAGE="$PACKAGE libxml-simple-perl"
fi
if [ $NET_IP -eq 1 ]
then
PACKAGE="$PACKAGE libnet-ip-perl"
fi
if [ $ARCHIVE_ZIP -eq 1 ]
then
PACKAGE="$PACKAGE libarchive-zip-perl"
fi
apt-get update
apt-get install $PACKAGE
if [ $? -ne 0 ]
then
echo "Installation aborted !"
echo "Installation script encounter problems to install packages !"
echo "One or more required PERL modules missing !" >> $SETUP_LOG
echo "Installation aborted" >> $SETUP_LOG
exit 1
fi
echo "All packages have been installed on this computer"
;;
*)
echo "Installation aborted !"
echo "Installation script cannot find missing packages for your distribution"
echo "One or more required PERL modules missing !" >> $SETUP_LOG
echo "Installation aborted" >> $SETUP_LOG
exit 1
;;
esac
else
echo "Installation aborted !"
echo "Please, install missing PERL modules first."
echo "One or more required PERL modules missing !" >> $SETUP_LOG
echo "Installation aborted" >> $SETUP_LOG
exit 1
fi
fi
echo
echo
echo -n "Do you wish to setup Rest API server on this computer ([y]/n)?"
read ligne
if [ -z "$ligne" ] || [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
then
echo
echo "+----------------------------------------------------------+"
echo "| Checking for REST API Dependencies ... |"
echo "+----------------------------------------------------------+"
echo
# Dependencies :
# => Mojolicious::Lite
# => Plack
# => Switch
$PERL_BIN -mMojolicious::Lite -e 'print "PERL module Mojolicious::Lite is available\n"' >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: PERL module Mojolicious::Lite is not installed !"
echo -n "Do you wish to continue (y/[n])?"
read ligne
if [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
then
echo "User choose to continue setup without PERL module Mojolicious::Lite" >> $SETUP_LOG
else
echo
echo "Installation aborted !"
echo "User choose to abort installation !" >> $SETUP_LOG
exit 1
fi
else
echo "Found that PERL module Mojolicious::Lite is available."
fi
$PERL_BIN -mSwitch -e 'print "PERL module Switch is available\n"' >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: PERL module Switch is not installed !"
echo -n "Do you wish to continue (y/[n])?"
read ligne
if [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
then
echo "User choose to continue setup without PERL module Switch" >> $SETUP_LOG
else
echo
echo "Installation aborted !"
echo "User choose to abort installation !" >> $SETUP_LOG
exit 1
fi
else
echo "Found that PERL module Switch is available."
fi
$PERL_BIN -mPlack::Handler -e 'print "PERL module Plack::Handler is available\n"' >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: PERL module Plack::Handler is not installed !"
echo -n "Do you wish to continue (y/[n])?"
read ligne
if [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
then
echo "User choose to continue setup without PERL module Plack::Handler" >> $SETUP_LOG
else
echo
echo "Installation aborted !"
echo "User choose to abort installation !" >> $SETUP_LOG
exit 1
fi
else
echo "Found that PERL module Plack::Handler is available."
fi
echo
echo "+----------------------------------------------------------+"
echo "| Configuring REST API Server files ... |"
echo "+----------------------------------------------------------+"
echo
# Get first INC path to determine a valid path
REST_API_DIRECTORY=$($PERL_BIN -e "print \"@INC[2]\"")
echo -n "Where do you want the API code to be store [$REST_API_DIRECTORY] ?"
read ligne
if [ -z "$ligne" ]
then
REST_API_DIRECTORY=$REST_API_DIRECTORY
else
REST_API_DIRECTORY="$ligne"
fi
echo "Copying files to $REST_API_DIRECTORY"
echo "Copying files to $REST_API_DIRECTORY" >> $SETUP_LOG
echo
echo "+----------------------------------------------------------+"
echo "| Configuring REST API Server configuration files ... |"
echo "+----------------------------------------------------------+"
echo
echo "Configuring Rest API server (file $API_REST_APACHE_CONF_FILE)" >> $SETUP_LOG
cp etc/ocsinventory/$API_REST_APACHE_CONF_FILE $API_REST_APACHE_CONF_FILE.local
$PERL_BIN -pi -e "s#'REST_API_PATH'#'$REST_API_DIRECTORY'#g" $API_REST_APACHE_CONF_FILE.local
$PERL_BIN -pi -e "s#'REST_API_LOADER_PATH'#'$REST_API_DIRECTORY/Api/Ocsinventory/Restapi/Loader.pm'#g" $API_REST_APACHE_CONF_FILE.local
echo "Writing Rest API configuration to file $APACHE_CONFIG_DIRECTORY/$API_REST_APACHE_CONF_FILE" >> $SETUP_LOG
cp -f $API_REST_APACHE_CONF_FILE.local $APACHE_CONFIG_DIRECTORY/zz-$API_REST_APACHE_CONF_FILE >> $SETUP_LOG 2>&1
cp -r Api/ $REST_API_DIRECTORY
fi
echo
echo "+----------------------------------------------------------+"
echo "| OK, looks good ;-) |"
echo "| |"
echo "| Configuring Communication server Perl modules... |"
echo "+----------------------------------------------------------+"
echo
echo "Configuring Communication server (perl Makefile.PL)" >> $SETUP_LOG
cd "Apache"
$PERL_BIN Makefile.PL
if [ $? -ne 0 ]
then
echo -n "Warning: Prerequisites too old ! Do you wish to continue (y/[n])?"
read ligne
if [ "$ligne" = "y" ]
then
echo "Maybe Communication server will encounter problems. Continuing anyway."
echo "Warning: Prerequisites too old ! Continuing anyway" >> $SETUP_LOG
else
echo "Installation aborted !"
exit 1
fi
fi
echo
echo "+----------------------------------------------------------+"
echo "| OK, looks good ;-) |"
echo "| |"
echo "| Preparing Communication server Perl modules... |"
echo "+----------------------------------------------------------+"
echo
echo "Preparing Communication server Perl modules (make)" >> $SETUP_LOG
$MAKE >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Prepare failed, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo
echo "+----------------------------------------------------------+"
echo "| OK, prepare finshed ;-) |"
echo "| |"
echo "| Installing Communication server Perl modules... |"
echo "+----------------------------------------------------------+"
echo
echo "Installing Communication server Perl modules (make install)" >> $SETUP_LOG
$MAKE install >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Install of Perl modules failed, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
cd ".."
echo
echo "+----------------------------------------------------------+"
echo "| OK, Communication server Perl modules install finished;-)|"
echo "| |"
echo "| Creating Communication server log directory... |"
echo "+----------------------------------------------------------+"
echo
echo "Creating Communication server log directory $OCS_COM_SRV_LOG."
echo "Creating Communication server log directory $OCS_COM_SRV_LOG" >> $SETUP_LOG
mkdir -p $OCS_COM_SRV_LOG >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to create log directory, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo
echo "Fixing Communication server log directory files permissions."
echo "Fixing Communication server log directory permissions" >> $SETUP_LOG
chown -R $APACHE_USER:$APACHE_GROUP $OCS_COM_SRV_LOG >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set log directory permissions, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
chmod -R gu+rwx $OCS_COM_SRV_LOG >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set log directory permissions, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
chmod -R o-w $OCS_COM_SRV_LOG >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set log directory permissions, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
# Log rotation, BSD style
if [ -f $NEWSYSLOG_CONF_FILE ]
then
echo "*** WARNING Please configure log rotation for files in $OCS_COM_SRV_LOG"
fi
# Log rotation, Linux flavor
if [ -d $LOGROTATE_CONF_DIR ]
then
echo "Configuring logrotate for Communication server."
echo "Configuring logrotate (ed logrotate.ocsinventory-NG)" >> $SETUP_LOG
cp etc/logrotate.d/$COM_SERVER_LOGROTATE_CONF_FILE logrotate.$COM_SERVER_LOGROTATE_CONF_FILE.local
$PERL_BIN -pi -e "s#PATH_TO_LOG_DIRECTORY#$OCS_COM_SRV_LOG#g" logrotate.$COM_SERVER_LOGROTATE_CONF_FILE.local
echo "******** Begin updated logrotate.$COM_SERVER_LOGROTATE_CONF_FILE.local ***********" >> $SETUP_LOG
cat logrotate.$COM_SERVER_LOGROTATE_CONF_FILE.local >> $SETUP_LOG
echo "******** End updated logrotate.COM_SERVER_LOGROTATE_CONF_FILE.local ***********" >> $SETUP_LOG
echo "Removing old communication server logrotate file $LOGROTATE_CONF_DIR/ocsinventory-NG"
echo "Removing old communication server logrotate file $LOGROTATE_CONF_DIR/ocsinventory-NG" >> $SETUP_LOG
rm -f "$LOGROTATE_CONF_DIR/ocsinventory-NG"
echo "Writing communication server logrotate to file $LOGROTATE_CONF_DIR/$COM_SERVER_LOGROTATE_CONF_FILE"
echo "Writing communication server logrotate to file $LOGROTATE_CONF_DIR/$COM_SERVER_LOGROTATE_CONF_FILE" >> $SETUP_LOG
cp -f logrotate.$COM_SERVER_LOGROTATE_CONF_FILE.local $LOGROTATE_CONF_DIR/$COM_SERVER_LOGROTATE_CONF_FILE >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to configure log rotation, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
fi
echo
echo
echo "+----------------------------------------------------------------------+"
echo "| OK, Communication server log directory created ;-) |"
echo "| |"
echo "| Creating Communication server plugins configuration directory... |"
echo "+----------------------------------------------------------------------+"
echo
echo "Creating Communication server plugins configuration directory $OCS_COM_SRV_PLUGINS_CONFIG_DIR."
echo "Creating Communication server plugins configuration directory $OCS_COM_SRV_PLUGINS_CONFIG_DIR" >> $SETUP_LOG
mkdir -p $OCS_COM_SRV_PLUGINS_CONFIG_DIR >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to create plugins confguration directory, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo
echo
echo "+----------------------------------------------------------------------+"
echo "| OK, Communication server plugins configuration directory created ;-) |"
echo "| |"
echo "| Creating Communication server plugins Perl directory... |"
echo "+----------------------------------------------------------------------+"
echo
echo "Creating Communication server plugins Perl directory $OCS_COM_SRV_PLUGINS_PERL_DIR."
echo "Creating Communication server plugins Perl directory $OCS_COM_SRV_PLUGINS_PERL_DIR" >> $SETUP_LOG
mkdir -p "$OCS_COM_SRV_PLUGINS_PERL_DIR/Apache/Ocsinventory/Plugins" >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to create plugins Perl directory, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo
#Fix permissions on server side for plugin engine (perl / plugins) dir usually in etc/ocsinventory-server..
# Where are located OCS Communication server plugins configuration files
chown -R $APACHE_USER:$APACHE_GROUPE $OCS_COM_SRV_PLUGINS_CONFIG_DIR
# Where are located OCS Communication server plugins perl files
chown -R $APACHE_USER:$APACHE_GROUPE $OCS_COM_SRV_PLUGINS_PERL_DIR
echo
echo "+----------------------------------------------------------------------+"
echo "| OK, Communication server plugins Perl directory created ;-) |"
echo "| |"
echo "| Now configuring Apache web server... |"
echo "+----------------------------------------------------------------------+"
echo
echo "To ensure Apache loads mod_perl before OCS Inventory NG Communication Server,"
echo "Setup can name Communication Server Apache configuration file"
echo "'z-$COM_SERVER_APACHE_CONF_FILE' instead of '$COM_SERVER_APACHE_CONF_FILE'."
echo "Do you allow Setup renaming Communication Server Apache configuration file"
echo -n "to 'z-$COM_SERVER_APACHE_CONF_FILE' ([y]/n) ?"
read ligne
if [ -z $ligne ] || [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
then
echo "OK, using 'z-$COM_SERVER_APACHE_CONF_FILE' as Communication Server Apache configuration file"
echo "OK, using 'z-$COM_SERVER_APACHE_CONF_FILE' as Communication Server Apache configuration file" >> $SETUP_LOG
FORCE_LOAD_AFTER_PERL_CONF=1
else
echo "OK, using '$COM_SERVER_APACHE_CONF_FILE' as Communication Server Apache configuration file"
echo "OK, using '$COM_SERVER_APACHE_CONF_FILE' as Communication Server Apache configuration file" >> $SETUP_LOG
FORCE_LOAD_AFTER_PERL_CONF=0
fi
echo "Configuring Apache web server (file $COM_SERVER_APACHE_CONF_FILE)" >> $SETUP_LOG
cp etc/ocsinventory/$COM_SERVER_APACHE_CONF_FILE $COM_SERVER_APACHE_CONF_FILE.local
$PERL_BIN -pi -e "s#DATABASE_SERVER#$DB_SERVER_HOST#g" $COM_SERVER_APACHE_CONF_FILE.local
$PERL_BIN -pi -e "s#DATABASE_PORT#$DB_SERVER_PORT#g" $COM_SERVER_APACHE_CONF_FILE.local
$PERL_BIN -pi -e "s#VERSION_MP#$APACHE_MOD_PERL_VERSION#g" $COM_SERVER_APACHE_CONF_FILE.local
$PERL_BIN -pi -e "s#PATH_TO_LOG_DIRECTORY#$OCS_COM_SRV_LOG#g" $COM_SERVER_APACHE_CONF_FILE.local
$PERL_BIN -pi -e "s#PATH_TO_PLUGINS_CONFIG_DIRECTORY#$OCS_COM_SRV_PLUGINS_CONFIG_DIR#g" $COM_SERVER_APACHE_CONF_FILE.local
$PERL_BIN -pi -e "s#PATH_TO_PLUGINS_PERL_DIRECTORY#$OCS_COM_SRV_PLUGINS_PERL_DIR#g" $COM_SERVER_APACHE_CONF_FILE.local
echo "******** Begin updated $COM_SERVER_APACHE_CONF_FILE.local ***********" >> $SETUP_LOG
cat $COM_SERVER_APACHE_CONF_FILE.local >> $SETUP_LOG
echo "******** End updated $COM_SERVER_APACHE_CONF_FILE.local ***********" >> $SETUP_LOG
echo "Removing old communication server configuration to file $APACHE_CONFIG_DIRECTORY/ocsinventory.conf"
echo "Removing old communication server configuration to file $APACHE_CONFIG_DIRECTORY/ocsinventory.conf" >> $SETUP_LOG
rm -f "$APACHE_CONFIG_DIRECTORY/ocsinventory.conf"
if [ $FORCE_LOAD_AFTER_PERL_CONF -eq 1 ]
then
rm -f "$APACHE_CONFIG_DIRECTORY/$COM_SERVER_APACHE_CONF_FILE"
echo "Writing communication server configuration to file $APACHE_CONFIG_DIRECTORY/z-$COM_SERVER_APACHE_CONF_FILE"
echo "Writing communication server configuration to file $APACHE_CONFIG_DIRECTORY/z-$COM_SERVER_APACHE_CONF_FILE" >> $SETUP_LOG
cp -f $COM_SERVER_APACHE_CONF_FILE.local $APACHE_CONFIG_DIRECTORY/z-$COM_SERVER_APACHE_CONF_FILE >> $SETUP_LOG 2>&1
res=$?
COM_SERVER_APACHE_CONF_FILE="z-$COM_SERVER_APACHE_CONF_FILE"
else
echo "Writing communication server configuration to file $APACHE_CONFIG_DIRECTORY/$COM_SERVER_APACHE_CONF_FILE"
echo "Writing communication server configuration to file $APACHE_CONFIG_DIRECTORY/$COM_SERVER_APACHE_CONF_FILE" >> $SETUP_LOG
cp -f $COM_SERVER_APACHE_CONF_FILE.local $APACHE_CONFIG_DIRECTORY/$COM_SERVER_APACHE_CONF_FILE >> $SETUP_LOG 2>&1
res=$?
fi
if [ $res -ne 0 ]
then
echo "*** ERROR: Unable to write $APACHE_CONFIG_DIRECTORY/$COM_SERVER_APACHE_CONF_FILE, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo
echo "+----------------------------------------------------------------------+"
echo "| OK, Communication server setup successfully finished ;-) |"
echo "| |"
echo "| Please, review $APACHE_CONFIG_DIRECTORY/$COM_SERVER_APACHE_CONF_FILE |"
echo "| to ensure all is good. Then restart Apache daemon. |"
echo "+----------------------------------------------------------------------+"
echo
echo "Leaving Apache directory" >> $SETUP_LOG
echo "Communication server installation successful" >> $SETUP_LOG
fi
echo
echo "Do you wish to setup Administration Server (Web Administration Console)"
echo -n "on this computer ([y]/n)?"
read ligne
if [ -z "$ligne" ] || [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
then
# Install Administration server
echo >> $SETUP_LOG
echo "============================================================" >> $SETUP_LOG
echo "Installing Administration server" >> $SETUP_LOG
echo "============================================================" >> $SETUP_LOG
echo
echo "+----------------------------------------------------------+"
echo "| Checking for Administration Server directories... |"
echo "+----------------------------------------------------------+"
echo
echo "CAUTION: Setup now install files in accordance with Filesystem Hierarchy"
echo "Standard. So, no file is installed under Apache root document directory"
echo "(Refer to Apache configuration files to locate it)."
echo "If you're upgrading from OCS Inventory NG Server 1.01 and previous, YOU"
echo "MUST REMOVE (or move) directories 'ocsreports' and 'download' from Apache"
echo "root document directory."
echo "If you choose to move directory, YOU MUST MOVE 'download' directory to"
echo "Administration Server writable/cache directory (by default"
echo "$ADM_SERVER_VAR_DIR), especially if you use deployment feature."
echo
echo -n "Do you wish to continue ([y]/n)?"
read ligne
if [ -z "$ligne" ] || [ "$ligne" = "y" ] || [ "$ligne" = "Y" ]
then
echo "Assuming directories 'ocsreports' and 'download' removed from"
echo "Apache root document directory."
echo
else
echo "Installation aborted !"
echo
exit 1
fi
echo "Checking for Administration Server directories..." >> $SETUP_LOG
echo "Where to copy Administration Server static files for PHP Web Console"
echo -n "[$ADM_SERVER_STATIC_DIR] ?"
read ligne
if test -z $ligne
then
ADM_SERVER_STATIC_DIR=$ADM_SERVER_STATIC_DIR
else
ADM_SERVER_STATIC_DIR="$ligne"
fi
echo "OK, using directory $ADM_SERVER_STATIC_DIR to install static files ;-)"
echo "Using directory $ADM_SERVER_STATIC_DIR for static files" >> $SETUP_LOG
echo
echo "Where to create writable/cache directories for deployment packages,"
echo -n "administration console logs, IPDiscover and SNMP [$ADM_SERVER_VAR_DIR] ?"
read ligne
if test -z $ligne
then
ADM_SERVER_VAR_DIR=$ADM_SERVER_VAR_DIR
else
ADM_SERVER_VAR_DIR="$ligne"
fi
echo "OK, writable/cache directory is $ADM_SERVER_VAR_DIR ;-)"
echo "Using $ADM_SERVER_VAR_DIR as writable/cache directory" >> $SETUP_LOG
echo
# Check for required Perl Modules (if missing, please install before)
# - DBI 1.40 or higher
# - DBD::mysql 2.9004 or higher
# - XML::Simple 2.12 or higher
# - Net::IP 1.21 or higher
#
echo
echo "+----------------------------------------------------------+"
echo "| Checking for required Perl Modules... |"
echo "+----------------------------------------------------------+"
echo
REQUIRED_PERL_MODULE_MISSING=0
echo "Checking for DBI PERL module..."
echo "Checking for DBI PERL module" >> $SETUP_LOG
$PERL_BIN -mDBI -e 'print "PERL module DBI is available\n"' >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: PERL module DBI is not installed !"
REQUIRED_PERL_MODULE_MISSING=1
else
echo "Found that PERL module DBI is available."
fi
echo "Checking for DBD::mysql PERL module..."
echo "Checking for DBD::mysql PERL module" >> $SETUP_LOG
$PERL_BIN -mDBD::mysql -e 'print "PERL module DBD::mysql is available\n"' >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: PERL module DBD::mysql is not installed !"
REQUIRED_PERL_MODULE_MISSING=1
else
echo "Found that PERL module DBD::mysql is available."
fi
echo "Checking for XML::Simple PERL module..."
echo "Checking for XML::Simple PERL module" >> $SETUP_LOG
$PERL_BIN -mXML::Simple -e 'print "PERL module XML::Simple is available\n"' >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: PERL module XML::Simple is not installed !"
REQUIRED_PERL_MODULE_MISSING=1
else
echo "Found that PERL module XML::Simple is available."
fi
echo "Checking for Net::IP PERL module..."
echo "Checking for Net::IP PERL module" >> $SETUP_LOG
$PERL_BIN -mNet::IP -e 'print "PERL module Net::IP is available\n"' >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: PERL module Net::IP is not installed !"
REQUIRED_PERL_MODULE_MISSING=1
else
echo "Found that PERL module Net::IP is available."
fi
if [ $REQUIRED_PERL_MODULE_MISSING -ne 0 ]
then
echo "*** ERROR: There is one or more required PERL modules missing on your computer !"
echo "Please, install missing PERL modules first."
echo "Installation aborted !"
echo "One or more required PERL modules missing !" >> $SETUP_LOG
echo "Installation aborted" >> $SETUP_LOG
exit 1
fi
echo
echo "+----------------------------------------------------------+"
echo "| Installing files for Administration server... |"
echo "+----------------------------------------------------------+"
echo
echo "Creating PHP directory $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR."
echo "Creating PHP directory $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR" >> $SETUP_LOG
mkdir -p $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR >> $SETUP_LOG 2>&1
if [ $? != 0 ]
then
echo "*** ERROR: Unable to create $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo "Copying PHP files to $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR."
echo "Copying PHP files to $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR" >> $SETUP_LOG
cp -Rf ocsreports/* $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/ >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to copy files in $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo "Fixing permissions on directory $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR."
echo "Fixing permissions on directory $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR" >> $SETUP_LOG
# Set PHP pages directory owned by root, group Apache
chown -R root:$APACHE_GROUP $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR >> $SETUP_LOG 2>&1
# Set "download/" "upload/" "plugins/main_section" "plugins/computer_detail" "plugins/language" "config/" own to apache
chown -R $APACHE_USER:$APACHE_GROUPE $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/config >> $SETUP_LOG 2>&1
chown -R $APACHE_USER:$APACHE_GROUPE $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/plugins/computer_detail >> $SETUP_LOG 2>&1
chown -R $APACHE_USER:$APACHE_GROUPE $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/plugins/main_sections >> $SETUP_LOG 2>&1
chown -R $APACHE_USER:$APACHE_GROUPE $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/plugins/language >> $SETUP_LOG 2>&1
chown -R $APACHE_USER:$APACHE_GROUPE $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/download >> $SETUP_LOG 2>&1
chown -R $APACHE_USER:$APACHE_GROUPE $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/upload >> $SETUP_LOG 2>&1
chown $APACHE_USER:$APACHE_GROUPE $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set permissions on $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
# Set PHP pages writable by root only
chmod -R go-w $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set permissions on $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
# Set database configuration file dbconfig.inc.php writable by Apache
echo "Creating database configuration file $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php."
echo "Creating database configuration file $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php" >> $SETUP_LOG
rm -f $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
echo "> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
echo -n '$_SESSION["SERVEUR_SQL"]="' >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
echo -n "$DB_SERVER_HOST" >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
echo '";' >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
echo -n '$_SESSION["COMPTE_BASE"]="' >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
echo -n "$DB_SERVER_USER" >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
echo '";' >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
echo -n '$_SESSION["PSWD_BASE"]="' >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
echo -n "$DB_SERVER_PWD" >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
echo '";' >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
echo "?>" >> $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
chown root:$APACHE_GROUP $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php
chmod g+w $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set permissions on $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/dbconfig.inc.php, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo "Creating IPDiscover directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR."
echo "Creating IPDiscover directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR" >> $SETUP_LOG
mkdir -p $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR >> $SETUP_LOG 2>&1
if [ $? != 0 ]
then
echo "*** ERROR: Unable to create $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR."
echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR" >> $SETUP_LOG
# Set IPD area owned by root, group Apache
chown -R root:$APACHE_GROUP $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
# Set IPD area writable by root only
chmod -R go-w $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
# Set IPD area writable by Apache group
chmod g+w $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
#Create packages directory
echo "Creating packages directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR."
echo "Creating packages directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR" >> $SETUP_LOG
mkdir -p $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR >> $SETUP_LOG 2>&1
if [ $? != 0 ]
then
echo "*** ERROR: Unable to create $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR."
echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR" >> $SETUP_LOG
# Set package area owned by root, group Apache
chown -R root:$APACHE_GROUP $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
# Set package area writable by root and Apache group only
chmod -R g+w,o-w $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
# Create snmp custom mibs directory
echo "Creating snmp mibs directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR."
echo "Creating snmp mibs directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR" >> $SETUP_LOG
mkdir -p $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR >> $SETUP_LOG 2>&1
if [ $? != 0 ]
then
echo "*** ERROR: Unable to create $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR."
echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR" >> $SETUP_LOG
# Set snmp area owned by root, group Apache
chown -R root:$APACHE_GROUP $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
# Set snmp area writable by root and Apache group only
chmod -R g+w,o-w $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
# Create logs directory
echo "Creating Administration server log files directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR."
echo "Creating Administration server log files directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR" >> $SETUP_LOG
mkdir -p $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR >> $SETUP_LOG 2>&1
if [ $? != 0 ]
then
echo "*** ERROR: Unable to create $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR."
echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR" >> $SETUP_LOG
# Set log files area owned by root, group Apache
chown -R root:$APACHE_GROUP $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
# Set log files area writable by root and Apache group only
chmod -R g+w,o-w $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_LOGS_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo "Creating Administration server scripts log files directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR."
echo "Creating Administration server scripts log files directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR" >> $SETUP_LOG
mkdir -p $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR >> $SETUP_LOG 2>&1
if [ $? != 0 ]
then
echo "*** ERROR: Unable to create $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR."
echo "Fixing permissions on directory $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR" >> $SETUP_LOG
# Set scripts log files area owned by root, group Apache
chown -R root:$APACHE_GROUP $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
# Set scripts log files area writable by root and Apache group only
chmod -R g+w,o-w $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set permissions on $ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SCRIPTS_LOGS_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo "Configuring IPDISCOVER-UTIL Perl script."
echo "Configuring IPDISCOVER-UTIL Perl script (ed ipdiscover-util.pl)" >> $SETUP_LOG
cp binutils/ipdiscover-util.pl ipdiscover-util.pl.local >> $SETUP_LOG 2>&1
$PERL_BIN -pi -e "s#localhost#$DB_SERVER_HOST#g" ipdiscover-util.pl.local
$PERL_BIN -pi -e "s#3306#$DB_SERVER_PORT#g" ipdiscover-util.pl.local
# echo "******** Begin updated ipdiscover-util.pl.local script ***********" >> $SETUP_LOG
# cat ipdiscover-util.pl.local >> $SETUP_LOG
# echo "******** End updated ipdiscover-util.pl.local script ***********" >> $SETUP_LOG
echo "Installing IPDISCOVER-UTIL Perl script."
echo "Installing IPDISCOVER-UTIL Perl script" >> $SETUP_LOG
cp ipdiscover-util.pl.local $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/ipdiscover-util.pl >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to copy files in $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo "Fixing permissions on IPDISCOVER-UTIL Perl script."
echo "Fixing permissions on IPDISCOVER-UTIL Perl script" >> $SETUP_LOG
chown root:$APACHE_GROUP $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/ipdiscover-util.pl >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set permissions on $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
chmod gou+x $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR/ipdiscover-util.pl >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to set permissions on $ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo "Configuring Apache web server (file $ADM_SERVER_APACHE_CONF_FILE)" >> $SETUP_LOG
cp etc/ocsinventory/$ADM_SERVER_APACHE_CONF_FILE $ADM_SERVER_APACHE_CONF_FILE.local
$PERL_BIN -pi -e "s#OCSREPORTS_ALIAS#$ADM_SERVER_REPORTS_ALIAS#g" $ADM_SERVER_APACHE_CONF_FILE.local
$PERL_BIN -pi -e "s#PATH_TO_OCSREPORTS_DIR#$ADM_SERVER_STATIC_DIR/$ADM_SERVER_STATIC_REPORTS_DIR#g" $ADM_SERVER_APACHE_CONF_FILE.local
$PERL_BIN -pi -e "s#IPD_ALIAS#$ADM_SERVER_IPD_ALIAS#g" $ADM_SERVER_APACHE_CONF_FILE.local
$PERL_BIN -pi -e "s#PATH_TO_IPD_DIR#$ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_IPD_DIR#g" $ADM_SERVER_APACHE_CONF_FILE.local
$PERL_BIN -pi -e "s#PACKAGES_ALIAS#$ADM_SERVER_PACKAGES_ALIAS#g" $ADM_SERVER_APACHE_CONF_FILE.local
$PERL_BIN -pi -e "s#PATH_TO_PACKAGES_DIR#$ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_PACKAGES_DIR#g" $ADM_SERVER_APACHE_CONF_FILE.local
$PERL_BIN -pi -e "s#SNMP_ALIAS#$ADM_SERVER_SNMP_ALIAS#g" $ADM_SERVER_APACHE_CONF_FILE.local
$PERL_BIN -pi -e "s#PATH_TO_SNMP_DIR#$ADM_SERVER_VAR_DIR/$ADM_SERVER_VAR_SNMP_DIR#g" $ADM_SERVER_APACHE_CONF_FILE.local
echo "******** Begin updated $ADM_SERVER_APACHE_CONF_FILE.local ***********" >> $SETUP_LOG
cat $ADM_SERVER_APACHE_CONF_FILE.local >> $SETUP_LOG
echo "******** End updated $ADM_SERVER_APACHE_CONF_FILE.local ***********" >> $SETUP_LOG
echo "Writing Administration server configuration to file $APACHE_CONFIG_DIRECTORY/$ADM_SERVER_APACHE_CONF_FILE"
echo "Writing communication server configuration to file $APACHE_CONFIG_DIRECTORY/$ADM_SERVER_APACHE_CONF_FILE" >> $SETUP_LOG
cp -f $ADM_SERVER_APACHE_CONF_FILE.local $APACHE_CONFIG_DIRECTORY/$ADM_SERVER_APACHE_CONF_FILE >> $SETUP_LOG 2>&1
if [ $? -ne 0 ]
then
echo "*** ERROR: Unable to write $APACHE_CONFIG_DIRECTORY/$ADM_SERVER_APACHE_CONF_FILE, please look at error in $SETUP_LOG and fix !"
echo
echo "Installation aborted !"
exit 1
fi
echo
echo "+----------------------------------------------------------------------+"
echo "| OK, Administration server installation finished ;-) |"
echo "| |"
echo "| Please, review $APACHE_CONFIG_DIRECTORY/$ADM_SERVER_APACHE_CONF_FILE"
echo "| to ensure all is good and restart Apache daemon. |"
echo "| |"
echo "| Then, point your browser to http://server/$ADM_SERVER_REPORTS_ALIAS"
echo "| to configure database server and create/update schema. |"
echo "+----------------------------------------------------------------------+"
echo
echo "Administration server installation successful" >> $SETUP_LOG
fi
echo
echo "Setup has created a log file $SETUP_LOG. Please, save this file."
echo "If you encounter error while running OCS Inventory NG Management server,"
echo "we can ask you to show us its content !"
echo
echo "DON'T FORGET TO RESTART APACHE DAEMON !"
echo
echo "Enjoy OCS Inventory NG ;-)"
echo
exit 0