-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_arch.sh
215 lines (176 loc) · 11 KB
/
setup_arch.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
#!/bin/zsh
source ./common_functions.sh
exported_log_function=$(typeset -f log_result)
SCRIPT_ORIGINAL_DIR=$(pwd)
read "username?What would you like your users name to be: "
read -s "password?Enter the desired password for ${username}:"
echo
read -s "confirm_pass?Confirm the password for ${username}:"
echo
if [[ "${password}" != "$confirm_pass" ]];
then
echo "Passwords do not match.Exiting."
exit 1
fi
# Create user
useradd -m -g users -s /bin/zsh ${username}
echo "${username}:${password}" | chpasswd
usermod -aG wheel root
usermod -aG wheel ${username}
echo "${username} ALL=(ALL:ALL) ALL" > /etc/sudoers.d/${username}
log_result $? "setup_arch.sh" "Created user ${username} with sudo privileges" "Failed to create user ${username}"
# Run custom script that handles everything related to actual installation of packages
./install_pkgs.sh "${username}"
# Enable NetworkManager to start on boot
systemctl enable NetworkManager
log_result $? "setup_arch.sh" "Enabled NetworkManager service" "Failed to enable NetworkManager service"
# Make sure NetworkManager is running
systemctl start NetworkManager
log_result $? "setup_arch.sh" "Started NetworkManager service" "Failed to start NetworkManager service"
# Install reflector with all default options
pacman -S --noconfirm reflector
log_result $? "setup_arch.sh" "Installed reflector package" "Failed to install reflector package"
# Backup mirrorlist
cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
log_result $? "setup_arch.sh" "Backed up mirrorlist" "Failed to backup mirrorlist"
# Run reflector to get the best pacman mirrors
reflector --verbose --latest 10 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
log_result $? "setup_arch.sh" "Ran reflector to get best pacman mirrors" "Failed to run reflector to get best pacman mirrors"
# Update and upgrade the system with all default options
pacman -Syyu --noconfirm
log_result $? "setup_arch.sh" "Updated and upgraded system" "Failed to update and/or upgrade system"
# Export default editor to be neovim
export EDITOR=nvim
log_result $? "setup_arch.sh" "Set EDITOR environment variable to neovim" "Failed to set EDITOR environment variable to neovim"
# Make directories
mkdir /home/${username}/Software # For software that needs files downloaded e.g. git cloning
mkdir /home/${username}/themes
mkdir /home/${username}/.icons
mkdir /home/${username}/.bin
mkdir /home/${username}/Documents
mkdir /home/${username}/Pictures
mkdir /home/${username}/Downloads
mkdir -p /mnt/usb_1/ /mnt/usb_2/ # Create directories for mountable media
mkdir -p /home/${username}/.config/dunst
mkdir -p /etc/pacman.d/hooks
mkdir -p /home/${username}/.local/share/applications
log_result $? "setup_arch.sh" "Create necessary directories" "Failed to create necessary directories"
cp dracula.qbtheme /home/${username}/themes
log_result $? "setup_arch.sh" "Copied qbittorrent theme to themes directory" "Failed to copy qbittorrent theme to themes directory"
cd /home/${username}/Software
# Set grub theme to dracula
git clone https://github.com/dracula/grub.git grub-dracula
cp -r grub-dracula/dracula /boot/grub/themes
log_result $? "setup_arch.sh" "Set grub theme to dracula" "Failed to set grub theme to dracula"
# Update grub configuration to set the theme
if [ "$(grep -q '^GRUB_THEME=' /etc/default/grub && echo yes || echo no)" = "no" ]; then
echo 'GRUB_THEME="/boot/grub/themes/dracula/theme.txt"' >> /etc/default/grub
else
sed -i 's|^GRUB_THEME=.*|GRUB_THEME="/boot/grub/themes/dracula/theme.txt"|' /etc/default/grub
fi
# Regenerate GRUB configuration
grub-mkconfig -o /boot/grub/grub.cfg
# Download copyq dracula theme and copy it to themes directory
# copyq_themes_dir="$(copyq info themes)"
git clone https://github.com/dracula/copyq.git copyq-dracula $(copyq info themes)
# cp copyq-dracula/dracula.ini $(copyq info themes)
log_result $? "setup_arch.sh" "Downloaded and copied copyq dracula theme to copyq themes directory" "Failed to download and copy copyq theme to its theme directory"
# Set dunst theme to dracula
git clone https://github.com/dracula/dunst.git dunst-dracula /home/${username}/.config/dunst
# cp dunst-dracula/dunstrc ~/.config/dunst/
log_result $? "setup_arch.sh" "Set dunst theme to dracula" "Failed to set dunst theme to dracula"
# Set GTK theme to dracula
git clone https://github.com/dracula/gtk.git /home/${username}/.themes/gtk-master-dracula
log_result $? "setup-arch.sh:: Set GTK theme to dracula" "Failed to set GTK theme to dracula"
# Set icon theme to dracula
git clone https://github.com/dracula/gtk/files/5214870/Dracula.zip /home/${username}/.icons/gtk-icons-dracula
log_result $? "setup_arch.sh" "Set icons theme to dracula" "Failed to set icons theme to dracula"
# Clone oh-my-zsh repository to user's home directory
HOME="/home/${username}" ZSH="/home/${username}/.oh-my-zsh" ZDOTDIR="/home/${username}" sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
git clone https://github.com/zsh-users/zsh-autosuggestions /home/${username}/.oh-my-zsh/custom/plugins/zsh-autosuggestions
# SDDM configuration
cd $SCRIPT_ORIGINAL_DIR
systemctl enable sddm
log_result $? "setup_arch.sh" "Enabled sddm service" "Failed to enable sddm service"
cp sddm/sddm.conf /etc/sddm.conf
log_result $? "setup_arch.sh" "Copied sddm config to its config directory" "Failed to copy sddm config to its config directory"
cp sddm/theme.conf /usr/share/sddm/themes/tokyo-night-sddm/theme.conf
log_result $? "setup_arch.sh" "Copied sddm theme to its theme directory" "Failed to copy sddm theme to its theme directory"
# Set global environment variables by appending to the /etc/environment file
echo "PATH=$PATH:/home/${username}/.bin" | sudo tee -a /etc/environment > /dev/null
log_result $? "setup_arch.sh" "Append user's .bin directory to PATH variable" "Failed to append user's .bin directory to PATH variable"
updatedb
log_result $? "setup_arch.sh" "Update db for file locating applications" "Failed to update db for file locating applications"
# Create pacman hook to clean cache after update, install, and remove operations
cp clean_package_cache.hook /etc/pacman.d/hooks/
mkdir -p /home/${username}/.local/share/applications
cp remap_caps_esc.hook /etc/pacman.d/hooks/
log_result $? "setup_arch.sh" "Copy pacman hooks to the required directory" "Failed to copy pacman hooks to the required directory"
# Prepare ufw
systemctl enable ufw.service
log_result $? "setup_arch.sh" "Enable ufw service" "Failed to enable ufw service"
systemctl start ufw.service
log_result $? "setup_arch.sh" "Start ufw service" "Failed to start ufw service"
ufw enable
log_result $? "setup_arch.sh" "Enable ufw" "Failed to enable ufw"
# Enable ntp daemon to avoid time desynchronisation
systemctl enable ntpd.service
log_result $? "setup_arch.sh" "Enable ntpd service" "Failed to enable ntpd service"
systemctl start ntpd.service
log_result $? "setup_arch.sh" "Start ntpd service" "Failed to start ntpd service"
ufw allow http
log_result $? "setup_arch.sh" "Allow http in ufw" "Failed to allow http in ufw"
ufw allow https
log_result $? "setup_arch.sh" "Allow https in ufw" "Failed to allow https in ufw"
ufw allow www
log_result $? "setup_arch.sh" "Allow www in ufw" "Failed to allow www in ufw"
# Copy .desktop file used to run neovim within a new alacritty window to the local applications directroy
cp alacritty-nvim.desktop /home/${username}/.local/share/applications/
log_result $? "setup_arch.sh" "Copy .desktop file used to run neovim within a new alacritty window to the local applications directory" "Failed to copy .desktop file used to run neovim within a new alacritty window to the local applications directory"
# Set some default apps by filetype
xdg-mime default feh.desktop image/png
log_result $? "setup_arch.sh" "Set feh as default image application (png)" "Failed to set feh as default image applicatin (png)"
xdg-mime default feh.desktop image/jpeg
log_result $? "setup_arch.sh" "Set feh as default image application (jpeg)" "Failed to set feh as default image applicatin (jpeg)"
xdg-mime default org.pwmt.zathura-pdf-poppler.desktop application/pdf
log_result $? "setup_arch.sh" "Set zathura as default pdf application" "Failed to set zathura as default pdf application"
xdg-mime default alacritty-nvim.desktop inode/x-empty
log_result $? "setup_arch.sh" "Set alacritty as default application for inode/empty files" "Failed to set alacritty as default application for inode/empty files"
xdg-mime default vlc.desktop audio/x-m4a
log_result $? "setup_arch.sh" "Set vlc as default audio application" "Failed to set vlc as default audio application"
# Copy wallpapers to ~/Pictures/ so that betterlockscreen has access to them
cp -r wallpapers/ /home/${username}/Pictures/
log_result $? "setup_arch.sh" "Copied wallpapers directory to Pictures" "Failedto copy wallpapers directory to Pictures"
# Initialise betterlockscreen with that folder
betterlockscreen -u /home/${username}/Pictures/wallpapers/ --fx dim --dim 50
# Might need this to properly set keymap
# localectl set-x11-keymap gb
# Transfer ownership of user's home directory to them
chown -R ${username}:users /home/${username}/
# Synchronise with dotfiles repository using chezmoi
su - "${username}" <<EOF
eval $exported_log_function
cd /home/${username}/
log_result $? "Changed directory to user home ($(pwd))" "Failed to change directory to user home ($(pwd))"
chezmoi init https://github.com/promitheas17j/dotfiles.git
log_result $? "setup_arch.sh" "Initialised chezmoi repo" "Failed to initialise chezmoi repo"
cd /home/"${username}"/.local/share/chezmoi
log_result $? "setup_arch.sh" "Changed directory to chezmoi directory" "Failed to change directory to chezmoi directory"
git pull
log_result $? "setup_arch.sh" "Pulled dotfiles from remote repo" "Failed to pull dotfiles from remote repo"
chezmoi update -v
log_result $? "setup_arch.sh" "Synched local dotfiles with chezmoi directory dotfiles" "Failed to synch local dotfiles with chezmoi directory dotfiles"
EOF
# Install treesitter cli to get rid of warning
npm install -g tree-sitter-cli
# Have packer setup its config and run updates
# nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
echo "If script finished without errors, do the following:"
echo "\t1) Go to copyq -> Preferences -> Appearance and load the dracula theme"
echo "\t2) Go to thunderbird -> Tools -> Add-ons and Themes and search for dracula then install it"
echo "\t3) Go to qbittorrent -> Tools -> Preferences -> Behaviour -> Interface -> Use custom UI Theme and select the dracula.qbtheme file"
echo "\t4) Open the file: /usr/share/dbus-1/services/org.xfce.xfce4-notityd.Notifications.service and change the line Name=org.freedesktop.Notifications to Name=org.freedesktop.NotificationsNone"
echo "\t5) Check log to see if any software failed to install, and attempt to install it manually after booting into the system"
# Might not need to manually do step 6 as I addedthe instruction after copying the wallpapers directory
echo "\t6) Point betterlockscreen to the wallpapers directory with betterlockscreen -u \"path/to/wallpaper/dir/\""
echo "\t7) Set up github ssh keys"