dotfiles/scripts/installArch.sh

112 lines
2.6 KiB
Bash
Raw Normal View History

2016-12-04 17:24:46 +01:00
#!/usr/bin/env bash
# Setups an Arch Linux system the way I like it
# (sourceable, requires sudo)
2016-12-06 15:57:36 +01:00
if which pacman &> /dev/null; then
2016-12-04 17:24:46 +01:00
# Not an Arch system
return 0
fi
# Configuration
function install-arch {
# 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
2016-12-06 15:57:36 +01:00
if which yaourt &> /dev/null; then
2016-12-04 17:24:46 +01:00
local YAOURT=1
fi
2016-12-06 15:57:36 +01:00
if which bauerbill &> /dev/null; then
2016-12-04 17:24:46 +01:00
local BAUERBILL=1
fi
if [ -z $YAOURT ]; then
prompt "Do you want yaourt on this machine?"
local YAOURT=$?
fi
2016-12-19 10:11:19 +01:00
if [ $YAOURT == 1 ]; then
2016-12-04 17:24:46 +01:00
if [ -z $BAUERBILL ]; then
prompt "Do you want bauerbill on this machine?"
local BAUERBILL=$?
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
TMP_DIR="$(mktemp -d /tmp/pkgbuild.XXXXXXXXXX)"
cd "$TMP_DIR"
wget "$1" -O PKGBUILD
makepkg -si
cd -
rm -rf "$TMP_DIR"
}
# SYSTEM
inst wget
2016-12-06 15:57:36 +01:00
pacman -Q yaourt &> /dev/null
2016-12-19 10:11:19 +01:00
if [[ $YAOURT == 1 && $? == 1 ]]; then
2016-12-04 17:24:46 +01:00
installPKGBUILD "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=package-query"
installPKGBUILD "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=yaourt"
fi
2016-12-06 15:57:36 +01:00
if pacman -Q pamac ; then
2016-12-04 17:24:46 +01:00
sudo pacman -Rsc pamac
fi
2016-12-06 15:57:36 +01:00
pacman -Q bauerbill &> /dev/null
2016-12-19 10:11:19 +01:00
if [[ $BAUERBILL == 1 && $? == 1 ]]; then
2016-12-04 17:24:46 +01:00
sudo pacman -Sy manjaro-{hotfixes,keyring,release,system} --noconfirm
gpg --recv-keys 1D1F0DC78F173680
installPKGBUILD http://xyne.archlinux.ca/projects/reflector/pkgbuild/PKGBUILD
yaourt -S bauerbill --noconfirm
bb-wrapper -Su
# TODO Prompt if all went well, if not restart
else
sudo pacman -Syu
fi
# Disable predictable network names
sudo ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
2017-01-16 20:17:09 +01:00
# TLP
# sudo pacman -S tlp
# sudo systemctl enable tlp.service tlp-sleep.service
# sudo systemctl disable systemd-rfkill
2016-12-04 17:24:46 +01:00
# TODO
# make -j8 in MAKEPKG
# time
# nfs
# hibernate
}