#!/bin/sh -e

# shellcheck disable=SC2312

if ! command -v sysctl >/dev/null 2>&1 || [ "$(uname -s)" = "Linux" ] \
  || ! cpus="$(command sysctl -n hw.ncpu 2>/dev/null)"; then
  if ! command -v getconf >/dev/null 2>&1 \
    || ! cpus="$(command getconf _NPROCESSORS_ONLN 2>/dev/null)"; then
    cpus=
  fi
fi

[ "${cpus}" -gt 1 ] || cpus=8
printf '%s\n' "${cpus}"
