summaryrefslogtreecommitdiffstats
path: root/installer
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2018-01-13 03:13:36 +0200
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2018-01-13 03:13:36 +0200
commit2d7bd09fb6f064978aa01415701f7c5ed35ca5d3 (patch)
tree683df98b6266fd550924964de7d9c321b561db62 /installer
parent5aabeec377b0c16d59a00a805a18c5897f6ecc5c (diff)
detect the number of processors on freebsd
Diffstat (limited to 'installer')
-rw-r--r--installer/functions.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/installer/functions.sh b/installer/functions.sh
index 765f1f134f..8c3af89e94 100644
--- a/installer/functions.sh
+++ b/installer/functions.sh
@@ -161,6 +161,22 @@ pidof() {
# -----------------------------------------------------------------------------
+export SYSTEM_CPUS=1
+portable_find_processors() {
+ if [ -f "/proc/cpuinfo" ]
+ then
+ # linux
+ SYSTEM_CPUS=$(grep -c ^processor /proc/cpuinfo)
+ else
+ # freebsd
+ SYSTEM_CPUS=$(sysctl hw.ncpu 2>/dev/null | grep ^hw.ncpu | cut -d ' ' -f 2)
+ fi
+ [ -z "${SYSTEM_CPUS}" -o $(( SYSTEM_CPUS )) -lt 1 ] && SYSTEM_CPUS=1
+}
+portable_find_processors
+
+# -----------------------------------------------------------------------------
+
run_ok() {
printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} ${*} \n\n"
}