-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinvokeit.sh
More file actions
executable file
·59 lines (51 loc) · 1.61 KB
/
Copy pathinvokeit.sh
File metadata and controls
executable file
·59 lines (51 loc) · 1.61 KB
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
theOS=$(uname)
if [[ "$theOS" != "Linux" ]]; then
echo "This script must be run on a Linux host!"
exit 1
fi
theDocker=$(which docker)
if [[ -f $theDocker ]]; then
echo "Found docker at $theDocker"
else
echo "docker not found, aborting!"
exit 1
fi
docker run --rm --name imagesrv netappt1:latest &
# is 4 seconds long enough?
sleep 4
theContainer=$(docker ps | grep imagesrv | awk '{ print $1 }')
if [[ -z $theContainer ]]; then
sleep 5
theContainer=$(docker ps | grep imagesrv | awk '{ print $1 }')
if [[ -z $theContainer ]]; then
echo "The container netappt1:latest did not start."
echo "You may need to edit this script and increase the sleep time."
echo "Exiting"
exit 1
fi
fi
echo "The container id is: $theContainer"
theAddress=$(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $theContainer)
if [[ -z $theAddress ]]; then
echo "The container IP address could not be determined. Exiting"
exit 1
fi
echo "Attempting to execute your web browser with $theAddress:9080"
theFire=$(which firefox)
if [[ -f $theFire ]]; then
$theFire $theAddress:9080
else
theXdg=$(which xdg-open)
if [[ -f $theXdg ]]; then
theStatus=$($theXdg $theAddress:9080)
if [[ $theStatus ]]; then
echo "xdg-open failed (again)"
echo "Try plugging $theAddress:9080 into your browser URL bar."
fi
else
echo "Could not find web browser"
echo "Try plugging $theAddress:9080 into your browser URL bar."
fi
fi
echo "When done, issue the command: docker stop imagesrv"