-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-linux.sh
More file actions
executable file
·308 lines (263 loc) · 9.1 KB
/
Copy pathsetup-linux.sh
File metadata and controls
executable file
·308 lines (263 loc) · 9.1 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
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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
#!/bin/bash
install_neovim_latest() {
echo -e "\033[36mInstalling Neovim .....\033[0m"
. /etc/os-release
case $ID in
debian|ubuntu)
REQUIRED_PKG="curl"
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $REQUIRED_PKG|grep "install ok installed")
echo Checking for $REQUIRED_PKG: $PKG_OK
if [ "" = "$PKG_OK" ]; then
echo "No $REQUIRED_PKG. Setting up $REQUIRED_PKG."
apt-get install $REQUIRED_PKG -y
fi
curl -f https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.tar.gz | sudo tar -xzvf - --strip-components=1 --overwrite -C /usr
;;
fedora)
dnf install neovim -y
;;
arch)
pacman -Sy --noconfirm --needed neovim
;;
*) echo "This is an unknown distribution."
;;
esac
}
install_fish_latest() {
. /etc/os-release
echo -e "\033[36mInstalling Fish .....\033[0m"
case $ID in
debian)
echo -e "\033[36mDebian \033[0m"
REQUIRED_PKG="wget curl gpg" # This breaks if any pkg is present
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $REQUIRED_PKG|grep "install ok installed")
echo Checking for $REQUIRED_PKG: $PKG_OK
if [ "" = "$PKG_OK" ]; then
echo "No $REQUIRED_PKG. Setting up $REQUIRED_PKG."
apt-get update
apt-get install $REQUIRED_PKG -y
fi
if [ -z "$VERSION_ID" ]; then VERSION_ID="Unstable"; fi
echo "deb http://download.opensuse.org/repositories/shells:/fish:/release:/4/Debian_$VERSION_ID/ /" | tee /etc/apt/sources.list.d/shells:fish:release:4.list
curl -fsSL https://download.opensuse.org/repositories/shells:fish:release:4/Debian_"$VERSION_ID"/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/shells_fish_release_4.gpg > /dev/null
apt-get update
apt-get install fish -y
# rm -f fish.deb
;;
ubuntu)
echo -e "\033[36mUbuntu \033[0m"
apt-get update
echo -e "\033[36mInstalling fish shell.....\033[0m"
add-apt-repository ppa:fish-shell/release-4
apt-get update
apt-get install fish -y
;;
fedora)
echo -e "\033[36mFedora \033[0m"
dnf install fish -y
;;
arch)
echo -e "\033[36mArch \033[0m"
pacman -Sy --noconfirm --needed fish
;;
*) echo " This is an unknown distribution ."
return 2
;;
esac
usermod -s /usr/bin/fish "$USERNAME"
}
install_kitty() {
. /etc/os-release
echo -e "\033[36mInstalling Kitty .....\033[0m"
case $ID in
# debian)
# echo -e "\033[36mDebian \033[0m"
# REQUIRED_PKG="wget curl gpg" # This breaks if any pkg is present
# PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $REQUIRED_PKG|grep "install ok installed")
# echo Checking for $REQUIRED_PKG: $PKG_OK
# if [ "" = "$PKG_OK" ]; then
# echo "No $REQUIRED_PKG. Setting up $REQUIRED_PKG."
# apt-get update
# apt-get install $REQUIRED_PKG -y
# fi
# if [ -z "$VERSION_ID" ]; then VERSION_ID="Unstable"; fi
# echo "deb http://download.opensuse.org/repositories/shells:/fish:/release:/4/Debian_$VERSION_ID/ /" | tee /etc/apt/sources.list.d/shells:fish:release:4.list
# curl -fsSL https://download.opensuse.org/repositories/shells:fish:release:4/Debian_"$VERSION_ID"/Release.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/shells_fish_release_4.gpg > /dev/null
# apt-get update
# apt-get install fish -y
# # rm -f fish.deb
# ;;
# ubuntu)
# echo -e "\033[36mUbuntu \033[0m"
# apt-get update
# echo -e "\033[36mInstalling fish shell.....\033[0m"
# add-apt-repository ppa:fish-shell/release-4
# apt-get update
# apt-get install fish -y
# ;;
fedora)
echo -e "\033[36mFedora \033[0m"
dnf install kitty -y
;;
arch)
echo -e "\033[36mArch \033[0m"
pacman -Sy --noconfirm --needed kitty wget unzip curl
;;
*) echo " This is an unknown distribution ."
return 2
;;
esac
wget https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/SourceCodePro.zip
unzip SourceCodePro.zip -d SourceCodePro
mkdir -p /home/$USERNAME/.local/share/fonts
mv SourceCodePro/*.ttf /home/$USERNAME/.local/share/fonts
chown -R $USERNAME:$USERNAME /home/$USERNAME/.local
su -c "fc-cache -fv" powder
rm -rf SourceCodePro SourceCodePro.zip
}
setup_docker() {
echo -e "\033[36mInstalling Docker .....\033[0m"
curl -fsSL https://get.docker.com | sh
if [[ -n $USERNAME ]]; then
usermod -aG docker $USERNAME
echo -e "\033[36m$USERNAME added to docker group\033[0m"
fi
echo -e "\033[36mDocker Installed .....\033[0m"
}
setup_user() {
echo "Setting User ..."
. /etc/os-release
case $ID in
debian|ubuntu)
echo -e "\033[36mDebian | Ubuntu \033[0m"
REQUIRED_PKG="sudo"
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' $REQUIRED_PKG|grep "install ok installed")
echo Checking for $REQUIRED_PKG: $PKG_OK
if [ "" = "$PKG_OK" ]; then
echo "No $REQUIRED_PKG. Setting up $REQUIRED_PKG."
apt-get update
apt-get install $REQUIRED_PKG -y
fi
;;
fedora)
echo -e "\033[36mFedora \033[0m"
dnf install sudo -y
;;
arch)
echo -e "\033[36mArch \033[0m"
pacman -Sy --noconfirm --needed sudo
;;
*) echo " This is an unknown distribution ."
return 2
;;
esac
echo "Enter Username"
read -r USERNAME
if [[ -z "$USERNAME" ]]; then echo "\033[31mUSERNAME not set.....\033[0m"; return; fi
home_dir="/home/$USERNAME"
home_config="$home_dir/.config"
fish_config_dir="$home_config/fish"
kitty_config_dir="$home_config/kitty/"
sugroup=$(getent group | grep -E "(wheel|sudo)" | head -n1 | cut -d: -f1)
case $sugroup in
sudo)
useradd -m $USERNAME -G sudo
;;
wheel)
useradd -m $USERNAME -G wheel
;;
*)
echo "sudo is not ready"
return 2
;;
esac
if [[ -d /root/.ssh ]]; then
cp -r /root/.ssh /home/$USERNAME/.ssh
chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh
fi
curl -sS https://starship.rs/install.sh | sh -s -- --yes
mkdir -p "$fish_config_dir"
mkdir -p "$kitty_config_dir"
cp /root/config.fish "$fish_config_dir"/config.fish
cp /root/kitty.conf "$kitty_config_dir"/kitty.conf
chown -R "$USERNAME":"$USERNAME" "/home/$USERNAME/"
starship preset jetpack -o /home/"$USERNAME"/.config/starship.toml
echo -e "\033[36mUser Created. SSH keys copied. Excecute passwd $USERNAME to setup password\033[0m"
}
setup_wrapper() {
echo -e "\033[33mSetup User ? (y/n).....\033[0m"
read -r choice
case $choice in
y|Y|yes|YES)
setup_user
;;
n|N|no|NO) echo "Skipped..."
;;
*) echo "Invalid input"
;;
esac
echo -e "\033[33mInstall fish ? (y/n)?\033[0m"
read -r choice
case $choice in
y|Y|yes|YES)
install_fish_latest
echo -e "\033[32mFish installed.....\033[0m"
;;
n|N|no|NO) echo "Skipped fish..."
;;
*) echo "Invalid input"
;;
esac
echo -e "\033[33mInstall neovim ? (y/n)?\033[0m"
read -r choice
case $choice in
y|Y|yes|YES)
install_neovim_latest
echo -e "\033[32mNeovim installed.....\033[0m"
;;
n|N|no|NO) echo "Skipped neovim..."
;;
*) echo "Invalid input"
;;
esac
echo -e "\033[33mInstall Kitty ? (y/n)?\033[0m"
read -r choice
case $choice in
y|Y|yes|YES)
install_kitty
echo -e "\033[32mKitty installed.....\033[0m"
;;
n|N|no|NO) echo "Skipped Kitty..."
;;
*) echo "Invalid input"
return 3
;;
esac
echo -e "\033[33mSetup Docker ? (y/n).....\033[0m"
read -r choice
case $choice in
y|Y|yes|YES)
setup_docker
;;
n|N|no|NO) echo "Skipped..."
;;
*) echo "Invalid input"
;;
esac
}
main() {
echo "Check root..."
if [ "$EUID" -ne 0 ]; then
echo "Error: please run with sudo"
exit 1
fi
if [ -n "$SUDO_USER" ]; then
echo "Sudo'd by: $SUDO_USER"
else
echo "Running as root directly"
fi
echo "Running as root "
setup_wrapper
echo -e "\033[32mCompleted\033[0m"
}
main "$@"