if statement for symlink of lighttpd.conf is wrong in cacti.postinst

Bug #1132415 reported by James Cole
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cacti (Ubuntu)
Fix Released
Low
Paul Gevers

Bug Description

When installing cacti on a system with lighttpd already installed, debian/cacti.postinst runs but fails to set up a symlink for the file lighttpd.conf

An excerpt of the code I believe to be at fault is here:

# Only try to add a symlink on a fresh install to respect
# changes done by the administrator
if [ "$2" = '' ]; then
    for server in $webservers; do
        if [ -d "/etc/${server}/conf.d" ]; then
            if [ ! -e "/etc/${server}/conf.d/cacti.conf" ] ; then
                ln -s ../../cacti/apache.conf "/etc/${server}/conf.d/cacti.conf"
            fi
            invoke-rc.d $server reload || true
 elif [ -d "/etc/${server}/conf-available" ]; then
            if [ ! -e "/etc/${server}/conf-available" ] ; then
                ln -s ../../cacti/lighttpd.conf "/etc/${server}/conf-available/cacti.conf"
            fi
        fi
    done
fi

I've included the part about apache to show where in regards to the full statement that the web server is restarted.

I believe the correct behavior should be as follows:

if [ "$2" = '' ]; then
   for server in $webservers; do
       if [ -d "/etc/${server}/conf.d" ]; then
           if [ ! -e "/etc/${server}/conf.d/cacti.conf" ] ; then
               ln -s ../../cacti/apache.conf "/etc/${server}/conf.d/cacti.conf"
           fi
       elif [ -d "/etc/${server}/conf-available" ]; then
           if [ ! -e "/etc/${server}/conf-available/20-cacti.conf" ] ; then
                  ln -s ../../cacti/lighttpd.conf "/etc/${server}/conf-available/20-cacti.conf"
                  lighty-enable-mod cacti
           fi
           invoke-rc.d $server reload || true
       fi
   done
fi

My changes reflect the fact that:
- it needs to check if the file already exists rather than checking the directory

- I've changed the file name to reflect what I believe to be an appropriate interpretation of the naming convention for the debian take on conf files for lighttpd which is nn-name where nn reflects the priority number

- included a call to lighty-enable-mod to then enable the cacti conf file (as we are installing cacti aren't we?)

- shifted the call to invoke a http reboot to after lighttpd statements so that in both apache and lighttpd cases the daemon is restarted

There is also a problem with the lighttpd.conf file that is provided, it is as so:

# Cacti Alias
alias.url += (
        "/cacti" => "usr/share/cacti/site",
)

it should be:

# Cacti Alias
alias.url += (
        "/cacti" => "/usr/share/cacti/site",
)

to reflect that it is relative to the root directory rather than current.

James Cole (2-launchpad)
description: updated
Revision history for this message
Paul Gevers (paul-climbing) wrote :

Hi,

Thanks for providing the patch. However, do you agree that the "invoke-rc.d $server reload || true" should be one line lower, i.e. after the "fi"? Now, in case of apache it does not get called.

Changed in cacti (Ubuntu):
assignee: nobody → Paul Gevers (paul-climbing)
status: New → Confirmed
status: Confirmed → Triaged
importance: Undecided → Low
Revision history for this message
James Cole (2-launchpad) wrote :

I do agree it should be one fi lower! I'm no programmer by far, but that is what I was trying to achieve!

Revision history for this message
Paul Gevers (paul-climbing) wrote : Request for help determining lighttpd settings for cacti

Hi James Cole,

I am currently trying to improve the configuration of cacti handling.
Part of it is to fix this bug, but while I tried out to install lighttpd
myself, I found that it is not clear to me how to configure it properly.

I now have lighttpd running and I want to get cacti processed by it as
well. I can enable the cacti module but then lighttpd gives me a "403 -
Forbidden" error. I then enabled the fastcgi-php module and after
installing php5-cli, lighttpd succesfully servered cacti. Now my
question is, is fastcgi-php needed, or can you also activate php
differently in lighttpd. I was not able to find the answer to that
question in a reasonable time. I hope you know (part of) the answer.

Paul

Revision history for this message
Paul Gevers (paul-climbing) wrote :
Changed in cacti (Ubuntu):
status: Triaged → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cacti - 0.8.8a+dfsg-6

---------------
cacti (0.8.8a+dfsg-6) unstable; urgency=low

  * Improve maintenance scripts
    - Prepare cacti configuration for Apache2.4 according to
      http://wiki.debian.org/Apache/PackagingFor24
    - Improve cacti.config to fix dpkg-reconfigure behavior for httpd's.
    - Restart lighttpd if needed (LP: #1132415)
    - Remove obsolete (Sarge) preinst code
  * Fix the lighttpd config template for absolute path (see LP: #1132415)
  * Lintian triggered improvements:
    - Update watch file for +dfsg in the version
    - Add dependency on mysql-client (next to virtual-mysql-client)
  * Bug fixes:
    - Add patch loadavg_multi_locale_friendly.patch to allow uptime script to
      work independent of the local locale (Closes: #704057)
    - Add patch fix_php_strict_warning_in_ping.patch to fix php 5.4 warnings
      (Closes: #694159)
    - Add patch poller_cache_rebuild_on_install.patch to start filling the
      auto-generated graphs upon installation (Upstream: 2229)
  * Move configuration files away from /usr/share/doc/cacti (policy 12.3)
  * Remove obsolete RM-Upload-Allowed from d/control
  * Revisited README.Debian

 -- Paul Gevers <email address hidden> Sun, 05 May 2013 16:41:13 +0200

Changed in cacti (Ubuntu):
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.