diff --git a/tools/scripts/embed_image.sh b/tools/scripts/embed_image.sh index f6423e028690d7d1b9e7ccbac69314c9aa5613f2..8691fbbb349057fe0f959eb0d64a7295a1a34dc8 100755 --- a/tools/scripts/embed_image.sh +++ b/tools/scripts/embed_image.sh @@ -3,6 +3,22 @@ # embeds an exe/elf file into a the Flocklab XML config file XMLFILE=flocklab.xml +SEDCMD=sed +B64CMD=base64 + +which $SEDCMD > /dev/null 2>&1 +if [ $? -ne 0 ]; +then + echo "command '$SEDCMD' not found" + exit 1 +fi + +which $B64CMD > /dev/null 2>&1 +if [ $? -ne 0 ]; +then + echo "command '$B64CMD' not found" + exit 1 +fi if [ $# -lt 1 ]; then @@ -29,9 +45,9 @@ fi B64FILE="$1.b64" -base64 $1 > $B64FILE -sed -i -n '1h;1!H;${ g;s/.*<\/data>/\n<\/data>/;p}' $XMLFILE -sed -i "//r ${B64FILE}" $XMLFILE +$B64CMD $1 > $B64FILE +$SEDCMD -i -n '1h;1!H;${ g;s/.*<\/data>/\n<\/data>/;p}' $XMLFILE +$SEDCMD -i "//r ${B64FILE}" $XMLFILE rm $B64FILE echo "image $1 embedded into $XMLFILE"