#!/bin/sh
d=""
[ -z "$SOURCE_DATE_EPOCH" ] || d=--date=@$SOURCE_DATE_EPOCH

if [ "$2" == "True" ]; then
  FILES=$(ls *.0|grep -v 'jackd\.0')
fi

if [ "$3" == "True" ]; then
  FILES="${FILES} jackd.0"
fi

test -z "${FILES}" && exit 0

for i in ${FILES} ; do
  echo "[SED] ${i}"
  sed -e "s/!VERSION!/${1}/g" -e "s/!DATE!/`date $d '+%B %Y'`/g" < ${i} > ${i%%0}1
done
