#!/usr/bin/bash
# File: diffall-plug-and-data.sh
#--------------------------------------------------------
# Run diffall on Android to report differences between 
# your $plug and $data content copies.  From/to order 
# doesn't matter here, and this does a full byte-for-byte 
# comparison, instead of checking times and sizes only. 
# This uses path variables set in your ~/.bash_profile.
# See _README.html for all general usage instructions.
#--------------------------------------------------------

# Load current path settings
source ~/.bash_profile

# Run in work folder for logs
pushd $work > /dev/null
echo "Starting: $PWD"

# Route logfile output here
logdir=Admin-Mergeall

# Filename passed as arg else generated
if [ $# == 1 ]
then
    logname=$1
else
    logname=diffall-$(date +%Y%m%d-%H%M%S).txt
fi

# Create logfiles dir if needed
if [ ! -e $logdir ] 
then
    mkdir $logdir
    echo "Created $logdir"
fi

# Run and save log, use diffall's own -u to unbuffer stdout/err for tails
python Mergeall-source/diffall.py \
    $plug \
    $data \
    -skipcruft -u \
        > $logdir/$logname

# Back to starting dir
popd > /dev/null
echo "Finished: $PWD"
