dotfiles/install_root.sh

75 lines
2.5 KiB
Bash
Raw Normal View History

2023-07-31 19:53:14 +00:00
#!/bin/bash
set -euo pipefail
2023-07-31 20:04:24 +00:00
# Arch installation script to be ran during OS installation, after chroot.
2023-07-31 20:04:51 +00:00
# $ arch-chroot /mnt
# $ pacman -S git
# $ git clone https://github.com/ItsDrike/dotfiles ~/dots
# $ cd ~/dots
# $ ./install_root.sh
2023-07-31 20:04:24 +00:00
# -----------------------------------------------------------------------
2023-07-31 19:53:14 +00:00
if [ "$UID" != 0 ]; then
echo >&2 "The script must be ran as root (after arch installation)!"
exit 1
fi
# cd into the dotfiles dir, no matter where the script was called from
pushd "$(dirname "$0")"
# Sync mirrors and update before other installations
pacman -Syu --noconfirm
2023-07-31 19:53:14 +00:00
# Install essential packages
2023-08-02 12:42:56 +00:00
pacman -S --noconfirm --needed \
networkmanager neovim sudo reflector pacman-contrib man-db man-pages rsync btop bind tldr base-devel git pkgfile
2023-07-31 19:53:14 +00:00
# Install packages necessary for this script / other scripts in this dotfiles repo
2023-08-02 12:42:56 +00:00
pacman -S --noconfirm --needed python-rich bc lua jq bat
2023-07-31 19:53:14 +00:00
# Copy over system configuration data
cp root/etc/pacman.conf /etc
cp root/etc/hosts /etc
HOSTNAME="$(cat /etc/hostname)"
sed -i "s/^127.0.1.1 pc.localdomain pc/127.0.1.1 ${HOSTNAME}.localdomain ${HOSTNAME}/g" /etc/locale.gen
2023-07-31 19:53:14 +00:00
install -m 640 root/etc/sudoers /etc
install -m 640 root/etc/sudoers.d/* /etc/sudoers.d
cp root/etc/modprobe.d/nobeep.conf /etc/modprobe.d # disable motherboard speaker
cp root/etc/sysctl.d/* /etc/sysctl.d # override some kernel parameters with more sensible values
cp -r root/etc/xdg/reflector /etc/xdg
cp -r root/usr/local/bin /usr/local
cp root/.rsync-filter /
# Sync pacman repos after /etc/pacman.conf got updated
sudo pacman -Sy
# Install zsh and make it the default shell for root
2024-02-17 21:45:42 +00:00
sudo pacman -S --noconfirm --needed zsh zoxide
chsh -s /usr/bin/zsh root
2023-07-31 19:53:14 +00:00
# Copy ZSH shell configuration
2023-08-02 00:29:54 +00:00
mkdir -p /etc/zsh
2023-08-02 12:46:23 +00:00
cp -ra root/etc/zsh /etc
2023-07-31 19:56:22 +00:00
mkdir -p ~/.config
2023-07-31 19:53:14 +00:00
cp -ra home/.config/shell ~/.config
cp -ra home/.config/zsh ~/.config
rm ~/.config/shell/py-alias # we don't need pyenv python aliases for root
rm -rf ~/.config/zsh/.zgenom
git clone https://github.com/jandamm/zgenom ~/.config/zsh/.zgenom
install -m 700 -d ~/.local/share/gnupg
# Enable some basic services
systemctl enable systemd-resolved
2023-12-29 14:07:57 +00:00
systemctl enable systemd-timesyncd
2023-07-31 19:53:14 +00:00
systemctl enable NetworkManager
2023-12-29 14:07:57 +00:00
systemctl mask systemd-networkd # We have NetworkManager for this
2023-07-31 19:53:14 +00:00
systemctl enable paccache.timer
systemctl enable reflector.timer
systemctl enable pkgfile-update.timer
echo "You can exit the chroot and re-run it with: arch-chroot /mnt zsh"
echo "This will put you into a configured ZSH shell, you can continue" \
"configuring the rest of the system manually from there"
popd