Skip to content

Commit 95dc8de

Browse files
cgruvercgruverdkwon17
authored
create a common entrypoint for base and udi, fix .config ownership for podman 5 (#209)
* incorporate changes from 74af9a2 Signed-off-by: cgruver <[email protected]> * Update base/ubi9/entrypoint.sh --------- Signed-off-by: cgruver <[email protected]> Co-authored-by: cgruver <[email protected]> Co-authored-by: David Kwon <[email protected]>
1 parent 74af9a2 commit 95dc8de

File tree

4 files changed

+58
-54
lines changed

4 files changed

+58
-54
lines changed

base/ubi9/.stow-local-ignore

+3
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@
1010
\.krew
1111
\.sdkman
1212
\.local/bin/podman
13+
14+
# Ignore files under .config directory
15+
\.config

base/ubi9/entrypoint.sh

+55
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ if [ ! -d "${HOME}/.config/containers" ]; then
1515
fi
1616
fi
1717

18+
# Create Sym Link for Composer Keys in /home/tooling/.config
19+
if [ -d /home/tooling/.config/composer ] && [ ! -d "${HOME}/.config/composer" ]; then
20+
mkdir -p ${HOME}/.config/composer
21+
ln -s /home/tooling/.config/composer/keys.dev.pub ${HOME}/.config/composer/keys.dev.pub
22+
ln -s /home/tooling/.config/composer/keys.tags.pub ${HOME}/.config/composer/keys.tags.pub
23+
fi
24+
1825
# Setup $PS1 for a consistent and reasonable prompt
1926
if [ -w "${HOME}" ] && [ ! -f "${HOME}"/.bashrc ]; then
2027
echo "PS1='[\u@\h \W]\$ '" > "${HOME}"/.bashrc
@@ -30,4 +37,52 @@ fi
3037

3138
source kubedock_setup
3239

40+
41+
# Stow
42+
## Required for https://github.com/eclipse/che/issues/22412
43+
44+
# /home/user/ will be mounted to by a PVC if persistUserHome is enabled
45+
mountpoint -q /home/user/; HOME_USER_MOUNTED=$?
46+
47+
# This file will be created after stowing, to guard from executing stow everytime the container is started
48+
STOW_COMPLETE=/home/user/.stow_completed
49+
50+
if [ $HOME_USER_MOUNTED -eq 0 ] && [ ! -f $STOW_COMPLETE ]; then
51+
# There may be regular, non-symlink files in /home/user that match the
52+
# pathing of files in /home/tooling. Stow will error out when it tries to
53+
# stow on top of that. Instead, we can append to the current
54+
# /home/tooling/.stow-local-ignore file to ignore pre-existing,
55+
# non-symlinked files in /home/user that match those in /home/tooling before
56+
# we run stow.
57+
#
58+
# Create two text files containing a sorted path-based list of files in
59+
# /home/tooling and /home/user. Cut off "/home/user" and "/home/tooling" and
60+
# only get the sub-paths so we can do a proper comparison
61+
#
62+
# In the case of /home/user, we want regular file types and not symbolic
63+
# links.
64+
find /home/user -type f -xtype f -print | sort | sed 's|/home/user||g' > /tmp/user.txt
65+
find /home/tooling -print | sort | sed 's|/home/tooling||g' > /tmp/tooling.txt
66+
# We compare the two files, trying to find files that exist in /home/user
67+
# and /home/tooling. Being that the files that get flagged here are not
68+
# already synlinks, we will want to ignore them.
69+
IGNORE_FILES="$(comm -12 /tmp/user.txt /tmp/tooling.txt)"
70+
# We no longer require the file lists, so remove them
71+
rm /tmp/user.txt /tmp/tooling.txt
72+
# For each file we need to ignore, append them to
73+
# /home/tooling/.stow-local-ignore.
74+
for f in $IGNORE_FILES; do echo "${f}" >> /home/tooling/.stow-local-ignore;done
75+
# We are now ready to run stow
76+
#
77+
# Create symbolic links from /home/tooling/ -> /home/user/
78+
stow . -t /home/user/ -d /home/tooling/ --no-folding -v 2 > /tmp/stow.log 2>&1
79+
# Vim does not permit .viminfo to be a symbolic link for security reasons, so manually copy it
80+
cp /home/tooling/.viminfo /home/user/.viminfo
81+
# We have to restore bash-related files back onto /home/user/ (since they will have been overwritten by the PVC)
82+
# but we don't want them to be symbolic links (so that they persist on the PVC)
83+
cp /home/tooling/.bashrc /home/user/.bashrc
84+
cp /home/tooling/.bash_profile /home/user/.bash_profile
85+
touch $STOW_COMPLETE
86+
fi
87+
3388
exec "$@"

universal/ubi9/Dockerfile

-2
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,6 @@ RUN chgrp -R 0 /home && chmod -R g=u /etc/passwd /etc/group /home /etc/pki
423423
# cleanup dnf cache
424424
RUN dnf -y clean all --enablerepo='*'
425425

426-
COPY --chown=0:0 entrypoint.sh /
427-
428426
USER 10001
429427

430428
ENV HOME=/home/user

universal/ubi9/entrypoint.sh

-52
This file was deleted.

0 commit comments

Comments
 (0)