#!/bin/bash

INC=/usr/share/ltsp/diskless-functions
if [ ! -e "$INC" ]; then
	echo "couldn't find $INC, exiting..." >&2
	exit 16
fi
. "$INC"


if [ -z "$1" ]; then
	echo "Usage: $PROG CHROOT [CONFIGS_DIR]"
	exit 1
fi

if [ ! -d "$1" ]; then
	echo "Not a directory: $1"
	exit 2
fi

CHROOT=`basename "$1"`
if [ -n "$2" ]; then
	CONFIGS="${2%*/}"
fi

CFG="$CONFIGS/$CHROOT"
for i in $(find $CFG ! -type d -printf "%P\n" | grep -E -v '(~|\.orig)$'); do
	[ ! -f "$1/$i" ] && continue

	mtime=`stat -c '%y' "$CFG/$i" | sed 's/\.000000000//'`
	mtime2=`stat -c '%y' "$1/$i" | sed 's/\.000000000//'`
	[ "$mtime" = "$mtime2" ] && continue

	echo "$mtime  $mtime2  $i"
done
