Skip to content

remove temp dir #575

@goldzahn

Description

@goldzahn

Hi,

on every server I have the problem that
/tmp/rear.XXXXXXXXX/outputfs/servername/ is not empty,
because of the file ".lockfile", so rmdir is never successful (see #298)

The solution of #298 was to add rm -Rf $BUILD_DIR/outputfs
in function cleanup_build_area_and_end_program()
in usr/share/rear/lib/framework-functions.sh
but this lead to problems mentioned in #465,
so it was changed to rmdir $v $BUILD_DIR/outputfs >&2

Looking at function cleanup_build_area_and_end_program() in usr/share/rear/lib/framework-functions.sh:

...
   # line below put in comment due to issue #465
   #rm -Rf $BUILD_DIR/outputfs
   rmdir $v $BUILD_DIR/outputfs >&2
   # in worst case it could not umount; so before remove the BUILD_DIR check if above outputfs is  gone
   mount | grep -q "$BUILD_DIR/outputfs"
   if [[ $? -eq 0 ]]; then
      # still mounted it seems
      LogPrint "Directory $BUILD_DIR/outputfs still mounted - trying lazy umount"  
      sleep 2
      umount -f -l $BUILD_DIR/outputfs >&2
      rmdir $v $BUILD_DIR/outputfs >&2
   fi
   rmdir $v $BUILD_DIR >&2
fi
Log "End of program reached"

Wouldn't it be better to drop the first
rmdir $v $BUILD_DIR/outputfs >&2
and to add
rm -Rf $BUILD_DIR/outputfs
in case $BUILD_DIR/outputfs is not mounted?

... 
   # line below put in comment due to issue #465
   #rm -Rf $BUILD_DIR/outputfs
   # in worst case it could not umount; so before remove the BUILD_DIR check if above outputfs is gone
   mount | grep -q "$BUILD_DIR/outputfs"
   if [[ $? -eq 0 ]]; then
        # still mounted it seems
        LogPrint "Directory $BUILD_DIR/outputfs still mounted - trying lazy umount"
        sleep 2
        umount -f -l $BUILD_DIR/outputfs >&2
        rmdir $v $BUILD_DIR/outputfs >&2
   else 
        # not mounted so we can safely delete $BUILD_DIR/outputfs
        rm -Rf $BUILD_DIR/outputfs
   fi
   rmdir $v $BUILD_DIR >&2
fi
Log "End of program reached"

So if $BUILD_DIR/outputfs is not mounted,
then rm -Rf $BUILD_DIR/outputfs can safely be used,
otherwise rmdir $v $BUILD_DIR/outputfs would be used.

What do you think?

Regards
goldzahn

Metadata

Metadata

Assignees

Labels

enhancementAdaptions and new features

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions