-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap
executable file
·72 lines (58 loc) · 2.04 KB
/
bootstrap
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
#!/usr/bin/env bash
#
# bootstrap stuff.
set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source "$SCRIPT_DIR"/common
setup_gitconfig () {
if ! [[ -f "$SCRIPT_DIR"/git/.gitconfig ]]; then
info 'setup gitconfig'
git_credential='cache'
if [ "$(uname -s)" == "Darwin" ]; then
git_credential='osxkeychain'
fi
user ' - What is your github author name?'
read -r -e git_authorname
user ' - What is your github author email?'
read -r -e git_authoremail
sed -e "s/AUTHORNAME/$git_authorname/g" \
-e "s/AUTHOREMAIL/$git_authoremail/g" \
-e "s/GIT_CREDENTIAL_HELPER/$git_credential/g" \
"$SCRIPT_DIR"/git/.gitconfig.example > "$SCRIPT_DIR"/git/.gitconfig
success 'gitconfig'
fi
}
install_symlinks () {
info "running symlinks : output logged to $LOG_FILE"
overwrite_all=false backup_all=false skip_all=false
for module in "${MODULES[@]}"; do
if [[ ! -f "$module/symlink.sh" ]]; then
warn "no symlink.sh file found for $module, skipping"
continue
fi
info ""
info "running symlink file : $module/symlink.sh"
info "==========================================="
info ""
if ! symlinks=$(sh -c "$module/symlink.sh" 2>&1); then
fail "failed to run symlink file : $module/symlink.sh"
else
for link in "${symlinks[@]}"; do
lines=()
while IFS=$'\n' read -r line; do lines+=("$line"); done < <(echo "$link" | tr "\n" "\n")
for line in "${lines[@]}"; do
IFS=" " read -r -a parts <<< "$line"
link_file "${parts[0]}" "${parts[1]}"
done
done
info ""
success "finished symlink file : $module/symlink.sh"
info "==========================================="
fi
done
}
echo ''
setup_gitconfig
install_symlinks
echo ''
echo 'All bootstrapped!'