Improved install scripts
Due to unforeseen events :/
This commit is contained in:
parent
8ec06d3618
commit
73cbcbb3f5
9 changed files with 176 additions and 96 deletions
|
@ -1,105 +1,157 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Setups an Arch Linux system the way I like it
|
||||
# (requires sudo)
|
||||
|
||||
if ! which pacman &> /dev/null; then
|
||||
echo "This is not an Arch Linux system (or pacman isn't installed)"
|
||||
exit 1
|
||||
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
|
||||
if which aurman &> /dev/null; then
|
||||
AURMAN=1
|
||||
fi
|
||||
if [ -z $AURMAN ]; then
|
||||
prompt "Do you want aurman on this machine?"
|
||||
AURMAN=$?
|
||||
fi
|
||||
# COMMON
|
||||
|
||||
# Install packages if they aren't installed
|
||||
function inst {
|
||||
# Could also use --needed but, meh
|
||||
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
|
||||
# TODO Download snapshots
|
||||
TMP_DIR="$(mktemp -d /tmp/pkgbuild.XXXXXXXXXX)"
|
||||
cd "$TMP_DIR"
|
||||
wget "$1" -O PKGBUILD
|
||||
makepkg -si --noconfirm
|
||||
cd -
|
||||
rm -rf "$TMP_DIR"
|
||||
}
|
||||
|
||||
# SYSTEM
|
||||
inst wget
|
||||
|
||||
# Aur
|
||||
|
||||
pacman -Q aurman &> /dev/null
|
||||
if [[ $AURMAN == 1 && $? == 1 ]]; then
|
||||
gpg --recv-keys 465022E743D71E39
|
||||
installPKGBUILD "https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=aurman"
|
||||
fi
|
||||
|
||||
# Git for /etc
|
||||
inst etckeeper
|
||||
sudo etckeeper init
|
||||
sudo pacman -S etckeeper --needed
|
||||
(cd /etc/; sudo git config user.name "etckeeper on $(cat /etc/hostname)"; sudo git config user.email "etckeeper@$(cat /etc/hostname)")
|
||||
sudo etckeeper commit "~/.dotfiles/scripts/install-arch commit"
|
||||
[ ! -d /etc/.git ] && sudo etckeeper init
|
||||
sudo etckeeper commit "install-arch script: begin"
|
||||
|
||||
# Install yay
|
||||
if ! pacman -Q yay &> /dev/null
|
||||
then
|
||||
mkdir -p $HOME/.cache/yay/yay
|
||||
cd $HOME/.cache/yay/yay
|
||||
curl -L https://aur.archlinux.org/cgit/aur.git/snapshot/yay.tar.gz | tar xzvf
|
||||
makepkg -si
|
||||
fi
|
||||
|
||||
# Keyboard layout
|
||||
echo '# File wrote by ~/.dotfiles/config/scripts/install-arch
|
||||
|
||||
Section "InputClass"
|
||||
Identifier "system-keyboard"
|
||||
MatchIsKeyboard "on"
|
||||
Option "XkbLayout" "us_qwerty-fr"
|
||||
EndSection
|
||||
' | sudo tee /etc/X11/xorg.conf.d/00-keyboard.conf
|
||||
|
||||
# Backlight (for Intel Devices)
|
||||
echo '# File wrote by ~/.dotfiles/config/scripts/install-arch
|
||||
|
||||
Section "Device"
|
||||
Identifier "Intel Graphics"
|
||||
Driver "intel"
|
||||
Option "Backlight" "intel_backlight"
|
||||
EndSection
|
||||
' | sudo tee /etc/X11/xorg.conf.d/20-intel.conf
|
||||
|
||||
# Touchpad
|
||||
echo '# File wrote by ~/.dotfiles/config/scripts/install-arch
|
||||
|
||||
Section "InputClass"
|
||||
Identifier "touchpad"
|
||||
Driver "libinput"
|
||||
MatchIsTouchpad "on"
|
||||
Option "Tapping" "on"
|
||||
EndSection
|
||||
' | sudo tee /etc/X11/xorg.conf.d/30-touchpad.conf
|
||||
|
||||
# Disable joystick as mouse
|
||||
echo '# File wrote by ~/.dotfiles/config/scripts/install-arch
|
||||
|
||||
Section "InputClass"
|
||||
Identifier "joystick catchall"
|
||||
MatchIsJoystick "on"
|
||||
MatchDevicePath "/dev/input/event*"
|
||||
Driver "joystick"
|
||||
Option "StartKeysEnabled" "False" #Disable mouse
|
||||
Option "StartMouseEnabled" "False" #support
|
||||
EndSection
|
||||
' | sudo tee /etc/X11/xorg.conf.d/50-joystick.conf
|
||||
|
||||
# Install same rules with nvidia-xrun
|
||||
if -d /etc/X11/nvidia-xorg.conf
|
||||
then
|
||||
function link { # filename
|
||||
ln -s /etc/X11/nvidia-xorg.conf/$1 ../xorg.conf.d/$1
|
||||
}
|
||||
link 00-keyboard.conf
|
||||
link 20-intel.conf # Yep
|
||||
link 30-touchpad.conf
|
||||
link 50-joystick.conf
|
||||
fi
|
||||
|
||||
# Uninstall Manjaro's pamac
|
||||
if pacman -Q pamac &> /dev/null ; then
|
||||
if pacman -Q pamac &> /dev/null
|
||||
then
|
||||
sudo pacman -Rsc pamac --noconfirm
|
||||
fi
|
||||
|
||||
# Ccache
|
||||
inst ccache
|
||||
sudo pacman -S ccache --needed
|
||||
sudo sed 's|BUILDENV=\(.\+\)!ccache\(.\+\)|BUILDENV=\1ccache\2|' /etc/makepkg.conf -i
|
||||
|
||||
# Makepkg config
|
||||
sudo sed 's|BUILDENV=\(.\+\)!color\(.\+\)|BUILDENV=\1color\2|' /etc/makepkg.conf -i
|
||||
|
||||
# Pacman config
|
||||
sudo sed 's|#Color|Color\nILoveCandy|' /etc/pacman.conf -i
|
||||
|
||||
# TLP
|
||||
inst tlp
|
||||
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 pacman -S tlp --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 --now
|
||||
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
|
||||
echo "# File wrote by ~/.dotfiles/config/scripts/install-arch
|
||||
|
||||
[Service]
|
||||
ExecStartPre=/bin/sh -c 'setleds +num < /dev/%I'
|
||||
" | sudo tee /etc/systemd/system/getty@.service.d/override.conf
|
||||
|
||||
# Makeflags
|
||||
sudo sed "s|#MAKEFLAGS=\"-j2\"|MAKEFLAGS=\"-j$(nproc)\"|" /etc/makepkg.conf -i
|
||||
# I'd rather have updates not take my whole CPU
|
||||
# sudo sed "s|#MAKEFLAGS=\"-j2\"|MAKEFLAGS=\"-j$(nproc)\"|" /etc/makepkg.conf -i
|
||||
|
||||
# DHCPCD
|
||||
sudo pacman -S dhcpcd --needed
|
||||
sudo systemctl enable dhcpcd --now
|
||||
|
||||
# Time synchronisation
|
||||
inst ntp
|
||||
sudo systemctl start ntpd
|
||||
sudo systemctl enable ntpd
|
||||
sudo pacman -S chrony --needed
|
||||
echo '# File wrote by ~/.dotfiles/config/scripts/install-arch
|
||||
|
||||
# MANUAL
|
||||
server 0.europe.pool.ntp.org offline
|
||||
server 1.europe.pool.ntp.org offline
|
||||
server 2.europe.pool.ntp.org offline
|
||||
server 3.europe.pool.ntp.org offline
|
||||
driftfile /etc/chrony.drift
|
||||
rtconutc
|
||||
rtcsync' | sudo tee /etc/chrony.conf
|
||||
sudo systemctl enable chronyd --now
|
||||
echo '# File wrote by ~/.dotfiles/config/scripts/install-arch
|
||||
|
||||
# Hibernation
|
||||
# Add resume=UUID=<UUID-of-swap-partition> to GRUB_CMDLINE_LINUX_DEFAULT and run `sudo grub-mkconfig -o /boot/grub/grub.cfg`
|
||||
if $if_up; then
|
||||
chronyc online
|
||||
elif $if_down; then
|
||||
chronyc offline
|
||||
fi
|
||||
' | sudo tee /etc/dhcpcd.exit-hook
|
||||
|
||||
# Grub other OS
|
||||
sudo pacman -S os-prober --needed
|
||||
sudo grub-mkconfig -o /boot/grub/grub.cfg
|
||||
|
||||
# Manual
|
||||
|
||||
echo '
|
||||
# Hibernation:
|
||||
sudo blkid | grep 'TYPE="swap"'
|
||||
sudoedit /etc/default/grub
|
||||
# Add resume=UUID=<UUID-of-swap-partition> to GRUB_CMDLINE_LINUX_DEFAULT
|
||||
sudo grub-mkconfig -o /boot/grub/grub.cfg
|
||||
'
|
||||
|
||||
echo '
|
||||
# wpa_supplicant (Wi-Fi)
|
||||
sudo pacman -S wpa_supplicant
|
||||
ip link
|
||||
[ ! -f /etc/wpa_supplicant/wpa_supplicant.conf ] && wpa_passphrase 'DUMMY' 'JustToHaveAConfigFiel' > /etc/wpa_supplicant/wpa_supplicant.conf
|
||||
# Replace wlo1 with the correct interface
|
||||
sudo systemctl start wpa_supplicant@wlo1.service
|
||||
sudo ln -s wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant-wlo1.conf
|
||||
'
|
||||
|
||||
sudo etckeeper commit "install-arch script: end"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue