-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·81 lines (67 loc) · 2.62 KB
/
bootstrap.sh
File metadata and controls
executable file
·81 lines (67 loc) · 2.62 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
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
#!/bin/bash -i
set -e
OS="$(uname -s)"
# collect user info
echo -n "Your name: "
read NAME
echo -n "Your email: "
read EMAIL
echo -n "Your rbw (Bitwarden) email: "
read RBW_EMAIL
PANEL_COLOR=""
CHEZMOI_DATA="name = \"$NAME\"\nemail = \"$EMAIL\"\nrbw_email = \"$RBW_EMAIL\""
echo -n "[sudo] password for $USER: "
read -s PASSWORD
echo
if [[ "$OS" == "Linux" ]]; then
echo -n "Top bar color override (leave blank for Dracula default, e.g. rgba(20, 20, 30, 0.98)): "
# a nice alternative: rgba(118, 0, 100, 0.95)
read PANEL_COLOR
fi
CHEZMOI_DATA="$CHEZMOI_DATA\npanel_color = \"$PANEL_COLOR\""
# install base deps
if [[ "$OS" == "Darwin" ]]; then
if ! command -v brew &>/dev/null; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
brew install ansible chezmoi
elif [[ "$OS" == "Linux" ]]; then
echo "$PASSWORD" | sudo -S dnf install -y ansible python3-psutil
mkdir -p /tmp/dotfiles
# install chezmoi
if [[ ! -f /tmp/dotfiles/chezmoi.tar.gz ]]; then
wget --no-clobber https://github.com/twpayne/chezmoi/releases/download/v2.10.0/chezmoi_2.10.0_linux_amd64.tar.gz -O /tmp/dotfiles/chezmoi.tar.gz
(cd /tmp/dotfiles && tar -xzf chezmoi.tar.gz)
fi
mkdir -p "$HOME/.local/bin"
install /tmp/dotfiles/chezmoi "$HOME/.local/bin"
fi
# init and apply chezmoi
mkdir -p "$HOME/Projects"
if [[ ! -d "$HOME/Projects/dotfiles" ]]; then
git clone https://github.com/alanchrt/dotfiles.git "$HOME/Projects/dotfiles"
fi
printf "$CHEZMOI_DATA\n" > "$HOME/Projects/dotfiles/.chezmoidata.toml"
chezmoi apply --source "$HOME/Projects/dotfiles"
# run ansible playbook
if [[ "$OS" == "Darwin" ]]; then
ANSIBLE_FORCE_COLOR=true ansible-playbook -v -c local \
"$HOME/Projects/dotfiles/macos.yml" \
-i "$HOME/Projects/dotfiles/hosts" \
--extra-vars "ansible_become_password=$PASSWORD"
elif [[ "$OS" == "Linux" ]]; then
# clean up chezmoi temp files
rm -r /tmp/dotfiles
ANSIBLE_FORCE_COLOR=true ansible-pull -v --checkout master \
--url https://github.com/alanchrt/dotfiles.git \
-i hosts --extra-vars "ansible_become_password=$PASSWORD"
fi
if [[ "$OS" == "Darwin" ]]; then
echo ""
echo "Manual steps:"
echo " 1. Install Karabiner-Elements: brew install --cask karabiner-elements"
echo " 2. Open Karabiner-Elements and grant Accessibility/Input Monitoring permissions"
echo " 3. Open Rectangle and grant Accessibility permissions"
fi
echo "Please restart this machine to make sure all groups, extensions, and services reload properly."