-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.sh
More file actions
201 lines (165 loc) · 7.17 KB
/
Config.sh
File metadata and controls
201 lines (165 loc) · 7.17 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
#/bin/sh
#script caught of the Github Liquorix-Package Repository and modified for my use
set -euo pipefail
log() {
local level=$1
local message=$2
echo ""
case "$level" in
INFO) printf "\033[32m[INFO ] %s\033[0m\n" "$message" ;; # green
WARN) printf "\033[33m[WARN ] %s\033[0m\n" "$message" ;; # yellow
ERROR) printf "\033[31m[ERROR] %s\033[0m\n" "$message" ;; # red
*) printf "[UNKNOWN] %s\n" "$message" ;;
esac
echo ""
}
if [ "$(id -u)" -ne 0 ]; then
log ERROR "You must run this script as root!"
exit 1
fi
if [ "$(uname -m)" != x86_64 ]; then
log ERROR "Architecture not supported"
exit 1
fi
export NEEDRESTART_SUSPEND="*" # suspend needrestart or it will restart services automatically
# Smash all possible distributions into one line
dists="$(
grep -P '^ID.*=' /etc/os-release | cut -f2 -d= | tr '\n' ' ' |
tr '[:upper:]' '[:lower:]' | tr -dc '[:lower:] [:space:]'
)"
# Append upstream distributions through package manager landmarks
command -v apt-get &>/dev/null && dists="$dists debian"
command -v pacman &>/dev/null && dists="$dists arch"
# Deduplicate and trim list of discovered distributions
dists=$(echo "$dists" | tr '[:space:]' '\n' | sort | uniq | xargs)
log INFO "Possible distributions: $dists"
case "$dists" in
*arch*)
repo_file='/etc/pacman.conf'
gpg_key1='9AE4078033F8024D'
gpg_key='3056513887B78AEB'
chk='https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst'
chm='https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst'
# Fist step
sudo pacman-key --keyserver hkps://keyserver.ubuntu.com --recv-keys $gpg_key1
sudo pacman-key --lsign-key $gpg_key1
log INFO "Liquorix keyring added to pacman-key"
if ! grep -q 'liquorix.net/archlinux' $repo_file; then
echo -e '\n[liquorix]\nServer = https://liquorix.net/archlinux/$repo/$arch' |
sudo tee -a $repo_file
log INFO "Liquorix repository added successfully to $repo_file"
else
log INFO "Liquorix repo already configured in $repo_file, skipped add step"
fi
if ! pacman -Q linux-lqx | awk '{print $1}' >/dev/null; then
sudo pacman -Sy --noconfirm linux-lqx linux-lqx-headers
log INFO "Liquorix kernel installed successfully"
else
log INFO "Liquorix kernel already installed"
fi
grub_cfg='/boot/grub/grub.cfg'
if [ -f "$grub_cfg" ]; then
if sudo grub-mkconfig -o "$grub_cfg"; then
log INFO "GRUB updated successfully"
else
log ERROR "GRUB update failed"
fi
fi
# Second step (Note: Chaotic-AUR is being added later to avoid the liquorix kernel update issue)
sudo pacman-key --keyserver hkps://keyserver.ubuntu.com --recv-keys $gpg_key
sudo pacman-key --lsign-key $gpg_key
log INFO "Chaotic-AUR keyring added to pacman-key"
if ! grep -q '/etc/pacman.d/chaotic-mirrorlist' $repo_file; then
echo -e '\n[chaotic-aur]\nInclude = /etc/pacman.d/chaotic-mirrorlist' |
sudo tee -a $repo_file
log INFO "Chaotic-AUR repository added successfully to $repo_file"
else
log INFO "Chaotic-AUR repo already configured in $repo_file, skipped add step"
fi
if ! pacman -Q chaotic-keyring | awk '{print $1}' >/dev/null; then
sudo pacman -U --noconfirm $chk
log INFO "Chaotic-keyring installed successfully"
else
log INFO "Chaotic-keyring already installed"
fi
if ! pacman -Q chaotic-mirrorlist | awk '{print $1}' >/dev/null; then
sudo pacman -U --noconfirm $chm
log INFO "Chaotic-mirrorlist installed successfully"
else
log INFO "Chaotic-mirrorlist already installed"
fi
# Step Three
if ! grep -q 'nihaals.github.io/visual-studio-code-insiders-arch/' $repo_file; then
echo -e '\n[visual-studio-code-insiders]\nServer = https://nihaals.github.io/visual-studio-code-insiders-arch/\nSigLevel = PackageOptional' |
sudo tee -a $repo_file
log INFO "Visual-studio-code-insiders repository added successfully to $repo_file"
else
log INFO "Visual-studio-code-insiders repo already configured in $repo_file, skipped add step"
fi
if ! pacman -Q visual-studio-code-insiders | awk '{print $1}' >/dev/null; then
sudo pacman -Sy --noconfirm visual-studio-code-insiders
log INFO "Visual-studio-code-insiders installed successfully"
else
log INFO "Visual-studio-code-insiders already installed"
fi
# Installs the noise-suppression-for-voice package ladspa and pipewire-pulse
if ! pacman -Q noise-suppression-for-voice | awk '{print $1}' >/dev/null; then
sudo pacman -Sy --noconfirm noise-suppression-for-voice ladspa
log INFO "Noise-suppression-for-voice installed successfully"
else
log INFO "Noise-suppression-for-voice already installed"
fi
if ! pacman -Q pipewire-pulse | awk '{print $1}' >/dev/null; then
sudo pacman -Sy --noconfirm pipewire-pulse
log INFO "Pipewire-pulse installed successfully"
else
log INFO "Pipewire-pulse already installed"
fi
# Create the folder and pick up the repository files and activates the services
if [ ! -d ~/.config/pipewire/ ]; then
mkdir -p ~/.config/pipewire/
else
log INFO "Pipewire folder already exists"
fi
if [ ! -d ~/.config/systemd/user/ ]; then
mkdir -p ~/.config/systemd/user/
else
log INFO "Systemd user folder already exists"
fi
if [ ! -d ~/.config/pipewire/input-filter-chain.conf ]; then
wget https://raw.githubusercontent.com/viniciusred/MyWorkstation/main/noise-suppression/input-filter-chain.conf -O ~/.config/pipewire/input-filter-chain.conf
else
log INFO "Pipewire input-filter-chain.conf already exists"
fi
if [ ! -d ~/.config/systemd/user/pipewire-input-filter-chain.service ]; then
wget https://raw.githubusercontent.com/viniciusred/MyWorkstation/main/noise-suppression/pipewire-input-filter-chain.service -O ~/.config/systemd/user/pipewire-input-filter-chain.service
else
log INFO "pipewire-input-filter-chain.service already exists"
fi
if ! systemctl --user is-active pipewire-input-filter-chain.service &>/dev/null; then
LOG INFO "Reloading systemd"
sudo systemctl --user daemon-reload
if ! systemctl --user is-enabled pipewire-input-filter-chain.service &>/dev/null; then
sudo systemctl --user enable --now pipewire-input-filter-chain.service
log INFO "Noise-suppresion-for-voice service enabled"
fi
fi
# Install docker and active the service
if ! pacman -Q docker | awk '{print $1}' >/dev/null; then
sudo pacman -Sy --noconfirm docker docker-buildx
log INFO "Docker installed successfully"
if ! systemctl is-active docker.service &>/dev/null; then
sudo systemctl enable --now docker.service
log INFO "Docker service enabled"
fi
sudo usermod -aG docker $USER && newgrp docker
log INFO "User added to docker group"
else
log INFO "Docker already installed"
fi
;;
*)
log ERROR "This distribution is not supported at this time"
exit 1
;;
esac