-
Notifications
You must be signed in to change notification settings - Fork 7
/
install.sh
281 lines (234 loc) · 8.58 KB
/
install.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
#!/bin/bash
# =======================================
# Script setup
# =======================================
set -e
set -o pipefail
# =======================================
# Helper functions
# =======================================
# Ask a question and return true or false based on the users input
ask() {
# from https://djm.me/ask
local prompt default reply
while true; do
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
default=Y
elif [ "${2:-}" = "N" ]; then
prompt="y/N"
default=N
else
prompt="y/n"
default=
fi
echo -n "$1 [$prompt] "
read -r reply </dev/tty
if [ -z "$reply" ]; then
reply=$default
fi
case "$reply" in
[Yy]*) return 0 ;;
[Nn]*) return 1 ;;
esac
done
}
# delete target, create dirs if they don't exist yet and finally symlink the dir
function linkDir {
rm -rf "$2"
mkdir -p "${2%/*}"
ln -sf "$1" "$2"
}
# replace line endings with a space (for use in package managers)
function fileToList {
echo $(cat "$1" | sed '/^\s*#\([^!]\|$\)/d' | tr +'\n' ' ' | tr -s ' ')
}
# create and copy files to directory
function copyToDir {
echo "$2" | sed 's%/[^/]*$%/%' | xargs mkdir -p
cp "$1" "$2"
}
# =======================================
# Installation functions
# =======================================
# moves all fonts into the fonts directories (overwriting existing files)
function install_fonts {
mkdir -p ~/.fonts
mkdir -p ~/.local/share/fonts
mkdir -p /usr/local/share/fonts
cp -rf ./fonts/* ~/.fonts
cp -rf ./fonts/* ~/.local/share/fonts
cp -rf ./fonts/* /usr/local/share/fonts
}
# install trizen, a aur helper
function install_trizen {
git clone https://aur.archlinux.org/trizen.git
pushd trizen || return
makepkg -si
popd || return
sudo rm -dRf trizen/
}
# Sets up time and date related stuff
function setDateTimeConfig {
systemctl enable ntpd
timedatectl set-ntp true
sudo ln -sf "$PWD"/config/networkmanager/09-timezone /etc/NetworkManager/dispatcher.d/09-timezone
}
function install_gtk {
mkdir -p "$HOME/.config/gtk-3.0"
mkdir -p "$HOME/.config/gtk-4.0"
ln -sf "$PWD"/config/gtk/settings.ini ~/.gtkrc-2.0.mine
ln -sf "$PWD"/config/gtk/settings.ini ~/.config/gtk-3.0/settings.ini
ln -sf "$PWD"/config/gtk/settings.ini ~/.config/gtk-4.0/settings.ini
}
# install other configs
function install_config {
install_gtk
# link directories
linkDir "$PWD"/wallpapers/images ~/Pictures/wallpapers
linkDir "$PWD"/i3 ~/.config/i3
linkDir "$PWD"/config/notify-osd/notify-osd ~/.notify-osd
linkDir "$PWD"/config/terminal/xfce4-term ~/.config/xfce4/terminal
linkDir "$PWD"/config/polybar ~/.config/polybar
linkDir "$PWD"/config/poshthemes ~/.config/poshthemes
linkDir "$PWD"/config/xfce4 ~/.config/xfce4/xfconf/xfce-perchannel-xml
linkdir "$PWD"/config/rofi ~/.config/rofi
# link user files
ln -sf "$PWD"/bash/.aliases ~/
ln -sf "$PWD"/bash/.bashrc ~/.bashrc
ln -sf "$PWD"/bash/.dotnet-install.sh ~/.dotnet-install.sh
ln -sf "$PWD"/bash/.alias.sh ~/.alias
ln -sf "$PWD"/config/nano/.nanorc ~/.nanorc
ln -sf "$PWD"/bash/.powerline-shell.json ~/.powerline-shell.json
ln -sf "$PWD"/config/mimeapps.list ~/.config/mimeapps.list
ln -sf "$PWD"/config/greenclip.toml ~/.config/greenclip.toml
ln -sf "$PWD"/config/terminalrc ~/.config/xfce4/terminal/terminalrc
mkdir -p ~/.config/Code/User/globalStorage/zokugun.sync-settings
ln -sf "$PWD"/config/git/settings.yml ~/.config/Code/User/globalStorage/zokugun.sync-settings/settings.yml
ln -sf "$PWD"/config/.gitconfig ~/.gitconfig
ln -sf "$PWD"/config/.npmrc ~/.npmrc
ln -sf "$PWD"/config/user-dirs.dirs ~/.config/user-dirs.dirs
mkdir -p ~/.pulse
ln -sf "$PWD"/config/pulse/daemon.conf ~/.pulse/daemon.conf
ln -sf "$PWD"/config/picom.conf ~/.config/picom.conf
# link autorandr files
mkdir -p "$HOME/.config/autorandr"
ln -sf "$PWD"/config/autorandr/postswitch ~/.config/autorandr/postswitch
# link system files / directories
sudo ln -sf "$PWD"/config/package-managers/pacman.conf /etc/pacman.conf
sudo ln -sf "$PWD"/config/package-managers/makepkg.conf /etc/makepkg.conf
sudo ln -sf "$PWD"/config/ntp.conf /etc/ntp.conf
sudo ln -sf "$PWD"/bash/Completion/ /etc/bash_completion.d
sudo ln -sf "$PWD"/config/environment /etc/environment
sudo ln -sf "$PWD"/config/.bash_profile ~/.bash_profile
# create empty .custom alias file
echo "" >~/.custom
echo "" >~/.variables
# files to be copied once
mkdir -p "$HOME/.config/Code/User"
cp "$PWD"/config/code/syncLocalSettings.json ~/.config/Code/User/
# system fixes
echo fs.inotify.max_user_watches=524288 | sudo tee /etc/sysctl.d/40-max-user-watches.conf && sudo sysctl --system
mkdir -p ~/Pictures/Screenshots
setDateTimeConfig
}
# Installs the dependencies on Arch Linux
function install_dependencies {
fileToList dependencies/pacman.txt | xargs sudo pacman --noconfirm -S
install_trizen
fileToList dependencies/aur.txt | xargs trizen -S --noconfirm
fileToList dependencies/npm.txt | xargs sudo npm install -g
}
# set up a new ssh key
function create_ssh_key {
ssh-keygen -t ed25519 -C "[email protected]"
eval "$(ssh-agent -s)"
}
# =======================================
# User output functions
# =======================================
# Run the intro bit
function intro {
echo "___ ___ _ _ _ _ _ "
echo "| \/ | | | (_) | | | | ( )"
echo "| . . | __ _ ___| |_ ___ _ __ _ __ ___ _ _ __ __| |___| |__ |/ "
echo "| |\/| |/ _\` / __| __/ _ \ '__| '_ \` _ \| | '_ \ / _' |_ / '_ \ "
echo "| | | | (_| \__ \ || __/ | | | | | | | | | | | (_| |/ /| | | | "
echo "\_| |_/\__,_|___/\__\___|_| |_| |_| |_|_|_| |_|\__,_/___|_| |_| "
echo " "
echo " "
echo " __ _ _ "
echo " / _(_) ___ (_) "
echo " ___ ___ _ __ | |_ _ __ _ ( _ ) _ __ _ ___ ___ "
echo " / __/ _ \| '_ \| _| |/ _\` | / _ \/\ | '__| |/ __/ _ \ "
echo "| (_| (_) | | | | | | | (_| | | (_> < | | | | (_| __/ "
echo " \___\___/|_| |_|_| |_|\__, | \___/\/ |_| |_|\___\___| "
echo " __/ | "
echo " |___/ "
echo ""
}
function computer {
echo " /\ "
echo " / \ "
echo " /_ %%==O=% _____________ "
echo " % - -% | '\\\\\\\\\\"
echo " _____c% > __ | ' ____|_ "
echo " (_|. . % \` % .' | + '||:::::: "
echo " ||. ___)%%%%_.' | '||_____| "
echo " ||.( \ ~ / ,)' \'_______|_____| "
echo " || /| \'/ |\ ___/____|___\___ "
echo " _,,,;!___*_____\_| _ ' <<<:| "
echo " / /| |_________'___o_o| "
echo " /_____/ / "
echo " |:____|/ \"Boy, I LOVE this stuff\". "
echo ""
echo ""
}
# =======================================
# Main loop
# =======================================
clear
# Run the intro function
intro
ask "Do you want to continue installing my config and rice?" Y &&
# Ask for dependency installation
if ask "Do you want to install the applications listen in ./dependencies? (might prompt for password)" Y; then
install_dependencies
fi
# Ask for SSH generation
if ask "Do you want to generate a new SSH key?" Y; then
create_ssh_key
fi
# Ask for config installation
if ask "Do you want to install the config files?" Y; then
install_config
fi
# Ask for font installation
if ask "Do you want to install the fonts?" Y; then
install_fonts
fi
# ask to enable the display manager
if ask "Do you want to enable sddm?" Y; then
sudo systemctl set-default graphical.target
sudo systemctl enable sddm.service
sudo mkdir -p "/etc/sddm.conf.d/"
curl "http://gravatar.com/avatar/$(echo -n "[email protected]" | md5sum - | cut -d' ' -f1)?s=1024" | sudo tee /usr/share/sddm/faces/mastermindzh.face.icon >/dev/null
sudo ln -sf "$PWD"/config/sddm/default.conf /etc/sddm.conf.d/
fi
clear
computer
# ask for pc specific install
prompt=$(echo $'\n> ' "Please select a specific computer to install or q to finish the install")
PS3="$prompt: "
select opt in "$PWD/computers"/*; do
if ((REPLY == "q")); then
break
elif ((REPLY > 0)); then
bash "$opt/install.sh"
break
else
echo "Invalid option. Try another one."
fi
done
clear
echo "Enjoy using my rice! Do not forget to select i3 in sddm :)"