summaryrefslogtreecommitdiffstats
path: root/netdata-installer.sh
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2016-07-14 21:12:20 +0300
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2016-07-14 21:12:20 +0300
commitacf0495000441c20b2664004fcaf934858a6830b (patch)
treed5469226091296f63756e6ea921d8da7485b859a /netdata-installer.sh
parentcea624c634ab7c67324899666ea988e1223dee41 (diff)
installer keeps old version of file and creates a new one with the stock version as .orig
Diffstat (limited to 'netdata-installer.sh')
-rwxr-xr-xnetdata-installer.sh16
1 files changed, 16 insertions, 0 deletions
diff --git a/netdata-installer.sh b/netdata-installer.sh
index 3a7a8d3530..dd2ce97322 100755
--- a/netdata-installer.sh
+++ b/netdata-installer.sh
@@ -394,16 +394,32 @@ for x in $(find "${NETDATA_PREFIX}/etc/netdata/" -name '*.conf' -type f)
do
if [ -f "${x}" ]
then
+ # make a backup of the configuration file
+ cp -p "${x}" "${x}.old"
+
if [ -z "${md5sum}" -o ! -x "${md5sum}" ]
then
+ # we don't have md5sum - keep it
cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}"
else
+ # find it relative filename
f="${x/*\/etc\/netdata\//}"
+
+ # find its checksum
md5="$(cat "${x}" | ${md5sum} | cut -d ' ' -f 1)"
+
+ # copy the original
+ if [ -f "conf.d/${f}" ]
+ then
+ cp "conf.d/${f}" "${x}.orig"
+ fi
+
if [ "${configs_signatures[${md5}]}" = "${f}" ]
then
+ # it is a stock version - don't keep it
echo >&2 "File '${x}' is stock version."
else
+ # edited by user - keep it
echo >&2 "File '${x}' has been edited by user."
cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}"
fi