forked from RobbiNespu/fedora-ultimate-setup-script
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLEGACY-fedora-ultimate-setup-script-2.sh
More file actions
executable file
·411 lines (366 loc) · 17.2 KB
/
Copy pathLEGACY-fedora-ultimate-setup-script-2.sh
File metadata and controls
executable file
·411 lines (366 loc) · 17.2 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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
#!/bin/bash
#==================================================================================================
#
# FILE: fedora-ultimate-setup-script.sh
# USAGE: fedora-ultimate-setup-script.sh
#
# DESCRIPTION: Post-installation setup script for Fedora 29 Workstation
# WEBSITE: https://www.elsewebdevelopment.com/
#
# REQUIREMENTS: Fresh copy of Fedora 29/30 installed on your computer
# https://dl.fedoraproject.org/pub/fedora/linux/releases/29/Workstation/x86_64/iso/
# AUTHOR: David Else
# COMPANY: Else Web Development
# VERSION: 2.2.1
#==================================================================================================
# WARNING sudo time outs and you need to enter password a few times
GREEN=$(tput setaf 2)
BOLD=$(tput bold)
RESET=$(tput sgr0)
#==================================================================================================
# set user preferences
#==================================================================================================
system_updates_dir="$HOME/offline-system-updates"
user_updates_dir="$HOME/offline-user-packages"
GIT_EMAIL='example@example.com'
GIT_USER_NAME='example-name'
REMOVE_LIST=(gnome-photos gnome-documents rhythmbox totem cheese)
create_package_list() {
declare -A packages=(
['drivers']='libva-intel-driver fuse-exfat'
['multimedia']='mpv ffmpeg mkvtoolnix-gui shotwell'
['utils']='gnome-tweaks tldr whipper keepassx transmission-gtk lshw mediainfo klavaro youtube-dl'
['gnome_extensions']='gnome-shell-extension-auto-move-windows.noarch gnome-shell-extension-pomodoro'
['emulation']='winehq-stable dolphin-emu mame'
['audio']='jack-audio-connection-kit'
['backup_sync']='borgbackup syncthing'
['languages']='java-1.8.0-openjdk nodejs php php-json'
['webdev']='code chromium chromium-libs-media-freeworld docker docker-compose ShellCheck'
['firefox extensions']='mozilla-https-everywhere mozilla-privacy-badger mozilla-ublock-origin'
)
for package in "${!packages[@]}"; do
echo "$package: ${GREEN}${packages[$package]}${RESET}" >&2
PACKAGES_TO_INSTALL+=(${packages[$package]})
done
}
#==================================================================================================
# add repositories
#==================================================================================================
add_repositories() {
echo "${BOLD}Adding repositories...${RESET}"
sudo dnf -y install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
if [[ ${PACKAGES_TO_INSTALL[*]} == *'winehq-stable'* ]]; then
sudo dnf config-manager --add-repo https://dl.winehq.org/wine-builds/fedora/29/winehq.repo
fi
if [[ ${PACKAGES_TO_INSTALL[*]} == *'code'* ]]; then
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
fi
}
#==================================================================================================
# setup visual studio code
#==================================================================================================
setup_vscode() {
local code_extensions=(ban.spellright
bierner.markdown-preview-github-styles
deerawan.vscode-dash
esbenp.prettier-vscode
foxundermoon.shell-format
ms-vsliveshare.vsliveshare
msjsdiag.debugger-for-chrome
ritwickdey.LiveServer
timonwong.shellcheck
WallabyJs.quokka-vscode)
for extension in "${code_extensions[@]}"; do
code --install-extension "$extension"
done
cat >"$HOME/.config/Code/User/settings.json" <<EOL
// Place your settings in this file to overwrite the default settings
{
// VS Code 1.36 general settings
"editor.renderWhitespace": "all",
"editor.dragAndDrop": false,
"editor.formatOnSave": true,
"editor.minimap.enabled": false,
"editor.detectIndentation": false,
"editor.tabSize": 2,
"workbench.activityBar.visible": false,
"workbench.tree.renderIndentGuides": "none",
"workbench.list.keyboardNavigation": "filter",
"window.menuBarVisibility": "toggle",
"zenMode.restore": true,
"zenMode.centerLayout": false,
"zenMode.fullScreen": false,
"git.autofetch": true,
"git.enableSmartCommit": true,
"git.decorations.enabled": false,
"npm.enableScriptExplorer": true,
"explorer.decorations.colors": false,
"search.followSymlinks": false,
// Privacy
"telemetry.enableTelemetry": false,
"extensions.showRecommendationsOnlyOnDemand": true,
// Language settings
"php.validate.executablePath": "/usr/bin/php",
"javascript.preferences.quoteStyle": "single",
"typescript.updateImportsOnFileMove.enabled": "always",
"files.exclude": {
"**/*.js": { "when": "$(basename).ts" },
"**/*.js.map": true
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// Shell Format extension
"shellformat.flag": "-i 4",
// Live Server extension
"liveServer.settings.donotShowInfoMsg": true,
"liveServer.settings.ChromeDebuggingAttachment": true,
"liveServer.settings.AdvanceCustomBrowserCmdLine": "/usr/bin/chromium-browser --remote-debugging-port=9222",
// Prettier extension
"prettier.singleQuote": true,
"prettier.trailingComma": "all",
"prettier.proseWrap": "always",
// Spellright extension
"spellright.language": ["English (British)"],
"spellright.documentTypes": ["markdown", "latex", "plaintext"]
// "typescript.referencesCodeLens.enabled": true,
// "javascript.referencesCodeLens.enabled": true,
}
EOL
}
#==================================================================================================
# setup jack
#==================================================================================================
setup_jack() {
sudo usermod -a -G jackuser "$USERNAME" # Add current user to jackuser group
sudo tee /etc/security/limits.d/95-jack.conf <<EOL
# Default limits for users of jack-audio-connection-kit
@jackuser - rtprio 98
@jackuser - memlock unlimited
@pulse-rt - rtprio 20
@pulse-rt - nice -20
EOL
}
#==================================================================================================
# setup git
#==================================================================================================
setup_git() {
if [[ -z $(git config --get user.name) ]]; then
git config --global user.name $GIT_USER_NAME
echo "No global git user name was set, I have set it to ${BOLD}$GIT_USER_NAME${RESET}"
fi
if [[ -z $(git config --get user.email) ]]; then
git config --global user.email $GIT_EMAIL
echo "No global git email was set, I have set it to ${BOLD}$GIT_EMAIL${RESET}"
fi
}
#==================================================================================================
# setup mpv (before it is run config file or dir does not exist)
#==================================================================================================
setup_mpv() {
mkdir "$HOME/.config/mpv"
cat >"$HOME/.config/mpv/mpv.conf" <<EOL
profile=gpu-hq
hwdec=auto
fullscreen=yes
EOL
}
#==================================================================================================
# install and create offline install
#==================================================================================================
create_offline_install() {
mkdir "$system_updates_dir" "$user_updates_dir"
echo "${BOLD}Updating Fedora, installing packages, and saving .rpm files...${RESET}"
sudo dnf -y --refresh upgrade --downloadonly --downloaddir="$system_updates_dir" --setopt=keepcache=1
sudo dnf -y install "$system_updates_dir"/*.rpm --setopt=keepcache=1
sudo dnf -y install "${PACKAGES_TO_INSTALL[@]}" --downloadonly --downloaddir="$user_updates_dir" --setopt=keepcache=1
sudo dnf -y install "$user_updates_dir"/*.rpm --setopt=keepcache=1
echo
echo "Your .rpm files live in ${GREEN}$system_updates_dir${RESET} and ${GREEN}$user_updates_dir${RESET}"
echo "On Fresh Fedora ISO install copy dirs into home folder and run script choosing option 3 (or use ${GREEN}sudo dnf install *.rpm${RESET} in respective directories)"
}
#==================================================================================================
# update_and_install_online
#==================================================================================================
update_and_install_online() {
echo "${BOLD}Updating Fedora and installing packages...${RESET}"
sudo dnf -y --refresh upgrade
sudo dnf -y install "${PACKAGES_TO_INSTALL[@]}"
}
#==================================================================================================
# update_and_install_offline
#==================================================================================================
update_and_install_offline() {
if [[ ! -d "$system_updates_dir" || ! -d "$user_updates_dir" ]]; then
echo "${GREEN}$system_updates_dir${RESET} or ${GREEN}$user_updates_dir${RESET} do not exist!"
exit 1
else
echo "${BOLD}Updating Fedora and installing packages...${RESET}"
sudo dnf -y install "$system_updates_dir"/*.rpm --setopt=keepcache=1
sudo dnf -y install "$user_updates_dir"/*.rpm --setopt=keepcache=1
fi
}
#==================================================================================================
# remove_unwanted_programs
#==================================================================================================
remove_unwanted_programs() {
echo "${BOLD}Removing unwanted programs...${RESET}"
sudo dnf -y remove "${REMOVE_LIST[@]}"
}
#==================================================================================================
# main
#==================================================================================================
main() {
if [[ $(rpm -E %fedora) -lt 29 ]]; then
echo >&2 "You must install at least ${GREEN}Fedora 29${RESET} to use this script" && exit 1
fi
clear
cat <<EOL
===================================================================================================
Welcome to the Fedora 29+ Ultimate Setup Script!
===================================================================================================
${BOLD}Programs to add:${RESET}
EOL
create_package_list
cat <<EOL
${BOLD}Programs to remove:${RESET}
${GREEN}${REMOVE_LIST[*]}${RESET}
${BOLD}Git globals will be set to:${RESET} USER_NAME ${GREEN}$GIT_USER_NAME${RESET} EMAIL ${GREEN}$GIT_EMAIL${RESET}
Would you like to use your internet connection to:
${BOLD}1${RESET} Download system updates and install/setup user selected programs
${BOLD}2${RESET} Download system updates and install/setup user selected programs
and create offline install files for future use
Or use offline install files created previously to:
${BOLD}3${RESET} Install system updates and install/setup user selected programs
EOL
#==============================================================================================
# choose options and set host name
#==============================================================================================
read -p "Please select from the above options (1/2/3) " -n 1 -r
echo
local hostname
read -rp "What is this computer's name? [$HOSTNAME] " hostname
if [[ ! -z "$hostname" ]]; then
hostnamectl set-hostname "$hostname"
fi
case $REPLY in
1)
set -euo pipefail
add_repositories
remove_unwanted_programs
update_and_install_online
;;
2)
set -euo pipefail
add_repositories
remove_unwanted_programs
create_offline_install
;;
3)
add_repositories
remove_unwanted_programs
update_and_install_offline
;;
*)
echo "$REPLY was an invalid choice"
exit
;;
esac
#==============================================================================================
# setup software
#==============================================================================================
echo "${BOLD}Setting up git globals...${RESET}"
setup_git
# note the spaces to make sure something like 'notnode' could not trigger 'nodejs' using [*]
case " ${PACKAGES_TO_INSTALL[*]} " in
*' code '*)
echo "${BOLD}Setting up Visual Studio Code...${RESET}"
setup_vscode
;;&
*' nodejs '*)
echo "${BOLD}Setting up pnpm...${RESET}"
sudo npm install -g pnpm npm-check eslint jsdom
cat >>"$HOME/.bashrc" <<EOL
export NPM_CHECK_INSTALLER=pnpm
EOL
;;&
*' mpv '*)
echo "${BOLD}Setting up mpv...${RESET}"
setup_mpv
;;&
*' jack-audio-connection-kit '*)
echo "${BOLD}Setting up jack...${RESET}"
setup_jack
;;&
esac
#==============================================================================================
# setup pulse audio
#
# *pacmd list-sinks | grep sample and see bit-depth available for interface
# *pulseaudio --dump-re-sample-methods and see re-sampling available
#
# *MAKE SURE your interface can handle s32le 32bit rather than the default 16bit
#==============================================================================================
echo "${BOLD}Setting up Pulse Audio...${RESET}"
sudo sed -i "s/; default-sample-format = s16le/default-sample-format = s32le/g" /etc/pulse/daemon.conf
sudo sed -i "s/; resample-method = speex-float-1/resample-method = speex-float-10/g" /etc/pulse/daemon.conf
sudo sed -i "s/; avoid-resampling = false/avoid-resampling = true/g" /etc/pulse/daemon.conf
#==============================================================================================
# setup gnome desktop gsettings
#==============================================================================================
echo "${BOLD}Setting up Gnome...${RESET}"
gsettings set org.gnome.settings-daemon.plugins.media-keys max-screencast-length 0 # Ctrl + Shift + Alt + R to start and stop screencast
gsettings set org.gnome.desktop.wm.preferences button-layout 'appmenu:minimize,maximize,close'
gsettings set org.gnome.desktop.interface clock-show-date true
gsettings set org.gnome.desktop.session idle-delay 1200
gsettings set org.gnome.desktop.input-sources xkb-options "['caps:backspace', 'terminate:ctrl_alt_bksp']"
gsettings set org.gnome.shell.extensions.auto-move-windows application-list "['org.gnome.Nautilus.desktop:2', 'org.gnome.Terminal.desktop:3', 'code.desktop:1', 'firefox.desktop:1']"
gsettings set org.gnome.shell enabled-extensions "['pomodoro@arun.codito.in', 'auto-move-windows@gnome-shell-extensions.gcampax.github.com']"
gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled true
#==============================================================================================
# make a few little changes
#==============================================================================================
mkdir "$HOME/sites"
echo "Xft.lcdfilter: lcdlight" >>"$HOME/.Xresources"
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
touch ~/Templates/empty-file # so you can create new documents from nautilus
cat >>"$HOME/.bashrc" <<EOL
alias ls="ls -ltha --color --group-directories-first" # l=long listing format, t=sort by modification time (newest first), h=human readable sizes, a=print hidden files
alias tree="tree -Catr --noreport --dirsfirst --filelimit 100" # -C=colorization on, a=print hidden files, t=sort by modification time, r=reversed sort by time (newest first)
EOL
cat <<EOL
===================================================
REBOOT NOW!!!! (or things may not work as expected)
shutdown -r
===================================================
EOL
}
main
# NOTES
# - mpv addition settings include:
# gpu-context=drm
# video-sync=display-resample
# interpolation
# tscale=oversample
#
# - Install 'Hide Top Bar' extension from Gnome software
# - Firefox "about:support" what is compositor? If 'basic' open "about:config"
# find "layers.acceleration.force-enabled" and switch to true, this will
# force OpenGL acceleration
# - Update .bash_profile with
# 'PATH=$PATH:$HOME/.local/bin:$HOME/bin:$HOME/Documents/scripts:$HOME/Documents/scripts/borg-backup'
# - Files > preferences > views > sort folders before files
# - Change shotwell import directory format to %Y/%m + rename lower case, import photos from external drive
# - UMS > un-tick general config > enable external network + check force network on interface correct network (wlp2s0)
# - make symbolic links to media ln -s /run/media/david/WD-Red-2TB/Media/Audio ~/Music