-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbootstrap.sh
executable file
·79 lines (63 loc) · 1.85 KB
/
bootstrap.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
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
#!/bin/sh
# A VERY minimal script to get things started
# Exit on error
set -e
command_exists() {
command -v "$@" >/dev/null 2>&1
}
error() {
echo "${RED}""Error: $*""${RESET}" >&2
}
warn() {
echo "${YELLOW}""Error: $*""${RESET}" >&2
}
announce() {
echo "${BLUE}""Notice: $*""${RESET}" >&2
}
setup_color() {
# Only use colors if connected to a terminal
if [ -t 1 ]; then
RED=$(printf '\033[31m')
BLUE=$(printf '\033[34m')
YELLOW=$(printf '\033[33m')
RESET=$(printf '\033[m')
else
RED=""
BLUE=""
YELLOW=""
RESET=""
fi
}
setup_color
# Prevent the cloned repository from having insecure permissions. Failing to do
# so causes compinit() calls to fail with "command not found: compdef" errors
# for users with insecure umasks (e.g., "002", allowing group writability). Note
# that this will be ignored under Cygwin by default, as Windows ACLs take
# precedence over umasks except for filesystems mounted with option "noacl".
umask g-w,o-w
command_exists brew || {
warn "homebrew is not installed (we need git)"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
brew install git
}
# shellcheck source=/dev/null
if [ -f ~/.seed-crystal/setup.sh ]; then
announce "This workstation has already been seeded. Re-running setup scripts."
cd ~/Documents/seed-crystal/
announce "\n$(cat -n ~/.seed-crystal/setup.sh)"
source ~/.seed-crystal/setup.sh
exit
fi
mkdir -p ~/.seed-crystal
mkdir -p ~/Documents
if [ ! -d ~/Documents/seed-crystal ]
then
announce "Cloning seed-crystal..."
git clone --depth=1 https://github.com/carbonfive/seed-crystal.git ~/Documents/seed-crystal || {
error "git clone of seed-crystal repo failed"
exit 1
}
fi
cd ~/Documents/seed-crystal
bin/workstation-setup.sh