@@ -20,22 +20,6 @@ if [ ! -d "${HOME}/.config/containers" ]; then
2020 fi
2121fi
2222
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
37- fi
38-
3923# Setup $PS1 for a consistent and reasonable prompt
4024if [ -w " ${HOME} " ] && [ ! -f " ${HOME} " /.bashrc ]; then
4125 echo " PS1='[\u@\h \W]\$ '" > " ${HOME} " /.bashrc
@@ -90,13 +74,86 @@ if [ $HOME_USER_MOUNTED -eq 0 ] && [ ! -f $STOW_COMPLETE ]; then
9074 #
9175 # Create symbolic links from /home/tooling/ -> /home/user/
9276 stow . -t /home/user/ -d /home/tooling/ --no-folding -v 2 > /tmp/stow.log 2>&1
93- # Vim does not permit .viminfo to be a symbolic link for security reasons, so manually copy it
94- cp /home/tooling/.viminfo /home/user/.viminfo
95- # We have to restore bash-related files back onto /home/user/ (since they will have been overwritten by the PVC)
96- # but we don't want them to be symbolic links (so that they persist on the PVC)
97- cp /home/tooling/.bashrc /home/user/.bashrc
98- cp /home/tooling/.bash_profile /home/user/.bash_profile
9977 touch $STOW_COMPLETE
10078fi
10179
80+ # Read .copy-files and copy files from /home/tooling to /home/user
81+ if [ -f " /home/tooling/.copy-files" ]; then
82+ echo " Processing .copy-files..."
83+ while IFS= read -r line || [[ -n " $line " ]]; do
84+ # Skip empty and commented lines
85+ [[ -z " $line " || " $line " == \# * ]] && continue
86+
87+ if [ -e " /home/tooling/$line " ]; then
88+ tooling_path=$( realpath " /home/tooling/$line " )
89+
90+ # Determine target path based on whether source is a directory
91+ if [ -d " $tooling_path " ]; then
92+ # For directories: copy to parent directory (e.g., dir1/dir2 -> /home/user/dir1/)
93+ target_parent=$( dirname " ${HOME} /${line} " )
94+ target_full=" $target_parent /$( basename " $tooling_path " ) "
95+
96+ # Skip if target directory already exists
97+ if [ -d " $target_full " ]; then
98+ echo " Directory $target_full already exists, skipping..."
99+ continue
100+ fi
101+
102+ echo " Copying directory $tooling_path to $target_parent /"
103+ mkdir -p " $target_parent "
104+ cp --no-clobber -r " $tooling_path " " $target_parent /"
105+ else
106+ # For files: copy to exact target path
107+ target_full=" ${HOME} /${line} "
108+ target_parent=$( dirname " $target_full " )
109+
110+ # Skip if target file already exists
111+ if [ -e " $target_full " ]; then
112+ echo " File $target_full already exists, skipping..."
113+ continue
114+ fi
115+
116+ echo " Copying file $tooling_path to $target_full "
117+ mkdir -p " $target_parent "
118+ cp --no-clobber -r " $tooling_path " " $target_full "
119+ fi
120+ else
121+ echo " Warning: /home/tooling/$line does not exist, skipping..."
122+ fi
123+ done < /home/tooling/.copy-files
124+ echo " Finished processing .copy-files."
125+ else
126+ echo " No .copy-files found, skipping copy operation."
127+ fi
128+
129+ # Create symlinks from /home/tooling/.config to /home/user/.config
130+ # Only create symlinks for files that don't already exist in destination.
131+ # This is done because stow ignores the .config directory.
132+ if [ -d /home/tooling/.config ]; then
133+ echo " Creating .config symlinks for files that don't already exist..."
134+
135+ # Find all files recursively in /home/tooling/.config
136+ find /home/tooling/.config -type f | while read -r file; do
137+ # Get the relative path from /home/tooling/.config
138+ relative_path=" ${file#/ home/ tooling/ .config/ } "
139+
140+ # Determine target path in /home/user/.config
141+ target_file=" ${HOME} /.config/${relative_path} "
142+ target_dir=$( dirname " $target_file " )
143+
144+ # Only create symlink if target file doesn't exist
145+ if [ ! -e " $target_file " ]; then
146+ # Create target directory if it doesn't exist
147+ mkdir -p " $target_dir "
148+ # Create symbolic link
149+ ln -s " $file " " $target_file "
150+ echo " Created symlink: $target_file -> $file "
151+ else
152+ echo " File $target_file already exists, skipping..."
153+ fi
154+ done
155+
156+ echo " Finished creating .config symlinks."
157+ fi
158+
102159exec " $@ "
0 commit comments