2016-12-30 18:05:54 +00:00
|
|
|
#!/bin/bash
|
|
|
|
USERNAME=`whoami`
|
2016-12-30 18:18:27 +00:00
|
|
|
MOUNT_PATH="/mnt"
|
2016-12-30 18:17:11 +00:00
|
|
|
CURRENT_DIRECTORY=`pwd -P` # untangle symbolic links if needed - SELinux needs the real path
|
2016-12-30 18:05:54 +00:00
|
|
|
IMAGE="debian:jessie"
|
|
|
|
|
|
|
|
if [[ -z $1 ]]; then
|
|
|
|
echo "usage: `basename $0` command_to_run_inside_a_container"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
RESOLVED_ARGUMENTS="$@"
|
2016-12-30 18:17:11 +00:00
|
|
|
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'"
|
2016-12-30 18:05:54 +00:00
|
|
|
|
|
|
|
# restore SELinux context for the current directory
|
|
|
|
restorecon -R "$CURRENT_DIRECTORY"
|
|
|
|
|