From d518bcb09d86c1a0d19c23c3997c738470202fad Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 19 Jul 2016 08:34:51 +0200 Subject: Calling container-nsenter program from container enter command. Signed-off-by: Daniel Baumann --- lib/container/enter | 12 +++++++++--- share/man/container-enter.1.txt | 5 +---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/container/enter b/lib/container/enter index 101b43e..4eff504 100755 --- a/lib/container/enter +++ b/lib/container/enter @@ -60,7 +60,7 @@ Parameters () Usage () { - echo "Usage: container ${COMMAND} -n|--name NAME [-- COMMAND|\"COMMANDS\"]" >&2 + echo "Usage: container ${COMMAND} -n|--name NAME" >&2 exit 1 } @@ -90,7 +90,13 @@ case "${STATE}" in esac LEADER="$(machinectl status ${NAME} | awk '/Leader: / { print $2 }')" -COMMANDS="$(echo ${@} | sed -e 's|.*-- ||')" # Run -nsenter --target ${LEADER} --mount --uts --ipc --net --pid --root --wd=/root ${COMMANDS} +if [ -e "${MACHINES}/${NAME}/usr/bin/container-nsenter" ] +then + OPTIONS="/usr/bin/container-nsenter" +else + OPTIONS="" +fi + +nsenter --target ${LEADER} --mount --uts --ipc --net --pid --root --wd=/root ${OPTIONS} diff --git a/share/man/container-enter.1.txt b/share/man/container-enter.1.txt index 792cac7..61c0f66 100644 --- a/share/man/container-enter.1.txt +++ b/share/man/container-enter.1.txt @@ -29,7 +29,7 @@ container-enter - Enter a container namespace SYNOPSIS -------- -*container enter* ['OPTIONS'] [-- COMMAND|"COMMANDS"] +*container enter* ['OPTIONS'] DESCRIPTION @@ -50,9 +50,6 @@ EXAMPLES *Enter to example.net container namespace:*:: sudo container enter -n example.net -*Execute 'ip a' in example.net container namespace:*:: - sudo container enter -n example.net -- 'ip a' - SEE ALSO -------- -- cgit v1.2.3