configs/arch-setup/install.sh

449 lines
12 KiB
Bash
Raw Normal View History

2023-11-17 16:47:52 +01:00
#!/usr/bin/env bash
2020-02-28 22:33:35 +01:00
2022-06-05 16:23:05 +02:00
set -euo pipefail
2020-10-12 07:16:00 +02:00
# function to keep sudo from timing out
function func_dont_timeout {
while true; do
sudo -v
sleep 60
done
}
# check if user is root
if [ "$EUID" -ne 0 ]; then
sudo -v
fi
# keep sudo active in background
func_dont_timeout &
2022-06-05 16:23:05 +02:00
# get script directory
scriptloc="$BASH_SOURCE"
setupdir=$(dirname "$scriptloc")
#setupdir=$(pwd)
2021-01-29 16:53:04 +01:00
2022-06-05 16:23:05 +02:00
#change to home directory
#cd "$HOME"
2020-02-28 22:33:35 +01:00
2022-03-20 12:23:09 +01:00
# check if multilib repo is enabled
2023-01-13 11:51:24 +01:00
if ! pacman -Sl multilib &>/dev/null; then
2022-03-20 12:23:09 +01:00
echo "Please enable the multilib repository first"
exit 1
fi
2022-03-20 11:27:27 +01:00
# fix install problems
echo Updating keyring
2023-05-21 16:52:53 +02:00
sudo pacman -Sy --noconfirm archlinux-keyring
echo Updating repos and packages
2023-05-21 16:47:30 +02:00
sudo pacman -Syu
echo Select packages to install
2022-03-20 11:24:29 +01:00
# remove previously selected packages on reruns
if [ -f "$setupdir/selectedpkgs.txt" ]; then
rm "$setupdir/selectedpkgs.txt"
fi
if [ -f "$setupdir/aurselectedpkgs.txt" ]; then
rm "$setupdir/aurselectedpkgs.txt"
fi
2020-06-12 16:23:06 +02:00
cmd=(dialog --separate-output --checklist "Select Desktop environment/Window manager:" 22 76 16)
options=(100 "[WM] sway" off)
2020-06-12 16:23:06 +02:00
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
clear
2023-01-13 11:51:24 +01:00
for choice in $choices; do
2020-06-12 16:23:06 +02:00
case $choice in
2021-03-15 14:31:35 +01:00
100)
2023-12-03 14:19:53 +01:00
printf '%s\n' 'sway' 'swaylock' 'swayidle' 'swaybg' 'xorg-xwayland' 'xdg-desktop-portal-wlr' 'xdg-desktop-portal-gtk' 'qt5-wayland' 'qt6-wayland' >> "$setupdir/selectedpkgs.txt"
;;
2020-06-12 16:23:06 +02:00
esac
done
2020-05-07 08:43:48 +02:00
2020-06-14 18:00:55 +02:00
cmd=(dialog --separate-output --checklist "Select browsers:" 22 76 16)
2023-01-13 11:51:24 +01:00
options=(0 "Firefox" on # any option can be set to default to "on"
10 "Chromium" off
20 "Torbrowser" off)
2020-06-14 18:00:55 +02:00
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
clear
2023-01-13 11:51:24 +01:00
for choice in $choices; do
2020-06-14 18:00:55 +02:00
case $choice in
2021-03-15 14:31:06 +01:00
0)
2022-06-05 16:23:05 +02:00
echo "firefox" >> "$setupdir/selectedpkgs.txt"
2020-06-14 18:00:55 +02:00
;;
2021-03-15 14:31:06 +01:00
10)
2022-06-05 16:23:05 +02:00
echo "chromium" >> "$setupdir/selectedpkgs.txt"
2020-06-14 18:00:55 +02:00
;;
2021-03-15 14:31:06 +01:00
20)
2022-06-05 16:23:05 +02:00
echo "torbrowser-launcher" >> "$setupdir/selectedpkgs.txt"
2020-06-21 22:16:27 +02:00
;;
2020-06-14 18:00:55 +02:00
esac
done
cmd=(dialog --separate-output --checklist "Select other programs:" 22 76 16)
2023-01-13 11:51:24 +01:00
options=(0 "VirtManager" off # any option can be set to default to "on"
1 "VMWare Workstation" off
10 "Steam" off
11 "Lutris" off
12 "Citra" off
20 "Krita" off
21 "Gimp" off
31 "YT-dlp" on
32 "Megatools" off
40 "Handbrake" off
41 "Audacity" off
42 "k3b" off
2023-11-25 15:07:40 +01:00
43 "kid3" off
2023-01-13 11:51:24 +01:00
60 "Discord" on
2023-11-17 16:46:03 +01:00
61 "Element" off
62 "Telegram" off
2023-01-13 11:51:24 +01:00
70 "TestSSL" off
80 "Onedriver" off)
2020-06-12 16:23:06 +02:00
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
clear
2023-01-13 11:51:24 +01:00
for choice in $choices; do
2020-06-12 16:23:06 +02:00
case $choice in
2021-03-15 14:30:36 +01:00
0)
2024-04-12 21:37:44 +02:00
printf '%s\n' 'qemu' 'virt-manager' 'ebtables' 'dnsmasq' 'edk2-ovmf' >> "$setupdir/selectedpkgs.txt"
2020-06-12 16:23:06 +02:00
;;
2021-03-20 14:00:52 +01:00
1)
2022-06-05 16:23:05 +02:00
echo "vmware-workstation" >> "$setupdir/aurselectedpkgs.txt"
2021-03-20 14:00:52 +01:00
;;
2021-03-15 14:26:47 +01:00
10)
2022-06-05 16:23:05 +02:00
printf '%s\n' 'steam' 'steam-native-runtime' >> "$setupdir/selectedpkgs.txt"
2020-06-12 16:23:06 +02:00
;;
2021-03-15 14:26:47 +01:00
11)
2022-06-05 16:23:05 +02:00
echo "lutris" >> "$setupdir/selectedpkgs.txt"
2020-06-12 16:23:06 +02:00
;;
2021-05-14 13:37:24 +02:00
12)
2023-01-13 11:51:24 +01:00
echo "citra-qt-git" >>"$setupdir/aurselectedpkgs.txt"
2021-05-14 13:37:24 +02:00
;;
2021-03-15 14:26:47 +01:00
20)
2022-06-05 16:23:05 +02:00
echo "krita" >> "$setupdir/selectedpkgs.txt"
2020-06-12 16:23:06 +02:00
;;
2021-03-15 14:26:47 +01:00
21)
2022-06-05 16:23:05 +02:00
echo "gimp" >> "$setupdir/selectedpkgs.txt"
2021-03-15 14:26:47 +01:00
;;
2021-10-18 17:36:46 +02:00
31)
2023-12-17 20:10:47 +01:00
printf '%s\n' 'yt-dlp' >>"$setupdir/aurselectedpkgs.txt"
2021-10-18 17:36:46 +02:00
;;
2021-12-29 09:05:24 +01:00
32)
2023-01-13 11:51:24 +01:00
echo "megatools-bin" >>"$setupdir/aurselectedpkgs.txt"
2021-12-29 09:05:24 +01:00
;;
2021-03-15 14:26:47 +01:00
40)
2023-01-13 11:51:24 +01:00
echo "handbrake" >>"$setupdir/selectedpkgs.txt"
2020-06-12 16:23:06 +02:00
;;
2021-03-15 14:26:47 +01:00
41)
echo "audacity" >>"$setupdir/selectedpkgs.txt"
2020-06-12 16:23:06 +02:00
;;
42)
2023-01-13 11:51:24 +01:00
printf '%s\n' 'k3b' 'cdparanoia' 'cdrdao' 'cdrtools' 'dvd+rw-tools' 'emovix' 'transcode' 'vcdimager' >>"$setupdir/selectedpkgs.txt"
;;
2023-11-25 15:07:40 +01:00
43)
echo "kid3" >>"$setupdir/selectedpkgs.txt"
;;
2021-03-15 14:26:47 +01:00
60)
echo "discord" >>"$setupdir/selectedpkgs.txt"
;;
2021-03-15 14:26:47 +01:00
61)
2023-01-13 11:51:24 +01:00
echo "element-desktop" >>"$setupdir/selectedpkgs.txt"
2020-07-30 17:01:12 +02:00
;;
2021-03-15 14:26:47 +01:00
62)
2023-01-13 11:51:24 +01:00
echo "telegram-desktop" >>"$setupdir/selectedpkgs.txt"
;;
2022-01-04 13:41:47 +01:00
70)
2023-01-13 11:51:24 +01:00
echo "testssl.sh" >>"$setupdir/selectedpkgs.txt"
2022-01-04 13:41:47 +01:00
;;
2022-10-06 13:56:40 +02:00
80)
2023-01-13 11:51:24 +01:00
echo "onedriver" >>"$setupdir/aurselectedpkgs.txt"
2022-06-05 16:23:05 +02:00
esac
done
in_acpufreq=0
cmd=(dialog --separate-output --checklist "Performance and Battery life" 22 76 16)
options=(0 "auto-cpufreq" off
1 "corectrl" off)
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
clear
for choice in $choices
do
case $choice in
0)
in_acpufreq=1
echo "auto-cpufreq-git" >> "$setupdir/aurselectedpkgs.txt"
# TODO Handle rest of installation
;;
1)
echo "corectrl" >> "$setupdir/aurselectedpkgs.txt"
2022-10-06 13:56:40 +02:00
;;
2020-06-12 16:23:06 +02:00
esac
done
in_doomemacs=0
2021-03-31 15:21:23 +02:00
in_podman=0
2020-09-07 19:50:09 +02:00
2021-03-31 15:21:23 +02:00
cmd=(dialog --separate-output --checklist "Devtools" 22 76 16)
2021-03-15 14:32:50 +01:00
options=(0 "doom-emacs" off
2023-01-13 11:51:24 +01:00
10 "Podman" off)
2020-09-07 19:50:09 +02:00
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
clear
2023-01-13 11:51:24 +01:00
for choice in $choices; do
2020-09-07 19:50:09 +02:00
case $choice in
2021-03-15 14:32:50 +01:00
0)
in_doomemacs=1
# TODO sort pacman and AUR packages
2022-01-20 09:01:00 +01:00
# pychecker not in AUR anymore
printf '%s\n' 'git' 'emacs-wayland' 'ripgrep' 'fd' 'pandoc' 'shellcheck' 'python-pipenv' 'python-isort' 'python-pytest' 'python-rednose' 'pychecker' 'texlive-core' 'pyright' 'python-grip' 'prettier' 'shfmt' >>"$setupdir/aurselectedpkgs.txt"
# TODO handle rest of installation
2020-09-07 19:50:09 +02:00
;;
2021-03-31 15:21:23 +02:00
10)
in_podman=1
;;
2020-09-07 19:50:09 +02:00
esac
done
2020-07-17 21:14:06 +02:00
cmd=(dialog --separate-output --checklist "Report installed packages?" 22 76 16)
2021-03-15 14:34:30 +01:00
options=(0 "pkgstats" off)
2020-07-17 21:14:06 +02:00
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
clear
2023-01-13 11:51:24 +01:00
for choice in $choices; do
2020-07-17 21:14:06 +02:00
case $choice in
2021-03-15 14:34:30 +01:00
0)
2023-01-13 11:51:24 +01:00
echo "pkgstats" >>"$setupdir/selectedpkgs.txt"
2020-07-17 21:14:06 +02:00
;;
esac
done
2022-06-05 16:23:05 +02:00
: '
# Packages installed on different systems
in_arco_pc=0
in_arco_hp=0
cmd=(dialog --separate-output --checklist "Install system specific packages?" 22 76 16)
options=(1 "Arco PC" off
2023-01-13 11:51:24 +01:00
2 "Arco HP" off)
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
clear
2023-01-13 11:51:24 +01:00
for choice in $choices; do
case $choice in
1)
in_arco_pc=1
;;
2)
in_arco_hp=1
;;
esac
done
2022-06-05 16:23:05 +02:00
'
2023-11-17 16:47:58 +01:00
if [ -f "$setupdir/notfoundpackages.txt" ]; then
rm "$setupdir/notfoundpackages.txt"
fi
2023-05-21 18:38:12 +02:00
2023-05-21 18:41:46 +02:00
# NOTE on unattended pacman installing
# Option 1: Will assume the default choice
#--noconfirm
# Option 2: Will always choose "yes", locale override needed to work all the time (might fail for other locales)
#yes | LC_ALL=en_US.UTF-8 pacman ...
#
# excpect & send
#uninstalling unused packages
echo Uninstalling unused packages
2023-11-17 16:49:52 +01:00
set +e
while read package; do
2023-05-21 18:46:30 +02:00
sudo pacman -Rns --noconfirm "$package"
done <"$setupdir/packages/uninstall.txt"
2023-11-17 16:49:52 +01:00
set -e
2022-06-05 16:23:05 +02:00
echo Uninstalled unused packages
2023-11-17 19:45:59 +01:00
# explicitly install pipewire first
sudo pacman -S --needed pipewire wireplumber pipewire-jack pipewire-pulse pipewire-alsa
#pacman programs
2020-06-12 16:23:06 +02:00
echo Installing default pacman programs
#sudo pacman -S --needed - <"$setupdir/packages/officialpkgs.txt"
while read package; do
2023-05-21 18:46:30 +02:00
sudo pacman -S --needed --noconfirm "$package" || echo "$package" >>"$setupdir/notfoundpackages.txt"
done <"$setupdir/packages/officialpkgs.txt"
2020-06-12 16:23:06 +02:00
echo Installed official programs
2020-05-07 08:43:48 +02:00
#install wine
echo Installing wine
#sudo pacman -S --needed - <"$setupdir/packages/winepkgs.txt"
while read package; do
2023-05-21 18:46:30 +02:00
sudo pacman -S --needed --noconfirm "$package" || echo "$package" >>"$setupdir/notfoundpackages.txt"
done <"$setupdir/packages/winepkgs.txt"
echo Installed wine
2023-05-21 19:26:19 +02:00
# install paru-bin
2022-06-05 16:23:05 +02:00
if [[ ! $(pacman -Q paru) ]]; then
2023-05-21 19:26:19 +02:00
echo "Installing paru from the AUR"
2022-03-25 21:45:55 +01:00
git clone https://aur.archlinux.org/paru-bin.git
cd paru-bin
2023-11-17 16:58:46 +01:00
makepkg -si
2021-03-09 11:45:34 +01:00
cd ..
2021-03-09 11:39:24 +01:00
fi
# AUR
2020-06-12 16:23:06 +02:00
echo Installing default AUR programs
2023-01-13 11:51:24 +01:00
paru -S --needed - <"$setupdir/packages/aurpkgs.txt"
# TODO for btrfsmaintenance, use btrfsmaintenance (1)
# TODO for jellyfin-media-player, use jellyfin-media-player (1)
2023-11-17 17:03:10 +01:00
# TODO sublimme-music (1)
# TODO for ttf-iosevka, use ttf-iosevka (1)
# TODO for ttf-ms-fonts, use ttf-ms-fonts (1)
# TODO for ttf-vista-fonts, use ttf-vista-fonts (1)
2023-11-17 17:17:04 +01:00
# TODO nohang (1)
2020-06-12 16:23:06 +02:00
echo Installed AUR programs
2020-03-01 10:38:40 +01:00
2023-05-21 16:52:53 +02:00
# theming
echo Installing themes and icons
paru -S --needed - <"$setupdir/packages/theme-packages.txt"
echo Installed themes and icons
###################
#selected programs#
###################
echo Installing selected programs
# install selected packages
if [ -f "$setupdir/selectedpkgs.txt" ]; then
echo Installing from official repository
# NOTE || true to continue if no packages have been selected
2023-05-21 20:08:27 +02:00
sudo pacman -S --needed --noconfirm - <"$setupdir/selectedpkgs.txt" || true
fi
# install selected aur packages
if [ -f "$setupdir/aurselectedpkgs.txt" ]; then
echo Installing from AUR
# NOTE || true to continue if no packages have been selected
2023-05-21 16:47:30 +02:00
paru -S --needed - <"$setupdir/aurselectedpkgs.txt" || true
fi
2022-06-05 16:23:05 +02:00
#performance and battery life
if [ $in_acpufreq -eq 1 ]; then
echo "Installing auto-cpufreq"
paru -S --needed auto-cpufreq-git
sudo auto-cpufreq --install
sudo systemctl start auto-cpufreq
sudo systemctl enable auto-cpufreq
fi
2021-03-31 15:21:23 +02:00
#devtools
if [ $in_doomemacs -eq 1 ]; then
2020-09-07 19:50:09 +02:00
echo "Installing doom-emacs"
2023-11-24 16:29:44 +01:00
# doom emacs
sudo pacman -S --needed emacs-wayland git
# unsorted
paru -S --needed fd pandoc python-pipenv python-isort python-pytest texlive-core clang
# python
2023-12-06 17:32:06 +01:00
sudo pacman -S --needed pyright python-black python-debugpy python-pyflakes
2023-11-24 16:29:44 +01:00
# shell
sudo pacman -S --needed shellcheck bash-language-server shfmt
# markdown
sudo pacman -S --needed prettier
# debugger
sudo pacman -S --needed nodejs lldb lldb-mi gdb unzip
# docker
2023-12-06 17:32:06 +01:00
paru -S --needed dockerfile-language-server dockfmt
2023-11-24 16:29:44 +01:00
# lookup
sudo pacman -S --needed ripgrep
# terraform
sudo pacman -S --needed terraform
# grammar
sudo pacman -S --needed languagetool
2023-12-06 17:32:06 +01:00
# php
sudo pacman -S --needed php composer
# web
sudo pacman -S --needed tidy stylelint
paru -S --needed js-beautify
2023-11-24 16:29:44 +01:00
# rest of installation
2023-11-17 17:45:23 +01:00
rm -rf ~/.config/emacs
2023-11-17 17:35:01 +01:00
git clone --depth 1 https://github.com/doomemacs/doomemacs ~/.config/emacs
~/.config/emacs/bin/doom install
export PATH="$PATH":$HOME/.config/emacs/bin
2020-09-07 19:50:09 +02:00
fi
2021-03-31 15:21:23 +02:00
if [ $in_podman -eq 1 ]; then
echo "Installing podman"
2024-04-12 16:27:14 +02:00
sudo pacman -S --needed podman fuse-overlayfs buildah aardvark-dns
2021-03-31 15:21:23 +02:00
sudo touch /etc/subuid /etc/subgid
sudo usermod --add-subuids 100000-165536 --add-subgids 100000-165536 "$USER"
sudo groupadd -f podman
sudo usermod -aG podman "$USER"
2021-03-31 15:21:23 +02:00
fi
# other system configs
2023-11-17 17:43:46 +01:00
: '
# arco pc
if [ $in_arco_pc -eq 1 ]; then
echo "Installing arco pc packages"
2023-01-13 11:51:24 +01:00
paru -S --needed - <"$setupdir/packages/lupusregina-packages.txt"
fi
# arco hp
if [ $in_arco_hp -eq 1 ]; then
2021-03-01 09:42:38 +01:00
echo "Installing arch hp packages"
2023-01-13 11:51:24 +01:00
paru -S --needed - <"$setupdir/packages/arch-hp-packages.txt"
fi
2023-11-17 17:43:46 +01:00
'
2023-02-24 15:00:55 +01:00
# install nix
2023-05-21 16:44:09 +02:00
#curl -sSf -L https://install.determinate.systems/nix | sh -s -- install
2023-02-24 15:00:55 +01:00
##############################
##### Configuration #####
##############################
2022-06-05 16:23:05 +02:00
echo Configuring packages
2020-09-27 14:06:50 +02:00
#change shell
2020-09-27 14:07:43 +02:00
chsh -s /usr/bin/fish "$USER"
2020-09-27 14:06:50 +02:00
# setup autotrash
2023-11-17 18:02:15 +01:00
#autotrash -td 5 --install
#systemctl --user enable autotrash.timer
2022-06-05 16:23:05 +02:00
#enable vnstat
sudo systemctl enable --now vnstat
2021-03-09 08:53:57 +01:00
# enable lockscreen for systemd
2022-06-05 16:23:05 +02:00
#sudo systemctl enable betterlockscreen@$USER
2021-03-09 08:53:57 +01:00
2020-11-17 15:34:39 +01:00
# enable firewall
echo "Enabling Firewall"
2021-11-06 14:06:55 +01:00
sudo systemctl enable --now firewalld
2022-07-20 11:27:44 +02:00
# || true because firewalld doesn't work without a reboot
sudo firewall-cmd --zone=public --permanent --remove-service=ssh || true
2020-11-17 15:34:39 +01:00
2023-11-17 15:49:05 +01:00
# enable gdm
sudo systemctl enable gdm
2021-01-23 19:54:05 +01:00
2021-03-17 15:54:09 +01:00
# regenerate locale
# Fixes rofi not launching
2022-06-05 16:23:05 +02:00
#sudo locale-gen
2021-03-17 15:54:09 +01:00
2022-06-05 21:20:29 +02:00
: '
2022-06-05 21:02:01 +02:00
if [[ $(pacman -Q | grep sway) ]]; then
2022-06-05 20:54:39 +02:00
sudo systemctl enable --now seatd.service
2022-06-05 21:04:53 +02:00
sudo gpasswd -a "$USER" seat 1>/dev/null
2022-06-05 20:54:39 +02:00
fi
2022-06-05 21:20:29 +02:00
'
2022-06-05 20:54:39 +02:00
2020-12-20 21:05:09 +01:00
# update fonts cache
fc-cache -f
2020-04-16 08:51:26 +02:00
echo Setting config
2023-11-17 18:19:47 +01:00
# FIXME not found
bash "$setupdir/../arch-config/install.sh"
2021-01-29 19:58:32 +01:00
2023-01-13 11:51:24 +01:00
if [[ $(pacman -Q pkgstats 2>/dev/null >/dev/null) ]]; then
2021-01-29 19:58:32 +01:00
pkgstats
fi
2020-07-30 11:00:22 +02:00
echo Finished everything
2020-11-17 21:09:57 +01:00
exit 0