forked from gf3/dotfiles
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
Latest commit
81 lines (67 loc) · 1.57 KB
/
Copy pathbootstrap.sh
File metadata and controls
81 lines (67 loc) · 1.57 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
75
76
77
78
79
80
# --- Functions --- #
# Notice title
functionnotice { echo"\033[1;32m=> $1\033[0m"; }
# Error title
functionerror { echo"\033[1;31m=> Error: $1\033[0m"; }
# List item
functionc_list { echo" \033[1;32m✔\033[0m $1"; }
# Error list item
functione_list { echo" \033[1;31m✖\033[0m $1"; }
# Check for dependency
functiondep {
# Check installed
local i=true
type -p $1&> /dev/null || i=false
# Check version
if$i;then
local version=$($1 --version | grep -oE -m 1 "[[:digit:]]+\.[[:digit:]]+\.?[[:digit:]]?")
[[ $version<$2 ]] &&local msg="$1 version installed: $version, version needed: $2"
else
local msg="Missing $1"
fi
# Save if dep not met
if!$i|| [ -n"$msg" ] ;then
missing+=($msg)
fi
}
# --- INIT --- #
current_pwd=$(pwd)
missing=()
# --- Check deps --- #
notice "Checking dependencies"
dep "git""1.7"
dep "hg""1.6"
dep "ruby""1.8"
dep "vim""7.3"
dep "tree""1.5"
if [ "${#missing[@]}"-gt"0" ];then
error "Missing dependencies"
forneedin"${missing[@]}";do
e_list "$need."
done
exit 1
fi
# Assumes ~/.dotfiles is *ours*
if [ -d~/.dotfiles ];then
# --- Update Repo --- #
notice "Updating"
cd~/.dotfiles
git pull origin master
git submodule init
git submodule update
# --- Install --- #
notice "Installing"
rake install
else
# --- Clone Repo --- #
notice "Downloading"
git clone --recursive git://github.com/gf3/dotfiles.git ~/.dotfiles
# --- Install --- #
notice "Installing"
cd~/.dotfiles
rake backup
rake install
fi
# --- Finished --- #
cd$current_pwd
notice "Done"