Debian11OcsInventory - sivasmartins/Documentos GitHub Wiki

OSC Inventory Server - Debian 11

Before Install

apt update

Base

apt -y install make cmake gcc build-essential

Apache2

apt -y install libapache2-mod-perl2 libapache-dbi-perl libapache-db-perl libapache2-mod-php

PHP

apt -y install php php-zip php-pclzip php-gd php-mysql php-soap php-curl php-json php-xml php-mbstring

PERL

apt -y install perl libxml-simple-perl libcompress-zlib-perl libdbi-perl libdbd-mysql-perl libnet-ip-perl libsoap-lite-perl libio-compress-perl libapache-dbi-perl libapache2-mod-perl2 libapache2-mod-perl2-dev libdbd-mysql-perl libnet-ip-perl libxml-simple-perl libarchive-zip-perl

cpan install XML::Entities Apache2::SOAP Net::IP Apache::DBI Mojolicious Switch Plack::Handler Archive::Zip

Database - MariaDB + Phpmyadmin

apt install -y mariadb-server phpmyadmin

Security

mysql_secure_installation

Create OCS Database

mysql -u root -p

create database ocsdb;
create user 'ocsuser'@'localhost' identified by 'ocspass';
grant all privileges on ocsdb.* to ocsuser@localhost identified by "ocspass";
flush privileges;
quit;

OCS INSTALL

Download

cd /tmp
wget https://github.com/OCSInventory-NG/OCSInventory-ocsreports/releases/download/2.11.1/OCSNG_UNIX_SERVER-2.11.1.tar.gz
tar xvf OCSNG_UNIX_SERVER-2.11.1.tar.gz
cd OCSNG_UNIX_SERVER-2.11.1

Config setup.sh

:~# vim setup.sh
DB_SERVER_HOST="localhost"
DB_SERVER_PORT="3306"
DB_SERVER_USER="ocsuser"
DB_SERVER_PWD="ocspass"

Database Import

mysql -u ocsuser -p ocsdb < /tmp/OCSNG_UNIX_SERVER-2.11.1/ocsreports/files/ocsbase.sql > log.log
#ocspass

Install

./setup.sh

Apache Config

ln -s /etc/apache2/conf-available/ocsinventory-reports.conf /etc/apache2/conf-enabled/ocsinventory-reports.conf
ln -s /etc/apache2/conf-available/z-ocsinventory-server.conf /etc/apache2/conf-enabled/z-ocsinventory-server.conf
ln -s /etc/apache2/conf-available/zz-ocsinventory-restapi.conf /

dbname, user or pass

vim /etc/apache2/conf-available/z-ocsinventory-server.conf
vim /etc/apache2/conf-available/zz-ocsinventory-restapi.conf

Restart

systemctl restart apache2

Apache redirect

cd /var/www/html
mv index.html index.html.old

:~# vim index.html
<meta http-equiv="refresh" content="1; url=/ocsreports/">

Access

http://$server_ip_address/ocsreports
admin
admin

After Install

cd /usr/share/ocsinventory-reports/ocsreports/
mv install.php install.php.old

Crontab

# cd /usr/share/ocsinventory-reports/ocsreports/crontab/
# Confirm if the paths are ok
# ./cron_all_software.php
# ./cron_cve_computer.php
# ./cron_cve.php
# ./cron_ipdiscover.php
# ./cron_purge_history.php
# ./cron_report_notification.php
# ./cron_wol.php

crontab -e
0 23 * * * cd /usr/share/ocsinventory-reports/ocsreports/crontab/ && php cron_all_software.php