-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·133 lines (101 loc) · 2.84 KB
/
bootstrap.sh
File metadata and controls
executable file
·133 lines (101 loc) · 2.84 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env bash
# bootstrap.sh
# modified from these:
# https://github.com/holman/dotfiles/blob/master/script/install
# https://github.com/mathiasbynens/dotfiles/blob/master/bootstrap.sh
set -o nounset
set -o errexit
set -o pipefail
DEBUG="${DEBUG:-false}"
[[ ${DEBUG} == true ]] && set -o xtrace
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
log_file="${__dir}/bootstrap.log"
# shellcheck disable=SC1090
[[ $(command -v k_custom_lib_loaded) ]] || source "${__dir}/shell/lib.sh"
date_header
usage() {
cat <<END
usage: [DEBUG=true] bootstrap.sh
Setup machine with my defaults. Env vars come from .env
Configures:
email: primary email address for the machine.
Used for: ssh key comment, associate to github.com
hostname: hostname for machine
machineuser: username for the machine to setup.
-h: show this help message
END
}
declare email
declare hostname
if [[ -f "${__dir}/.env" ]]; then
set -o allexport
# shellcheck source=/dev/null
source "${__dir}/.env"
set +o allexport
else
echo ".env file doesn't exist. creating from .example file."
cp "${__dir}/.env.example" "${__dir}/.env"
error "IMPORTANT: edit values and re-run bootstrap." 1
fi
while getopts "h" opt; do
case $opt in
h)
usage
exit 0
;;
\?)
exit 1
;;
esac
done
shift $(( OPTIND -1 ))
[[ -z "${email:-}" ]] && error "email is empty" 1
echo ''
if [[ "${DEBUG}" == true ]]; then
declare -p
fi
status "${BASH_SOURCE[0]} | ..."
echo "setting up machine $(hostname) as ${hostname} for ${email}..."
declare data_dir="${HOME}/data"
if [[ -d "${data_dir}" ]]; then
typed_message 'SKIP' "${data_dir} exists."
else
typed_message 'CREATE' "${data_dir}...";
mkdir "${data_dir}"
fi
echo ''
touch "${HOME}/.bash_profile"
# export for child shells
export email
export hostname
export pw
export machineuser
export username
export log_file
export apple_store_user
export apple_store_pw
# pre-req: MAC allow applescript to run in terminal
[[ $(command -v osascript) ]] && osascript "${__dir}/macosx/script/show_security_settings.applescript"
# find the installers and run them iteratively
find . -name install.sh | sort | while read -r installer ; do sh -c "${installer}" ; done
sh -c "${__dir}/macosx/bootstrap.sh"
sh -c "${__dir}/system/bootstrap.sh"
sh -c "${__dir}/git/bootstrap.sh"
sh -c "${__dir}/jetbrains/bootstrap.sh"
sh -c "${__dir}/vim/bootstrap.sh"
sh -c "${__dir}/shell/bootstrap.sh"
sh -c "${__dir}/node/bootstrap.sh"
sh -c "${__dir}/ruby/bootstrap.sh"
typed_message 'CLEANUP' "removing env vars"
echo ''
typed_message '-----' 'All installed! check for [FAIL] to fix any issues and re-run.'
unset email
unset hostname
unset pw
unset machineuser
unset username
unset log_file
unset apple_store_user
unset apple_store_pw
killall "Terminal" &> /dev/null || true
exit 0