summaryrefslogtreecommitdiffstats
path: root/system/edit-config.in
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-06 16:11:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-06 16:11:34 +0000
commitd079b656b4719739b2247dcd9d46e9bec793095a (patch)
treed2c950c70a776bcf697c963151c5bd959f8a9f03 /system/edit-config.in
parentReleasing debian version 1.37.1-2. (diff)
downloadnetdata-d079b656b4719739b2247dcd9d46e9bec793095a.tar.xz
netdata-d079b656b4719739b2247dcd9d46e9bec793095a.zip
Merging upstream version 1.38.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'system/edit-config.in')
-rwxr-xr-xsystem/edit-config.in83
1 files changed, 0 insertions, 83 deletions
diff --git a/system/edit-config.in b/system/edit-config.in
deleted file mode 100755
index 050d97cde..000000000
--- a/system/edit-config.in
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/env sh
-
-[ -f /etc/profile ] && . /etc/profile
-
-file="${1}"
-
-if [ "$(command -v editor)" ]; then
- EDITOR="${EDITOR-editor}"
-else
- EDITOR="${EDITOR-vi}"
-fi
-
-[ -z "${NETDATA_USER_CONFIG_DIR}" ] && NETDATA_USER_CONFIG_DIR="@configdir_POST@"
-[ -z "${NETDATA_STOCK_CONFIG_DIR}" ] && NETDATA_STOCK_CONFIG_DIR="@libconfigdir_POST@"
-
-if [ -z "${file}" ]; then
- cat << EOF
-
-USAGE:
- ${0} FILENAME
-
- Copy and edit the stock config file named: FILENAME
- if FILENAME is already copied, it will be edited as-is.
-
- The EDITOR shell variable is used to define the editor to be used.
-
- Stock config files at: '${NETDATA_STOCK_CONFIG_DIR}'
- User config files at: '${NETDATA_USER_CONFIG_DIR}'
-
- Available files in '${NETDATA_STOCK_CONFIG_DIR}' to copy and edit:
-
-EOF
-
- cd "${NETDATA_STOCK_CONFIG_DIR}" || exit 1
- ls >&2 -R ./*.conf ./*/*.conf
- exit 1
-
-fi
-
-edit() {
- echo >&2 "Editing '${1}' ..."
-
- # check we can edit
- if [ ! -w "${1}" ]; then
- echo >&2 "Cannot write to ${1}! Aborting ..."
- exit 1
- fi
-
- "${EDITOR}" "${1}"
- exit $?
-}
-
-copy_and_edit() {
- # check we can copy
- if [ ! -w "${NETDATA_USER_CONFIG_DIR}" ]; then
- echo >&2 "Cannot write to ${NETDATA_USER_CONFIG_DIR}! Aborting ..."
- exit 1
- fi
-
- if [ ! -f "${NETDATA_USER_CONFIG_DIR}/${1}" ]; then
- echo >&2 "Copying '${NETDATA_STOCK_CONFIG_DIR}/${1}' to '${NETDATA_USER_CONFIG_DIR}/${1}' ... "
- cp -p "${NETDATA_STOCK_CONFIG_DIR}/${1}" "${NETDATA_USER_CONFIG_DIR}/${1}" || exit 1
- fi
-
- edit "${NETDATA_USER_CONFIG_DIR}/${1}"
-}
-
-# make sure it is not absolute filename
-c1="$(echo "${file}" | cut -b 1)"
-if [ "${c1}" = "/" ] || [ "${c1}" = "." ]; then
- echo >&2 "Please don't use filenames starting with '/' or '.'"
- exit 1
-fi
-
-# already exists
-[ -f "${NETDATA_USER_CONFIG_DIR}/${file}" ] && edit "${NETDATA_USER_CONFIG_DIR}/${file}"
-
-# stock config is valid, copy and edit
-[ -f "${NETDATA_STOCK_CONFIG_DIR}/${file}" ] && copy_and_edit "${file}"
-
-# no such config found
-echo >&2 "File '${file}' is not found in '${NETDATA_STOCK_CONFIG_DIR}'"
-exit 1