diff options
authorPedro Alvarez <>2016-05-13 14:16:23 (GMT)
committerPedro Alvarez <>2016-05-13 16:09:01 (GMT)
commitca449ed8c6b02d63936e191b36bbef0ac5127699 (patch)
parentd6db02ba19525911671d35d1357e6e9f258ff573 (diff)
Use new Symlink if the User hasn't changed it
Uppgrades after some changes to systemd that moved things from /lib to /usr/lib were broken. The reason was that baserock-system-config-sync was keeping the existing symlinks in /etc pointing to /lib and wasn't using the new ones generated by the Systemd build. This commit ensures that if the user didn't change the Symlink, the new version provided is used. But if the user changed, we keep the modified version. Change-Id: I063c558e0454e53a1dab5f964be5f4a100e0ab93
1 files 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"
cp -a "$v1" "$vt"