summaryrefslogtreecommitdiff
path: root/src/op_mode/containers_op.sh
blob: 9c410bd7f161977c4971ce8fa716ec7895c8f4b8 (plain)
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
#!/usr/bin/env bash

# Expect 2 args or "show-containers" or "show-images"
if [[ $# -ne 2 ]] && [[ $1 != "--show-containers" ]] && [[ $1 != "--show-images" ]] && [[ $1 != "--show-networks" ]] ; then
    echo "Image not set or not found"
    exit 1
fi

OPTION=$1
IMAGE=$2

# Download image
pull_image() {
    sudo podman pull ${IMAGE}
}

# Remove image
remove_image() {
    sudo podman image rm ${IMAGE}
}

# Show containers
show_containers() {
    sudo podman ps -a
}

# Show image
show_images() {
    sudo podman image ls
}

# Show networks
show_networks() {
    sudo podman network ls
}

if [ "$OPTION" = "--pull" ]; then
    pull_image
    exit 0
fi

if [ "$OPTION" = "--remove" ]; then
    remove_image
    exit 0
fi

if [ "$OPTION" = "--show-containers" ]; then
    show_containers
    exit 0
fi

if [ "$OPTION" = "--show-networks" ]; then
    show_networks
    exit 0
fi

if [ "$OPTION" = "--show-images" ]; then
    show_images
    exit 0
fi