From 9dd49bb73361f8b831326b85c1afc2e7e713cba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyryl=20P=C5=82otnicki?= Date: Fri, 30 Dec 2016 18:05:54 +0000 Subject: [PATCH 1/3] Added a 'runjessie' tool to run commands inside a jessie container --- tools/runjessie | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 tools/runjessie diff --git a/tools/runjessie b/tools/runjessie new file mode 100755 index 00000000..f2591409 --- /dev/null +++ b/tools/runjessie @@ -0,0 +1,17 @@ +#!/bin/bash +MOUNT_PATH="/tmp/data" +CURRENT_DIRECTORY=`pwd -P` # untangle symbolic links if needed +USERNAME=`whoami` +IMAGE="debian:jessie" + +if [[ -z $1 ]]; then + echo "usage: `basename $0` command_to_run_inside_a_container" + exit 1 +fi + +RESOLVED_ARGUMENTS="$@" +docker run -i -t -v "$CURRENT_DIRECTORY":"$MOUNT_PATH":Z $IMAGE bash -c "useradd -M -d $MOUNT_PATH $USERNAME 2>&1 > /dev/null && bash -c '$RESOLVED_ARGUMENTS'" + +# restore SELinux context for the current directory +restorecon -R "$CURRENT_DIRECTORY" + From 60bd885c99d638d4292bb3a03ac4c3ec32e1ada2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyryl=20P=C5=82otnicki?= Date: Fri, 30 Dec 2016 18:17:11 +0000 Subject: [PATCH 2/3] Change the current running directory to the mount directory --- tools/runjessie | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/runjessie b/tools/runjessie index f2591409..00b05687 100755 --- a/tools/runjessie +++ b/tools/runjessie @@ -1,7 +1,7 @@ #!/bin/bash -MOUNT_PATH="/tmp/data" -CURRENT_DIRECTORY=`pwd -P` # untangle symbolic links if needed USERNAME=`whoami` +MOUNT_PATH="/home/$USERNAME" +CURRENT_DIRECTORY=`pwd -P` # untangle symbolic links if needed - SELinux needs the real path IMAGE="debian:jessie" if [[ -z $1 ]]; then @@ -10,7 +10,7 @@ if [[ -z $1 ]]; then fi RESOLVED_ARGUMENTS="$@" -docker run -i -t -v "$CURRENT_DIRECTORY":"$MOUNT_PATH":Z $IMAGE bash -c "useradd -M -d $MOUNT_PATH $USERNAME 2>&1 > /dev/null && bash -c '$RESOLVED_ARGUMENTS'" +docker run -i -t -v "$CURRENT_DIRECTORY":"$MOUNT_PATH":Z $IMAGE bash -c "useradd -M -d '$MOUNT_PATH' $USERNAME && cd '$MOUNT_PATH' && bash -c '$RESOLVED_ARGUMENTS'" # restore SELinux context for the current directory restorecon -R "$CURRENT_DIRECTORY" From c408bb5d741e130506c9161ca1b2c85ccdc5fe12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyryl=20P=C5=82otnicki?= Date: Fri, 30 Dec 2016 18:18:27 +0000 Subject: [PATCH 3/3] Change the default mount directory for runjessie to /mnt --- tools/runjessie | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/runjessie b/tools/runjessie index 00b05687..6edaeb26 100755 --- a/tools/runjessie +++ b/tools/runjessie @@ -1,6 +1,6 @@ #!/bin/bash USERNAME=`whoami` -MOUNT_PATH="/home/$USERNAME" +MOUNT_PATH="/mnt" CURRENT_DIRECTORY=`pwd -P` # untangle symbolic links if needed - SELinux needs the real path IMAGE="debian:jessie"