summaryrefslogtreecommitdiffstats
path: root/vnamespace.netns
blob: 57e8881dbe881c7eddecd3e427d03ca9f85f1003 (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
#!/bin/bash

: ${UTIL_VSERVER_VARS:=/usr/share/util-vserver/netns/util-vserver-vars}
test -e "$UTIL_VSERVER_VARS" || {
    echo $"Can not find util-vserver installation (the file '$UTIL_VSERVER_VARS' would be expected); aborting..." >&2
    exit 1
}
. "$UTIL_VSERVER_VARS"
. "$_LIB_FUNCTIONS"
. "$_LIB_VSERVER_FUNCTIONS"

ARGS=( "$@" )

while :
do
    case "$1" in
        -i|--index|-e|--enter)
            VSERVER_DIR="$($_VSERVER_INFO "$2" ID)"
            getFileValue VSERVER_NAME "${VSERVER_DIR}/name"
            break
            ;;

        --mask)
            shift
            shift
            ;;

        --)
            break
            ;;

        *)
            shift
            ;;
    esac
done

if [[ -n "$VSERVER_NAME" && -d "${VSERVER_DIR}/spline-netns/" ]]; then
    exec $_IP netns exec "$VSERVER_NAME" /usr/sbin/vnamespace "${ARGS[@]}"
fi

exec /usr/sbin/vnamespace "${ARGS[@]}"