-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap
executable file
·37 lines (33 loc) · 1.3 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
#!/bin/bash
#
# Minimal script to bootstrap https://yadm.io before it clones our dotfiles
unset GIT_DIR GIT_WORK_TREE INTERACTIVE XDG_CONFIG_HOME
command -v bash >/dev/null 2>&1 || { printf >&2 "\e[31mERROR\e[0m: bash must be installed!\n" && exit 1; }
command -v git >/dev/null 2>&1 || { printf >&2 "\e[31mERROR\e[0m: git must be installed!\n" && exit 1; }
[ -n "$BASH_VERSION" ] || { printf >&2 "\e[31mERROR\e[0m: must be executed using bash!\n" && exit 1; }
set -euo pipefail
# Prompt for and remember password
echo "Prompting for sudo password"
if [ "${EUID:-$(id -u)}" -eq 0 ]; then
:
elif [ -t 0 ]; then
sudo --validate
else
sudo -n true
fi
while true; do
command -v sudo &>/dev/null || exit
sudo -n true
sleep 60
kill -0 "$$" || exit
done &>/dev/null &
# On macOS, the default git needs CLT. Let brew install them headlessly.
if [ "$(uname)" = "Darwin" ] && ! [ -e "/Library/Developer/CommandLineTools/usr/bin/git" ]; then
echo "Installing Homebrew"
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# Install yadm and run bootstrap
echo "Bootstrapping dotfiles"
# shellcheck source=/dev/null
source /dev/stdin <<<"$(curl -fsSL bootstrap.yadm.io)"
yadm clone --bootstrap https://github.com/branchvincent/dotfiles.git -f