-
Notifications
You must be signed in to change notification settings - Fork 7
/
bootstrap
executable file
·53 lines (46 loc) · 1.89 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
#!/usr/bin/env bash
set -euo pipefail
export YP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null && pwd)"
source ${YP_DIR}/sh/common.inc.sh
cd ${YP_DIR}
! command -v git >/dev/null || {
YP_GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ "${YP_GIT_BRANCH}" = "master" ]]; then
echo_warn "Pulling and resetting your local 'master' branch of yplatform"
echo_warn "to the latest commit on 'origin/master'..."
echo_info "Switch to another local branch to skip this behaviour."
git reset
git stash --all
git checkout master
git fetch
git reset --hard origin/master
git clean -xdf .
fi
}
# Check sudo permissions if using sudo.
echo_info "Bootstrapping with YP_SUDO=${YP_SUDO}..."
if [[ -z "${YP_SUDO}" ]]; then
true
elif [[ "${YP_SUDO}" = "yp_nosudo_fallback" ]]; then
prompt_q_to_continue "sudo is not available. Do you have root access instead?"
else
echo "Enter your sudo password for bootstrap."
${YP_SUDO} true || {
echo_err "You need sudo/root access (called 'local admin rights' on MacOS) to bootstrap properly."
echo_err "If you don't have sudo/root access, try contacting the IT department."
exit 1
}
fi
# Execute the OS specific boostrap process.
${YP_DIR}/bootstrap/bootstrap
# Offer to upgrade users login shell to homebrew's bash.
${YP_DIR}/bin/use-homebrew-bash
# User feedback
echo
echo "==> Next steps:"
echo "- Append the following to your '~/.bashrc' or '~/.zshrc' or similar:"
echo " source ~/${YP_DIR#"${HOME}"/}/sh/dev.inc.sh"
echo "- Configure your git. See https://github.com/ysoftwareab/yplatform/tree/master/gitconfig#readme"
echo "- Configure your ssh. See https://github.com/ysoftwareab/yplatform/tree/master/sshconfig#readme"
echo "- Restart your shell, and you're good to go."
read -r -p "Press Enter to confirm you have read the above and finish dev/bootstrap."