-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.sh
executable file
·238 lines (180 loc) · 6.82 KB
/
main.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
#!/bin/bash
set -e
##############################
# Options and Variables
##############################
source var.sh
##############################
# Declare functions
##############################
pre_install() {
echo -e "[START] Preprocessing\n" | tee -a "$log_file"
mkdir -p "$path_to_tools" "$HOME/.config"
echo -e "[DONE] Preprocessing\n" | tee -a "$log_file"
}
add_repos() {
echo -e "[START] Installing repositories\n" | tee -a "$log_file"
# Blackarch
echo -e "Adding Blackarch repository\n" | tee -a "$log_file"
curl -O https://blackarch.org/strap.sh
sudo chmod +x strap.sh
sudo ./strap.sh
rm strap.sh
sudo pacman -Syyu
sudo pacman -S --noconfirm blackman
echo -e "Finished adding Blacharch repository\n" | tee -a "$log_file"
# Archstrike
echo -e "Adding Archstrike repository\n" | tee -a "$log_file"
echo -e "\n[archstrike]\nServer = https://mirror.archstrike.org/\$arch/\$repo\n" | sudo tee -a /etc/pacman.conf
signature="9D5F1C051D146843CDA4858BDE64825E7CBC0D51"
#signature=$(curl -s 'https://archstrike.org/wiki/setup' | grep -oP 'pacman-key --lsign-key [A-Z0-9]+' | cut -d' ' -f3 | head -1)
sudo pacman-key --init
sudo dirmngr < /dev/null
wget https://archstrike.org/keyfile.asc
sudo pacman-key --add keyfile.asc
rm keyfile.asc
sudo pacman -Sy
sudo pacman-key --lsign-key "$signature"
sudo pacman -S archstrike-keyring archstrike-mirrorlist
sudo sed -i 's|Server = https://mirror.archstrike.org/$arch/$repo|Include = /etc/pacman.d/archstrike-mirrorlist|' /etc/pacman.conf
sudo pacman -Syy --noconfirm
echo -e "Finished adding Archstrike repository\n" | tee -a "$log_file"
echo -e "[DONE] Installing repositories\n" | tee -a "$log_file"
}
install_pkg_min() {
echo -e "[START] Installing minimal packages\n" | tee -a "$log_file"
sudo pacman -S --needed - < "$path_to_pkgs/pacman-min" || exit 1
echo -e "[DONE] Installing minimal packages \n" | tee -a "$log_file"
}
dotfiles() {
echo -e "[START] Installing dot files\n" | tee -a "$log_file"
[ -d "$path_to_dotfiles" ] || git clone --depth 1 --recurse-submodules "$url_to_dotfiles" "$path_to_dotfiles"
[ -d "$path_to_scripts" ] || git clone --depth 1 "$url_to_scripts" "$path_to_scripts"
for line in "$path_to_dotfiles"/home/.*; do
target="$(echo "$line" | cut -d/ -f 7)"
[ "$target" != "." ] && [ "$target" != ".." ] && ln -sf "$line" "$HOME/$target"
done || exit 1
for line in "$path_to_dotfiles"/config/*; do
target="$(echo "$line" | cut -d/ -f 7)"
ln -sf "$line" "$HOME/.config/$target"
done || exit 1
echo -e "[DONE] Installing dot files\n" | tee -a "$log_file"
}
install_pkg() {
echo -e "[START] Installing with standard package manager\n" | tee -a "$log_file"
files=("$path_to_pkgs/pacman")
systemd-detect-virt -q && files+=("$path_to_pkgs/pacman-guest") || files+=("$path_to_pkgs/pacman-host")
cat "${files[@]}" | sudo pacman -S --needed --disable-download-timeout - || exit 1
echo -e "[DONE] Installing with standard package manager\n" | tee -a "$log_file"
}
install_aur() {
echo -e "[START] Installing stuff from the AUR\n" | tee -a "$log_file"
files=("$path_to_pkgs/aur")
systemd-detect-virt -q || files+=("$path_to_pkgs/aur-host")
readarray -t pkgs <<< "$(cat "${files[@]}")"
yay -Sa --needed "${pkgs[@]}" || exit 1
echo -e "[DONE] Installing stuff from the AUR\n" | tee -a "$log_file"
}
install_pip() {
echo -e "[START] Installing python modules\n" | tee -a "$log_file"
while read -r line; do
python3 -m pipx install "$line"
done < "$path_to_pkgs/pipx"
echo -e "[DONE] Installing python modules\n" | tee -a "$log_file"
}
install_npm() {
echo -e "[START] Installing npm tools\n" | tee -a "$log_file"
# Setup npm to be used without sudo
npm config set prefix ~/.npm
export PATH="$PATH:$HOME/.npm/bin"
xargs npm install -g < "$path_to_pkgs/npm" || exit 1
echo -e "[DONE] Installing npm tools\n" | tee -a "$log_file"
}
install_rust() {
echo -e "[START] Installing rust tools\n" | tee -a "$log_file"
rustup default stable
# Rust Language Server
rustup component add clippy rust-analysis rust-analyzer rust-docs rust-src rustfmt
cargo install cargo-audit --features=fix
cargo install cargo-update
xargs cargo install < "$path_to_pkgs/rust"
echo -e "[DONE] Installing rust tools\n" | tee -a "$log_file"
}
install_go() {
echo -e "[START] Installing go tools\n" | tee -a "$log_file"
go env -w GO111MODULE=on
xargs -I pkg go install "pkg" < "$path_to_pkgs/go"
echo -e "[DONE] Installing go tools\n" | tee -a "$log_file"
}
setup() {
echo -e "[START] Setting up tools\n" | tee -a "$log_file"
# Loop through /setup and run every script
for dir in ./setup/*; do
cd "$dir"
bash setup.sh
cd "$path_current"
done || exit 1
echo -e "[DONE] Setting up tools\n" | tee -a "$log_file"
}
misc() {
if [ "$(systemd-detect-virt -q)" ]; then
sudo cp ./misc/powertop.service /etc/systemd/system/
sudo cp ./misc/audio_powersave.conf /etc/modprobe.d/
sudo cp ./misc/logind.conf /etc/systemd/
# touchpad stuff
sudo cp ./misc/30-touchpad.conf /etc/X11/xorg.conf.d/
# allow acpilight's xbacklight to control brightness without sudo
sudo cp ./misc/backlight.rules /etc/udev/rules.d/
sudo cp /usr/share/ddcutil/data/90-nvidia-i2c.conf /etc/X11/xorg.conf.d/
sudo cp /usr/share/ddcutil/data/45-ddcutil-i2c.rules /usr/share/ddcutil/data/45-ddcutil-usb.rules
# allow ddcutil to control brightness without sudo
sudo cp ./misc/i2c-dev.conf /etc/modules-load.d/i2c-dev.conf
sudo usermod -aG i2c video "$USER"
fi
}
post_install() {
echo -e "[START] Post-installtion\n" | tee -a "$log_file"
# create some directories
mkdir -p \
~/{Desktop,Downloads,Videos} \
~/torrents/{downloads,incomplete,seeds,torrents} \
~/Pictures/screenshots
echo "updatedb"
sudo updatedb
sudo systemctl enable apparmor
sudo systemctl enable archlinux-keyring-wkd-sync.timer
sudo systemctl enable bluetooth
sudo systemctl enable cronie
sudo systemctl enable NetworkManager
sudo systemctl disable NetworkManager-wait-online.service
systemctl --user enable pueued.service
systemctl --user enable pipewire-pulse
systemctl --user enable wireplumber
#sudo systemctl enable powertop.service
if [ "$(systemd-detect-virt -q)" ]; then
sudo systemctl enable auto-cpufreq
sudo systemctl enable syslog-ng@default
systemctl enable --user mpd
fi
sudo usermod -aG audit,mount,network,video "$USER"
[ "$SHELL" = "/usr/bin/zsh" ] || chsh -s "$(which zsh)"
echo -e "[DONE] Post-installtion\n" | tee -a "$log_file"
}
##############################
# main() - Run all the stuff
##############################
echo -e "Running install and setup\n"
#pre_install
#add_repos
#install_pkg_min
#dotfiles
#install_pkg
#install_aur
#install_pip
#install_npm
#install_rust
#install_go
#setup
#misc
#post_install
echo -e "Done with everything!\n"