2018-09-25 01:03:07 +02:00
|
|
|
#!/bin/bash
|
2016-04-11 05:18:39 +02:00
|
|
|
#
|
|
|
|
# This script allows you to launch several images
|
|
|
|
# from this repository once they're built.
|
|
|
|
#
|
|
|
|
# Make sure you add the `docker run` command
|
|
|
|
# in the header of the Dockerfile so the script
|
|
|
|
# can find it and execute it.
|
|
|
|
#
|
|
|
|
# Use pulseaudio/Dockerfile and skype/Dockerfile as examples.
|
2018-09-25 01:03:07 +02:00
|
|
|
set -e
|
|
|
|
set -o pipefail
|
2016-04-11 05:18:39 +02:00
|
|
|
|
2018-09-25 01:03:07 +02:00
|
|
|
if [[ $# -eq 0 ]]; then
|
2016-04-11 05:18:39 +02:00
|
|
|
echo "Usage: $0 [--test] image1 image2 ..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-09-25 01:03:07 +02:00
|
|
|
if [[ "$1" = "--test" ]]; then
|
2016-04-11 05:18:39 +02:00
|
|
|
TEST=1
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
|
|
|
for name in "$@"; do
|
2018-09-25 01:03:07 +02:00
|
|
|
if [[ ! -d "$name" ]]; then
|
|
|
|
echo "Unable to find container configuration with name: $name"
|
2016-04-11 05:18:39 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-09-25 01:17:06 +02:00
|
|
|
script=$(sed -n '/docker run/,/^#$/p' "$name/Dockerfile" | head -n -1 | sed "s/#//" | sed "s#\\\\##" | tr '\n' ' ' | sed "s/\$@//" | sed 's/""//')
|
2018-09-25 01:03:07 +02:00
|
|
|
echo "Running: $script"
|
2016-04-11 05:18:39 +02:00
|
|
|
|
|
|
|
if [ $TEST ]; then
|
2018-09-25 01:03:07 +02:00
|
|
|
echo "$script"
|
2016-04-11 05:18:39 +02:00
|
|
|
else
|
2018-09-25 01:03:07 +02:00
|
|
|
eval "$script"
|
2016-04-11 05:18:39 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
shift
|
|
|
|
done
|