htg-content/tests/check_assets.sh

30 lines
480 B
Bash

#!/bin/bash
if [ -f config.sh ]; then
. config.sh
fi
if [ -z "$POSTS_DIR" ]
then
echo "POSTS_DIR environment variable is unset." > /dev/stderr
exit 2
fi
if [ -z "$ASSETS_DIR" ]
then
echo "ASSETS_DIR environment variable is unset." > /dev/stderr
exit 2
fi
rc=0
sed -rn 's|^.*\!\[.*\]\(%assets_url%/(.*)\)$|\1|p' $POSTS_DIR/* | while read line
do
if [ ! -f "$ASSETS_DIR/$line" ]
then
echo "$line not found"
rc=1
fi
done
exit $rc