dotfiles-old/.local/installers/artix/artix-install.sh

267 lines
7.7 KiB
Bash
Executable File

#!/bin/sh
GIT_REPOS_DIR="$HOME/.local/src/"
. ./programs.sh
#$1 -> repo name to enable
#$2 -> mirror list file name in /etc/pacman.d/ (default: mirrorlist)
#ex: enable_repo lib32
#ex: enable_repo community mirrorlist-arch
enable_repo() {
REPO="$1"
MIRRORLIST="mirrorlist"
[ "$2" ] && MIRRORLIST="$2"
if [ $# -gt 0 ] && [ -z "$(grep "^\[$1" /etc/pacman.conf)" ]; then
sudo sh -c "echo "[$REPO]" >> /etc/pacman.conf"
sudo sh -c "echo "Include\ =\ /etc/pacman.d/$MIRRORLIST" >> /etc/pacman.conf"
sudo sh -c "echo "" >> /etc/pacman.conf"
fi
}
enable_repos() {
#enable lib32
enable_repo lib32 mirrorlist
sudo pacman -Sy
#add arch linux repos
sudo pacman -S --noconfirm artix-archlinux-support lib32-artix-archlinux-support
sudo pacman-key --populate archlinux
sudo pacman -Sy
#enable artix universe repo
if [ -z "$(grep "universe" /etc/pacman.conf)" ]; then
sudo sh -c 'echo "[universe]" >> /etc/pacman.conf'
sudo sh -c 'echo "Server = https://universe.artixlinux.org/\$arch" >> /etc/pacman.conf'
sudo sh -c 'echo "Server = https://mirror1.artixlinux.org/universe/\$arch" >> /etc/pacman.conf'
sudo sh -c 'echo "Server = https://mirror.pascalpuffke.de/artix-universe/\$arch" >> /etc/pacman.conf'
sudo sh -c 'echo "Server = https://artixlinux.qontinuum.space:4443/universe/os/" >> /etc/pacman.conf'
sudo sh -c 'echo "Server = https://mirror1.cl.netactuate.com/artix/universe/\$arch" >> /etc/pacman.conf'
sudo sh -c 'echo "" >> /etc/pacman.conf'
fi
#ENABLE ARCH REPOSITORIES HERE
#enable arch community repo
enable_repo extra mirrorlist-arch
enable_repo community mirrorlist-arch
enable_repo multilib mirrorlist-arch
sudo pacman -Sy
#install yay for aur support
mkdir -p ~/.local/src/
git clone https://aur.archlinux.org/yay.git ~/.local/src/yay/
cd ~/.local/src/yay || return
makepkg -si
cd -
}
runit_setup() {
VIRTMGR=""
WIRELESS=""
for arg in "$@"
do
[ "$arg" = "--virt-manager" ] && VIRTMGR="true"
[ "$arg" = "--wireless" ] && WIRELESS="true"
done
sudo ln -s /etc/runit/sv/ufw /run/runit/service/
sudo ln -s /etc/runit/sv/cronie /run/runit/service/
sudo ln -s /etc/runit/sv/chrony /run/runit/service/
sudo ln -s /etc/runit/sv/connmand /run/runit/service/
sudo ln -s /etc/runit/sv/socklog /run/runit/service/
if [ "$VIRTMGR" ]; then
sudo ln -s /etc/runit/sv/libvirtd /run/runit/service
sudo ln -s /etc/runit/sv/virtlockd /run/runit/service
sudo ln -s /etc/runit/sv/virtlogd /run/runit/service
fi
if [ "$WIRELESS" ]; then
sudo ln -s /etc/runit/sv/tlp /run/runit/service/
sudo ln -s /etc/runit/sv/bluetoothd /run/runit/service/
fi
}
wireless() {
sudo pacman -S --noconfirm wpa_supplicant bluez bluez-utils tlp
sudo pacman -S --noconfirm wpa_supplicant-runit tlp-runit
runit_setup --wireless
}
configure() {
#setup home directories
mkdir ~/docs/
mkdir ~/dl/
mkdir ~/media/
mkdir -p ~/.local/share/gnupg/
mkdir -p ~/.config/mpd/playlists
mkdir -p ~/.local/share/desktop
#setup ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow http
sudo ufw allow https
#sudo ufw allow ssh
sudo ufw allow ntp
sudo ufw allow 67:68/tcp
sudo ufw allow 53
#allow torrent client traffic
sudo ufw allow 56881:56889/tcp
#rules to allow steam
sudo ufw allow 27000:27036/udp
sudo ufw allow 27036:27037/tcp
sudo ufw allow 4380/udp
sudo ufw enable
#install zsh shell
chsh -s /bin/zsh "$USER"
#setup .zprofile and zsh history file
cd ~ || return
ln -s ~/.profile ~/.zprofile
mkdir -p ~/.cache/zsh
touch ~/.cache/zsh/history
#replace sudo with doas
echo "installing doas, symlinking to sudo, and UNINSTALLING SUDO. sudo is uninstalled using doas so permissions should be setup right if you are able to uninstall. (y/N)"
read input
if [ "$input" = "y" ]; then
echo "permit persist $USER as root" >> ~/.cache/doas.conf
sudo cp ~/.cache/doas.conf /etc/doas.conf
rm ~/.cache/doas.conf
doas pacman -R sudo && doas ln -s /bin/doas /bin/sudo #TODO ARCH SPECIFIC
fi
#set limits for esync
sudo sh -c "echo '$USER hard nofile 524288' >> /etc/security/limits.conf"
#set limits for monero
sudo sh -c "echo '$USER hard memlock 2048' >> /etc/security/limits.conf"
sudo sh -c "echo '$USER hard memlock 2048' >> /etc/security/limits.conf"
sudo groupadd nogroup #needed to use slock
#fix issue with arduino ide and tiling wms
sudo sh -c 'echo "export _JAVA_AWT_WM_NONREPARENTING=1" >> /etc/profile.d/jre.sh'
#set console terminal font
sudo sh -c 'echo "FONT=Lat2-Terminus16" >> /etc/vconsole.conf'
#set grub theme
sudo sed -i 's/#GRUB_COLOR_NORMAL/GRUB_COLOR_NORMAL/g' /etc/default/grub
sudo sed -i 's/#GRUB_COLOR_HIGHLIGHT/GRUB_COLOR_HIGHLIGHT/g' /etc/default/grub
#download collapse OS
mkdir -p "$HOME"/.local/src/
cd "$HOME"/.local/src/
wget http://collapseos.org/files/collapseos-latest.tar.gz
cd -
#set wallpaper
ln -s ~/media/img/wallpapers/alena-aenami-eclipse-1k.jpg ~/.config/wall
#link Xresources for xwayland
ln -s ~/.config/Xresources ~/.Xdefaults
#set /tmp to tmpfs
if [ -z "$(grep "/tmp" /etc/fstab)" ]; then
sudo sh -c 'echo "tmpfs /tmp tmpfs rw,nodev,nosuid,size=2G 0 0" >> /etc/fstab'
fi
}
base() {
#enable repos (lib32, community, and universe) and install yay
enable_repos
#install all packages in $PKGS
sudo pacman --noconfirm --needed -S - < ./pkgs/base.list
#installl all packages in $AUR_PKGS
yay --noconfirm --needed -S - < ./pkgs/aur.list
#setup local git repos defined in $GIT_REPOS to $GIT_REPOS_DIR
sh ~/.local/scripts/install.sh add-repos ./pkgs/repos.list
#runit configuration
runit_setup
#configure programs, directories, change shell, etc
configure
#install microcode for CPU
echo "enter CPU type to install microcode for (amd intel)"
read input
if [ "$input" = "amd" ]; then
sudo pacman -S amd-ucode
elif [ "$input" = "intel" ]; then
sudo pacman -S intel-ucode
fi
#rebuild kernel after install for microcode
sudo mkinitcpio -P #rebuild kernel
sudo grub-mkconfig -o /boot/grub/grub.cfg #update grub
echo "installation finished"
}
help() {
echo " artix-install.sh"
echo " --base perform basic install. Enable repos, install programs"
echo " --gaming install steam and lutris. Use flags --amd, --nvidia, --intel to install"
echo " with corresponding graphics drivers. Otherwise you will be prompted"
echo " --virt-manager install virt-manager"
echo " --wireless install/setup programs for wifi/bluetooth"
echo " --ungoogled-chromium install ungoogled-chromium. also installs chrome-web-store and ublock origin"
}
BASE=""
GAMING=""
WIRELESS=""
UNGOOGLED_CHROMIUM=""
VIRT_MANAGER=""
for arg in "$@"
do
[ "$arg" = "--base" ] && BASE="true"
[ "$arg" = "--gaming" ] && GAMING="true"
[ "$arg" = "--virt-manager" ] && VIRTMGR="true"
[ "$arg" = "--wireless" ] && WIRELESS="true"
[ "$arg" = "--ungoogled-chromium" ] && UNGOOGLED_CHROMIUM="true"
[ "$arg" = "--help" ] && help && exit
done
[ "$#" = "0" ] && help && exit
[ "$BASE" ] && base
[ "$GAMING" ] && gaming "$@"
[ "$WIRELESS" ] && wireless
[ "$UNGOOGLED_CHROMIUM" ] && ungoogled_chromium "$@"
[ "$VIRT_MANAGER" ] && virt_manager