installer keeps old version of file and creates a new one with the stock version as .orig
Costa Tsaousis (ktsaou) committed
Jul 14, 2016 at 21:12 UTC
acf0495000441c20b2664004fcaf934858a6830b
1 file changed
+16
netdata-installer.sh
+16
@@ -394,16 +394,32 @@ for x in $(find "${NETDATA_PREFIX}/etc/netdata/" -name '*.conf' -type f)
394
do
395
if [ -f "${x}" ]
396
then
397
+ # make a backup of the configuration file
398
+ cp -p "${x}" "${x}.old"
399
+
400
if [ -z "${md5sum}" -o ! -x "${md5sum}" ]
401
then
402
+ # we don't have md5sum - keep it
403
cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}"
404
else
405
+ # find it relative filename
406
f="${x/*\/etc\/netdata\//}"
407
+
408
+ # find its checksum
409
md5="$(cat "${x}" | ${md5sum} | cut -d ' ' -f 1)"
410
+
411
+ # copy the original
412
+ if [ -f "conf.d/${f}" ]
413
+ then
414
+ cp "conf.d/${f}" "${x}.orig"
415
+ fi
416
+
417
if [ "${configs_signatures[${md5}]}" = "${f}" ]
418
then
419
+ # it is a stock version - don't keep it
420
echo >&2 "File '${x}' is stock version."
421
else
422
+ # edited by user - keep it
423
echo >&2 "File '${x}' has been edited by user."
424
cp -p "${x}" "${x}.installer_backup.${installer_backup_suffix}"
425
fi