-
Notifications
You must be signed in to change notification settings - Fork 6
/
bootstrap
executable file
·41 lines (33 loc) · 1.75 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
#!/bin/bash
# Save this file as ~/.config/yadm/bootstrap and make it executable. It will
# execute all executable files (excluding templates and editor backups) in the
# ~/.config/yadm/bootstrap.d directory when run.
set -eu
# Install Homebrew and packages first
source "$HOME/.config/yadm/brew.sh"
# Switch to zsh
if [[ "$SHELL" != *"zsh" ]]; then
chsh -s $(which zsh)
fi
# Directory to look for bootstrap executables in
BOOTSTRAP_D="${BASH_SOURCE[0]}.d"
if [[ ! -d "$BOOTSTRAP_D" ]]; then
echo "Error: bootstrap directory '$BOOTSTRAP_D' not found" >&2
exit 1
fi
find "$BOOTSTRAP_D" -type f | sort | while IFS= read -r bootstrap; do
if [[ -x "$bootstrap" && ! "$bootstrap" =~ "##" && ! "$bootstrap" =~ "~$" ]]; then
if ! "$bootstrap"; then
BOOTSTRAP_FILENAME=$(basename -- $bootstrap)
echo -e "\033[0;31m\nFailed installing '${BOOTSTRAP_FILENAME%%.*}'...\033[0m" >&2
echo -e "\033[0;31mYou can try one of the following:\033[0m" >&2
echo -e "\033[0;31m\t(1) Check the output above to see what went wrong and try to manually fix it\033[0m" >&2
echo -e "\033[0;31m\t(2) Open the bootstrap script and manually run each command: '$HOME/.config/yadm/bootstrap.d/$BOOTSTRAP_FILENAME'\033[0m" >&2
echo -e "\033[0;31m\t(3) Skip the installation of '${BOOTSTRAP_FILENAME%%.*}' by removing its bootstrap script: 'rm $HOME/.config/yadm/bootstrap.d/$BOOTSTRAP_FILENAME'\033[0m" >&2
echo -e "\033[0;31m\t(4) If nothing is working, you can always open a new issue in my dotfiles repo: 'https://github.com/ZhongXiLu/dotfiles/issues/new'\033[0m" >&2
exit 1
fi
fi
done
# Install zscaler certificate after everything else is installed
source "$HOME/.config/yadm/zcli.sh"