handle dot files that are already dymlinks
This commit is contained in:
parent
727ef7f81c
commit
9a297db034
17
setup.sh
17
setup.sh
@ -4,26 +4,29 @@
|
|||||||
# setup folder pointers and target files
|
# setup folder pointers and target files
|
||||||
|
|
||||||
dir=~/linux_user_setup
|
dir=~/linux_user_setup
|
||||||
olddir=~/linux_user_setup_restore
|
backup=~/linux_user_setup_restore
|
||||||
files=".bashrc .vimrc .tmux.conf .psqlrc"
|
files=".bashrc .vimrc .tmux.conf .psqlrc"
|
||||||
|
|
||||||
# create the resore directory if it doesn't already exist
|
# create the resore directory if it doesn't already exist
|
||||||
|
|
||||||
if [ ! -d $olddir ]
|
if [ ! -d $backup ]
|
||||||
then
|
then
|
||||||
mkdir $olddir
|
mkdir $backup
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# loop through each target file, move it and create a symlink to the replacements
|
# loop through each target file, move it and create a symlink to the replacements
|
||||||
|
|
||||||
for file in $files
|
for file in $files
|
||||||
do
|
do
|
||||||
#if the file is already a symlink then do nothing
|
#if the file is not a symlink the just _move_ it, otherwise _copy_ the linked file
|
||||||
if [ ! -L "$file"]
|
if [ ! -L $file ];
|
||||||
then
|
then
|
||||||
echo "moving $file to $olddir"
|
echo "moving $file to $backup"
|
||||||
mv ~/$file $olddir
|
mv ~/$file $backup
|
||||||
echo "snapping $file to be a new symlink to version controlled file in $dir"
|
echo "snapping $file to be a new symlink to version controlled file in $dir"
|
||||||
ln -s $dir/$file ~/$file
|
ln -s $dir/$file ~/$file
|
||||||
|
else
|
||||||
|
# if the target file is a symlink, copy the linked file
|
||||||
|
cp $(readlink -f $file) $backup
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user