From 1b3b5925f839d337891d73d8f71fd49b13f1010d Mon Sep 17 00:00:00 2001 From: Pedro Alvarez Date: Fri, 13 May 2016 14:16:23 +0000 Subject: Use updated symlinks when they differ --- .../baserock-system-config-sync | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/baserock-system-config-sync/baserock-system-config-sync b/baserock-system-config-sync/baserock-system-config-sync index cb37a8a..8bc4790 100755 --- a/baserock-system-config-sync/baserock-system-config-sync +++ b/baserock-system-config-sync/baserock-system-config-sync @@ -103,11 +103,23 @@ merge() { if [ -d "$vp" -a ! -h "$vp" ]; then mkdir "$vt" elif [ -h "$vp" ]; then - # chose a symbolic link in this order - # of preference: Vuser, V2, V1 - if [ -h "$vu" ]; then + # Symbolic links. + if [ -h "$vu" -a -h "$v1" ]; then + if [ "$(readlink $v1)" == "$(readlink $vu)" ]; then + # User hasn't overriden the old v1 value: switch + # to v2. + cp -a "$v2" "$vt" + else + # User overwrote the v1 value; keep what they did + cp -a "$vu" "$vt" + fi + elif [ -h "$vu" ]; then + # Old behaviour that may not make sense: preserve user + # created symlink, if original was not a link cp -a "$vu" "$vt" elif [ -h "$v2" ]; then + # Old behaviour that may not make sense: use newly + # created link, if original was not a link cp -a "$v2" "$vt" else cp -a "$v1" "$vt" -- cgit v1.2.1