#!/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
	diff -U 0 "$1/$i" "$CFG/$i"
done
