#!/bin/sh

set -e
SIGNATURE_FILE={{ signature_file }}
NSIGNATURE_FILE={{ signature_file }}.tmp

touch $SIGNATURE_FILE
{{ sha256sum }} {{ path_list }} 2> /dev/null | sort -k 66 > $NSIGNATURE_FILE

if diff "$SIGNATURE_FILE" "$NSIGNATURE_FILE" > /dev/null ; then
  # No changes since last run just propagate information
  rm -f ${NSIGNATURE_FILE}
  exit 1
else
  # Changes since last run, so store new value and propagate information
  mv "$NSIGNATURE_FILE" "$SIGNATURE_FILE"
  exit 0
fi
