X-Git-Url: http://club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=install-symlinks.sh;h=820d5b3ee33281c00934ffa75149c7a928195aac;hb=378960d9bed5d9276d1e6d3ef29d4cd2a81d7d57;hp=41bda44f2b8504add2cdc3997999c67cd3737a2c;hpb=993671d30b462c6ce8158e690087efa37c02b7da;p=cmccabe-etc diff --git a/install-symlinks.sh b/install-symlinks.sh index 41bda44..820d5b3 100755 --- a/install-symlinks.sh +++ b/install-symlinks.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # install-symlinks.sh @@ -15,8 +15,22 @@ die() { exit 1 } -FULLPATH=`readlink -f $0` -BASEDIR=`dirname ${FULLPATH}` +copy_ssh_old=0 +for file in .bashrc .ssh .profile; do + if [ -f ../$file ]; then + if [ -L ../$file ]; then + : + else + echo "moving old $file to $file-old" + mv -f ../$file ../$file-old + if [ $file == .ssh ]; then + copy_ssh_old=1 + fi + fi + fi +done + +BASEDIR=`pwd` for file in ${BASEDIR}/.[^.]*; do # get base file name, like ".gitconfig" basefile=`basename ${file}` @@ -25,9 +39,9 @@ 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 + #[ "${basefile}" == ".ssh" ] && continue pushd .. > /dev/null if [ -L ${basefile} ]; then @@ -44,3 +58,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