-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·46 lines (38 loc) · 1.4 KB
/
install.sh
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
#!/bin/bash
echo "edwinbalani's dotfiles/install.sh starting up..."
# A reliable way of getting the current directory name
DOTFILES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export DOTFILES_DIR
printf "export DOTFILES_DIR=%s\n" "$DOTFILES_DIR" > "$HOME/.dotfiles-location"
source "$DOTFILES_DIR/util.sh"
# Arguments for ln
# from https://github.com/bndabbs/dotfiles/blob/master/setup.sh
params="-sf"
while getopts "vib" args; do
case $args in
v)
params="$params -v"
;;
i)
params="$params -i"
;;
b)
params="$params -b"
;;
esac
done
LINK_CMD="ln $params"
# First, update the dotfiles themselves (if they were git cloned in the first place)
if [ -d "$DOTFILES_DIR/.git" ]; then
echo "Updating dotfiles..."
current_head=$(git --work-tree="$DOTFILES_DIR" --git-dir="$DOTFILES_DIR/.git" rev-parse HEAD)
git --work-tree="$DOTFILES_DIR" --git-dir="$DOTFILES_DIR/.git" pull origin master
if [ "$(git --work-tree="$DOTFILES_DIR" --git-dir="$DOTFILES_DIR/.git" log --stat "$current_head.." -- install/ install.sh util.sh | wc -l)" -ne 0 ]; then
echo "WARNING: the installation scripts were updated by 'git pull'."
echo " Please re-run this file ($0) to continue installation."
exit 1
fi
fi
for component in $DOTFILES_DIR/install/*.sh; do
source "$component"
done