#!/bin/bash

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


[[ -z $1 ]] && {
	echo "Usage: $PROG CHROOT [CONFIGS_DIR]"
	exit 1
}

[[ ! -d $1 ]] && {
	echo "Not a directory: $1"
	exit 2
}

CHROOT=`basename "$1"`
[[ -n $2 ]] && {
	CONFIGS="${2%*/}"
}

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
