text: // Generated by CoffeeScript 2.7.0
  // # `nikita.service.stop`
  
  // Stop a service.
  // Note, does not throw an error if service is not installed.
  
  // ## Output
  
  // * `$status`   
  //   Indicates if the service was stopped ("true") or if it was already stopped 
  //   ("false").
  
  // ## Example
  
  // ```js
  // const {$status} = await nikita.service.stop([{
  //   name: 'gmetad'
  // })
  // console.info(`Service was stopped: ${$status}`)
  // ```
  
  // ## Schema definitions
  var definitions, handler;
  
  definitions = {
    config: {
      type: 'object',
      properties: {
        'name': {
          $ref: 'module://@nikitajs/service/lib/install#/definitions/config/properties/name'
        }
      },
      required: ['name']
    }
  };
  
  // ## Handler
  handler = async function({
      config,
      tools: {log}
    }) {
    var $status, err;
    log({
      message: `Stop service ${config.name}`,
      level: 'INFO'
    });
    try {
      ({$status} = (await this.execute({
        command: `ls /lib/systemd/system/*.service /etc/systemd/system/*.service /etc/rc.d/* /etc/init.d/* 2>/dev/null | grep -w "${config.name}" || exit 3
  if command -v systemctl >/dev/null 2>&1; then
    systemctl status ${config.name} || exit 3
    systemctl stop ${config.name}
  elif command -v service >/dev/null 2>&1; then
    service ${config.name} status || exit 3
    service ${config.name} stop
  else
    echo "Unsupported Loader" >&2
    exit 2
  fi`,
        code: [0, 3]
      })));
      if ($status) {
        // arch_chroot: config.arch_chroot
        // arch_chroot_rootdir: config.arch_chroot_rootdir
        log({
          message: "Service is stopped",
          level: 'INFO'
        });
      }
      if (!$status) {
        return log({
          message: "Service already stopped",
          level: 'WARN'
        });
      }
    } catch (error) {
      err = error;
      if (err.exit_code === 2) {
        throw Error("Unsupported Loader");
      }
    }
  };
  
  // ## Exports
  module.exports = {
    handler: handler,
    metadata: {
      argument_to_config: 'name',
      definitions: definitions
    }
  };
  