Add support for init.d script addition and removal 
---------------------------------------------------

                 Key: MOJO-1231
                 URL: http://jira.codehaus.org/browse/MOJO-1231
             Project: Mojo
          Issue Type: Improvement
          Components: rpm
         Environment: linux (fedora and redhat) 
            Reporter: Erik Drolshammer


When installing java applications with rpm we often want init.d scripts as 
well. This is not difficult using bash scripting, but it is error prone and 
hard to reuse across projects. 
Would it be possible to add support to the rpm-maven-plugin for this? 

For example add these as bash-scripts and add a property "generateInitDScripts" 
(true/false) to enable disabled them? 
They must of course be removed when removing the rpm package. 

Below is a suggestion for bash script. 


<postinstall>
            echo Configuring ${pom.name} init scripts
            #!/bin/sh
            #echo RPM_INSTALL_PREFIX: $RPM_INSTALL_PREFIX
            #echo prefix: %{prefix}

            ln -s $RPM_INSTALL_PREFIX/bin/${rpm.appname} 
/etc/init.d/${rpm.appname}
            #update-rc.d ${rpm.appname} start 20 3 5 . stop 20 0 1 2 4 6 .

            # configure chkconfig install

            if [ -x /sbin/chkconfig ]; then
            /sbin/chkconfig --add ${rpm.appname}
            else
            ln -sf /etc/init.d/${rpm.appname} /etc/rc.d/rc3.d/S20${rpm.appname}
            ln -sf /etc/init.d/${rpm.appname} /etc/rc.d/rc5.d/S20${rpm.appname}

            ln -sf /etc/init.d/${rpm.appname} /etc/rc.d/rc0.d/K10${rpm.appname}
            ln -sf /etc/init.d/${rpm.appname} /etc/rc.d/rc1.d/K10${rpm.appname}
            ln -sf /etc/init.d/${rpm.appname} /etc/rc.d/rc2.d/K10${rpm.appname}
            ln -sf /etc/init.d/${rpm.appname} /etc/rc.d/rc4.d/K10${rpm.appname}
            ln -sf /etc/init.d/${rpm.appname} /etc/rc.d/rc6.d/K10${rpm.appname}
            fi
</postinstall>
<preremove>
            echo Removing ${rpm.appname} ...

            #chkconfig scripts removal
            #only on uninstall, not on upgrades.
            if [ $1 = 0 ]; then
            /etc/init.d/${rpm.appname} stop
            if [ -x /sbin/chkconfig ]; then
            echo "chkconfig --del ${rpm.appname}"
            /sbin/chkconfig --del ${rpm.appname}
            else
            echo "Deleting /etc/rc.d/rc?.d/???${rpm.appname}"
            rm -f /etc/rc.d/rc?.d/???${rpm.appname}
            fi
            fi
          </preremove>
          <postremove>
            echo "Deleting /etc/init.d/${rpm.appname}"
            rm /etc/init.d/${rpm.appname}
            echo ${rpm.appname} is Successfully Removed!
          </postremove>


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to