summaryrefslogtreecommitdiffstats
path: root/installer
diff options
context:
space:
mode:
authorFederico Ceratto <federico.ceratto@gmail.com>2017-12-19 23:39:21 +0000
committerFederico Ceratto <federico.ceratto@gmail.com>2017-12-19 23:39:21 +0000
commit61aedf201c2c4bf0e5aa4db32e74f4d860b88593 (patch)
treebcf4f9a0cd8bc2daf38b2ff9f29bfcc1e5ed8968 /installer
parentNew upstream version 1.8.0+dfsg (diff)
downloadnetdata-61aedf201c2c4bf0e5aa4db32e74f4d860b88593.tar.xz
netdata-61aedf201c2c4bf0e5aa4db32e74f4d860b88593.zip
New upstream version 1.9.0+dfsgupstream/1.9.0+dfsg
Diffstat (limited to 'installer')
-rw-r--r--installer/functions.sh102
1 files changed, 96 insertions, 6 deletions
diff --git a/installer/functions.sh b/installer/functions.sh
index cfc2d7ea..d403bfe5 100644
--- a/installer/functions.sh
+++ b/installer/functions.sh
@@ -120,6 +120,7 @@ netdata_banner() {
# portable service command
service_cmd="$(which_cmd service)"
+rcservice_cmd="$(which_cmd rc-service)"
systemctl_cmd="$(which_cmd systemctl)"
service() {
local cmd="${1}" action="${2}"
@@ -132,6 +133,10 @@ service() {
then
run "${service_cmd}" "${cmd}" "${action}"
return $?
+ elif [ ! -z "${rcservice_cmd}" ]
+ then
+ run "${rcservice_cmd}" "${cmd}" "${action}"
+ return $?
fi
return 1
}
@@ -437,7 +442,7 @@ install_non_systemd_init() {
run update-rc.d netdata defaults && \
run update-rc.d netdata enable && \
return 0
- elif [[ "${key}" =~ ^(amzn-201[567]|ol|CentOS release 6|Red Hat Enterprise Linux Server release 6).* ]]
+ elif [[ "${key}" =~ ^(amzn-201[567]|ol|CentOS release 6|Red Hat Enterprise Linux Server release 6|Scientific Linux CERN SLC release 6|CloudLinux Server release 6).* ]]
then
echo >&2 "Installing init.d file..."
run cp system/netdata-init-d /etc/init.d/netdata && \
@@ -488,8 +493,15 @@ install_netdata_service() {
if [ ${ret} -eq 0 ]
then
- NETDATA_START_CMD="service netdata start"
- NETDATA_STOP_CMD="service netdata stop"
+ if [ ! -z "${service_cmd}" ]
+ then
+ NETDATA_START_CMD="service netdata start"
+ NETDATA_STOP_CMD="service netdata stop"
+ elif [ ! -z "${rcservice_cmd}" ]
+ then
+ NETDATA_START_CMD="rc-service netdata start"
+ NETDATA_STOP_CMD="rc-service netdata stop"
+ fi
fi
return ${ret}
@@ -628,6 +640,84 @@ install_netdata_logrotate() {
}
# -----------------------------------------------------------------------------
+# download netdata.conf
+
+fix_netdata_conf() {
+ local owner="${1}"
+
+ if [ "${UID}" -eq 0 ]
+ then
+ run chown "${owner}" "${filename}"
+ fi
+ run chmod 0664 "${filename}"
+}
+
+generate_netdata_conf() {
+ local owner="${1}" filename="${2}" url="${3}"
+
+ if [ ! -s "${filename}" ]
+ then
+ cat >"${filename}" <<EOFCONF
+# netdata can generate its own config.
+# Get it with:
+#
+# wget -O ${filename} "${url}"
+#
+# or
+#
+# curl -s -o ${filename} "${url}"
+#
+EOFCONF
+ fix_netdata_conf "${owner}"
+ fi
+}
+
+download_netdata_conf() {
+ local owner="${1}" filename="${2}" url="${3}"
+
+ if [ ! -s "${filename}" ]
+ then
+ echo >&2
+ echo >&2 "-------------------------------------------------------------------------------"
+ echo >&2
+ echo >&2 "Downloading default configuration from netdata..."
+ sleep 5
+
+ # remove a possibly obsolete download
+ [ -f "${filename}.new" ] && rm "${filename}.new"
+
+ # disable a proxy to get data from the local netdata
+ export http_proxy=
+ export https_proxy=
+
+ # try curl
+ run curl -s -o "${filename}.new" "${url}"
+ ret=$?
+
+ if [ ${ret} -ne 0 -o ! -s "${filename}.new" ]
+ then
+ # try wget
+ run wget -O "${filename}.new" "${url}"
+ ret=$?
+ fi
+
+ if [ ${ret} -eq 0 -a -s "${filename}.new" ]
+ then
+ run mv "${filename}.new" "${filename}"
+ run_ok "New configuration saved for you to edit at ${filename}"
+ else
+ [ -f "${filename}.new" ] && rm "${filename}.new"
+ run_failed "Cannnot download configuration from netdata daemon using url '${url}'"
+
+ generate_netdata_conf "${owner}" "${filename}" "${url}"
+ fi
+
+ fix_netdata_conf "${owner}"
+ fi
+}
+
+
+# -----------------------------------------------------------------------------
# add netdata user and group
NETDATA_ADDED_TO_DOCKER=0
@@ -642,15 +732,15 @@ add_netdata_user_and_group() {
if [ ${UID} -eq 0 ]
then
portable_add_group netdata || return 1
- portable_add_user netdata || return 1
+ portable_add_user netdata || return 1
portable_add_user_to_group docker netdata && NETDATA_ADDED_TO_DOCKER=1
portable_add_user_to_group nginx netdata && NETDATA_ADDED_TO_NGINX=1
portable_add_user_to_group varnish netdata && NETDATA_ADDED_TO_VARNISH=1
portable_add_user_to_group haproxy netdata && NETDATA_ADDED_TO_HAPROXY=1
portable_add_user_to_group adm netdata && NETDATA_ADDED_TO_ADM=1
portable_add_user_to_group nsd netdata && NETDATA_ADDED_TO_NSD=1
- portable_add_user_to_group proxy netdata && NETDATA_ADDED_TO_PROXY=1
- portable_add_user_to_group squid netdata && NETDATA_ADDED_TO_SQUID=1
+ portable_add_user_to_group proxy netdata && NETDATA_ADDED_TO_PROXY=1
+ portable_add_user_to_group squid netdata && NETDATA_ADDED_TO_SQUID=1
return 0
fi