diff options
Diffstat (limited to '')
-rwxr-xr-x | netdata-installer.sh | 53 |
1 files changed, 2 insertions, 51 deletions
diff --git a/netdata-installer.sh b/netdata-installer.sh index f3f444f6..356eb4e4 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 # ----------------------------------------------------------------------------- |