Commit 94ff2a5b authored by Valérian STG_CAZANAVE's avatar Valérian STG_CAZANAVE Committed by Tom Jorquera

`start.sh`: Add check to ensure $YAML file exists and is valid

Add verification to `start.sh` to ensure the given YAML file exists.
Check also if the files listed in the $YAML file exist.
Stop `start.sh` with an error code when the file contains errors.
parent d095a1e6
......@@ -30,6 +30,35 @@ if [ "$YAML" == "" ] ; then
exit 1;
fi;
# we expect a certain number of files to be referenced in the yaml
# and those files to exist at the referenced paths
check-file()
{
FILE=$(grep $1: $YAML | awk '{print $2}');
if [ "$FILE" == "" ]; then
echo "Missing $1 in $YAML"
return 2
elif [ ! -f $FILE ]; then
echo "Wrong $1 path $FILE in $YAML"
return 3
fi
}
if [ -f $YAML ]; then
for file in "model" "lda-mat" "word-syms" "fst"; do
check-file $file
error=$?
if [ $error -ne 0 ]; then
exit $error
fi
done
else
echo "The $YAML file doesn't exist"
exit 1
fi
# everything is good
if [ "$MASTER" == "localhost" ] ; then
# start a local master
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment