Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-2611

Services do not respect chkconfig specified state when switching runlevels

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Low
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.11.0, 3.10.2, 3.7.6
    • Component/s: None
    • Labels:
      None
    • Platform:
      RHEL or CentOS

      Description

      If the cfengine services are configured to be OFF at runlevel 2:

      [root@hub ~]# chkconfig --list cfengine3
      cfengine3      	0:off	1:off	2:off	3:on	4:on	5:on	6:off
      

      Then running init 2 should cause the services to shut down automatically. Currently they do not.

      [root@hub ~]# init 2
      [root@hub ~]# sleep 120
      [root@hub ~]# pgrep -f /var/cfengine/bin | wc -l
      33
      

      This seems to be related to a missing file in /var/lock/subsys/. We create files for each component daemon, but since we do not create one that matches the name of the service (cfengine3) the service is never automatically stopped.

      Ref: http://www.nico.schottelius.org/blog/why-centos-does-not-stop-your-init-script/

      These small changes seem to correct the issue:

      diff --git a/misc/init.d/cfengine3.in b/misc/init.d/cfengine3.in
      index b4a6142..ac6f1e1 100644
      --- a/misc/init.d/cfengine3.in
      +++ b/misc/init.d/cfengine3.in
      @@ -254,6 +254,7 @@ cf_start_daemon()
           if [ "$REDHAT" = "1" ] && [ "$FUNC" = "1" ]; then
               daemon "$daemon" "$@"
               cf_touch "/var/lock/subsys/$base_daemon"
      +        cf_touch "/var/lock/subsys/cfengine3"
           elif [ "$REDHAT" = "1" ] && [ "$FUNC" = "0" ]; then
               "$daemon" "$@"
               cf_touch "/var/lock/subsys/$base_daemon"
      @@ -347,10 +348,12 @@ cf_stop_daemon()
           if [ "$REDHAT" = "1" ] && [ "$FUNC" = "1" ]; then
               if [ -f "/var/lock/subsys/$base_daemon" ]; then
                   cf_rm -f "/var/lock/subsys/$base_daemon"
      +            cf_rm -f "/var/lock/subsys/cfengine3"
               fi
           elif [ "$REDHAT" = "1" ] && [ "$FUNC" = "0" ]; then
               if [ -f "/var/lock/subsys/$base_daemon" ]; then
                   cf_rm -f "/var/lock/subsys/$base_daemon"
      +            cf_rm -f "/var/lock/subsys/cfengine3"
               fi
       
           # SUSE
      

        Attachments

          Activity

            People

            • Assignee:
              a10042 Nick Anderson
              Reporter:
              a10042 Nick Anderson
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel