-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
executable file
·281 lines (239 loc) · 11.1 KB
/
setup.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
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
#!/usr/bin/env bash
# just a quick script to install some reqs for onboardme
# works on Debian (Bookworm) based distros and macOS (13.0.1 and later)
# Checks for: brew, git, and python3.12
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~ LinuxBrew PATH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
if [[ $(uname) == *"Linux"* ]]; then
export XDG_DATA_HOME="$HOME/.local"
# iptables on debian is here
export PATH=$PATH:/usr/sbin:/usr/share
# pip packages with command line tools install here by default with apt installed python
export PATH=$PATH:$XDG_DATA_HOME/bin
# this relative is used for both macOS and Debian based distros
pip_path_suffix="lib/python$PYTHON_VERSION/site-packages"
# apt installed location of pip installed python3.x packages
pip_packages="$HOME/.local/$pip_path_suffix"
# not working in debian via onboardme :( not sure why
# export PYTHONUSERBASE=$XDG_DATA_HOME
# make python do it's cache in ~/.cache/python
export PYTHONPYCACHEPREFIX=$XDG_CACHE_HOME
fi
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ macOS PATH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
# powerline - a fancy extensible prompt: https://powerline.readthedocs.io
if [[ $(uname) == *"Darwin"* ]]; then
# make python do it's cache in ~/.cache/python
export PYTHONPYCACHEPREFIX=$XDG_CACHE_HOME/python
# put python data into $HOME/.local/share/python
export PYTHONUSERBASE=$XDG_DATA_HOME/python
echo 'export XDG_DATA_HOME="$HOME/.local/share"' >> ~/.bash_profile
echo 'export PYTHONUSERBASE=$XDG_DATA_HOME/python' >> ~/.bash_profile
pip_packages="$XDG_DATA_HOME/python/lib/python/site-packages"
# this is for python XDG spec stuff
export PATH="$PYTHONUSERBASE/bin:$PATH"
echo 'export PATH="$PYTHONUSERBASE/bin:$PATH"' >> ~/.bash_profile
if [ $(uname -a | grep arm > /dev/null ; echo $?) -eq 0 ]; then
# On apple silicon: brew default installs here
export PATH=/opt/homebrew/bin:$PATH
echo 'export PATH=/opt/homebrew/bin:$PATH' >> ~/.bash_profile
fi
fi
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Python ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# python default install location when you: pip$VERSION install --user package
export PATH=$PATH:$HOME/.local/bin:/usr/local/bin
# Run py cmds in this file b4 the 1st prompt is displayed in interactive mode
export PYTHONSTARTUP=$XDG_CONFIG_HOME/python/interactive_startup.py
# extremely simply loading bar
function simple_loading_bar() {
echo ""
echo " "
for i in $(seq 1 $1); do
echo -n "❤︎ ";
sleep 1
done
echo ""
}
OS=$(uname)
echo -e "-------------------------------- \033[94m 🛋️ Comfy Warning \033[00m -------------------------------"
echo "Before we begin, please make sure you're on a wired connection, or sitclose to the wifi. This "
echo "might take a while if you're a fresh OS install and you'll need to present to enter your password "
echo "for package installs, so grab some tea and get comfy :3"
printf "\nHere's some relaxing music: https://youtu.be/-5KAN9_CzSA"
while true; do
printf "\n\n"
read -p "Are you ready to get started? Do you have a nice cup of ☕? [y/n] " answer
if [ "$answer" != "y" ]; then
printf "\nThat's totally reasonable. You take your time, and I will be here."
simple_loading_bar 5
else
break
fi
done
echo -e "\n-------------------------------- \033[94m 🎬 Beginning Setup \033[00m -------------------------------"
echo ""
if [[ "$OS" == *"Linux"* ]]; then
echo -e "---------------------------- \033[94m Updating existing apt packages \033[00m --------------------"
DEBIAN_FRONTEND=noninteractive sudo echo "deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb-src http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb http://deb.debian.org/debian-security/ bookworm-security main contrib non-free
deb-src http://deb.debian.org/debian-security/ bookworm-security main contrib non-free
deb http://deb.debian.org/debian bookworm-updates main contrib non-free
deb-src http://deb.debian.org/debian bookworm-updates main contrib non-free
deb http://deb.debian.org/debian bookworm-backports main
deb http://deb.debian.org/debian bullseye-backports main" > /etc/apt/sources.list;
sudo apt-get update; sudo apt-get -y upgrade; sudo apt-get -y full-upgrade
echo -e "\033[92m apt updated/upgraded :3 \033[00m"
fi
# git should be default installed on macOS Monterey :shrug:
echo -e "-------------------------------- \033[94m Checking for Git \033[00m ------------------------------"
which git > /dev/null
git_return_code=$?
if [ $git_return_code -eq 0 ]; then
echo -e "\033[92mGit already installed :3 \033[00m"
else
echo "Git not installed or in path, attempting to install git..."
# we use *"linux"* because linux2 is a possibility, and who knows what else
if [[ "$OS" == "Linux"* ]]; then
DEBIAN_FRONTEND=noninteractive sudo apt-get install -y git
git_return_code=$?
if [ $git_return_code -ne 0 ]; then
echo "Git didn't install. This may be because you don't have main branch"
echo "software enabled on Debian. You can enable that via the GUI under:"
echo "Software & Updates (Software-properties-gtk) > Debian Software"
exit
fi
fi
# wait.... how can this work if brew doesn't work yet.... 🤔
if [ "$OS" == "Darwin" ]; then
echo "running: brew install git"
brew install git
fi
echo -e "\033[92mGit Installed :3 \033[00m"
fi
echo "running: git config --global init.defaultBranch main"
git config --global init.defaultBranch main
# Make sure xcode is present on macOS, since it needs to be
# re-installed when upgrading from 12.x -> 13.x
if [ "$OS" == "Darwin" ]; then
echo -e "-------------------------------- \033[94m Ensuring Xcode is present \033[00m ------------------------------"
echo "running: xcode-select --install"
xcode-select --install
fi
echo -e "------------------------------- \033[94m Checking for Brew \033[00m ------------------------------\n"
echo "Doing some linux brew path/env checking..."
# source the existing bashrc, just in case
if [ -f "~/.bashrc" ]; then
. ~/.bashrc
elif [ -f "~/.bash_profile" ]; then
. ~/.bash_profile
fi
env | grep -i "brew"
brew_return_code=$?
# if this still isn't in our path, export it and source this bashrc
if [ $brew_return_code -ne 0 ]; then
if [[ "$OS" == *"Linux"* ]]; then
# HomeBrew on Linux needs all of this to work
export HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew
export HOMEBREW_CELLAR=/home/linuxbrew/.linuxbrew/Cellar
export HOMEBREW_REPOSITORY=/home/linuxbrew/.linuxbrew/Homebrew
export MANPATH=$MANPATH:/home/linuxbrew/.linuxbrew/share/man
export INFOPATH=$INFOPATH:/home/linuxbrew/.linuxbrew/share/info
export PATH=$PATH:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin
echo "Linuxbrew isn't in your path. Let's get that installed :)"
# make sure this is all in the bashrc for new shells
echo "export HOMEBREW_PREFIX=/home/linuxbrew/.linuxbrew" >> ~/.bashrc
echo "export HOMEBREW_CELLAR=/home/linuxbrew/.linuxbrew/Cellar" >> ~/.bashrc
echo "export HOMEBREW_REPOSITORY=/home/linuxbrew/.linuxbrew/Homebrew" >> ~/.bashrc
echo "export MANPATH=$MANPATH:/home/linuxbrew/.linuxbrew/share/man" >> ~/.bashrc
echo "export INFOPATH=$INFOPATH:/home/linuxbrew/.linuxbrew/share/info" >> ~/.bashrc
echo "PATH=$PATH:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> ~/.bashrc
# source the bashrc, for this shell
. ~/.bashrc
else
# check if this an M1 mac or not
uname -a | grep arm > /dev/null
M1=$?
if [ $M1 -eq 0 ]; then
# for the M1/M2 brew default installs here
echo "PATH=/opt/homebrew/bin:$PATH" >> ~/.bash_profile
fi
# source the bashrc, for this shell
. ~/.bash_profile
fi
fi
which brew > /dev/null
brew_return_code=$?
if [ $brew_return_code -ne 0 ]; then
echo "Installing brew really quick, this will require your credentials for sudo abilities..."
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo -e "\033[92mBrew installed :3 \033[00m"
else
echo -e "\033[92mBrew already installed :3 \033[00m"
fi
echo -e "--------------------------\033[94m Checking for Python3 and pip3\033[00m -------------------------"
if [[ "$OS" == *"Linux"* ]]; then
echo ""
echo "We will remove /usr/lib/python3.*/EXTERNALLY-MANAGED until Debian Bookworm decides on a better way forward with virtual envs."
echo "See: https://salsa.debian.org/cpython-team/python3/-/blob/master/debian/README.venv"
if [ -e /usr/lib/python3.*/EXTERNALLY-MANAGED ]; then
sudo rm /usr/lib/python3.*/EXTERNALLY-MANAGED
fi
fi
# check to make sure we have python3 and pip3 installed
which python3.12 > /dev/null
py_return_code=$?
if [ $py_return_code -ne 0 ]; then
if [ "$OS" == "Darwin" ]; then
echo "Installing Python3.12 via brew..."
brew install python@3.12
echo -e "\033[92mPython3.12 installed :3 \033[00m"
else
echo "Installing Python3.12 via apt..."
DEBIAN_FRONTEND=noninteractive && \
sudo apt-get install -y software-properties-common && \
sudo add-apt-repository -y ppa:deadsnakes/ppa && \
sudo apt install -y python3.12 && \
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12
echo 'export PATH="$PATH:$HOME/.local/bin/"' >> ~/.bashrc
. ~/.bashrc
echo -e "\033[92mPython3.12 installed :3 \033[00m"
fi
else
echo -e "\033[92mPython3.12 already installed :3 \033[00m"
which pip3.12 > /dev/null
pip_return_code=$?
if [ $pip_return_code -ne 0 ]; then
echo -e "\033[92mInstalling pip via apt... \033[00m"
DEBIAN_FRONTEND=noninteractive && \
sudo apt-get update && \
sudo apt-get install -y python3-pip python3-venv && \
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.12
echo 'export PATH="$PATH:$HOME/.local/bin/"' >> ~/.bashrc
. ~/.bashrc
echo -e "\033[92mPip3.12 installed :3 \033[00m"
fi
fi
echo -e "--------------------------\033[94m Installing OnBoardMe :D \033[00m -------------------------"
pip3.12 install --break-system-packages --upgrade --user pipx
pipx install onboardme
pipx_install_return_code=$?
if [ $pipx_install_return_code -ne 0 ]; then
echo "Something went wrong with the installation of onboardme. :("
else
echo ""
echo -e "------------------------------ \033[92mSuccess~! ^O^\033[00m -----------------------------------"
echo ""
# source the existing bashrc, just in case
if [[ "$OS" == *"Linux"* ]]; then
echo -e "Please run:\033[92m source ~/.bashrc \033[00m"
else
echo -e "Please run:\033[92m source ~/.bash_profile \033[00m"
fi
echo ""
echo -e "✨ Then you can try running the following:"
echo "onboardme --help"
echo ""
fi