]> arthur.barton.de Git - netdata.git/commitdiff
installer keeps old version of file and creates a new one with the stock version...
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 14 Jul 2016 18:12:20 +0000 (21:12 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 14 Jul 2016 18:12:20 +0000 (21:12 +0300)
netdata-installer.sh

index 3a7a8d353065d6c6fe36a35d66b385d9138f9bde..dd2ce97322cdaa96cc84df21f81ae11d0bb7b6b4 100755 (executable)
@@ -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