scripts/private-network: Remove Docker specifics

This commit is contained in:
Fabio Rehm 2014-06-09 00:21:01 -03:00
parent 044322d70f
commit 0bd071f95d

View file

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
# This is a snapshot of https://github.com/jpetazzo/pipework/blob/edbd33ab49ab0dff0bee46b019055360f325a6e5/pipework # This is a snapshot of https://github.com/jpetazzo/pipework/blob/edbd33ab49ab0dff0bee46b019055360f325a6e5/pipework
# with docker specifics trimmed out
set -e set -e
@ -79,18 +80,8 @@ done < /proc/mounts
N=$(find "$CGROUPMNT" -name "$GUESTNAME" | wc -l) N=$(find "$CGROUPMNT" -name "$GUESTNAME" | wc -l)
case "$N" in case "$N" in
0) 0)
# If we didn't find anything, try to lookup the container with Docker. echo "Container $GUESTNAME not found."
if which docker >/dev/null exit 1
then
DOCKERPID=$(docker inspect --format='{{ .State.Pid }}' $GUESTNAME)
[ "$DOCKERPID" = "<no value>" ] && {
echo "Container $GUESTNAME not found, and unknown to Docker."
exit 1
}
else
echo "Container $GUESTNAME not found, and Docker not installed."
exit 1
fi
;; ;;
1) 1)
true true
@ -132,15 +123,11 @@ else
fi fi
fi fi
if [ $DOCKERPID ]; then NSPID=$(head -n 1 $(find "$CGROUPMNT" -name "$GUESTNAME" | head -n 1)/tasks)
NSPID=$DOCKERPID [ "$NSPID" ] || {
else echo "Could not find a process inside container $GUESTNAME."
NSPID=$(head -n 1 $(find "$CGROUPMNT" -name "$GUESTNAME" | head -n 1)/tasks) exit 1
[ "$NSPID" ] || { }
echo "Could not find a process inside container $GUESTNAME."
exit 1
}
fi
[ ! -d /var/run/netns ] && mkdir -p /var/run/netns [ ! -d /var/run/netns ] && mkdir -p /var/run/netns
[ -f /var/run/netns/$NSPID ] && rm -f /var/run/netns/$NSPID [ -f /var/run/netns/$NSPID ] && rm -f /var/run/netns/$NSPID