diff --git a/snippets/keep_cfengine_keys b/snippets/keep_cfengine_keys index 1c7b428..78116ab 100644 --- a/snippets/keep_cfengine_keys +++ b/snippets/keep_cfengine_keys @@ -30,14 +30,12 @@ function findkeys continue fi # Copy current host keys out to be reused - if [ -d /tmp/$tmpdir$SEARCHDIR ]; then - cp -a /tmp/$tmpdir$SEARCHDIR/${PATTERN}* /tmp/$TEMPDIR + if [ -d /tmp/$tmpdir$SEARCHDIR ] && cp -a /tmp/$tmpdir$SEARCHDIR/${PATTERN}* /tmp/$TEMPDIR; then keys_found="yes" umount /tmp/$tmpdir rm -r /tmp/$tmpdir break - elif [ -n "$SHORTDIR" ] && [ -d /tmp/$tmpdir$SHORTDIR ]; then - cp -a /tmp/$tmpdir$SHORTDIR/${PATTERN}* /tmp/$TEMPDIR + elif [ -n "$SHORTDIR" ] && [ -d /tmp/$tmpdir$SHORTDIR ] && cp -a /tmp/$tmpdir$SHORTDIR/${PATTERN}* /tmp/$TEMPDIR; then keys_found="yes" umount /tmp/$tmpdir rm -r /tmp/$tmpdir diff --git a/snippets/keep_files b/snippets/keep_files index 5913d8b..858db5d 100644 --- a/snippets/keep_files +++ b/snippets/keep_files @@ -35,14 +35,12 @@ function findkeys continue fi # Copy current host keys out to be reused - if [ -d /tmp/$tmpdir$SEARCHDIR ]; then - cp -a /tmp/$tmpdir$SEARCHDIR/${PATTERN}* /tmp/$TEMPDIR + if [ -d /tmp/$tmpdir$SEARCHDIR ] && cp -a /tmp/$tmpdir$SEARCHDIR/${PATTERN}* /tmp/$TEMPDIR; then keys_found="yes" umount /tmp/$tmpdir rm -r /tmp/$tmpdir break - elif [ -n "$SHORTDIR" ] && [ -d /tmp/$tmpdir$SHORTDIR ]; then - cp -a /tmp/$tmpdir$SHORTDIR/${PATTERN}* /tmp/$TEMPDIR + elif [ -n "$SHORTDIR" ] && [ -d /tmp/$tmpdir$SHORTDIR ] && cp -a /tmp/$tmpdir$SHORTDIR/${PATTERN}* /tmp/$TEMPDIR; then keys_found="yes" umount /tmp/$tmpdir rm -r /tmp/$tmpdir