Add .gradle/gradle.properties
[cmccabe-etc] / install-symlinks.sh
1 #!/usr/bin/env bash
2
3 #
4 # install-symlinks.sh
5 #
6 # Script for installing symlinks to these rc files into your home directory.
7 # It's assumed that your home directory is the directory immediately above this
8 # one.
9 #
10 # Colin McCabe
11 #
12
13 die() {
14         echo "$@"
15         exit 1
16 }
17
18 copy_ssh_old=0
19 for file in .bashrc .ssh .profile; do
20     if [ -f ../$file ]; then
21         if [ -L ../$file ]; then
22             :
23         else
24             echo "moving old $file to $file-old"
25             mv -f ../$file ../$file-old
26             if [ $file == .ssh ]; then
27                 copy_ssh_old=1
28             fi
29         fi
30     fi
31 done
32
33 BASEDIR=`pwd`
34 for file in ${BASEDIR}/.[^.]*; do
35         # get base file name, like ".gitconfig"
36         basefile=`basename ${file}`
37
38         # get relative file name, like "cmccabe-etc/.gitconfig"
39         relfile=`echo ${file} | sed 's_.*/\([^/]*/[^/]*\)$_\1_'`
40
41         # skip files which we don't want to link
42         [ "${basefile}" == ".git" ] && continue
43         [ "${basefile}" == ".gitignore" ] && continue
44         #[ "${basefile}" == ".ssh" ] && continue
45
46         pushd .. > /dev/null
47         if [ -L ${basefile} ]; then
48                 # Someone already created this link. Pass over it in silence
49                 :
50         elif [ ! -a ${basefile} ]; then
51                 # Create the link
52                 ln -s ${relfile} || die "failed to link ${relfile}"
53                 echo "created ${relfile}..."
54         elif [ -f ${basefile} ]; then
55                 echo "${basefile} already exists as a regular file"
56         else
57                 echo "${basefile} already exists"
58         fi
59         popd > /dev/null
60 done
61
62 if [ $copy_ssh_old -eq 1 ]; then
63     echo "copying files from .ssh-old to .ssh"
64     cp -f ../.ssh-old/* ../.ssh
65     echo "chmod 600 ../.ssh/config"
66     chmod 600 ../.ssh/*
67 fi