Created
December 18, 2014 14:09
-
-
Save gregorg/9359a4c151bfcf4ca3a0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install_conf() { | |
src="$envdir/$1" | |
dst=$2 | |
# METHODE AVEC "install" | |
mode=600 | |
if [ -h $dst ] | |
then | |
rm -vf $dst | |
fi | |
if ! diff -q $src $dst 2>/dev/null | |
then | |
echo "Install $dst" | |
install -m $mode $src $dst | |
fi | |
} | |
# METHODE AVEC SYMLINK | |
link_conf() { | |
src="$envdir/$1" | |
dst=$2 | |
if [ -f $dst ] && [ ! -h $dst ] | |
then | |
mv -v "$dst" "${dst}.bak" | |
fi | |
# Suppression du symlink s'il ne pointe pas au bon endroit | |
if [ -h $dst ] | |
then | |
cdst=$( readlink $dst ) | |
if [ "$cdst" != "$src" ] | |
then | |
rm -vf $dst | |
fi | |
fi | |
# Création du dossier cible s'il n'existe pas | |
dstfolder="${dst%/*}" | |
if [ ! -d "$dstfolder" ] | |
then | |
mkdir -p "$dstfolder" | |
fi | |
# Création du symlink | |
if [ ! -h $dst ] | |
then | |
ln -sv $src $dst | |
fi | |
} | |
link_conf alias ~/.alias | |
link_conf vimrc ~/.vimrc | |
link_conf gvimrc ~/.gvimrc | |
link_conf gitconfig ~/.gitconfig | |
link_conf screenrc ~/.screenrc | |
link_conf dialogrc ~/.dialogrc | |
link_conf psqlrc ~/.psqlrc | |
test -d ~/.ssh || mkdir -p ~/.ssh && chmod 700 ~/.ssh | |
install_conf ssh_config ~/.ssh/config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment