summaryrefslogtreecommitdiffstats
path: root/docker/enter-build-container-internal.sh
blob: 7da96fde37637f5ae6009664b8b1315a6ad676a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
set -e

if [ $# -ne 0 ]; then
  echo "Usage: $0"
  echo "This script should not be called manually."
  exit 1
fi

USERNAME=builder
DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
cd $DIR

CALLER_UID=$(stat -c "%u" $DIR)
CALLER_GID=$(stat -c "%g" $DIR)

groupadd -f -g $CALLER_GID $USERNAME
useradd -u $CALLER_UID -g $CALLER_GID $USERNAME
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

su -c "mkdir -p $DIR/../.ccache" $USERNAME
su -c "ln -sf $DIR/../.ccache /home/$USERNAME/.ccache" $USERNAME

su -c "mkdir -p $DIR/../.m2" $USERNAME
su -c "ln -sf $DIR/../.m2 /home/$USERNAME/.m2" $USERNAME

cd $DIR/.. 
su $USERNAME