3 # This script "cleans" the UPPER directory tree for a subhost by
4 # comparing it with the LOWER tree and remove all files that are equal
7 PROGRAMDIR="$(dirname $(realpath $0))"
8 . $PROGRAMDIR/functions
17 if [ ! -d "$UPPER" ] || [ ! -d "$LOWER" ] ; then
18 echo "*** needs a root path" >&2
22 if is_live $NAME ; then
23 echo "** Cannot clean running subhost **" >&2
30 if [ "$UPPER" = "$LOWER" ] ; then
31 echo "** UPER and LOWER are the same directory **" >&2
37 DIFFS=/tmp/clean-$NAME.$$
39 find $UPPER -type f -printf '%P\n'| while read X ; do
40 cmp "$UPPER/$X" "$LOWER/$X" >> $DIFFS 2>&1 && rm "$UPPER/$X"
43 echo "(See details in $DIFFS)"