[Pkg-nagios-devel] Bug#698139: init script breaks badly with empty icinga.cfg, resulting in package being in a bad state

Peter Palfrader weasel at debian.org
Mon Jan 14 11:12:08 UTC 2013


Package: icinga-common
Version: 1.7.1-4
Severity: important

When, for some reason or another, one ends up with an empty icinga.cfg,
the init script fails:

> root at buran:~# service icinga start
> /etc/init.d/icinga: 85: shift: can't shift that many
> root at buran:~# dash -x /etc/init.d/icinga start
> + set -e
> + . /lib/lsb/init-functions
> + run-parts --lsbsysinit --list /lib/lsb/init-functions.d
> + [ -r /lib/lsb/init-functions.d/20-left-info-blocks ]
> + . /lib/lsb/init-functions.d/20-left-info-blocks
> + FANCYTTY=
> + [ -e /etc/lsb-base-logging.sh ]
> + true
> + DAEMON=/usr/sbin/icinga
> + NAME=icinga
> + DESC=icinga monitoring daemon
> + ICINGACFG=/etc/icinga/icinga.cfg
> + CGICFG=/etc/icinga/cgi.cfg
> + NICENESS=5
> + [ -x /usr/sbin/icinga ]
> + [ -r /etc/default/icinga ]
> + . /etc/default/icinga
> + ICINGACFG=/etc/icinga/icinga.cfg
> + CGICFG=/etc/icinga/cgi.cfg
> + NICENESS=5
> + IDO2DB=no
> + [ ! -f /etc/icinga/icinga.cfg ]
> + get_config lock_file
> + [  ]
> + sed s@=@ @
> + grep ^lock_file /etc/icinga/icinga.cfg
> + set --
> + shift
> /etc/init.d/icinga: 85: shift: can't shift that many
> + THEPIDFILE=


This is particularly bad since it means the postinst script of icinga-common
fails, and the packages are left in a mess:

} root at buran:/var/cache/apt/archives# dpkg -i icinga-common_1.7.1-4_all.deb 
} (Reading database ... 39379 files and directories currently installed.)
} Preparing to replace icinga-common 1.7.1-4 (using icinga-common_1.7.1-4_all.deb) ...
} /etc/init.d/icinga: 85: shift: can't shift that many
} invoke-rc.d: initscript icinga, action "stop" failed.
} dpkg: warning: subprocess old pre-removal script returned error exit status 2
} dpkg: trying script from the new package instead ...
} /etc/init.d/icinga: 85: shift: can't shift that many
} invoke-rc.d: initscript icinga, action "stop" failed.
} dpkg: error processing icinga-common_1.7.1-4_all.deb (--install):
}  subprocess new pre-removal script returned error exit status 2
} /etc/init.d/icinga: 85: shift: can't shift that many
} invoke-rc.d: initscript icinga, action "start" failed.
} dpkg: error while cleaning up:
}  subprocess installed post-installation script returned error exit status 2
} Errors were encountered while processing:
}  icinga-common_1.7.1-4_all.deb

] # dpkg --remove icinga-common
] # dpkg --remove icinga-common icinga-core icinga-cgi  icinga
] dpkg: error processing icinga-common (--remove):
]  Package is in a very bad inconsistent state - you should
]  reinstall it before attempting a removal.

Maybe in addition to making the init script more robust, you want to run
dh_installinit with --error-handler=icinga_error_init and define such a
function in your postinst.

See #652884 for an example in Tor.

Cheers,
weasel



More information about the Pkg-nagios-devel mailing list