From 3b779d72c94ba347a60a9e8dde6b00905543e104 Mon Sep 17 00:00:00 2001 From: ramonn Date: Wed, 22 May 2013 16:58:14 +0000 Subject: [PATCH] 2013-05-22 Ramon Novoa * pandora_server.spec, pandora_server.redhat.spec, DEBIAN/postinst, DEBIAN/conffiles, DEBIAN/make_deb_package.sh, conf/pandora_server.conf.new, pandora_server_installer: Merged Sancho's changes from 4.0 branch. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8191 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 10 +++++++ pandora_server/DEBIAN/conffiles | 1 - pandora_server/DEBIAN/make_deb_package.sh | 1 - pandora_server/DEBIAN/postinst | 12 ++++---- ...ra_server.conf => pandora_server.conf.new} | 0 pandora_server/pandora_server.redhat.spec | 23 ++++++++++----- pandora_server/pandora_server.spec | 29 +++++++++---------- pandora_server/pandora_server_installer | 5 ++-- 8 files changed, 49 insertions(+), 32 deletions(-) delete mode 100755 pandora_server/DEBIAN/conffiles rename pandora_server/conf/{pandora_server.conf => pandora_server.conf.new} (100%) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 2668bf9894..10af532e6d 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,13 @@ +2013-05-22 Ramon Novoa + + * pandora_server.spec, + pandora_server.redhat.spec, + DEBIAN/postinst, + DEBIAN/conffiles, + DEBIAN/make_deb_package.sh, + conf/pandora_server.conf.new, + pandora_server_installer: Merged Sancho's changes from 4.0 branch. + 2013-05-20 Ramon Novoa * util/pandora_xml_stress.pl: Added support for strictly incremental diff --git a/pandora_server/DEBIAN/conffiles b/pandora_server/DEBIAN/conffiles deleted file mode 100755 index 7a4bd226ed..0000000000 --- a/pandora_server/DEBIAN/conffiles +++ /dev/null @@ -1 +0,0 @@ -/etc/pandora/pandora_server.conf diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index a5b1acf104..4f3527967a 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/DEBIAN/make_deb_package.sh @@ -68,7 +68,6 @@ then mkdir -p temp_package/usr/sbin/ mkdir -p temp_package/etc/init.d/ mkdir -p temp_package/etc/pandora/ - touch temp_package/etc/pandora/pandora_server.conf mkdir -p temp_package/var/spool/pandora/data_in chmod 770 temp_package/var/spool/pandora/data_in mkdir -p temp_package/var/spool/pandora/data_in/conf diff --git a/pandora_server/DEBIAN/postinst b/pandora_server/DEBIAN/postinst index 061e0703b7..4bca4d729e 100755 --- a/pandora_server/DEBIAN/postinst +++ b/pandora_server/DEBIAN/postinst @@ -72,13 +72,13 @@ echo "Creating setup directory in /etc/pandora" mkdir /etc/pandora 2> /dev/null #Check if exist old conf file -count_lines_conf=`cat /etc/pandora/pandora_server.conf | wc -l` - -if [ $count_lines_conf -eq 0 ] +if [ ! -e /etc/pandora/pandora_server.conf ] then - rm /etc/pandora/pandora_server.conf - ln -s /usr/share/pandora_server/conf/pandora_server.conf /etc/pandora/ - chmod 770 /etc/pandora/pandora_server.conf + cp /usr/share/pandora_server/conf/pandora_server.conf.new /etc/pandora/pandora_server.conf + chmod 600 /etc/pandora/pandora_server.conf +else + cp /usr/share/pandora_server/conf/pandora_server.conf.new /etc/pandora/pandora_server.conf.new + echo "Skipping creation of pandora_server.conf: there is already one." fi echo "Linking startup script to /etc/rc2.d" diff --git a/pandora_server/conf/pandora_server.conf b/pandora_server/conf/pandora_server.conf.new similarity index 100% rename from pandora_server/conf/pandora_server.conf rename to pandora_server/conf/pandora_server.conf.new diff --git a/pandora_server/pandora_server.redhat.spec b/pandora_server/pandora_server.redhat.spec index ff36364769..3e8cc72306 100644 --- a/pandora_server/pandora_server.redhat.spec +++ b/pandora_server/pandora_server.redhat.spec @@ -76,7 +76,7 @@ rm -f $RPM_BUILD_ROOT%{prefix}/pandora_server/util/PandoraFMS rm -f $RPM_BUILD_ROOT%{prefix}/pandora_server/util/recon_scripts/PandoraFMS install -m 0644 util/pandora_logrotate $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d/pandora_server -install -m 0640 conf/pandora_server.conf $RPM_BUILD_ROOT%{_sysconfdir}/pandora/ +install -m 0640 conf/pandora_server.conf.new $RPM_BUILD_ROOT%{_sysconfdir}/pandora/pandora_server.conf.new cat < $RPM_BUILD_ROOT%{_sysconfdir}/cron.hourly/pandora_db #!/bin/bash @@ -91,11 +91,6 @@ rm -fr $RPM_BUILD_ROOT getent passwd pandora >/dev/null || \ /usr/sbin/useradd -d %{prefix}/pandora_server -s /sbin/nologin -M -g 0 pandora -if [ -e "/etc/pandora/pandora_server.conf" ] -then - cat /etc/pandora/pandora_server.conf > /etc/pandora/pandora_server.conf.old -fi - exit 0 %post @@ -113,6 +108,18 @@ if [ "$1" = 1 ]; then echo " " fi +# This will avoid pandora_server.conf overwritting on UPGRADES. + +if [ ! -e "/etc/pandora/pandora_server.conf" ] +then + echo "Creating a new version of Pandora FMS Server config file at /etc/pandora/pandora_server.conf" + cat /etc/pandora/pandora_server.conf.new > /etc/pandora/pandora_server.conf +else + # Do a copy of current .conf, just in case. + echo "An existing version of pandora_server.conf is found." + cat /etc/pandora/pandora_server.conf > /etc/pandora/pandora_server.conf.old +fi + echo "Don't forget to start Tentacle Server daemon if you want to receive" echo "data using tentacle" @@ -151,9 +158,11 @@ exit 0 %{_bindir}/tentacle_server %dir %{_localstatedir}/log/pandora %dir %{_sysconfdir}/pandora -%config(noreplace) %{_sysconfdir}/pandora/pandora_server.conf %dir %{_localstatedir}/spool/pandora +%defattr(600,root,root) +/etc/pandora/pandora_server.conf.new + %defattr(770,pandora,apache) %{_localstatedir}/spool/pandora/data_in diff --git a/pandora_server/pandora_server.spec b/pandora_server/pandora_server.spec index b098a732ac..7d8cc2d8bd 100644 --- a/pandora_server/pandora_server.spec +++ b/pandora_server/pandora_server.spec @@ -80,8 +80,8 @@ cp -aRf util/tentacle_serverd $RPM_BUILD_ROOT/etc/init.d/ cp -aRf man/man1/pandora_server.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ cp -aRf man/man1/tentacle_server.1.gz $RPM_BUILD_ROOT/usr/share/man/man1/ -rm -f $RPM_BUILD_ROOT%{prefix}/pandora_server/util/PandoraFMS -rm -f $RPM_BUILD_ROOT%{prefix}/pandora_server/util/recon_scripts/PandoraFMS +rm -Rf $RPM_BUILD_ROOT%{prefix}/pandora_server/util/PandoraFMS +rm -Rf $RPM_BUILD_ROOT%{prefix}/pandora_server/util/recon_scripts/PandoraFMS %clean rm -fr $RPM_BUILD_ROOT @@ -91,11 +91,7 @@ if [ "`id pandora | grep uid | wc -l`" = 0 ] then /usr/sbin/useradd -d %{prefix}/pandora -s /bin/false -M -g 0 pandora fi - -if [ -e "/etc/pandora/pandora_server.conf" ] -then - cat /etc/pandora/pandora_server.conf > /etc/pandora/pandora_server.conf.old -fi +exit 0 %post chkconfig pandora_server on @@ -109,18 +105,21 @@ if [ ! -d /etc/pandora ] ; then mkdir -p /etc/pandora fi -if [ ! -e /etc/pandora/pandora_server.conf ] ; then - ln -s /usr/share/pandora_server/conf/pandora_server.conf /etc/pandora/ - echo "Pandora FMS Server configuration is /etc/pandora/pandora_server.conf" - echo "Pandora FMS Server main directory is %{prefix}/pandora_server/" - echo "The manual can be reached at: man pandora or man pandora_server" - echo "Pandora FMS Documentation is in: http://pandorafms.org" - echo " " +if [ ! -e "/etc/pandora/pandora_server.conf" ] +then + echo "Creating a new version of Pandora FMS Server config file at /etc/pandora/pandora_server.conf" + cat /etc/pandora/pandora_server.conf.new > /etc/pandora/pandora_server.conf +else + # Do a copy of current .conf, just in case. + echo "An existing version of pandora_server.conf is found." + cat /etc/pandora/pandora_server.conf > /etc/pandora/pandora_server.conf.old fi echo "Don't forget to start Tentacle Server daemon if you want to receive" echo "data using tentacle" +exit 0 + %preun # Upgrading @@ -145,7 +144,7 @@ rm -Rf /etc/init.d/pandora_server rm -Rf %{prefix}pandora_server rm -Rf /var/log/pandora rm -Rf /usr/lib/perl5/PandoraFMS/ -rm -Rf /etc/pandora/pandora_server.conf +rm -Rf /etc/pandora/pandora_server.conf* rm -Rf /var/spool/pandora rm -Rf /etc/init.d/pandora_server /etc/init.d/tentacle_serverd rm -Rf /usr/bin/pandora_exec /usr/bin/pandora_server /usr/bin/tentacle_server diff --git a/pandora_server/pandora_server_installer b/pandora_server/pandora_server_installer index fa113e0a8c..159d62d468 100755 --- a/pandora_server/pandora_server_installer +++ b/pandora_server/pandora_server_installer @@ -297,8 +297,8 @@ perl-TimeDate perl-XML-Simple perl-XML-Twig perl-libwww-perl mysql-client" echo cp NetBSD/pandora_server.conf $PANDORA_CFG_DIR cp NetBSD/pandora_server.conf $PANDORA_CFG_DIR else - echo cp conf/pandora_server.conf $PANDORA_CFG_DIR - cp conf/pandora_server.conf $PANDORA_CFG_DIR + echo cp conf/pandora_server.conf.new $PANDORA_CFG_DIR + cp conf/pandora_server.conf.new $PANDORA_CFG_DIR fi chmod 770 $PANDORA_CFG_FILE @@ -549,6 +549,7 @@ uninstall () { rm -Rf $PANDORA_LOG 2> /dev/null rm -Rf $PANDORA_CFG_FILE 2> /dev/null + rm -Rf "$PANDORA_CFG_FILE.new" 2> /dev/null rm -Rf $PANDORA_SERVER 2> /dev/null rm -Rf /usr/bin/pandora_server 2> /dev/null rm -Rf /usr/bin/pandora_exec 2> /dev/null