Skip to content

Commit 913d24b

Browse files
dkwon17eye0fra
authored andcommitted
fix: create links in entrypoint for files under /home/tooling/.config (#226)
* fix: create links in entrypoint for files under /home/tooling/.config Files under /home/tooling/.config are not stowed in the entrypoint because it is in the .stow-local-ignore file. Stow ignores everything in the .config folder because the /home/user/.config folder should be created in the entrypoint in order to have proper user permissions required for Podman 5.x. Signed-off-by: David Kwon <[email protected]>
1 parent 4a1e80b commit 913d24b

File tree

2 files changed

+39
-5
lines changed

2 files changed

+39
-5
lines changed

base/ubi9/.copy-files

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# This file contains a list directories or files to copy over from /home/tooling to /home/user in entrypoint.sh.
2+
#
3+
# For example, the following will copy /home/tooling/testfile to /home/user/testfile:
4+
# ./testfile
5+
#
6+
# The goal of this file is to copy over files that cannot be used as symbolic links created by stow.
7+
# For example, Vim does not permit .viminfo to be a symbolic link for security reasons, therefore it is copied
8+
# over to /home/user manually without stow.
9+
#
10+
# When copying over directories or files from /home/tooling to /home/user using this file, remember to add the
11+
# directory or file to .stow-local-ignore so that a symbolic link is not created.
12+
13+
14+
# Vim does not permit .viminfo to be a symbolic link for security reasons, so manually copy it
15+
.viminfo
16+
17+
# We have to restore bash-related files back onto /home/user/ (since they will have been overwritten by the PVC)
18+
# but we don't want them to be symbolic links (so that they persist on the PVC)
19+
.bashrc
20+
.bash_profile

base/ubi9/entrypoint.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#!/bin/bash
22

3+
# Replace /home/tooling/* path to /home/user/* path
4+
replace_user_home() {
5+
echo "$1" | sed "s|^/home/tooling|$HOME|"
6+
}
7+
38
# Ensure $HOME exists when starting
49
if [ ! -d "${HOME}" ]; then
510
mkdir -p "${HOME}"
@@ -15,11 +20,20 @@ if [ ! -d "${HOME}/.config/containers" ]; then
1520
fi
1621
fi
1722

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+
# Find files under /home/tooling/.config and create symlinks. The /home/tooling/.config folder
24+
# is ignored by stow with the .stow-local-ignore file
25+
if [ -d /home/tooling/.config ]; then
26+
for file in $(find /home/tooling/.config -type f); do
27+
tooling_dir=$(dirname "$file")
28+
29+
# Create dir in /home/user if it does not exist already
30+
mkdir -p $(replace_user_home "$tooling_dir")
31+
32+
# Create symbolic link if it does not exist already
33+
if [ ! -f $(replace_user_home $file) ]; then
34+
ln -s $file $(replace_user_home $file)
35+
fi
36+
done
2337
fi
2438

2539
# Setup $PS1 for a consistent and reasonable prompt

0 commit comments

Comments
 (0)