GNS3 Docker Images
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

39 lines
844 B

#!/bin/sh
# create IOU docker image
set -e
if [ $# -lt 3 ]; then
echo "Usage: create-iou-image <image> <license> <startup-config> [<private-config>]" >&2
exit 1
fi
temp=$(mktemp -d /tmp/iou.XXXXXXXXXX)
# copy image
mkdir -p "$temp/data/usr/local/bin"
cp -p "$1" "$temp/data/usr/local/bin/iou.bin"
chmod 755 "$temp/data/usr/local/bin/iou.bin"
# copy license
mkdir -p "$temp/data/root"
cp -p "$2" "$temp/data/root/.iourc"
# copy configs
mkdir -p "$temp/data/iou"
cp -p "$3" "$temp/data/iou/startup-config"
[ $# -ge 4 ] && cp -p "$4" "$temp/data/iou/private-config"
# create Dockerfile
cat > "$temp/Dockerfile" << 'EOF'
FROM iou-base
ADD data /
VOLUME [ "/iou" ]
EOF
# create image
image=$(basename "$1" .bin | tr -c -s 'a-zA-Z0-9.\n' - | tr A-Z a-z)
echo "Creating $image"
echo
docker build --force-rm -t "$image" "$temp"
rm -r "$temp"