-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrun
executable file
·59 lines (49 loc) · 1.66 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
#
# Copyright (c) 2020-2024 IAR Systems AB
#
# Run a container with the IAR Build Tools
#
# See LICENSE for detailed license information
#
function _bx_show_help() {
echo "Usage: ${BASH_SOURCE[0]} iarsystems/bx<package>:<version> <container-name>"
echo " "
}
function _bx_run_container()
{
if [ "${BASH_SOURCE[0]}" != "${0}" ]; then
echo "ERROR: The script should be executed directly. Do not source." >&2
_bx_show_help
return 1
fi
if [ $# -lt 2 ]; then
_bx_show_help
return 1
fi
local SCRIPT_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )
local IMAGE_PACKAGE=$( echo ${1} | cut -d/ -f2 | cut -d: -f1 )
local IMAGE_VERSION=$( echo ${1} | cut -d: -f2 )
declare -a BX_DOCKER_IMAGES_LIST=( $(docker images --filter "reference=iarsystems/${IMAGE_PACKAGE}:${IMAGE_VERSION}" -q --format "{{.Repository}}:{{.Tag}}" ) )
if [ -z ${BX_DOCKER_IMAGES_LIST} ]; then
echo "Image ${IMAGE_PACKAGE}:${IMAGE_VERSION} not found."
return 1
fi
echo -- Starting Running a container for ${IMAGE_PACKAGE,,}-${IMAGE_VERSION}...
CONTAINER_ID=$( docker run \
--detach \
--tty \
--hostname `hostname` \
--restart=unless-stopped \
--name ${2} \
--volume LMS2:/usr/local/etc/IARSystems \
--volume `pwd`:/build \
${1})
echo "-- The working directory is `pwd`."
echo " "
echo -- Now source the aliases-set script:
echo . ${SCRIPT_PATH}/aliases-set ${CONTAINER_ID}
}
_bx_run_container $@
unset -f _bx_run_container
unset -f _bx_show_help