forked from Davi5Alexander/docker_pppwn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpodman.sh
74 lines (66 loc) · 1.44 KB
/
podman.sh
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
#!/bin/bash
###########################
# ./podman.sh build
# ./podman.sh run eth0 1100
# ./podman.sh rm
# ./podman.sh rmi
# ./podman.sh clean
# ./podman.sh all eth0 1100
###########################
INTERFACE=${2:-eth0}
FIRMWAREVERSION=${3:-1100}
IMAGE_TAG="localhost/pppwn-cpp:latest"
build_image() {
echo "Building Docker image with tag $IMAGE_TAG..."
podman build -t $IMAGE_TAG .
podman save -o pppwn-cpp.tar $IMAGE_TAG
sudo podman load -i pppwn-cpp.tar
}
run_container() {
echo "Running container..."
sudo podman run -d \
--name pppwn \
--network host \
--privileged \
--env INTERFACE=$INTERFACE \
--env FIRMWAREVERSION=$FIRMWAREVERSION \
--restart on-failure \
$IMAGE_TAG
}
stop_and_remove_container() {
echo "Stopping and removing container..."
sudo podman stop pppwn
sudo podman rm pppwn
}
remove_image() {
echo "Removing image..."
podman rmi $IMAGE_TAG
sudo podman rmi $IMAGE_TAG
rm pppwn-cpp.tar
}
case "$1" in
build)
build_image
;;
run)
run_container
;;
rm)
stop_and_remove_container
;;
rmi)
remove_image
;;
clean)
stop_and_remove_container
remove_image
;;
all)
build_image
run_container
;;
*)
echo "Usage: $0 {build|run|rm|rmi|clean|all} [INTERFACE] [FIRMWAREVERSION]"
exit 1
esac
exit 0