#!/bin/bash

SRV=$1
if [ -z "$SRV" ]; then
    echo "usage: $0 machine"
    exit 1
fi

dirname="/var/lib/risotto/templates/$SRV"
if [ ! -d "$dirname" ]; then
    echo "cannot find $dirname"
    echo "usage: $0 machine"
    exit 1
fi
cd $dirname
find -type f | while read a; do
    cfile="/var/lib/machines/$SRV/usr/share/factory/$a"
    if [ -f "$cfile" ]; then
        diff -u "$cfile" "$a"
    fi
done
cd - > /dev/null