Created
July 18, 2012 17:27
-
-
Save kitchen/3137599 to your computer and use it in GitHub Desktop.
dotfiles make-symlinks
This file contains hidden or 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
#!/bin/bash | |
# pull in the submodules and set them up | |
git submodule init | |
git submodule update | |
# main loop to catch them all! | |
shopt -s dotglob | |
for i in * ; do | |
if [[ $i == "." || $i = ".." || $i = "make-symlinks" || $i = ".ssh" \ | |
|| $i == ".git" || $i == ".gitmodules" || $i == "README" ]]; then | |
continue | |
fi | |
linkpath=`readlink ~/$i` | |
if [[ $linkpath == ~/.dotfiles/$i ]]; then | |
# move along | |
true | |
else | |
if [[ -e ~/$i ]]; then | |
# something is there, what is it? | |
if [[ -L "~/$i" ]]; then | |
# it's a symlink, but not to the right place! | |
echo "~/$i is a symlink, but it's not to the right place (should be ~/.dotfiles/$i" | |
else | |
# it's just a file, methinks? we'll test it. | |
echo "~/$i is an existing file or directory, not going to touch it!" | |
fi | |
else | |
# doesn't exist, make the link! | |
echo "creating symlink ~/$i -> ~/.dotfiles/$i" | |
ln -s ~/.dotfiles/$i ~/$i || echo "unable to create symlink ~/$i -> ~/.dotfiles/$i" | |
fi | |
fi | |
done | |
shopt -u dotglob | |
# .ssh files need to be done spiffylike, and we'll just smash what's already there, if anything | |
cd .ssh | |
./mkauth.sh | |
test -d ~/.ssh || mkdir -m 0700 ~/.ssh | |
ln -sf ~/.dotfiles/.ssh/config ~/.ssh/config || echo "unable to create .ssh/config symlink, eek!" | |
ln -sf ~/.dotfiles/.ssh/authorized_keys ~/.ssh/authorized_keys || echo "unable to create .ssh/authorized_keys symlink, eek!" | |
cd $OLDPWD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment