~cyplo/dotfiles

ref: 83ddcc09dc68389b129d598722eca9e90a6dff33 dotfiles/tools/runjessie -rwxr-xr-x 624 bytes
83ddcc09 — Cyryl Płotnicki remove broken i3 msg call 1 year, 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash
USERNAME=`whoami`
MOUNT_PATH="/mnt"
CURRENT_DIRECTORY=`pwd -P` # untangle symbolic links if needed - SELinux needs the real path
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 && cd '$MOUNT_PATH' && bash -c '$RESOLVED_ARGUMENTS'"

# restore SELinux context for the current directory
restorecon_path=`which restorecon`
if [[ -x "$restorecon_path" ]]; then 
    restorecon -R "$CURRENT_DIRECTORY"
fi