Repository navigation
Expand file tree
/
Copy pathbootstrap
More file actions
executable file
路37 lines (33 loc) 路 1.69 KB
/
Copy pathbootstrap
File metadata and controls
executable file
路37 lines (33 loc) 路 1.69 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
#!/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"
[ "${EUID:-$(id -u)}" -eq 0 ] || sudo --validate
while true; do
command -v sudo &>/dev/null || exit
sudo -n true
sleep 60
kill -0 "$$" || exit
done &>/dev/null &
# On macOS, system 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 disable=SC2016
yadm="$(curl -fsSL bootstrap.yadm.io | sed 's|$YADM_REPO/raw/$YADM_RELEASE/yadm|https://github.com/yadm-dev/yadm/raw/master/yadm|')"
shasum="$(command -v sha256sum || command -v shasum || echo "openssl dgst -sha256")"
got="$(printf '%s' "$yadm" | $shasum | awk '{print $1}')"
want=b55476d8f12b64f37e44fd67f17e173c2268701dc63d8574293327311f0dedb2
[ "$got" = "$want" ] || { printf >&2 "\e[31mERROR\e[0m: Checksum mismatch! Got: %s\n" "$got" && exit 1; }
# shellcheck source=/dev/null
source /dev/stdin <<<"$yadm"
yadm clone --bootstrap https://github.com/branchv/dotfiles.git -f