From 335988fd99a16fb540389658aee9eb839f397ce7 Mon Sep 17 00:00:00 2001 From: rdaforno Date: Wed, 23 Oct 2019 14:54:08 +0200 Subject: [PATCH] script updated --- tools/scripts/embed_image.sh | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tools/scripts/embed_image.sh b/tools/scripts/embed_image.sh index f6423e0..8691fbb 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" -- GitLab