-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
177 lines (172 loc) · 8.09 KB
/
setup.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
#!/bin/sh
# Refresh Arch keyrings and install dialog
pacman --noconfirm -S dialog
case "$(readlink -f /sbin/init)" in
*systemd* )
pacman --noconfirm -S archlinux-keyring >/dev/null 2>&1
;;
*)
pacman --noconfirm --needed -S artix-keyring artix-archlinux-support >/dev/null 2>&1
for repo in extra community; do
grep -q "^\[$repo\]" /etc/pacman.conf ||
echo "[$repo]
Include = /etc/pacman.d/mirrorlist-arch" >> /etc/pacman.conf
done
pacman-key --populate archlinux
;;
esac
# Get name and pass variables
getuserandpass() { \
name=$(dialog --inputbox "First, please enter a name for the user account." 10 60 3>&1 1>&2 2>&3 3>&1) || exit
while ! echo "$name" | grep "^[a-z_][a-z0-9_-]*$" >/dev/null 2>&1; do
name=$(dialog --no-cancel --inputbox "Username not valid. Give a username beginning with a letter, with only lowercase letters, - or _." 10 60 3>&1 1>&2 2>&3 3>&1)
done
pass1=$(dialog --no-cancel --passwordbox "Enter a password for that user." 10 60 3>&1 1>&2 2>&3 3>&1)
pass2=$(dialog --no-cancel --passwordbox "Retype password." 10 60 3>&1 1>&2 2>&3 3>&1)
while ! [ "$pass1" = "$pass2" ]; do
unset pass2
pass1=$(dialog --no-cancel --passwordbox "Passwords do not match.\\n\\nEnter password again." 10 60 3>&1 1>&2 2>&3 3>&1)
pass2=$(dialog --no-cancel --passwordbox "Retype password." 10 60 3>&1 1>&2 2>&3 3>&1)
done
VMWAREGUEST=$(dialog --inputbox "Type 'yes' if running in VMware" 10 60 3>&1 1>&2 2>&3 3>&1)
INSTALLDM=$(dialog --inputbox "Type 'yes' if you want a DM" 10 60 3>&1 1>&2 2>&3 3>&1)
}
getuserandpass
# Upgrade
pacman --noconfirm -Syu || exit 1
pacman --noconfirm --needed -S base-devel linux-firmware diffutils neovim man-db man-pages wget texinfo exfat-utils e2fsprogs
newperms() {
sed -i "/#Deploydot/d" /etc/sudoers
echo "$* #Deploydot" >> /etc/sudoers ;}
newperms "%wheel ALL=(ALL) NOPASSWD: ALL"
useradd -m -s /bin/bash "$name" && mkdir -p /home/"$name" && chown "$name":wheel /home/"$name"
echo "$name:$pass1" | chpasswd
unset pass1 pass2
usermod -a -G wheel,video,audio "$name"
# Use all cores for compile
sed -i "s/-j2/-j$(nproc)/;s/^#MAKEFLAGS/MAKEFLAGS/" /etc/makepkg.conf
# Make pacman and yay nice-looking
grep -q "ILoveCandy" /etc/pacman.conf || sed -i "/#VerbosePkgLists/a ILoveCandy" /etc/pacman.conf
sed -i "s/^#ParallelDownloads = 8$/ParallelDownloads = 5/;s/^#Color$/Color/" /etc/pacman.conf
# Install Yay and Git
pacman --noconfirm -S git
cd /tmp
sudo -u "$name" git clone https://aur.archlinux.org/yay.git
cd yay
sudo -u "$name" makepkg --noconfirm -si
sudo -u "$name" yay -S --noconfirm libxft-bgra-git
# Essential Software
pacman --noconfirm -S xorg-server xorg-xwininfo xorg-xinit xorg-xprop xorg-xdpyinfo xdotool || { echo 'failed at installing packages from official repo' ; exit 1; }
# Bloat Software
pacman --noconfirm -S neofetch xarchiver vifm highlight rofi ncmpcpp mpc zathura zathura-pdf-mupdf zathura-djvu poppler || { echo 'failed at installing packages from official repo' ; exit 1; }
# Bloat Software 2
pacman --noconfirm -S newsboat xcompmgr tmux htop ed arandr ffmpeg atool mediainfo yt-dlp unrar unzip socat || { echo 'failed at installing packages from official repo' ; exit 1; }
# Bloat Software 3
pacman --noconfirm -S mpv mpd gnome-keyring exfat-utils dosfstools ntfs-3g libnotify dunst bc ffmpegthumbnailer || { echo 'failed at installing packages from official repo' ; exit 1; }
# Bloat Software 4
pacman --noconfirm -S sxiv lxappearance qt5ct scrot nitrogen xorg-font-util bmon || { echo 'failed at installing packages from official repo' ; exit 1; }
# Bloat Software 5
pacman --noconfirm -S streamlink zsh zsh-history-substring-search broot pacman-contrib || { echo 'failed at installing packages from official repo' ; exit 1; }
# Bloat Software 6
pacman --noconfirm -S unclutter inotify-tools pcmanfm-gtk3 xclip alsa-utils rsync || { echo 'failed at installing packages from official repo' ; exit 1; }
# Pulseaudio
pacman --noconfirm -S pipewire pipewire-pulse pulsemixer pamixer
# Ueberzug and Preview
sudo -u "$name" yay -S --noconfirm python-ueberzug
sudo -u "$name" yay -S --noconfirm fontpreview-git
# Fonts
sudo -u "$name" yay -S --noconfirm nerd-fonts-hack
sudo -u "$name" yay -S --noconfirm ttf-iosevka
sudo -u "$name" yay -S --noconfirm ttf-joypixels
sudo -u "$name" yay -S --noconfirm nerd-fonts-cascadia-code
sudo -u "$name" yay -S --noconfirm ttf-material-design-icons-git
sudo -u "$name" yay -S --noconfirm brave
sudo -u "$name" yay -S --noconfirm zsh-theme-powerlevel10k
fc-cache
# Clone dotfiles to home
dir=$(mktemp -d)
git clone -b master --depth 1 https://github.com/Batresh/dotfiles "$dir/gitrepo"
cp -rfT "$dir/gitrepo" /home/$name
cd /home/$name
rm -rf .git
# Shell change
chsh -s /usr/bin/zsh root
chsh -s /usr/bin/zsh "$name"
sudo -u "$name" mkdir -p "/home/$name/.cache/zsh/"
mkdir /usr/share/xsessions && mv /home/$name/.local/share/extras/dwm.desktop /usr/share/xsessions/dwm.desktop
mv /home/$name/.local/share/extras/siji.ttf /usr/share/fonts/TTF/
cd /home/$name/.local/src/dwm
sudo make install
cd /home/$name/.local/src/dwmblocks
sudo make install
cd /home/$name/.local/src/st
sudo make install
cd /home/$name/.local/src/dmenu
sudo make install
mkdir /home/"$name"/.icons
cd /tmp
git clone https://github.com/sainnhe/gruvbox-material-gtk
cp -r gruvbox-materials-gtk/icons/Gruvbox-Material-Dark /home/"$name"/.icons
rm /tmp/gruvbox-material-gtk
# serveral important commands, `shutdown`, `reboot`, updating, etc. without a password.
newperms "%wheel ALL=(ALL) ALL #Deploydot
%wheel ALL=(ALL) NOPASSWD: /usr/bin/shutdown,/usr/bin/reboot,/usr/bin/poweroff,/usr/bin/halt,/usr/bin/systemctl suspend,/usr/bin/wifi-menu,/usr/bin/mount,/usr/bin/umount,/usr/bin/pacman -Sy,/usr/bin/pacman -Syy,/usr/bin/pacman -Syu,/usr/bin/pacman -Syyu,/usr/bin/packer -Syu,/usr/bin/packer -Syyu,/usr/bin/systemctl restart NetworkManager,/usr/bin/rc-service NetworkManager restart,/usr/bin/pacman -Syyu --noconfirm,/usr/bin/loadkeys,/usr/bin/yay,/usr/bin/pacman -Syyuw --noconfirm"
# Remove System Beep
rmmod pcspkr
echo "blacklist pcspkr" > /etc/modprobe.d/nobeep.conf
# Permissions
chown -R "$name":wheel /home/"$name"
# Avoid blank screen when setting brigtness
sudo -u $name light -N 1
# Tap to click
[ ! -f /etc/X11/xorg.conf.d/40-libinput.conf ] && printf 'Section "InputClass"
Identifier "libinput touchpad catchall"
MatchIsTouchpad "on"
MatchDevicePath "/dev/input/event*"
Driver "libinput"
# Enable left mouse button by tapping
Option "Tapping" "on"
EndSection' > /etc/X11/xorg.conf.d/40-libinput.conf
# Fix fluidsynth/pulseaudio issue.
grep -q "OTHER_OPTS='-a pulseaudio -m alsa_seq -r 48000'" /etc/conf.d/fluidsynth ||
echo "OTHER_OPTS='-a pulseaudio -m alsa_seq -r 48000'" >> /etc/conf.d/fluidsynth
# Start/restart PulseAudio.
killall pulseaudio; sudo -u "$name" pulseaudio --start
WHICHINIT=$(stat /proc/1/exe | head -1)
if [[ $WHICHINIT == *runit* ]]; then
dbus-uuidgen >| /etc/machine-id
rm /run/runit/service/agetty-tty3 /run/runit/service/agetty-tty4 /run/runit/service/agetty-tty5 /run/runit/service/agetty-tty6
if [ $VMWAREGUEST = yes ]; then
pacman --noconfirm -S open-vm-tools xf86-video-vmware
mkdir /etc/runit/sv/vmtoolsd
cat > /etc/runit/sv/vmtoolsd/run << EOF
#!/bin/sh
exec /usr/bin/vmtoolsd
EOF
chmod 755 /etc/runit/sv/vmtoolsd/run
ln -s /etc/runit/sv/vmtoolsd /run/runit/service
fi
if [ $INSTALLDM = yes ]; then
pacman -S --noconfirm lightdm lightdm-gtk-greeter lightdm-runit
fi
fi
if [[ $WHICHINIT == *systemd* ]]; then
if [ $VMWAREGUEST = yes ]; then
pacman --noconfirm -S open-vm-tools xf86-video-vmware
systemctl enable vmtoolsd && systemctl start vmtoolsd
systemctl enable vmware-vmblock-fuse && systemctl start vmware-vmblock-fuse
fi
if [ $INSTALLDM = yes ]; then
pacman -S --noconfirm lightdm lightdm-gtk-greeter
systemctl enable lightdm
fi
fi
if [ $INSTALLDM = yes ]; then
groupadd -r autologin
gpasswd -a $name autologin
sed -i "s/^#autologin-user=/autologin-user=$name/" /etc/lightdm/lightdm.conf
fi
# Install independent plugins
git clone https://github.com/zdharma/fast-syntax-highlighting /usr/share/zsh/plugins/fsh
[[ $WHICHINIT == *runit* ]] && ln -sf /etc/runit/sv/lightdm /run/runit/service
[[ $WHICHINIT == *systemd* ]] && systemctl start lightdm