Return if the named service is enabled to start on boot

    root
        Enable/disable/mask unit files in the specified root directory

    CLI Example:

    .. code-block:: bash

        salt '*' service.enabled <service name>
544012
def enabled(name, root=None, **kwargs):  # pylint: disable=unused-argument
    '''
    
    '''
    # Try 'systemctl is-enabled' first, then look for a symlink created by
    # systemctl (older systemd releases did not support using is-enabled to
    # check templated services), and lastly check for a sysvinit service.
    if __salt__['cmd.retcode'](_systemctl_cmd('is-enabled', name, root=root),
                               python_shell=False,
                               ignore_retcode=True) == 0:
        return True
    elif '@' in name:
        # On older systemd releases, templated services could not be checked
        # with ``systemctl is-enabled``. As a fallback, look for the symlinks
        # created by systemctl when enabling templated services.
        local_config_path = _root(LOCAL_CONFIG_PATH, '/')
        cmd = ['find', local_config_path, '-name', name,
               '-type', 'l', '-print', '-quit']
        # If the find command returns any matches, there will be output and the
        # string will be non-empty.
        if bool(__salt__['cmd.run'](cmd, python_shell=False)):
            return True
    elif name in _get_sysv_services(root):
        return _sysv_enabled(name, root)

    return False
65730
def _service_is_sysv(name):
    '''
    
    '''
    script = '/etc/init.d/{0}'.format(name)
    return not _service_is_upstart(name) and os.access(script, os.X_OK)
315778
def _check_repo_sign_utils_support(name):
    '''
    
    '''
    if salt.utils.path.which(name):
        return True
    else:
        raise CommandExecutionError(
            'utility \'{0}\' needs to be installed or made available in search path'.format(name)
        )
1327399
def enable_service(conn, service='ceph'):
    
    if is_systemd(conn):
        remoto.process.run(
            conn,
            [
                'systemctl',
                'enable',
                '{service}'.format(service=service),
            ]
        )
    else:
        remoto.process.run(
            conn,
            [
                'chkconfig',
                '{service}'.format(service=service),
                'on',
            ]
        )
1157293
def restart_service(service, log=False):
    
    with settings():
        if log:
            bookshelf2.logging_helpers.log_yellow(
                'stoping service %s' % service)
        sudo('service %s stop' % service)
        if log:
            bookshelf2.logging_helpers.log_yellow(
                'starting service %s' % service)
        sudo('service %s start' % service)
    return True
897870
def start(name):
    '''
    
    '''
    __salt__['file.remove']('{0}/down'.format(_service_path(name)))
    cmd = 'svc -u {0}'.format(_service_path(name))
    return not __salt__['cmd.retcode'](cmd, python_shell=False)
465506
def get_enabled():
    '''
    
    '''
    prefix = '/etc/rc[S{0}].d/S'.format(_get_runlevel())
    ret = set()
    lines = glob.glob('{0}*'.format(prefix))
    for line in lines:
        ret.add(re.split(prefix + r'\d+', line)[1])
    return sorted(ret)
242111
def disabled(name):
    '''
    
    '''
    ret = {'name': name,
           'result': True,
           'changes': {},
           'comment': ''}

    stat = __salt__['rdp.status']()

    if stat:
        if __opts__['test']:
            ret['result'] = None
            ret['comment'] = 'RDP will be disabled'
            return ret

        ret['result'] = __salt__['rdp.disable']()
        ret['changes'] = {'RDP was disabled': True}
        return ret

    ret['comment'] = 'RDP is disabled'
    return ret
884754
def remove(name):
    '''
    
    '''

    if not enabled(name):
        return False

    svc_path = _service_path(name)
    if not os.path.islink(svc_path):
        log.error('%s is not a symlink: not removed', svc_path)
        return False

    if not stop(name):
        log.error('Failed to stop service %s', name)
        return False
    try:
        os.remove(svc_path)
    except IOError:
        log.error('Unable to remove symlink %s', svc_path)
        return False
    return True
1024890
def is_enabled():
    
    output = subprocess.check_output(['ufw', 'status'],
                                     universal_newlines=True,
                                     env={'LANG': 'en_US',
                                          'PATH': os.environ['PATH']})

    m = re.findall(r'^Status: active\n', output, re.M)

    return len(m) >= 1
29639
def status(name, sig=None):
    '''
    
    '''

    proxy_fn = 'dummy.service_status'
    resp = __proxy__[proxy_fn](name)
    if resp['comment'] == 'stopped':
        return False
    if resp['comment'] == 'running':
        return True
1095750
def available(name):
    '''
    
    '''
    (enabled_services, disabled_services) = _get_service_list(include_enabled=True,
                                                              include_disabled=True)
    return name in enabled_services or name in disabled_services
744813
def service_enable(s_name, **connection_args):
    '''
    
    '''
    ret = True
    service = _service_get(s_name, **connection_args)
    if service is None:
        return False
    nitro = _connect(**connection_args)
    if nitro is None:
        return False
    try:
        NSService.enable(nitro, service)
    except NSNitroError as error:
        log.debug('netscaler module error - NSService.enable() failed: %s', error)
        ret = False
    _disconnect(nitro)
    return ret
1366927
def get_enabled(jail=None):
    '''
    
    '''
    ret = []
    service = _cmd(jail)
    prf = _get_jail_path(jail) if jail else ''
    for svc in __salt__['cmd.run']('{0} -e'.format(service)).splitlines():
        ret.append(os.path.basename(svc))

    # This is workaround for bin/173454 bug
    for svc in get_all(jail):
        if svc in ret:
            continue
        if not os.path.exists('{0}/etc/rc.conf.d/{1}'.format(prf, svc)):
            continue
        if enabled(svc, jail=jail):
            ret.append(svc)

    return sorted(ret)
764519
def get_enabled():
    '''
    
    '''
    ret = set()
    for name in _iter_service_names():
        if _service_is_upstart(name):
            if _upstart_is_enabled(name):
                ret.add(name)
        else:
            if _service_is_sysv(name):
                if _sysv_is_enabled(name):
                    ret.add(name)
    return sorted(ret)
874578
def start(name):
    '''
    
    '''
    cmd = '/usr/sbin/svcadm enable -s -t {0}'.format(name)
    retcode = __salt__['cmd.retcode'](cmd, python_shell=False)
    if not retcode:
        return True
    if retcode == 3:
        # Return code 3 means there was a problem with the service
        # A common case is being in the 'maintenance' state
        # Attempt a clear and try one more time
        clear_cmd = '/usr/sbin/svcadm clear {0}'.format(name)
        __salt__['cmd.retcode'](clear_cmd, python_shell=False)
        return not __salt__['cmd.retcode'](cmd, python_shell=False)
    return False
911482
def is_enabled(self, name):
        
        if self.services and name in self.services:
            return self.services[name]['config'] == 'enabled'
        return False