def enable(name, start=False, **kwargs):
 if (not available(name)):
  return False
 alias = get_svc_alias()
 if (name in alias):
  log.error('This service is aliased, enable its alias instead')
  return False
 svc_realpath = _get_svc_path(name)[0]
 down_file = os.path.join(svc_realpath, 'down')
 if enabled(name):
  if os.path.exists(down_file):
   try:
    os.unlink(down_file)
   except OSError:
    log.error('Unable to remove file {0}'.format(down_file))
    return False
  return True
 if (not start):
  log.trace('need a temporary file {0}'.format(down_file))
  if (not os.path.exists(down_file)):
   try:
    salt.utils.fopen(down_file, 'w').close()
   except IOError:
    log.error('Unable to create file {0}'.format(down_file))
    return False
 try:
  os.symlink(svc_realpath, _service_path(name))
 except IOError:
  log.error('Unable to create symlink {0}'.format(down_file))
  if (not start):
   os.unlink(down_file)
  return False
 cmd = 'sv status {0}'.format(_service_path(name))
 retcode_sv = 1
 count_sv = 0
 while ((retcode_sv != 0) and (count_sv < 10)):
  time.sleep(0.5)
  count_sv += 1
  call = __salt__['cmd.run_all'](cmd)
  retcode_sv = call['retcode']
 if ((not start) and os.path.exists(down_file)):
  try:
   os.unlink(down_file)
  except OSError:
   log.error('Unable to remove temp file {0}'.format(down_file))
   retcode_sv = 1
 if (retcode_sv != 0):
  os.unlink(os.path.join([_service_path(name), name]))
  return False
 return True

def enable ( name , start = False , ** kwargs ) : if ( not available ( name ) ) : return False alias = get_svc_alias ( ) if ( name in alias ) : log . error ( 'This service is aliased, enable its alias instead' ) return False svc_realpath = _get_svc_path ( name ) [ 0 ] down_file = os . path . join ( svc_realpath , 'down' ) if enabled ( name ) : if os . path . exists ( down_file ) : try : os . unlink ( down_file ) except OSError : log . error ( 'Unable to remove file {0}' . format ( down_file ) ) return False return True if ( not start ) : log . trace ( 'need a temporary file {0}' . format ( down_file ) ) if ( not os . path . exists ( down_file ) ) : try : salt . utils . fopen ( down_file , 'w' ) . close ( ) except IOError : log . error ( 'Unable to create file {0}' . format ( down_file ) ) return False try : os . symlink ( svc_realpath , _service_path ( name ) ) except IOError : log . error ( 'Unable to create symlink {0}' . format ( down_file ) ) if ( not start ) : os . unlink ( down_file ) return False cmd = 'sv status {0}' . format ( _service_path ( name ) ) retcode_sv = 1 count_sv = 0 while ( ( retcode_sv != 0 ) and ( count_sv < 10 ) ) : time . sleep ( 0.5 ) count_sv += 1 call = __salt__ [ 'cmd.run_all' ] ( cmd ) retcode_sv = call [ 'retcode' ] if ( ( not start ) and os . path . exists ( down_file ) ) : try : os . unlink ( down_file ) except OSError : log . error ( 'Unable to remove temp file {0}' . format ( down_file ) ) retcode_sv = 1 if ( retcode_sv != 0 ) : os . unlink ( os . path . join ( [ _service_path ( name ) , name ] ) ) return False return True
enable the named service to start at boot cli example: .