-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·68 lines (58 loc) · 2 KB
/
install.sh
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
#!/usr/bin/env bash
# NOTE: setup-modules/_env.bash will also set DOTFILES_DIR (if it's unset) so we
# use INSTALL_INTO to differneatie
INSTALL_INTO=${DOTFILES_DIR:-$HOME/dotfiles}
echo "Installing dotfiles into $INSTALL_INTO"
if [[ -f "$INSTALL_INTO/setup-modules/_env.bash" ]]; then
# shellcheck source=./setup-modules/_env.bash
source "$INSTALL_INTO/setup-modules/_env.bash"
elif [[ -f setup-modules/_env.bash ]]; then
source setup-modules/_env.bash
else
echo 'Error: could not source setup-modules/_env.bash'
echo 'Tip: either set DOTFILES_DIR or run this script from that directory.'
exit 1
fi
require functions/ssh-helpers
require functions/brew-helpers
ensure_brew_ready
sourcedot brewfiles/essential
ensure_ssh_key
if [[ -d $INSTALL_INTO ]]; then
(
cd "$INSTALL_INTO"
if git status --short --branch; then
echo Valid repository
if git remote -v | grep -q https; then
echo "Error: $INSTALL_INTO was cloned over https - git protocol is required to receive updates"
# TODO: add option to backup and clean current INSTALL_INTO directory so installer can continue
exit 1
fi
# TODO: make expected git origin configurable
if ! git remote -v | grep -q 'mfdj/macos-dotfiles'; then
echo "Error: $INSTALL_INTO was not cloned from expected origin (mfdj/macos-dotfiles)"
exit 1
fi
if ! git fetch; then
echo Ensure Github has the public key
cat ~/.ssh/id_ed25519.pub
echo 'open https://github.com/settings/keys'
exit 1
fi
else
echo "Error: $INSTALL_INTO was not git cloned"
exit 1
fi
)
else
if ! git clone [email protected]:mfdj/macos-dotfiles.git "$INSTALL_INTO"; then
echo Ensure Github has the public key
cat ~/.ssh/id_ed25519.pub
echo 'open https://github.com/settings/keys'
exit 1
fi
fi
# Ready to setup
export DOTFILES_DIR=${INSTALL_INTO}
cd "$DOTFILES_DIR"
./setup.sh