1 # Function to do all of the temporary dir/file migration work
6 # Usage: _clean_tmpdirs [-v] new_dir old_dir ...
8 # Move temporary directories (which may be actively in use as
9 # with pmdammv files) from one temporary directory to another
10 # so as to transparently upgrade without loss of service.
12 # -v option is verbose mode for debugging
16 if [ $# -gt 0 -a X"$1" = "X-v" ]
24 echo >&2 "Usage: _clean_tmpdirs [-v] new_dir old_dir subdirs ..."
31 [ "$_new_tmp_dir" != "$old_tmp_dir" ] || return
35 d="$_old_tmp_dir/$_subdir"
36 test -d "$d" -a -k "$d" || continue
39 [ "$f" != "*" ] || continue
41 target="$_new_tmp_dir/$_subdir/$f"
42 [ "$source" != "$target" ] || continue
43 [ ! -f "$target" ] || continue
44 $_verbose && echo + mv -fu "$source" "$target"
45 mv -fu "$source" "$target" || true
47 $_verbose && echo + rmdir "$d"
48 cd && rmdir "$d" 2>/dev/null || true