Fix clone and yo in Theia image

6.19.x
Eugene Ivantsov 2018-08-28 15:40:08 +03:00
parent fe7d1e9696
commit bc3e97a58a
2 changed files with 28 additions and 0 deletions

View File

@ -2,6 +2,16 @@
set -e
set -u
for f in "/etc/passwd" "/etc/group"; do
chgrp -R 0 ${f}
chmod -R g+rwX ${f};
done
# Generate passwd.template
cat /etc/passwd | sed s#root:x.*#root:x:\${USER_ID}:\${GROUP_ID}::\${HOME}:/bin/bash#g > ${HOME}/passwd.template
# Generate group.template
cat /etc/group | sed s#root:x:0:#root:x:0:0,\${USER_ID}:#g > ${HOME}/group.template
# Install basic software used for checking github API rate limit
yum install -y epel-release
yum -y install curl jq expect

18
dockerfiles/theia/src/start.sh Normal file → Executable file
View File

@ -10,6 +10,24 @@
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
export USER_ID=$(id -u)
export GROUP_ID=$(id -g)
if ! grep -Fq "${USER_ID}" /etc/passwd; then
# current user is an arbitrary
# user (its uid is not in the
# container /etc/passwd). Let's fix that
cat ${HOME}/passwd.template | \
sed "s/\${USER_ID}/${USER_ID}/g" | \
sed "s/\${GROUP_ID}/${GROUP_ID}/g" | \
sed "s/\${HOME}/\/home\/theia/g" > /etc/passwd
cat ${HOME}/group.template | \
sed "s/\${USER_ID}/${USER_ID}/g" | \
sed "s/\${GROUP_ID}/${GROUP_ID}/g" | \
sed "s/\${HOME}/\/home\/theia/g" > /etc/group
fi
if [ -z "$THEIA_PORT" ]; then
export THEIA_PORT=3000
else