# /proc/1/sched exposes the host's pid of our init !
# http://stackoverflow.com/a/37016302
- local pid=$( cat /proc/1/sched | head -n 1 | { IFS='(),#:' read name pid th threads; echo $pid; } )
- local p=$(( pid + 0 ))
+ local pid=$( cat /proc/1/sched 2>/dev/null | head -n 1 | { IFS='(),#:' read name pid th threads; echo $pid; } )
+ pid=$(( pid + 0 ))
[ ${pid} -ne 1 ] && return 0
# lxc sets environment variable 'container'
# Be nice on production environments
renice 19 $$ >/dev/null 2>/dev/null
-processors=$(grep ^processor </proc/cpuinfo 2>/dev/null | wc -l)
+processors=$(cat /proc/cpuinfo 2>/dev/null | grep ^processor | wc -l)
[ $(( processors )) -lt 1 ] && processors=1
# you can set CFLAGS before running installer
if [ ${UID} -eq 0 ]
then
- run chown "${NETDATA_USER}:root" "${NETDATA_LOG_DIR}"
+ # find the admin group
+ admin_group=
+ test -z "${admin_group}" && getent group root >/dev/null 2>&1 && admin_group="root"
+ test -z "${admin_group}" && getent group daemon >/dev/null 2>&1 && admin_group="daemon"
+ test -z "${admin_group}" && admin_group="${NETDATA_USER}"
+
+ run chown "${NETDATA_USER}:${admin_group}" "${NETDATA_LOG_DIR}"
run chown -R root "${NETDATA_PREFIX}/usr/libexec/netdata"
run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type d -exec chmod 0755 {} \;
run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -exec chmod 0644 {} \;