2017-02-12 11:41:03 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Setups an Arch Linux system the way I like it
|
|
|
|
# (requires sudo)
|
|
|
|
|
2017-11-02 16:48:43 +01:00
|
|
|
if ! which pacman &> /dev/null; then
|
2017-02-12 11:41:03 +01:00
|
|
|
echo "This is not an Arch Linux system (or pacman isn't installed)"
|
2017-11-02 16:48:43 +01:00
|
|
|
exit 1
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Configuration
|
|
|
|
function prompt { # text
|
|
|
|
while true; do
|
|
|
|
read -p "$1 [yn] " yn
|
|
|
|
case $yn in
|
|
|
|
[Yy]* ) return 1;;
|
|
|
|
[Nn]* ) return 0;;
|
|
|
|
* ) echo "Please answer yes or no.";;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Don't ask for things that are already there
|
2017-11-02 16:48:43 +01:00
|
|
|
if which pacaur &> /dev/null; then
|
|
|
|
PACAUR=1
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
if which bauerbill &> /dev/null; then
|
2017-11-02 16:48:43 +01:00
|
|
|
BAUERBILL=1
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
|
2017-11-02 16:48:43 +01:00
|
|
|
if [ -z $PACAUR ]; then
|
|
|
|
prompt "Do you want pacaur on this machine?"
|
|
|
|
PACAUR=$?
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
2017-11-02 16:48:43 +01:00
|
|
|
if [ $PACAUR == 1 ]; then
|
2017-02-12 11:41:03 +01:00
|
|
|
if [ -z $BAUERBILL ]; then
|
|
|
|
prompt "Do you want bauerbill on this machine?"
|
2017-11-02 16:48:43 +01:00
|
|
|
BAUERBILL=$?
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
BAUERBILL=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# COMMON
|
|
|
|
|
|
|
|
# Install packages if they aren't installed
|
|
|
|
function inst {
|
|
|
|
for pkg in $*; do
|
|
|
|
pacman -Q $pkg &> /dev/null
|
|
|
|
if [ $? == 1 ]; then
|
|
|
|
sudo pacman -S $pkg --noconfirm
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Install package from PKGBUILD file
|
|
|
|
function installPKGBUILD { # url
|
2017-11-02 16:48:43 +01:00
|
|
|
# TODO Download snapshots
|
2017-02-12 11:41:03 +01:00
|
|
|
TMP_DIR="$(mktemp -d /tmp/pkgbuild.XXXXXXXXXX)"
|
|
|
|
cd "$TMP_DIR"
|
|
|
|
wget "$1" -O PKGBUILD
|
2017-11-02 16:48:43 +01:00
|
|
|
makepkg -si --noconfirm
|
2017-02-12 11:41:03 +01:00
|
|
|
cd -
|
|
|
|
rm -rf "$TMP_DIR"
|
|
|
|
}
|
|
|
|
|
|
|
|
# SYSTEM
|
|
|
|
inst wget
|
|
|
|
|
2017-11-02 16:48:43 +01:00
|
|
|
# Aur
|
|
|
|
|
|
|
|
pacman -Q pacaur &> /dev/null
|
|
|
|
if [[ $PACAUR == 1 && $? == 1 ]]; then
|
|
|
|
installPKGBUILD "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=cower"
|
|
|
|
installPKGBUILD "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=pacaur"
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
|
2017-11-02 16:48:43 +01:00
|
|
|
# Git for /etc
|
|
|
|
sudo pacman -S etckeeper --noconfirm --needed
|
|
|
|
sudo etckeeper init
|
|
|
|
sudo etckeeper commit "~/.dotfiles/scripts/install-arch commit"
|
|
|
|
|
|
|
|
# Uninstall Manjaro's pamac
|
|
|
|
if pacman -Q pamac &> /dev/null ; then
|
|
|
|
sudo pacman -Rsc pamac --noconfirm
|
2017-02-12 11:41:03 +01:00
|
|
|
fi
|
|
|
|
|
2017-11-02 16:48:43 +01:00
|
|
|
# Ccache
|
|
|
|
sudo pacman -S ccache --noconfirm --needed
|
|
|
|
sudo sed 's|BUILDENV=\(.\+\)!ccache\(.\+\)|BUILDENV=\1ccache\2|' /etc/makepkg.conf -i
|
|
|
|
|
|
|
|
# Bauerbill
|
2017-02-12 11:41:03 +01:00
|
|
|
pacman -Q bauerbill &> /dev/null
|
|
|
|
if [[ $BAUERBILL == 1 && $? == 1 ]]; then
|
2017-11-02 16:48:43 +01:00
|
|
|
sudo pacman -Sy
|
2017-02-12 11:41:03 +01:00
|
|
|
|
|
|
|
gpg --recv-keys 1D1F0DC78F173680
|
|
|
|
installPKGBUILD http://xyne.archlinux.ca/projects/reflector/pkgbuild/PKGBUILD
|
2017-11-02 16:48:43 +01:00
|
|
|
pacaur -S bauerbill --noconfirm --noedit
|
2017-02-12 11:41:03 +01:00
|
|
|
|
2017-11-02 16:48:43 +01:00
|
|
|
bauerbill -Su --noconfirm
|
2017-02-12 11:41:03 +01:00
|
|
|
else
|
|
|
|
sudo pacman -Syu
|
|
|
|
fi
|
|
|
|
|
|
|
|
# TLP
|
2017-11-02 16:48:43 +01:00
|
|
|
sudo pacman -S tlp --noconfirm --needed
|
|
|
|
sudo sed 's|SATA_LINKPWR_ON_BAT=min_power|SATA_LINKPWR_ON_BAT=max_performance|' /etc/default/tlp -i
|
|
|
|
sudo systemctl enable tlp.service tlp-sleep.service
|
|
|
|
sudo systemctl disable systemd-rfkill.service systemd-rfkill.socket
|
|
|
|
sudo tlp start
|
|
|
|
|
|
|
|
# Numlock on boot
|
|
|
|
echo -e "[Service]\nExecStartPre=/bin/sh -c 'setleds +num < /dev/%I'" | sudo systemctl edit getty\@.service
|
|
|
|
|
|
|
|
# Makeflags
|
|
|
|
sudo sed "s|#MAKEFLAGS=\"-j2\"|MAKEFLAGS=\"-j$(nproc)\"|" /etc/makepkg.conf -i
|
|
|
|
|
|
|
|
# Time synchronisation
|
|
|
|
sudo pacman -S ntp --noconfirm --needed
|
|
|
|
sudo systemctl start ntpd
|
|
|
|
sudo systemctl enable ntpd
|
|
|
|
|
|
|
|
# MANUAL
|
|
|
|
|
|
|
|
# Hibernation
|
|
|
|
# Add resume=UUID=<UUID-of-swap-partition> to GRUB_CMDLINE_LINUX_DEFAULT and run `sudo grub-mkconfig -o /boot/grub/grub.cfg`
|
2017-02-12 11:41:03 +01:00
|
|
|
|