-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-run
executable file
·44 lines (38 loc) · 1.04 KB
/
docker-run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
if [ -z "$1" ]; then
echo "First argument needs to be the path to the flasher image."
exit 1
fi
BALENA_IMAGE_FLASHER=$1
if [[ "$BALENA_IMAGE_FLASHER" != /* ]]; then
echo "Image argument needs to be an absolute path."
exit 1
fi
if [ ! -f "$BALENA_IMAGE_FLASHER" ]; then
echo "Image argument not found."
exit 1
fi
# join arguments to pass to the container...
shift
args=()
while [[ $# -gt 1 ]]; do
args+=("$1 $2")
shift
shift
done
flasher_args="${args[*]}"
# Get the absolute script location
pushd "$(dirname "$0")" > /dev/null 2>&1
SCRIPTPATH="$(pwd)"
popd > /dev/null 2>&1
echo "Building tool, please wait..."
extraction_container="$(docker build -q -f Dockerfile.amd64 .)"
balena_image_name="$(basename ${BALENA_IMAGE_FLASHER})"
export USER_ID="$(id -u $USER)"
docker run --privileged --rm \
-v /dev:/dev \
-v "$SCRIPTPATH/output":/output \
-v "$BALENA_IMAGE_FLASHER":"/$balena_image_name" \
-e USER_ID \
"$extraction_container" \
balena-image-flasher-unwrap --balena-image-flasher "/$balena_image_name" -o /output $flasher_args