Re: Creating an RPM to install a daemon
On Thu, Oct 28, 2010 at 5:10 PM, Joe Flowers joe.flow...@nofreewill.comwrote: 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 http://fedoraproject.org/wiki/Packaging/SysVInitScript https://fedoraproject.org/wiki/Packaging/ScriptletSnippets http://fedoraproject.org/wiki/Packaging/Guidelines the standard way is (example squid with some my comment) .. Requires(post): /sbin/chkconfig Requires(preun): /sbin/service /sbin/chkconfig Requires(postun): /sbin/service . .. %post /sbin/chkconfig --add squid %preun #last removal if [ $1 = 0 ] ; then service squid stop /dev/null 21 rm -f /var/log/squid/* /sbin/chkconfig --del squid fi %postun #restart the service if it was already running, in update only if [ $1 -ge 1 ] ; then service squid condrestart /dev/null 21 fi 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 RPM) * 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 Managerhttp://rpm5.org User Communication List rpm-users@rpm5.org
Creating an RPM to install a daemon
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? Thanks! Joe --- __ RPM Package Managerhttp://rpm5.org User Communication List rpm-users@rpm5.org
Re: Creating an RPM to install a daemon
On Oct 28, 2010, at 11:10 AM, Joe Flowers 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 (aside) Well first of all, chkconfig doesn't do the right thing in many cases like installing into a chroot, or with SELinux enabled, or if networking isn't configured, etc etc etc. So one can make a strong argument (I just tried, YMMV) for _NOT_ doing chkconfig in package scriptlets whatsoever, but rather configure daemon startup (if changed) in some other way, The underlying design principle that is violated with chkconfig in packaging scriptlets is that package management != configuration management the important difference is the persistence involved: The time scale and state for package management is rather different than that for configuration management. And in many cases :One size does not fit all usage cases. But the specific answer to your question is usually to add to %post/%preun. You likely have examples on your system using chkconfig already installed: rpm -qa --scripts /tmp/scripts and then look for an example of what is being attempted with chkconfig. Do the same thing. Should this line go somewhere in the Makefile (like the install section), or should it go in the RPM .spec file somewhere? Not the Makefile, but in the %post or %preun scriptlet in the spec file. Is there some other command I should use rather than this external chkconfig program? For configuring a daemon to start at a run level, chkconfig is what you want. hth 73 de Jeff __ RPM Package Managerhttp://rpm5.org User Communication List rpm-users@rpm5.org