[icinga-checkins] icinga.org: icinga-core/tdressler/sqlite: idoutils: add new sqlite package to icinga.spec

git at icinga.org git at icinga.org
Sun Apr 14 22:01:18 CEST 2013


Module: icinga-core
Branch: tdressler/sqlite
Commit: 7d84720607dc94f3d92d5011df0682d76a3ccace
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=7d84720607dc94f3d92d5011df0682d76a3ccace

Author: Thomas Dressler <tdressler at tdressler.net>
Date:   Sun Apr 14 21:57:54 2013 +0200

idoutils: add new sqlite package to icinga.spec
refs #3945

---

 icinga.spec |   68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/icinga.spec b/icinga.spec
index a9b0e2a..222fbd2 100644
--- a/icinga.spec
+++ b/icinga.spec
@@ -90,6 +90,7 @@ Group: Applications/System
 Requires: %{name} = %{version}-%{release}
 Requires: libdbi-dbd-mysql
 Conflicts: %{name}-idoutils-libdbi-pgsql
+Conflicts: %{name}-idoutils-libdbi-sqlite
 
 %description idoutils-libdbi-mysql
 This package contains the idoutils broker module for %{name} which provides
@@ -101,11 +102,24 @@ Group: Applications/System
 Requires: %{name} = %{version}-%{release}
 Requires: libdbi-dbd-pgsql
 Conflicts: %{name}-idoutils-libdbi-mysql
+Conflicts: %{name}-idoutils-libdbi-sqlite
 
 %description idoutils-libdbi-pgsql
 This package contains the idoutils broker module for %{name} which provides
 database storage via libdbi and pgsql.
 
+%package idoutils-libdbi-sqlite
+Summary: database broker module for %{name}
+Group: Applications/System
+Requires: %{name} = %{version}-%{release}
+Requires: libdbi-dbd-sqlite
+BuildRequires: sqlite > 3.4
+Conflicts: %{name}-idoutils-libdbi-mysql
+Conflicts: %{name}-idoutils-libdbi-pgsql
+
+%description idoutils-libdbi-sqlite
+This package contains the idoutils broker module for %{name} which provides
+database storage via libdbi and sqlite.
 
 %package doc
 Summary: documentation %{name}
@@ -212,6 +226,9 @@ install -m0644 include/*.h "%{buildroot}%{_includedir}/%{name}"
 # create perfdata dir by default
 install -d -m0755 "%{buildroot}%{_localstatedir}/spool/%{name}/perfdata"
 
+#install sqlite db
+sqlite3 %{buildroot}%{spooldir}/icinga.db < module/idoutils/db/sqlite/sqlite.sql
+
 %pre
 # Add icinga user
 %{_sbindir}/groupadd icinga 2> /dev/null || :
@@ -326,6 +343,45 @@ if [ $1 -eq 0 ]; then
     /sbin/chkconfig --del ido2db
 fi
 
+%post idoutils-libdbi-sqlite
+/sbin/chkconfig --add ido2db
+# delete old bindir/idomod.o if it exists
+if [ -f %{_bindir}/idomod.o ]
+then
+    rm -f %{_bindir}/idomod.o
+fi
+### change ido2db.cfg to match sqlite config
+# check if this is an upgrade
+if [ $1 -eq 2 ]
+then
+        %{__cp} %{_sysconfdir}/icinga/ido2db.cfg %{_sysconfdir}/icinga/ido2db.cfg.sqlite
+        %{__perl} -pi -e '
+                s|db_servertype=mysql|db_servertype=sqlite3|;
+                s|db_port=3306|db_port=|;
+                s|db_host=3306|db_host=%{spooldir}|;
+                s|db_name=.*|db_name=icinga.db|;
+                ' %{_sysconfdir}/icinga/ido2db.cfg.sqlite
+        %logmsg "Warning: upgrade, sqlite config written to ido2db.cfg.sqlite"
+        %logmsg "idoutils-libdbi-sqlite installed. don't forget to upgrade db schema, check README.RHEL.idoutils"
+fi
+# install
+if [ $1 -eq 1 ]
+then
+        %{__perl} -pi -e '
+                s|db_servertype=mysql|db_servertype=sqlite|;
+                s|db_port=3306|db_port=|;
+                s|db_host=3306|db_host=%{spooldir}|;
+                s|db_name=.*|db_name=icinga.db|;
+                ' %{_sysconfdir}/icinga/ido2db.cfg
+        %logmsg "idoutils-libdbi-sqlite installed. preconfigured database icinga.db has been installed in %{spooldir}."
+fi
+
+
+%preun idoutils-libdbi-sqlite
+if [ $1 -eq 0 ]; then
+    /sbin/service ido2db stop &>/dev/null || :
+    /sbin/chkconfig --del ido2db
+fi
 
 %clean
 %{__rm} -rf %{buildroot}
@@ -435,6 +491,18 @@ fi
 %{_bindir}/log2ido
 %{_libdir}/%{name}/idomod.so
 
+%files idoutils-libdbi-sqlite
+%defattr(-,root,root,-)
+%doc README LICENSE Changelog UPGRADING module/idoutils/db README.RHEL README.RHEL.idoutils
+%attr(755,-,-) %{_initrddir}/ido2db
+%attr(660,root,root) %config(noreplace) %{_sysconfdir}/%{name}/ido2db.cfg
+%config(noreplace) %{_sysconfdir}/%{name}/idomod.cfg
+%config(noreplace) %{_sysconfdir}/%{name}/modules/idoutils.cfg
+%config(noreplace) %{_sysconfdir}/%{name}/objects/ido2db_check_proc.cfg
+%{_bindir}/ido2db
+%{_bindir}/log2ido
+%{_libdir}/%{name}/idomod.so
+%{spooldir}/icinga.db
 
 %changelog
 * Thu Apr 25 2013 Michael Friedrich <michael.friedrich at netways.de> - 1.9.0-1





More information about the icinga-checkins mailing list