install-symlinks.sh: chmod 600 .ssh/config
[cmccabe-etc] / install-symlinks.sh
index d381326..ebb21b7 100755 (executable)
@@ -15,6 +15,26 @@ die() {
        exit 1
 }
 
+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"
@@ -24,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
@@ -43,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/config
+fi