summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2017-12-14 01:37:28 +0200
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2017-12-14 01:37:28 +0200
commit28b86c731d9ecb6b72238a5367b3f824d51c75a1 (patch)
tree91a0b5a8a7321a7e0cc7f22495c08db4bba33ae4
parent489c3e6fe1dbe912189c47b655aae95fe83f79a2 (diff)
both installers download configuration from netdata.conf and provide a sane default when this is not possible
-rw-r--r--installer/functions.sh84
-rwxr-xr-xmakeself/install-or-update.sh2
-rwxr-xr-xmakeself/jobs/70-netdata-git.install.sh4
-rwxr-xr-xmakeself/jobs/99-makeself.install.sh68
-rw-r--r--makeself/makeself.lsm2
-rwxr-xr-xnetdata-installer.sh53
6 files changed, 129 insertions, 84 deletions
diff --git a/installer/functions.sh b/installer/functions.sh
index a5449faf4e..d403bfe520 100644
--- a/installer/functions.sh
+++ b/installer/functions.sh
@@ -640,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
@@ -654,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
diff --git a/makeself/install-or-update.sh b/makeself/install-or-update.sh
index b64e7be335..34630cf169 100755
--- a/makeself/install-or-update.sh
+++ b/makeself/install-or-update.sh
@@ -162,7 +162,9 @@ progress "starting netdata"
restart_netdata "/opt/netdata/bin/netdata"
if [ $? -eq 0 ]
then
+ download_netdata_conf "${NETDATA_USER}:${NETDATA_GROUP}" "/opt/netdata/etc/netdata/netdata.conf" "http://localhost:19999/netdata.conf"
netdata_banner "is installed and running now!"
else
+ generate_netdata_conf "${NETDATA_USER}:${NETDATA_GROUP}" "/opt/netdata/etc/netdata/netdata.conf" "http://localhost:19999/netdata.conf"
netdata_banner "is installed now!"
fi
diff --git a/makeself/jobs/70-netdata-git.install.sh b/makeself/jobs/70-netdata-git.install.sh
index 0486ce11a8..a9e6b39b48 100755
--- a/makeself/jobs/70-netdata-git.install.sh
+++ b/makeself/jobs/70-netdata-git.install.sh
@@ -16,8 +16,12 @@ run ./netdata-installer.sh --install "${NETDATA_INSTALL_PARENT}" \
--dont-start-it \
${NULL}
+# delete the generated netdata.conf, so that the static installer will generate a new one
+rm "${NETDATA_INSTALL_PATH}/etc/netdata/netdata.conf"
+
if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ]
then
run strip ${NETDATA_INSTALL_PATH}/bin/netdata
run strip ${NETDATA_INSTALL_PATH}/usr/libexec/netdata/plugins.d/apps.plugin
+ run strip ${NETDATA_INSTALL_PATH}/usr/libexec/netdata/plugins.d/cgroup-network
fi
diff --git a/makeself/jobs/99-makeself.install.sh b/makeself/jobs/99-makeself.install.sh
index 465a319527..528d18fcb9 100755
--- a/makeself/jobs/99-makeself.install.sh
+++ b/makeself/jobs/99-makeself.install.sh
@@ -2,12 +2,44 @@
. $(dirname "${0}")/../functions.sh "${@}" || exit 1
+run cd "${NETDATA_SOURCE_PATH}" || exit 1
+
+# -----------------------------------------------------------------------------
+# find the netdata version
+
+NOWNER="unknown"
+ORIGIN="$(git config --get remote.origin.url || echo "unknown")"
+if [[ "${ORIGIN}" =~ ^git@github.com:.*/netdata.*$ ]]
+ then
+ NOWNER="${ORIGIN/git@github.com:/}"
+ NOWNER="${NOWNER/\/netdata*/}"
+
+elif [[ "${ORIGIN}" =~ ^https://github.com/.*/netdata.*$ ]]
+ then
+ NOWNER="${ORIGIN/https:\/\/github.com\//}"
+ NOWNER="${NOWNER/\/netdata*/}"
+fi
+
+# make sure it does not have any slashes in it
+NOWNER="${NOWNER//\//_}"
+
+if [ "${NOWNER}" = "firehol" ]
+ then
+ NOWNER=
+else
+ NOWNER="-${NOWNER}"
+fi
+
+VERSION="$(git describe || echo "undefined")"
+[ -z "${VERSION}" ] && VERSION="undefined"
+
+FILE_VERSION="${VERSION}-$(uname -m)-$(date +"%Y%m%d-%H%M%S")${NOWNER}"
+
# -----------------------------------------------------------------------------
# copy the files needed by makeself installation
run mkdir -p "${NETDATA_INSTALL_PATH}/system"
-run cd "${NETDATA_SOURCE_PATH}" || exit 1
cp \
makeself/post-installer.sh \
@@ -65,6 +97,9 @@ rm "${NETDATA_INSTALL_PATH}/sbin" \
# -----------------------------------------------------------------------------
# create the makeself archive
+cat "${NETDATA_MAKESELF_PATH}/makeself.lsm" |\
+ sed "s|NETDATA_VERSION|${FILE_VERSION}|g" >"${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp"
+
"${NETDATA_MAKESELF_PATH}/makeself.sh" \
--gzip \
--complevel 9 \
@@ -72,7 +107,7 @@ rm "${NETDATA_INSTALL_PATH}/sbin" \
--needroot \
--target "${NETDATA_INSTALL_PATH}" \
--header "${NETDATA_MAKESELF_PATH}/makeself-header.sh" \
- --lsm "${NETDATA_MAKESELF_PATH}/makeself.lsm" \
+ --lsm "${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp" \
--license "${NETDATA_MAKESELF_PATH}/makeself-license.txt" \
--help-header "${NETDATA_MAKESELF_PATH}/makeself-help-header.txt" \
"${NETDATA_INSTALL_PATH}" \
@@ -81,37 +116,12 @@ rm "${NETDATA_INSTALL_PATH}/sbin" \
./system/post-installer.sh \
${NULL}
+rm "${NETDATA_MAKESELF_PATH}/makeself.lsm.tmp"
# -----------------------------------------------------------------------------
# copy it to the netdata build dir
-NOWNER="unknown"
-ORIGIN="$(git config --get remote.origin.url || echo "unknown")"
-if [[ "${ORIGIN}" =~ ^git@github.com:.*/netdata.*$ ]]
- then
- NOWNER="${ORIGIN/git@github.com:/}"
- NOWNER="${NOWNER/\/netdata*/}"
-
-elif [[ "${ORIGIN}" =~ ^https://github.com/.*/netdata.*$ ]]
- then
- NOWNER="${ORIGIN/https:\/\/github.com\//}"
- NOWNER="${NOWNER/\/netdata*/}"
-fi
-
-# make sure it does not have any slashes in it
-NOWNER="${NOWNER//\//_}"
-
-if [ "${NOWNER}" = "firehol" ]
- then
- NOWNER=
-else
- NOWNER="-${NOWNER}"
-fi
-
-VERSION="$(git describe || echo "undefined")"
-[ -z "${VERSION}" ] && VERSION="undefined"
-
-FILE="netdata-${VERSION}-$(uname -m)-$(date +"%Y%m%d-%H%M%S")${NOWNER}.gz.run"
+FILE="netdata-${FILE_VERSION}.gz.run"
cp "${NETDATA_INSTALL_PATH}.gz.run" "${FILE}"
echo >&2 "Self-extracting installer copied to '${FILE}'"
diff --git a/makeself/makeself.lsm b/makeself/makeself.lsm
index 0267962948..6bd4703db2 100644
--- a/makeself/makeself.lsm
+++ b/makeself/makeself.lsm
@@ -1,6 +1,6 @@
Begin3
Title: netdata
-Version: 1.6.0
+Version: NETDATA_VERSION
Description: netdata is a system for distributed real-time performance and health monitoring.
It provides unparalleled insights, in real-time, of everything happening on the
system it runs (including applications such as web and database servers), using
diff --git a/netdata-installer.sh b/netdata-installer.sh
index f3f444f667..356eb4e4f6 100755
--- a/netdata-installer.sh
+++ b/netdata-installer.sh
@@ -817,16 +817,7 @@ install_netdata_service || run_failed "Cannot install netdata init service."
started=0
if [ ${DONOTSTART} -eq 1 ]
then
- if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
- then
- echo "# Get config from http://127.0.0.1:${NETDATA_PORT}/netdata.conf" >"${NETDATA_PREFIX}/etc/netdata/netdata.conf"
-
- if [ "${UID}" -eq 0 ]
- then
- chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
- fi
- chmod 0644 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
- fi
+ generate_netdata_conf "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf" "http://localhost:${NETDATA_PORT}/netdata.conf"
else
restart_netdata ${NETDATA_PREFIX}/usr/sbin/netdata "${@}"
@@ -845,47 +836,7 @@ else
# -----------------------------------------------------------------------------
# save a config file, if it is not already there
- if [ ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf" ]
- then
- echo >&2
- echo >&2 "-------------------------------------------------------------------------------"
- echo >&2
- echo >&2 "Downloading default configuration from netdata..."
- sleep 5
-
- # remove a possibly obsolete download
- [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
-
- # disable a proxy to get data from the local netdata
- export http_proxy=
- export https_proxy=
-
- # try wget
- wget 2>/dev/null -O "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
- ret=$?
-
- # try curl
- if [ ${ret} -ne 0 -o ! -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
- then
- curl -s -o "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "http://localhost:${NETDATA_PORT}/netdata.conf"
- ret=$?
- fi
-
- if [ ${ret} -eq 0 -a -s "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ]
- then
- mv "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
- echo >&2 "New configuration saved for you to edit at ${NETDATA_PREFIX}/etc/netdata/netdata.conf"
-
- if [ "${UID}" -eq 0 ]
- then
- chown "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
- fi
- chmod 0664 "${NETDATA_PREFIX}/etc/netdata/netdata.conf"
- else
- echo >&2 "Cannnot download configuration from netdata daemon using url 'http://localhost:${NETDATA_PORT}/netdata.conf'"
- [ -f "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new" ] && rm "${NETDATA_PREFIX}/etc/netdata/netdata.conf.new"
- fi
- fi
+ download_netdata_conf "${NETDATA_USER}" "${NETDATA_PREFIX}/etc/netdata/netdata.conf" "http://localhost:${NETDATA_PORT}/netdata.conf"
fi
# -----------------------------------------------------------------------------