RPM Community Forums

Mailing List Message of <rpm-users>

Re: Creating an RPM to install a daemon

From: devzero2000 <pinto.elia@gmail.com>
Date: Fri 29 Oct 2010 - 15:29:16 CEST
Message-ID: <AANLkTi=DK=du0txUJvHoYsHRqavQYrSmfvMHAhTF6B97@mail.gmail.com>
On Thu, Oct 28, 2010 at 5:10 PM, Joe Flowers <joe.flowers@nofreewill.com>wrote:

> Hello Everyone,
> I am trying to create an RPM that will install a daemon "correctly", but
> I'm not sure if or where I should put the command:
> chkconfig --level 345 /etc/rc.d/mydaemon on
> Should this line go somewhere in the Makefile (like the "install" section),
> or should it go in the RPM .spec file somewhere?
> Is there some other command I should use rather than this external
> "chkconfig" program?
> If you want to use the fedora way to do packaging


the "standard" way is (example squid with some my comment)
Requires(post): /sbin/chkconfig
Requires(preun): /sbin/service /sbin/chkconfig
Requires(postun): /sbin/service

/sbin/chkconfig --add squid

#last removal
if [ $1 = 0 ] ; then
        service squid stop >/dev/null 2>&1
        rm -f /var/log/squid/*
        /sbin/chkconfig --del squid

#restart the service if it was already running, in update only
if [ "$1" -ge "1" ] ; then
        service squid condrestart >/dev/null 2>&1

If you were curious of why there are if condition based on the number of
package installed ($1) that it's because in update RPM performs the
following sequence of actions (the install-before-remove sequence tipical of

    *      Run%pre of new package
    *      Install new files
    *      Run% post of new package
    *      Run% preun of old package
    *      Delete any old files not overwritten by newer ones
    *      Run% postun of old package

best regards

> Thanks!
> Joe
> ---------------
> ______________________________________________________________________
> RPM Package Manager                                    http://rpm5.org
> User Communication List                             rpm-users@rpm5.org
Received on Fri Oct 29 15:29:35 2010
Driven by Jeff Johnson and the RPM project team.
Hosted by OpenPKG and Ralf S. Engelschall.
Powered by FreeBSD and OpenPKG.