Re: Factorised code for adding a file in /etc/apache2/conf.d/ and restarting apache ?
Le Sun, Jul 06, 2008 at 03:41:09PM +0200, Marc Chantreux a écrit :
> On Sun, Jul 06, 2008 at 10:19:34PM +0900, Charles Plessy wrote:
> > if [ -x /etc/init.d/apache2 ]; then
> > if which invoke-rc.d >/dev/null 2>&1; then
> > invoke-rc.d apache2 reload
> > else
> > /etc/init.d/apache2 reload
> > fi
> > fi
>
> why not something simple like
>
> /etc/init.d/apache2 reload || error_function
Because invoking directly init.d scripts is forbidden by the Policy:
http://www.debian.org/doc/debian-policy/ch-opersys.html#s9.3.3
"The package maintainer scripts must use invoke-rc.d to invoke the
/etc/init.d/* initscripts, instead of calling them directly."
For the test of existence of /etc/init.d/apache2, it may be a matter of
taste...
In that case again, having some helper functions would make the the
script easier to read and factorise some code...
Bonne journée
--
Charles Plessy
http://charles.plessy.org
Wakō, Saitama, Japan
Reply to: