added checks for existing files

This commit is contained in:
Christian Koptein 2024-05-01 10:50:13 +02:00
parent 461561964a
commit c2178640aa

View File

@ -1,14 +1,20 @@
#! /bin/bash #! /bin/bash
set -eou pipefail
mkdir -p $HOME/.ssh mkdir -p $HOME/.ssh
for link in bashrc gitconfig screenrc Xresources Xdefaults Xmodmap themes fonts aliases vim vimrc ;do for link in bashrc gitconfig screenrc Xresources Xdefaults Xmodmap themes fonts aliases vim vimrc ;do
#remove real files if present, making room for links
if [ -f $HOME/.$link ]; then
rm -rf $HOME/.$link && ln -s $(pwd)/$link $HOME/.$link; #echo 'removing' $HOME/.$link;
rm $HOME/.$link;
fi
if [ ! -e $HOME/.$link ]; then
#echo 'linking ' $(pwd)/$link $HOME/.$link;
ln -s $(pwd)/$link $HOME/.$link;
fi
done done
ln -s $(pwd)/sshconfig $HOME/.ssh/config if [ ! -e $HOME/.$link ]; then
ln -s $(pwd)/sshconfig $HOME/.ssh/config;
fi
cat $(pwd)/pubkeys/* > $HOME/.ssh/authorized_keys cat $(pwd)/pubkeys/* > $HOME/.ssh/authorized_keys