-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathubuntu.sh
More file actions
158 lines (136 loc) · 5.31 KB
/
Copy pathubuntu.sh
File metadata and controls
158 lines (136 loc) · 5.31 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/env bash
# setup.sh – sudo -E ./setup.sh
set -euo pipefail
[[ $EUID -eq 0 ]] || { echo "Run with sudo -E" >&2; exit 1; }
# --- interactive helpers ------------------------------------------------------
# Default to "yes" when running non-interactively (e.g., piped/CI).
confirm() {
local prompt="${1:?prompt}"
local default_yes="${2:-true}" # true/false
local reply
if [[ ! -t 0 ]]; then
$default_yes && return 0 || return 1
fi
while true; do
if $default_yes; then
read -r -p "$prompt [Y/n] " reply || true
reply="${reply:-Y}"
else
read -r -p "$prompt [y/N] " reply || true
reply="${reply:-N}"
fi
case "${reply,,}" in
y|yes) return 0 ;;
n|no) return 1 ;;
*) echo "Please answer y or n." ;;
esac
done
}
SKIP_MINICONDA=false
SKIP_1PASSWORD=false
SKIP_ZEN=false
# Let env vars override prompts (useful for automation):
# SKIP_MINICONDA=1 SKIP_1PASSWORD=1 SKIP_ZEN=1 sudo -E ./setup.sh
[[ "${SKIP_MINICONDA:-0}" == "1" ]] && SKIP_MINICONDA=true
[[ "${SKIP_1PASSWORD:-0}" == "1" ]] && SKIP_1PASSWORD=true
[[ "${SKIP_ZEN:-0}" == "1" ]] && SKIP_ZEN=true
# If not forced via env, ask interactively.
if [[ "${SKIP_MINICONDA:-0}" != "1" ]] && ! confirm "Install Miniconda?" true; then
SKIP_MINICONDA=true
fi
if [[ "${SKIP_1PASSWORD:-0}" != "1" ]] && ! confirm "Install 1Password (desktop)?" true; then
SKIP_1PASSWORD=true
fi
if [[ "${SKIP_ZEN:-0}" != "1" ]] && ! confirm "Install Zen Browser?" true; then
SKIP_ZEN=true
fi
# --- base packages ------------------------------------------------------------
apt -qq update
apt -qq install -y curl wget git zsh ca-certificates gnupg lsb-release
# oh-my-zsh setup
[[ -d $HOME/.oh-my-zsh ]] ||
CHSH=no RUNZSH=no KEEP_ZSHRC=yes \
bash <(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh) --unattended
# default shell
[[ $(getent passwd "$SUDO_USER" | cut -d: -f7) == "$(command -v zsh)" ]] ||
usermod -s "$(command -v zsh)" "$SUDO_USER"
# re-exec into zsh
[[ -n "${ZSH_VERSION:-}" ]] || exec zsh "$0" "$@"
# CLI tools
apt -qq install -y bat eza duf neovim unzip build-essential clang btop
# --- miniconda ---------------------------------------------------------------
if ! $SKIP_MINICONDA; then
if ! command -v conda &>/dev/null; then
wget -q https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p "$HOME/miniconda" && rm ~/miniconda.sh
grep -qF miniconda/etc/profile.d/conda.sh ~/.zshrc 2>/dev/null ||
echo '. "$HOME/miniconda/etc/profile.d/conda.sh"' >>~/.zshrc
# shellcheck disable=SC1091
source "$HOME/miniconda/etc/profile.d/conda.sh"
conda init -q zsh
fi
else
echo "Skipping Miniconda."
fi
# --- Docker ------------------------------------------------------------------
sudo apt update
sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# --- desktop extras -----------------------------------------------------------
command -v gnome-shell &>/dev/null || exit 0
# 1password
if ! $SKIP_1PASSWORD; then
if ! command -v 1password &>/dev/null; then
curl -sS https://downloads.1password.com/linux/keys/1password.asc |
gpg --dearmor | tee /usr/share/keyrings/1password-archive-keyring.gpg >/dev/null
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/1password-archive-keyring.gpg] https://downloads.1password.com/linux/debian/$(dpkg --print-architecture) stable main" \
>/etc/apt/sources.list.d/1password.list
apt -qq update && apt -qq install -y 1password
fi
else
echo "Skipping 1Password."
fi
# zen-browser
if ! $SKIP_ZEN; then
ZEN_DIR=$HOME/Applications/zen-browser
[[ -x $ZEN_DIR/zen-bin ]] || {
mkdir -p ~/Applications
wget -qO- https://github.com/zen-browser/desktop/releases/latest/download/zen.linux-x86_64.tar.xz |
tar -xJ -C ~/Applications
mv ~/Applications/zen.linux-x86_64 "$ZEN_DIR"
}
grep -qF 'alias zen=' ~/.zshrc 2>/dev/null ||
echo "alias zen='$ZEN_DIR/zen/zen-bin'" >>~/.zshrc
mkdir -p ~/.local/share/applications
cat >~/.local/share/applications/zen-browser.desktop <<EOF
[Desktop Entry]
Name=Zen Browser
Exec=$ZEN_DIR/zen-bin --no-sandbox %u
Icon=$ZEN_DIR/browser/chrome/icons/default/default128.png
Terminal=false
Type=Application
Categories=Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;
EOF
update-desktop-database ~/.local/share/applications &>/dev/null
else
echo "Skipping Zen Browser."
fi
# cursor cli
curl https://cursor.com/install -fsS | bash
grep -qF 'export PATH="$HOME/.local/bin:$PATH"' ~/.zshrc 2>/dev/null ||
echo 'export PATH="$HOME/.local/bin:$PATH"' >>~/.zshrc
# shellcheck disable=SC1090
source ~/.zshrc
echo "Done. Log out/in for the new shell to activate."