diff options
author | Sol Jerome <solj@ices.utexas.edu> | 2010-03-26 14:06:05 +0000 |
---|---|---|
committer | Sol Jerome <solj@ices.utexas.edu> | 2010-03-26 09:07:30 -0500 |
commit | b83d5c4bec70d53a85a6897d2d2271ea58c3cf20 (patch) | |
tree | cfd58eedd1f1a75363e238f0d32763ed31023930 | |
parent | 5ee259750bbef505378a1fc342c518b9a08540d5 (diff) | |
download | bcfg2-b83d5c4bec70d53a85a6897d2d2271ea58c3cf20.tar.gz bcfg2-b83d5c4bec70d53a85a6897d2d2271ea58c3cf20.tar.bz2 bcfg2-b83d5c4bec70d53a85a6897d2d2271ea58c3cf20.zip |
RcUpdate: Add supervised service install
Signed-off-by: Sol Jerome <solj@ices.utexas.edu>
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5800 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r-- | src/lib/Client/Tools/RcUpdate.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/lib/Client/Tools/RcUpdate.py b/src/lib/Client/Tools/RcUpdate.py index 0a556ef2d..e59a4a28d 100644 --- a/src/lib/Client/Tools/RcUpdate.py +++ b/src/lib/Client/Tools/RcUpdate.py @@ -5,6 +5,7 @@ import os import Bcfg2.Client.Tools import Bcfg2.Client.XML + class RcUpdate(Bcfg2.Client.Tools.SvcTool): '''RcUpdate support for Bcfg2''' name = 'RcUpdate' @@ -17,7 +18,7 @@ class RcUpdate(Bcfg2.Client.Tools.SvcTool): Verify Service status for entry. Assumes we run in the "default" runlevel. ''' - # check is service is enabled + # check if service is enabled cmd = '/sbin/rc-update show default | grep %s' rc = self.cmd.run(cmd % entry.get('name'))[0] is_enabled = (rc == 0) @@ -30,8 +31,8 @@ class RcUpdate(Bcfg2.Client.Tools.SvcTool): self.logger.debug('Init script for service %s does not exist' % entry.get('name')) return False - - # check is service is enabled + + # check if service is enabled cmd = '/etc/init.d/%s status | grep started' rc = self.cmd.run(cmd % entry.attrib['name'])[0] is_running = (rc == 0) @@ -46,7 +47,7 @@ class RcUpdate(Bcfg2.Client.Tools.SvcTool): elif entry.get('status') == 'off' and (is_enabled or is_running): entry.set('current_status', 'on') return False - + return True def InstallService(self, entry): @@ -56,12 +57,20 @@ class RcUpdate(Bcfg2.Client.Tools.SvcTool): ''' self.logger.info('Installing Service %s' % entry.get('name')) if entry.get('status') == 'on': + # make sure it's running if in supervised mode + if entry.get('mode', 'default') == 'supervised' \ + and entry.get('current_status') == 'off': + self.start_service(entry) # make sure it's enabled cmd = '/sbin/rc-update add %s default' rc = self.cmd.run(cmd % entry.get('name'))[0] return (rc == 0) elif entry.get('status') == 'off': + # make sure it's not running if in supervised mode + if entry.get('mode', 'default') == 'supervised' \ + and entry.get('current_status') == 'on': + self.stop_service(entry) # make sure it's disabled cmd = '/sbin/rc-update del %s default' rc = self.cmd.run(cmd % entry.get('name'))[0] @@ -78,4 +87,3 @@ class RcUpdate(Bcfg2.Client.Tools.SvcTool): specified = [srv.get('name') for srv in self.getSupportedEntries()] return [Bcfg2.Client.XML.Element('Service', type='rc-update', name=name) \ for name in allsrv if name not in specified] - |