Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·74 lines (63 loc) · 1.71 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·74 lines (63 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash -e
cd
# Location of repository.
REPONAME='MacConfig'
REPOLOC="$HOME/bin/$REPONAME"
# Clone the dotfiles repository and execute the profile script.
[ -d $REPOLOC ] || git clone https://github.com/DavidPotter/$REPONAME.git $REPOLOC
(
set -e
cd $REPOLOC
TEMPFILE="`mktemp -t install.XXXXXX`"
trap '{ rm -f "$TEMPFILE"; }' EXIT
set +e
git fetch origin
git show origin/master:dotfiles/profile > "$TEMPFILE"
echo "Executing $TEMPFILE"
source "$TEMPFILE"
set -e
gup
)
# Helper function to create a link if the destination doesn't exist
# or display an error message detailing why it failed.
function create_link()
{
local SRC="$1"
local DST="$2"
if [ ! -e "$DST" ]
then
ln -sv "$SRC" "$DST"
else
if [ ! -L "$DST" ] || [ "`readlink "$DST"`" != "$SRC" ]
then
echo -n "$REPONAME: $DST already exists" >&2
if [ -L "$DST" ]
then
echo " (pointing to `readlink "$DST"`)"
else
echo " (not a symlink)"
fi
fi
fi
}
# Loop through the files in the dotfiles directory and create a symlink to each one
# from a file with the same name but with a dot prefix (a dotfile) in the home directory.
# Special-case the profile script.
find $REPOLOC/dotfiles -maxdepth 1 -type f -not -name 'install.sh' -not -name 'README*' | while read SRC
do
DST="`echo "$SRC" | sed -e 's#.*/#.#'`"
if echo "$SRC" | grep -q /profile$
then
create_link "$SRC" .bash_profile
create_link "$SRC" .bashrc
else
create_link "$SRC" "$DST"
fi
done
# Install the ChangeHosts script to detect changes in the network configuration
# and set up the correct hosts file.
#source $REPOLOC/installChangeHosts.sh
echo '#'
echo '# Invoke the following command to complete the installation:'
echo '# source ~/.bash_profile'
echo '#'