Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
templates: Consistent use of locking
Move to per-template lock (except for oracle that's per-container).
Also ensure that the path used for the lock is relative to LOCALSTATEDIR.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
  • Loading branch information
stgraber committed Dec 6, 2012
1 parent 75350ec commit fe253ca
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions templates/lxc-altlinux.in
Expand Up @@ -228,7 +228,7 @@ install_altlinux()
return 1
fi
return 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-altlinux

return $?
}
Expand Down Expand Up @@ -325,7 +325,7 @@ clean()
echo -n "Purging the download cache for ALTLinux-$release..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-altlinux
}

usage()
Expand Down
4 changes: 2 additions & 2 deletions templates/lxc-debian.in
Expand Up @@ -191,7 +191,7 @@ install_debian()

return 0

) 200>@LOCALSTATEDIR@/lock/subsys/lxc
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-debian

return $?
}
Expand Down Expand Up @@ -261,7 +261,7 @@ clean()
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0

) 200>@LOCALSTATEDIR@/lock/subsys/lxc
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-debian
}

usage()
Expand Down
4 changes: 2 additions & 2 deletions templates/lxc-fedora.in
Expand Up @@ -233,7 +233,7 @@ install_fedora()
fi

return 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-fedora

return $?
}
Expand Down Expand Up @@ -301,7 +301,7 @@ clean()
echo -n "Purging the download cache for Fedora-$release..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-fedora
}

usage()
Expand Down
4 changes: 2 additions & 2 deletions templates/lxc-lenny.in
Expand Up @@ -166,7 +166,7 @@ install_debian()
return 1
fi
return 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-lenny

return $?
}
Expand Down Expand Up @@ -234,7 +234,7 @@ clean()
echo -n "Purging the download cache..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-lenny
}

usage()
Expand Down
4 changes: 2 additions & 2 deletions templates/lxc-opensuse.in
Expand Up @@ -242,7 +242,7 @@ install_opensuse()
fi

return 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-opensuse

return $?
}
Expand Down Expand Up @@ -314,7 +314,7 @@ clean()
echo -n "Purging the download cache..."
rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1
exit 0
) 200>@LOCALSTATEDIR@/lock/subsys/lxc
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-opensuse
}

usage()
Expand Down
4 changes: 2 additions & 2 deletions templates/lxc-oracle.in
Expand Up @@ -337,7 +337,7 @@ container_rootfs_create()
fi
done

mkdir -p /var/lock/subsys/
mkdir -p @LOCALSTATEDIR@/lock/subsys/lxc
(
flock -x 200
if [ $? -ne 0 ]; then
Expand Down Expand Up @@ -433,7 +433,7 @@ container_rootfs_create()
echo "Rebuilding rpm database"
rm -f $container_rootfs/var/lib/rpm/__db*
chroot $container_rootfs rpm --rebuilddb >/dev/null 2>&1
) 200>/var/lock/subsys/lxc-oracle-$name
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-oracle-$name
}

usage()
Expand Down
2 changes: 1 addition & 1 deletion templates/lxc-ubuntu-cloud.in
Expand Up @@ -395,7 +395,7 @@ EOF
echo "If you do not have a meta-data service, this container will likely be useless."

fi
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-ubucloud
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-ubuntu-cloud

copy_configuration $path $rootfs $name $arch $release

Expand Down
4 changes: 2 additions & 2 deletions templates/lxc-ubuntu.in
Expand Up @@ -259,7 +259,7 @@ install_ubuntu()
release=$2
flushcache=$3
cache="@LOCALSTATEDIR@/cache/lxc/$release"
mkdir -p /var/lock/subsys/
mkdir -p @LOCALSTATEDIR@/lock/subsys/

(
flock -x 200
Expand Down Expand Up @@ -293,7 +293,7 @@ install_ubuntu()

return 0

) 200>/var/lock/subsys/lxc
) 200>@LOCALSTATEDIR@/lock/subsys/lxc-ubuntu

return $?
}
Expand Down

0 comments on commit fe253ca

Please sign in to comment.