-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·211 lines (190 loc) · 5.19 KB
/
install.sh
File metadata and controls
executable file
·211 lines (190 loc) · 5.19 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
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
#!/usr/bin/env bash
export EDITOR=vim
COLOR_RED="\033[0;31m"
COLOR_GREEN="\033[0;32m"
COLOR_YELLOW="\033[1;33m"
COLOR_BLUE="\033[0;34m"
COLOR_OFF="\033[0m"
check () {
message=$1
echo -e "${COLOR_YELLOW}? ${1}${COLOR_OFF}"
}
status () {
message=$1
echo -e "${COLOR_BLUE}> ${1}${COLOR_OFF}"
}
confirm () {
message=$1
echo -e "${COLOR_GREEN}+ ${1}${COLOR_OFF}"
}
fail () {
message=$1
echo -e "${COLOR_RED}X ${1} Aborting...${COLOR_OFF}"
exit 1
}
check "Setting up variables"
home=$(echo "$HOME" | sed 's:/*$::')
python_version="3.13"
export EDITOR=vim
export XDG_BIN_HOME="${XDG_BIN_HOME:-$home/.local/bin}"
export PATH="$XDG_BIN_HOME:$PATH"
confirm "Setup complete"
check "Checking if $USER has already been added to sudoers"
sudo grep $USER /etc/sudoers > /dev/null 2>&1
if (( $? ))
then
status "Making passwordless sudo"
echo "$USER ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/$USER > /dev/null
if (( $? ))
then
fail "Failed to configure sudo! Aborting..."
else
confirm "Added $USER to sudoers"
fi
else
confirm "$USER is already a sudoer"
fi
check "Checking if git is installed"
command -v uv > /dev/null 2>&1
if (( $? ))
then
status "Installing git"
if [[ "$OSTYPE" == "darwin"* ]]
then
sudo port -N install git
else
sudo apt install git
fi
if (( $? ))
then
fail "Failed to install git!"
else
confirm "Installed git"
fi
else
confirm "git is already installed"
fi
check "Checking if uv is installed"
command -v uv > /dev/null 2>&1
if (( $? ))
then
status "Installing uv"
if [[ "$OSTYPE" == "darwin"* ]]
then
sudo port -N install uv
else
curl -LsSf https://astral.sh/uv/install.sh | sh
fi
if (( $? ))
then
fail "Failed to install uv!"
else
confirm "Installed uv"
fi
source "$XDG_BIN_HOME/env"
else
confirm "uv is already installed."
fi
# I'm not sure that this is still needed. Need to check on a fresh Ubuntu install
# check "Checking if python3.12-venv is installed (needed by Mason FOR NOW)"
# apt -qq list python3.12-venv > /dev/null 2>&1
# if (( $? ))
# then
# status "Installing python3.12-venv"
# sudo apt install -y python3.12-venv
# if (( $? ))
# then
# fail "Failed to install python3.12-venv"
# else
# confirm "Installed python3.12-venv"
# fi
# else
# confirm "python3.12-venv is already installed"
# fi
check "Checking if python $python_version is installed"
uv python list | grep $python_version > /dev/null 2>&1
if (( $? ))
then
status "Installing python $python_version via uv"
uv python install $python_version
if (( $? ))
then
fail "Failed to install python $python_version!"
else
confirm "Installed python $python_version"
fi
else
confirm "python $python_version is already available through uv"
fi
status "Making parent directories for dot"
mkdir -p $home/src/dusktreader
check "Checking if dot is cloned to this machine yet"
if [[ ! -d "$home/src/dusktreader/dot" ]]
then
status "Cloning dot repository (via https)"
git -C $home/src/dusktreader clone https://github.com/dusktreader/dot.git
if (( $? ))
then
fail "Failed to clone dot repository!"
else
confirm "Cloned dot repository"
fi
status "Changing dot origin url to use ssh for future access"
git -C $home/src/dusktreader/dot remote set-url origin git@github.com:dusktreader/dot.git
if (( $? ))
then
fail "Failed to change origin to ssh url!"
else
confirm "Updated origin url"
fi
else
confirm "dot is already cloned on this machine"
check "Checking if dot repository needs to be updated"
git -C $home/src/dusktreader/dot fetch https://github.com/dusktreader/dot.git > /dev/null 2>&1
if (( $? ))
then
fail "Failed to fetch from origin!"
fi
local_ref=$(git -C $home/src/dusktreader/dot rev-parse HEAD)
remote_ref=$(git -C $home/src/dusktreader/dot rev-parse FETCH_HEAD 2>/dev/null)
if [[ -z "$remote_ref" ]]
then
confirm "dot repository has no upstream tracking branch, skipping pull"
elif [[ "$local_ref" != "$remote_ref" ]]
then
status "dot repository is behind upstream, pulling"
git -C $home/src/dusktreader/dot pull --ff-only https://github.com/dusktreader/dot.git
if (( $? ))
then
fail "Failed to pull dot repository! Resolve conflicts and re-run."
else
confirm "Pulled dot repository"
fi
else
confirm "dot repository is up to date"
fi
fi
check "Checking if dot is installed yet"
dot-version > /dev/null 2>&1
if (( $? ))
then
status "Installing dot via uv"
uv tool install $home/src/dusktreader/dot --force --python=$python_version --editable
if (( $? ))
then
fail "Failed to install dot!"
else
confirm "Installed dot"
fi
else
confirm "dot is already installed"
fi
status "Configuring dot"
dt configure --root=$home/src/dusktreader/dot ${DOT_FORCE:+--force}
if (( $? ))
then
fail "Failed to configure dot!"
else
confirm "Configured dot"
fi
confirm "Completed installation! To activate > source $home/.bashrc"