# $Id: smeserver-inventory-tools.spec,v 1.4 2008/11/25 16:20:24 slords Exp $ # Authority: cool34000 # Name: Sylvain Gomez %define name smeserver-inventory-tools %define version 1 %define release 7 %define rpmver 4.0.4 Summary: OCS Inventory NG and GLPI are web-based Inventory tool & Information Resource-Manager Name: %{name} Version: %{version} Release: %{release}%{?dist} License: GPL Group: SME/Addon Source: %{name}-%{version}.tar.gz URL: http://www.ocsinventory-ng.org/,http://www.glpi-project.org/ BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot Requires: e-smith-base Requires: e-smith-release >= 7 Requires: mod_perl >= 1.99_16-4 Requires: monitor-edid >= 1.11-1 Requires: ocsinventory-ipdiscover >= 1.01-2 Requires: ocsinventory-agent >= 0.0.6-1 Requires: perl-Apache-DBI >= 0.9901-2.2 Requires: perl-Archive-Tar >= 1.23-3.99_2 Requires: perl-Compress-Zlib >= 1.42-1 Requires: perl-Crypt-OpenSSL-Bignum >= 0.03-1.2 Requires: perl-Crypt-OpenSSL-RSA >= 0.21-1.2 Requires: perl-IO-Socket-SSL >= 1.01-1 Requires: perl-IO-Zlib >= 1.04-2 Requires: perl-Mail-DomainKeys >= 0.21-2 Requires: perl-MIME-Lite >= 3.01-2.2 Requires: perl-Net-IP >= 1.23-1 Requires: perl-Net-Jabber >= 2.0-1.2 Requires: perl-Net-XMPP >= 1.0-1.2 Requires: perl-SOAP-Lite >= 0.69-1 Requires: perl-XML-SAX >= -0.12-7 Requires: perl-XML-Simple >= 2.14-4 Requires: perl-XML-Stream >= 1.22-1.2 BuildRequires: e-smith-devtools Conflicts: smeserver-ocs_inventory_ng Conflicts: smeserver-glpi %description This RPM is an unofficial addon for the SME Server 7.x. OCS Inventory NG is an application designed to help a network or system administrator keep track of the computers configuration and software that are installed on the network. GLPI is the Information Resource-Manager with an additional Administration-Interface. http://your_server/ocs http://your_server/glpi %changelog * Sat Nov 10 2007 Sylvain Gomez [1-7] Security fix - Fix security issue on dbconfig.inc.php - We now use root:www 440 - Fix perms on ocsreports folder and ipdiscover-util.pl (750 for both) - Fix problem while importing ocsagent.exe into MySQL - MaxUpload limit raised to 100M by default (new install only) * Thu Nov 8 2007 Sylvain Gomez [1-6] Maintenance release - Thanks again to Stefen Noble - Removed useless MySQL custom-template - Removed ocsagent.exe guide.pdf - Upload limit fixed - 'MaxUpload' DB entry added to set dynamically max upload file size (default still at 10M) - Events moved to domain-modify - 2 new 'url' types added for ocs' virtual locations - Uninstall script now also deletes new DB values + logs + old inventories - Improved Apache templates to allow adding aliases for both web interfaces - RPM runs verbosely * Wed Nov 7 2007 Sylvain Gomez [1-5] Fixing Deployment feature - Thanks again to Stefen Noble - New apache template to add cacert.pem file - cacert.pem is copied from your existing ssl.srt if not present * Tue Nov 6 2007 Sylvain Gomez [1-4] Fixing a few bugs - perl-XML-SAX added to dependencies list - Fix /usr/lib/perl5/vendor_perl/5.8.5/XML/SAX/ParserDetails.ini not existing - Account 'download' created with type 'url' * Tue Nov 6 2007 Sylvain Gomez [1-3] Fixing a few bugs and minor changes. Thanks to Stefen Noble - MySQL database is imported with a safer method (use IF NOT EXIST) - OCS Apache template modified - Minor changes in the uninstall script - Crond restart deleted (not needed) - Launching inventory is for install only now (not update) - Type changed to url instead of reserved * Sun Nov 4 2007 Sylvain Gomez [1-2] Fixing a few bugs - Upload fixed - OCS Apache template modified - ocsagent.exe is now included in ./ocs/files * Fri Nov 2 2007 Sylvain Gomez [1-1] Original version - OCS Inventory NG 1.01 - OCS Linux Agent 0.0.6 - GLPI 0.68.3-2 %prep %setup %build perl createlinks # Default DB parameters DEFAULTS1=root/etc/e-smith/db/configuration/defaults/ocs DEFAULTS2=root/etc/e-smith/db/accounts/defaults/ocs DEFAULTS3=root/etc/e-smith/db/configuration/defaults/glpi DEFAULTS4=root/etc/e-smith/db/accounts/defaults/glpi DEFAULTS5=root/etc/e-smith/db/accounts/defaults/download DEFAULTS6=root/etc/e-smith/db/accounts/defaults/ocsinterface DEFAULTS7=root/etc/e-smith/db/accounts/defaults/ocsinventory mkdir -p $DEFAULTS1 mkdir -p $DEFAULTS2 mkdir -p $DEFAULTS3 mkdir -p $DEFAULTS4 mkdir -p $DEFAULTS5 mkdir -p $DEFAULTS6 mkdir -p $DEFAULTS7 echo "ocsweb" > $DEFAULTS1/DbName echo "ocs" > $DEFAULTS1/DbUser echo "off" > $DEFAULTS1/HTTPS echo "global" > $DEFAULTS1/InventoryAccess echo "600" > $DEFAULTS1/InventoryDelay echo "localhost" > $DEFAULTS1/InventoryServer echo "100M" > $DEFAULTS1/MaxUpload echo "OCS Inventory NG" > $DEFAULTS1/Name echo "local" > $DEFAULTS1/PublicAccess echo "service" > $DEFAULTS1/type echo "url" > $DEFAULTS2/type echo "glpi" > $DEFAULTS3/DbName echo "glpi" > $DEFAULTS3/DbUser echo "off" > $DEFAULTS3/HTTPS echo "GLPI" > $DEFAULTS3/Name echo "local" > $DEFAULTS3/PublicAccess echo "service" > $DEFAULTS3/type echo "url" > $DEFAULTS4/type echo "url" > $DEFAULTS5/type echo "url" > $DEFAULTS6/type echo "url" > $DEFAULTS7/type # Creating templates.metadata TEMPLATE1=root/etc/e-smith/templates.metadata/etc/e-smith/sql/init TEMPLATE2=root/etc/e-smith/templates.metadata/opt/inventory/ocs/ocsreports TEMPLATE3=root/etc/e-smith/templates.metadata/opt/inventory/glpi/config mkdir -p $TEMPLATE1 mkdir -p $TEMPLATE2 mkdir -p $TEMPLATE3 echo 'PERMS=0540' > $TEMPLATE1/80ocs_mysql.sql echo 'PERMS=0540' > $TEMPLATE1/80glpi_mysql.sql echo 'PERMS=0540' > $TEMPLATE1/81ocs-glpi.sql echo 'UID="root"' > $TEMPLATE2/dbconfig.inc.php echo 'GID="www"' >> $TEMPLATE2/dbconfig.inc.php echo 'PERMS=0440' >> $TEMPLATE2/dbconfig.inc.php echo 'UID="root"' > $TEMPLATE3/config_db.php echo 'GID="www"' >> $TEMPLATE3/config_db.php echo 'PERMS=0440' >> $TEMPLATE3/config_db.php %install rm -rf $RPM_BUILD_ROOT (cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT) rm -f %{name}-%{version}-filelist /sbin/e-smith/genfilelist $RPM_BUILD_ROOT > %{name}-%{version}-filelist %clean rm -rf $RPM_BUILD_ROOT %pre # Checking if Inventory files are present before updating # If present, installation files + MySQL DB + DB values are saved if [ -d /opt/inventory ]; then case $LANG in fr_FR) echo "Sauvegarde de l'ancienne install dans /opt/RPM_BACKUP" ;; *) echo "Backing up old install in /opt/RPM_BACKUP" ;; esac mkdir -p /opt/RPM_BACKUP cd /opt tar -czf /opt/RPM_BACKUP/ocs_glpi.tar.gz inventory if [ -d /opt/inventory/ocs ] ; then mysqldump ocsweb > /opt/RPM_BACKUP/ocs.sql fi if [ -d /opt/inventory/glpi ] ; then mysqldump glpi > /opt/RPM_BACKUP/glpi.sql fi /sbin/e-smith/db configuration show ocs > /opt/RPM_BACKUP/ocs_glpi-config.txt echo " " >> /opt/RPM_BACKUP/ocs_glpi-config.txt /sbin/e-smith/db configuration show glpi >> /opt/RPM_BACKUP/ocs_glpi-config.txt fi %post # Initializing SME DB /etc/e-smith/events/actions/initialize-default-databases # Variables DOMAIN=$(/sbin/e-smith/db configuration get DomainName) SRVNAME=$(/sbin/e-smith/db configuration get SystemName) UPDATE=$(ls /opt | grep -c inventory) if [ -d /opt/inventory/ocs ] ; then UPDTOCS=1 ; else UPDTOCS=0 ; fi if [ -d /opt/inventory/glpi ] ; then UPDTGLPI=1 ; else UPDTGLPI=0 ; fi # Decompressing files mkdir -p /opt/inventory tar -xzf /usr/share/doc/smeserver-OCS_GLPI/Sources/ocs.tar.gz -C /opt/inventory tar -xzf /usr/share/doc/smeserver-OCS_GLPI/Sources/glpi.tar.gz -C /opt/inventory # Preparing configuration mkdir -p /var/log/ocsinventory-NG chown www:www /var/log/ocsinventory-NG chmod 775 /var/log/ocsinventory-NG rm -rf /opt/inventory/conf rm -f /etc/ocsinventory-agent/ocsinv.conf mv /usr/lib/perl5/site_perl/5.8.5/Apache/Ocsinventory/Server/Modperl2.pm.txt /usr/lib/perl5/site_perl/5.8.5/Apache/Ocsinventory/Server/Modperl2.pm if [ "$UPDTOCS" = "0" ] ; then cp /usr/share/doc/smeserver-OCS_GLPI/Sources/ocs.sql /etc/e-smith/sql/init/81ocs_db.sql fi if [ "$UPDTGLPI" = "0" ] ; then cp /usr/share/doc/smeserver-OCS_GLPI/Sources/glpi-$LANG.sql /etc/e-smith/sql/init/83glpi_db.sql fi /sbin/e-smith/config setprop modPerl status enabled /sbin/e-smith/config setprop mysqld InnoDB enabled # Fixing XML::SAX ParserDetails.ini if [ ! -e /usr/lib/perl5/vendor_perl/5.8.5/XML/SAX/ParserDetails.ini ]; then touch /usr/lib/perl5/vendor_perl/5.8.5/XML/SAX/ParserDetails.ini chmod 444 /usr/lib/perl5/vendor_perl/5.8.5/XML/SAX/ParserDetails.ini perl -MXML::SAX -e "XML::SAX->add_parser(q(XML::SAX::PurePerl))->save_parsers()" fi # Copying SME's certificate into cacert.pem if the file do not exist # This file is used by deployment function if [ ! -e /home/e-smith/ssl.crt/cacert.pem ]; then cp /home/e-smith/ssl.crt/$SRVNAME.$DOMAIN.crt /home/e-smith/ssl.crt/cacert.pem fi # Applying modifications /sbin/e-smith/expand-template /etc/my.cnf service mysqld restart 2>/dev/null >/dev/null /sbin/e-smith/signal-event domain-modify if [ "$UPDTOCS" = "0" ] ; then case $LANG in fr_FR) echo "Inventaire du serveur SME en cours, veuillez patienter..." ;; *) echo "Inventorying SME Server, please wait this may take a while..." ;; esac /usr/sbin/ocsinventory-agent -s localhost fi echo "-------------------------------------------------------------------------------" case $LANG in fr_FR) case $UPDATE in 0) echo "Installation d'OCS Inventory NG (Serveur+Agent) & GLPI terminée !" ;; *) echo "Mise à jour d'OCS Inventory NG (Serveur+Agent) & GLPI terminée !" ;; esac echo "Pour plus de détails, visitez http://wiki.contribs.org/OCS_Inventory_Tools/fr" ;; *) case $UPDATE in 0) echo "OCS Inventory NG (Server+Agent) & GLPI Installation finished!" ;; *) echo "OCS Inventory NG (Server+Agent) & GLPI Update finished!" ;; esac echo "For more details, see http://wiki.contribs.org/OCS_Inventory_Tools" ;; esac echo "-------------------------------------------------------------------------------" %preun if [ $1 = 0 ] ; then mv /usr/share/doc/smeserver-OCS_GLPI/Sources/DO_NOT_USE_OR_DELETE/OCS_GLPI-Full-Uninstall.sh /root/ mv /usr/lib/perl5/site_perl/5.8.5/Apache/Ocsinventory/Server/Modperl2.pm /usr/lib/perl5/site_perl/5.8.5/Apache/Ocsinventory/Server/Modperl2.pm.txt fi %postun if [ $1 = 0 ] ; then # Restoring default default values..." /sbin/e-smith/config setprop mysqld InnoDB disabled /sbin/e-smith/expand-template /etc/my.cnf service mysqld restart 2>/dev/null >/dev/null /sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf /etc/rc7.d/S86httpd-e-smith sigusr1 2>/dev/null >/dev/null echo "Uninstallation finished!" echo " " echo "If you want to completly remove OCS & GLPI" echo "(installation files, MySQL user+database and Agent RPMs)" echo "please issue the following command at the prompt:" echo "# sh /root/OCS_GLPI-Full-Uninstall.sh" fi %files -f %{name}-%{version}-filelist %defattr(-,root,root)