This patch provides the delete of the mount points in case when mount
was not successful (attempt to mount swap partition, for example)
Patch is made against master branch. It is pushed into my clone branch
already (
http://github.com/lflaks/cobbler/tree/master)
In that branch there is also another snippet keep_cfengine_keys which is
almost identical except for different keys.
--
Leon
diff --git a/snippets/keep_ssh_host_keys b/snippets/keep_ssh_host_keys
index ce1d939..be1d2d4 100644
--- a/snippets/keep_ssh_host_keys
+++ b/snippets/keep_ssh_host_keys
@@ -25,8 +25,10 @@ function findkeys
tmpdir=$(mktemp -d $name.XXXXXX)
mkdir -p /tmp/$tmpdir
mount $disk /tmp/$tmpdir
- [ $? -eq 0 ] || continue # Skip to the next partition if the mount fails
-
+ if [ $? -ne 0 ]; then # Skip to the next partition if the mount fails
+ rm -rf /tmp/$tmpdir
+ continue
+ fi
# Copy current host keys out to be reused
if [ -d /tmp/$tmpdir$SEARCHDIR ]; then
cp -a /tmp/$tmpdir$SEARCHDIR/${PATTERN}* /tmp/$TEMPDIR