-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_linux.sh
More file actions
executable file
·241 lines (196 loc) · 7.09 KB
/
Copy pathsetup_linux.sh
File metadata and controls
executable file
·241 lines (196 loc) · 7.09 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
#!/bin/bash
set -euo pipefail
##########################################################################
# This script assumes you installed Fedora KDE with the netinstaller
# and unticked all additional packages (except Firefox and LibreOffice).
# Requires a good internet connection, otherwise you might need to input password
# for sudo multiple times.
# The desktop option targets a desktop with two GPUs (one Intel and one Nvidia),
# of which the Nvidia one would be passed through into a Windows 10 VM for gaming.
# The laptop option targets a Lenovo Thinkpad with AMD APU.
# TODO:
# - Automate the post installation tasks
# - Automate VFIO and Looking Glass installation
# - Add error handling
##########################################################################
# Check desktop or laptop
# https://superuser.com/a/1107191
if [[ "$(cat /sys/class/dmi/id/chassis_type)" == 3 ]]; then
is_desktop=1
elif [[ " 9 10 11 14 " =~ [[:space:]]$(cat /sys/class/dmi/id/chassis_type)[[:space:]] ]]; then
is_desktop=0
else
echo "Unrecognized computer type."
read -rp "Enter 1 if you are on desktop, 0 if you are on laptop."$'\n' is_desktop
if [[ ! " 0 1 " =~ [[:space:]]${is_desktop}[[:space:]] ]]; then
echo "Incorrect input, quitting..."
exit 1
fi
fi
if [[ "$is_desktop" == 1 ]]; then
echo "Running on desktop..."
else
echo "Running on laptop..."
fi
pushd /tmp
sudo dnf upgrade -y
# Disable searching for missing programs from DNF repo
sudo sed -ie 's/SoftwareSourceSearch=true/SoftwareSourceSearch=false/g' /etc/PackageKit/CommandNotFound.conf
# Delete built-in Fedora flatpak remote
sudo flatpak remote-delete fedora
{
# Setup flatpak in background
echo "Setting up Flathub and installing flatpaks..."
flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
flatpak install -y flathub \
com.github.wwmm.easyeffects \
io.podman_desktop.PodmanDesktop \
md.obsidian.Obsidian \
com.moonlight_stream.Moonlight
} &
# Install packages (that need configurations with root) early
sudo dnf install -y \
@virtualization \
zsh
# Change default shell to Zsh
sudo chsh -s "$(which zsh)" "$(whoami)"
if [[ "$is_desktop" == 1 ]]; then
# Enable libvirtd for VM autoboot
sudo systemctl enable libvirtd
fi
# Setup RPMFusion
echo "Enabling RPMFusion and install media codecs..."
sudo dnf install -y \
"https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm" \
"https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm"
# Multimedia related
sudo dnf swap -y ffmpeg-free ffmpeg --allowerasing
sudo dnf update -y @multimedia --setopt="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin
if [[ "$is_desktop" != 1 ]]; then
sudo dnf swap -y mesa-va-drivers mesa-va-drivers-freeworld
sudo dnf swap -y mesa-va-drivers.i686 mesa-va-drivers-freeworld.i686
fi
# Add 3rd party repos
sudo dnf copr enable -y zeno/scrcpy
sudo dnf copr enable -y jdxcode/mise
sudo dnf copr enable -y regunakyle/sarasa-gothic
sudo dnf copr enable -y regunakyle/symbols-nerd-font
sudo dnf config-manager setopt google-chrome.enabled=1
# VSCode repo
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\nautorefresh=1\ntype=rpm-md\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/yum.repos.d/vscode.repo > /dev/null
# DNF install
echo "Installing packages from DNF..."
packages="@core \
age \
akmod-v4l2loopback \
btop \
btrfs-assistant \
calibre \
code \
discord \
docker-compose \
fcitx5-chinese-addons \
fcitx5-table-extra \
fd-find \
filezilla \
fzf \
git-all \
git-delta \
google-chrome-stable \
gwenview \
hugo \
iperf3 \
kate \
kolourpaint \
mediawriter \
meld \
mise \
nmap \
obs-studio \
okular \
podman-docker \
python3-docutils \
qalculate-qt \
qbittorrent \
ripgrep \
sarasa-gothic \
scrcpy \
shellcheck \
sqlitebrowser \
strawberry \
symbols-nerd-font \
tmux \
uv \
vlc"
# python-build dependencies
packages="${packages} \
make gcc patch zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel \
libffi-devel xz-devel libuuid-devel gdbm-libs libnsl2"
if [[ "$is_desktop" == 1 ]]; then
packages="${packages} \
intel-media-driver \
libvirt-devel \
solaar"
# Looking Glass dependencies
packages="${packages} \
cmake gcc-c++ libglvnd-devel fontconfig-devel spice-protocol nettle-devel \
pkgconf-pkg-config binutils-devel libxkbcommon-x11-devel wayland-devel wayland-protocols-devel \
dejavu-sans-mono-fonts libdecor-devel pipewire-devel libsamplerate-devel \
dkms kernel-devel kernel-headers obs-studio-devel"
else
packages="${packages} \
rpi-imager \
tailscale"
fi
# Suppress podman-docker messages
sudo mkdir -p /etc/containers
sudo touch /etc/containers/nodocker
sudo dnf install -y $packages
# Enable Podman socket for Docker compatiblity
systemctl --user enable --now podman.socket
# Setup Mise and Chezmoi
mise use -g chezmoi
mise exec chezmoi -- chezmoi init --apply --force regunakyle
mise install
# Get antidote
git clone --depth=1 https://github.com/mattmc3/antidote.git "$HOME"/.antidote
# Setup JetBrains
# https://github.com/nagygergo/jetbrains-toolbox-install/blob/master/jetbrains-toolbox.sh
TMP_DIR="/tmp"
INSTALL_DIR="$HOME/.local/share/JetBrains/Toolbox"
SYMLINK_DIR="$HOME/.local/bin"
echo "### INSTALL JETBRAINS TOOLBOX ###"
echo -e "\e[94mFetching the URL of the latest version...\e[39m"
ARCHIVE_URL=$(curl -s 'https://data.services.jetbrains.com/products/releases?code=TBA&latest=true&type=release' | grep -Po '"linux":.*?[^\\]",' | awk -F ':' '{print $3,":"$4}'| sed 's/[", ]//g')
ARCHIVE_FILENAME=$(basename "$ARCHIVE_URL")
echo -e "\e[94mDownloading $ARCHIVE_FILENAME...\e[39m"
rm "$TMP_DIR/$ARCHIVE_FILENAME" 2>/dev/null || true
wget -q --show-progress -cO "$TMP_DIR/$ARCHIVE_FILENAME" "$ARCHIVE_URL"
echo -e "\e[94mExtracting to $INSTALL_DIR...\e[39m"
mkdir -p "$INSTALL_DIR"
rm "$INSTALL_DIR/jetbrains-toolbox" 2>/dev/null || true
tar -xzf "$TMP_DIR/$ARCHIVE_FILENAME" -C "$INSTALL_DIR" --strip-components=1
rm "$TMP_DIR/$ARCHIVE_FILENAME"
chmod +x "$INSTALL_DIR/bin/jetbrains-toolbox"
echo -e "\e[94mSymlinking to $SYMLINK_DIR/jetbrains-toolbox...\e[39m"
mkdir -p $SYMLINK_DIR
rm "$SYMLINK_DIR/jetbrains-toolbox" 2>/dev/null || true
ln -s "$INSTALL_DIR/bin/jetbrains-toolbox" "$SYMLINK_DIR/jetbrains-toolbox"
popd
echo "Waiting for flatpak installation to finish..."
wait
cat <<EOF
Install finished! You should reboot now to ensure everything works correctly.
After that, you may want to config SSH, VSCode, JetBrains, BTRFS snapshots and Windows 10 VM.
EOF
unset TMP_DIR
unset INSTALL_DIR
unset SYMLINK_DIR
unset ARCHIVE_URL
unset ARCHIVE_FILENAME
unset is_desktop
unset filename
unset packages
# Start Tmux
exec tmux