File: test-bed

package info (click to toggle)
sshuttle 1.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 920 kB
  • sloc: python: 6,313; sh: 361; makefile: 161
file content (42 lines) | stat: -rwxr-xr-x 791 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env bash
set -e
cd "$(dirname "$0")"

if [[ -z $1 || $1 = -* ]]; then
    set -- up "$@"
fi

function with_set_x() {
    set -x
    "$@"
    {
        ec=$?
        set +x
        return $ec
    } 2>/dev/null
}

function build() {
    # podman build -t ghcr.io/sshuttle/sshuttle-testbed .
    with_set_x docker build --progress=plain -t ghcr.io/sshuttle/sshuttle-testbed -f Containerfile .
}

function compose() {
    # podman-compose "$@"
    with_set_x docker compose "$@"
}

function get-ip() {
    local container_name=sshuttle-testbed-"$1"
    docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' "$container_name"
}

if [[ $1 == get-ip ]]; then
    shift
    get-ip "$@"
else
    if [[ $* = *--build* ]]; then
        build
    fi
    compose "$@"
fi