getent group "${groupname}" > /dev/null 2>&1
[ $? -ne 0 ] && return 1
- # find the users in the docker group
+ # find the user is already in the group
local users=$(getent group "${groupname}" | cut -d ':' -f 4)
if [[ ",${users}," =~ ,${username}, ]]
then
# username is already there
- :
+ return 0
else
# username is not in group
echo >&2 "Adding ${username} user to the ${groupname} group ..."
fi
}
-run find ./system/ -type f -a \! -name \*.in -a \! -name Makefile\* -a \! -name \*.conf -a \! -name \*.service -exec chmod 755 {} \;
+run find ./system/ -type f -a \! -name \*.in -a \! -name Makefile\* -a \! -name \*.conf -a \! -name \*.service -a \! -name \*.logrotate -exec chmod 755 {} \;
NETDATA_ADDED_TO_DOCKER=0
+NETDATA_ADDED_TO_NGINX=0
if [ ${UID} -eq 0 ]
then
portable_add_group netdata
portable_add_user netdata
portable_add_user_to_group docker netdata && NETDATA_ADDED_TO_DOCKER=1
+ portable_add_user_to_group nginx netdata && NETDATA_ADDED_TO_NGINX=1
if [ -d /etc/logrotate.d -a ! -f /etc/logrotate.d/netdata ]
then
echo >&2 "Adding netdata logrotate configuration ..."
run cp system/netdata.logrotate /etc/logrotate.d/netdata
fi
+
+ if [ -f /etc/logrotate.d/netdata ]
+ then
+ echo >&2 "Fixing netdata logrotate permissions ..."
+ run chmod 644 /etc/logrotate.d/netdata
+ fi
fi
if [ ${UID} -eq 0 ]
then
- run chown -R root:root "${NETDATA_PREFIX}/usr/libexec/netdata"
+ 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 {} \;
run find "${NETDATA_PREFIX}/usr/libexec/netdata" -type f -a -name \*.plugin -exec chmod 0755 {} \;
# stop a running netdata
isnetdata() {
- [ -z "$1" -o ! -f "/proc/$1/stat" ] && return 1
- [ "$(cat "/proc/$1/stat" | cut -d '(' -f 2 | cut -d ')' -f 1)" = "netdata" ] && return 0
- return 1
+ if [ -d /proc/self ]
+ then
+ [ -z "$1" -o ! -f "/proc/$1/stat" ] && return 1
+ [ "$(cat "/proc/$1/stat" | cut -d '(' -f 2 | cut -d ')' -f 1)" = "netdata" ] && return 0
+ return 1
+ fi
+ return 0
}
stop_netdata_on_pid() {
run update-rc.d netdata enable && \
installed_init_d=1
- elif [ "${key}" = "CentOS release 6.8 (Final)" ]
+ elif [ "${key}" = "CentOS release 6.8 (Final)" -o "${key}" = "amzn-2016.09" ]
then
run cp system/netdata-init-d /etc/init.d/netdata && \
run chmod 755 /etc/init.d/netdata && \
echo " gpasswd -d netdata docker"
fi
+getent group nginx > /dev/null
+if [ $? -eq 0 -a "${NETDATA_ADDED_TO_NGINX}" = "1" ]
+ then
+ echo
+ echo "You may also want to remove the netdata user from the nginx group"
+ echo "by running:"
+ echo " gpasswd -d netdata nginx"
+fi
+
UNINSTALL
chmod 750 netdata-uninstaller.sh