X-Git-Url: http://club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=install-symlinks.sh;h=7c762bb748177e2b16dfe9f012482693006c209e;hb=7baae411b0b7e504f18e97a27768d0bf378d5027;hp=f922179437fe0ca0145f69c1e92e3821eb6fc49f;hpb=87d1b9b9a2e878a7743995657c1fd807d634022b;p=cmccabe-etc diff --git a/install-symlinks.sh b/install-symlinks.sh index f922179..7c762bb 100755 --- a/install-symlinks.sh +++ b/install-symlinks.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # install-symlinks.sh @@ -15,8 +15,27 @@ die() { exit 1 } -FULLPATH=`readlink -f $0` -BASEDIR=`dirname ${FULLPATH}` +if [ -f ../.bashrc ]; then + if [ -L ../.bashrc ]; then + : + else + echo "moving old .bashrc to .bashrc-old" + mv -f ../.bashrc ../.bashrc-old + fi +fi + +copy_ssh_old=0 +if [ -d ../.ssh ]; then + if [ -L ../.ssh ]; then + : + else + echo "moving old .ssh to .ssh-old" + mv -f ../.ssh ../.ssh-old + copy_ssh_old=1 + fi +fi + +BASEDIR=`pwd` for file in ${BASEDIR}/.[^.]*; do # get base file name, like ".gitconfig" basefile=`basename ${file}` @@ -25,9 +44,8 @@ for file in ${BASEDIR}/.[^.]*; do relfile=`echo ${file} | sed 's_.*/\([^/]*/[^/]*\)$_\1_'` # skip files which we don't want to link - if [ "${basefile}" == ".git" ]; then - continue; - fi + [ "${basefile}" == ".git" ] && continue + [ "${basefile}" == ".gitignore" ] && continue pushd .. > /dev/null if [ -L ${basefile} ]; then @@ -44,3 +62,10 @@ for file in ${BASEDIR}/.[^.]*; do fi popd > /dev/null done + +if [ $copy_ssh_old -eq 1 ]; then + echo "copying files from .ssh-old to .ssh" + cp -f ../.ssh-old/* ../.ssh + echo "chmod 600 ../.ssh/config" + chmod 600 ../.ssh/* +fi