-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.install.sh
executable file
·95 lines (76 loc) · 2.49 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
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
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
OS_NAME=$( uname -s | tr '[:upper:]' '[:lower:]')
OS_ARCH=$( uname -m )
function installHomebrew {
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)";
}
function coGitBare {
DOTFILES_REPO="$1"
DOTFILES_WORKDIR="$2"
DOTFILES_BARE="$2/$3"
git clone --bare "$DOTFILES_REPO" "$DOTFILES_BARE/"
git --git-dir="$DOTFILES_BARE" config --local status.showUntrackedFiles no
git --git-dir="$DOTFILES_BARE" config --local core.sparseCheckout true
# Include everything
echo "/*" > "$DOTFILES_BARE/info/sparse-checkout"
# Exclude readme
echo "!/Readme.md" >> "$DOTFILES_BARE/info/sparse-checkout"
# Ignore Library folder on Linux
if [ "$OS_NAME" = "darwin" ]; then
echo "!Library" >> "$DOTFILES_BARE/info/sparse-checkout"
fi
cd "$DOTFILES_WORKDIR"
# recursive-submodules is limited to git >= 2.13
# We are doing it the old way here to increase compatibility
# git --git-dir="$DOTFILES_BARE" --work-tree="$DOTFILES_WORK_DIR/" checkout -f --recurse-submodules
git --git-dir="$DOTFILES_BARE" --work-tree="$DOTFILES_WORKDIR/" checkout -f
git --git-dir="$DOTFILES_BARE" --work-tree="$DOTFILES_WORKDIR/" submodule update --init --recursive
# Manual pull to create FETCH_HEAD
git --git-dir="$DOTFILES_BARE" --work-tree="$DOTFILES_WORKDIR/" pull
touch "$DOTFILES_BARE/FETCH_HEAD"
}
if ! command -v "git" &> /dev/null; then
case "$OS_NAME" in
darwin*)
xcode-select --install || true
;;
linux*)
sudo apt install -y curl make git
;;
*)
echo "Unsupported OS: $(uname)"
exit 1
;;
esac
else
echo "Skipping basics installation as they are already installed."
fi
cd "$HOME" || exit 1
if ! command -v "brew" &> /dev/null; then
case "$OS_ARCH" in
aarch64)
echo "Skipping homebrew installation as it is unsupported on $OS_ARCH"
echo "https://docs.brew.sh/Homebrew-on-Linux#arm-unsupported"
;;
*)
installHomebrew
;;
esac
else
echo "Skipping homebrew installation as it is already installed."
fi
if [ ! -d ".dotfiles-bare-repo/" ]; then
coGitBare "https://github.com/heussd/dotfiles.git" "$HOME/" ".dotfiles-bare-repo/"
echo "Onboarding complete. Re-execute for private dotfiles."
exit 0
else
echo "Skipping dotfiles onboarding as it is already onboarded"
fi
if [ ! -d ".dotfiles-private-bare-repo/" ]; then
coGitBare "https://github.com/heussd/dotfiles-private" "$HOME/" ".dotfiles-private-bare-repo/"
else
echo "Skipping private dotfiles onboarding as it is already onboarded"
fi