-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_container.sh
More file actions
86 lines (82 loc) · 2.21 KB
/
Copy pathrun_container.sh
File metadata and controls
86 lines (82 loc) · 2.21 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/bash
compose=podman-compose
oci_cmd=podman
function find_container_name() {
# find container name that matches passed argument
test=$(eval "$oci_cmd ps --format '{{.Names}}' | grep $1")
echo $test # return matched container name
}
function usage() {
echo This script is intended as a simple wrapper for running the env and sim podman containers.
echo
echo Usage:
echo " cmd [command]"
echo
echo Available Commands:
echo " [all] start both the sim and env containers"
echo " shutdown shutdown both containers if any are running"
echo " sim start sim only"
echo " env start env only"
echo " h, help print this"
echo " restart [all] restart both the sim and env containers"
echo " restart sim restart the sim container"
echo " restart env restart the env container"
echo " attach [env] attach the env container (it must be running)"
echo " attach sim attach the sim container (it must be running)"
echo
}
# very simple command implementation
case $1 in
""|all)
eval "$compose up -d"
;;
shutdown)
eval "$compose down"
;;
sim)
eval "$compose run --rm sim"
;;
env)
eval "$compose run --rm env"
;;
h|help)
usage
;;
restart)
case $2 in
""|all)
eval "$compose restart"
;;
sim)
eval "$compose restart sim"
;;
env)
eval "$compose restart env"
;;
*)
echo "Could not restart '$2'"
usage
;;
esac
;;
attach)
case $2 in
""|env)
container=$(find_container_name env)
eval "$oci_cmd attach $container"
;;
sim)
container=$(find_container_name sim)
eval "$oci_cmd attach $container"
;;
*)
echo "Could not attach to '$2'"
usage
;;
esac
;;
*)
echo "Unrecognized command '$1'"
usage
;;
esac