Skip to content

Instantly share code, notes, and snippets.

@flashvoid
Last active January 9, 2017 05:32
Show Gist options
  • Save flashvoid/91fe970428c062affd1da5cc9bbc1649 to your computer and use it in GitHub Desktop.
Save flashvoid/91fe970428c062affd1da5cc9bbc1649 to your computer and use it in GitHub Desktop.
#!/bin/bash -ex
replace_template_entries() {
MAP=$1
REPLACEMENT_TAG=$2
ACTION=$3
TOOLCHAIN_DOCKERFILE="/tmp/testsetup"
echo "MAP=$MAP, REPLACEMENT_TAG=$REPLACEMENT_TAG, ACTION=$ACTION"
for PAIR in $MAP
do
SRC=$(echo $PAIR | cut -f1 -d=)
DEST=$(echo $PAIR | cut -f2 -d=)
sed -i.bak "/$REPLACEMENT_TAG/i \\
$ACTION $SRC $DEST" $TOOLCHAIN_DOCKERFILE
done
sed -i.bak "s#$REPLACEMENT_TAG##g" $TOOLCHAIN_DOCKERFILE
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment