2019-11-23 02:25:47 +01:00
|
|
|
#!/bin/bash
|
2019-11-24 08:18:07 +01:00
|
|
|
#
|
2019-12-26 15:52:33 +01:00
|
|
|
set -e
|
2019-12-26 15:30:45 +01:00
|
|
|
echo (){
|
|
|
|
/bin/echo "#########################################"
|
|
|
|
/bin/echo "$@"
|
|
|
|
/bin/echo "#########################################"
|
|
|
|
}
|
2019-11-24 08:18:07 +01:00
|
|
|
#LICENSE#{{{
|
2019-11-23 02:25:47 +01:00
|
|
|
# Copyright (c) 2012 Tom Wambold
|
2019-12-09 19:25:42 +01:00
|
|
|
#
|
2019-11-23 02:25:47 +01:00
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
2019-12-09 19:25:42 +01:00
|
|
|
#
|
2019-11-23 02:25:47 +01:00
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
2019-12-09 19:25:42 +01:00
|
|
|
#
|
2019-11-23 02:25:47 +01:00
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
# SOFTWARE.
|
2019-11-24 08:18:07 +01:00
|
|
|
#}}}
|
|
|
|
#ABOUT#{{{
|
2019-11-23 02:25:47 +01:00
|
|
|
# This script will set up an Arch installation with a 100 MB /boot partition
|
|
|
|
# and an encrypted LVM partition with swap and / inside. It also installs
|
|
|
|
# and configures systemd as the init system (removing sysvinit).
|
|
|
|
#
|
|
|
|
# You should read through this script before running it in case you want to
|
|
|
|
# make any modifications, in particular, the variables just below, and the
|
|
|
|
# following functions:
|
|
|
|
#
|
|
|
|
# partition_drive - Customize to change partition sizes (/boot vs LVM)
|
|
|
|
# setup_lvm - Customize for partitions inside LVM
|
|
|
|
# install_packages - Customize packages installed in base system
|
|
|
|
# (desktop environment, etc.)
|
|
|
|
# install_aur_packages - More packages after packer (AUR helper) is
|
|
|
|
# installed
|
|
|
|
# set_netcfg - Preload netcfg profiles
|
2019-11-24 22:10:50 +01:00
|
|
|
#}}}
|
2019-11-25 02:49:08 +01:00
|
|
|
# CONFIGURE THESE VARIABLES{{{
|
|
|
|
# Drive to install to.
|
|
|
|
DRIVE='/dev/sda'
|
|
|
|
|
|
|
|
# Hostname of the installed machine.
|
|
|
|
HOSTNAME='arch'
|
|
|
|
|
|
|
|
# Encrypt everything (except /boot). Leave blank to disable.
|
|
|
|
ENCRYPT_DRIVE=''
|
|
|
|
|
|
|
|
# Passphrase used to encrypt the drive (leave blank to be prompted).
|
|
|
|
DRIVE_PASSPHRASE=''
|
|
|
|
|
|
|
|
# Root password (leave blank to be prompted).
|
|
|
|
ROOT_PASSWORD=''
|
|
|
|
|
|
|
|
# Main user to create (by default, added to wheel group, and others).
|
|
|
|
USER_NAME='lelgenio'
|
2019-12-26 15:09:22 +01:00
|
|
|
# Link to users dotfiles repo(git)
|
|
|
|
# Assumed to have stow-able modules on its root(cd .dotfiles;stow*/)
|
|
|
|
DOTFILES_URL="https://gitlab.com/$USER_NAME/dotfiles"
|
2020-04-19 21:17:46 +02:00
|
|
|
USER_SHELL='fish'
|
2019-11-25 02:49:08 +01:00
|
|
|
|
|
|
|
# The main user's password (leave blank to be prompted).
|
|
|
|
USER_PASSWORD=''
|
|
|
|
|
|
|
|
# System timezone.
|
|
|
|
TIMEZONE='America/Sao_Paulo'
|
|
|
|
|
2020-04-18 04:17:35 +02:00
|
|
|
# Country code for pacman repos
|
2020-05-03 05:56:17 +02:00
|
|
|
COUNTRY='brazil'
|
2020-04-18 04:17:35 +02:00
|
|
|
|
2019-11-25 02:49:08 +01:00
|
|
|
# Have /tmp on a tmpfs or not. Leave blank to disable.
|
|
|
|
# Only leave this blank on systems with very little RAM.
|
|
|
|
TMP_ON_TMPFS='TRUE'
|
|
|
|
|
|
|
|
KEYMAP='br-abnt2'
|
|
|
|
# KEYMAP='dvorak'
|
|
|
|
|
|
|
|
LANG=pt_BR.UTF-8
|
|
|
|
|
|
|
|
# Choose your video driver
|
|
|
|
# For Intel
|
|
|
|
VIDEO_DRIVER="i915"
|
|
|
|
# For nVidia
|
|
|
|
#VIDEO_DRIVER="nouveau"
|
|
|
|
# For ATI
|
|
|
|
#VIDEO_DRIVER="radeon"
|
|
|
|
# For generic stuff
|
|
|
|
#VIDEO_DRIVER="vesa"
|
|
|
|
|
2019-11-26 04:28:26 +01:00
|
|
|
REMOVE_PKGS=false
|
|
|
|
FULL_INSTALL=false
|
2019-11-26 03:02:36 +01:00
|
|
|
#}}}
|
|
|
|
# PACKAGES{{{
|
2019-12-26 11:44:59 +01:00
|
|
|
set_pkgs() {
|
2019-11-26 03:02:36 +01:00
|
|
|
# sudo to allow to run as a user later
|
2020-04-18 04:17:35 +02:00
|
|
|
sudo pacman -Sy
|
2019-11-26 03:02:36 +01:00
|
|
|
|
|
|
|
pkgs_base+=' base linux-zen linux-firmware intel-ucode lvm2 '
|
2020-04-19 21:41:24 +02:00
|
|
|
pkgs_base+=' fish bluez cronie git man-db'
|
|
|
|
# netctl
|
2020-04-19 22:47:45 +02:00
|
|
|
pkgs_base+=' netctl dhcpd ifplugged wpa_supplicant dialog'
|
2020-04-19 21:41:24 +02:00
|
|
|
|
2019-11-26 03:53:09 +01:00
|
|
|
pkgs_base+=" $(pacman -Sgq base-devel)"
|
2019-12-26 11:44:59 +01:00
|
|
|
if $IS_BIOS;then
|
|
|
|
pkgs_base+=' grub'
|
|
|
|
fi
|
2019-11-26 03:02:36 +01:00
|
|
|
|
|
|
|
pkgs+=" $pkgs_base"
|
|
|
|
# DE
|
2019-12-26 05:18:19 +01:00
|
|
|
pkgs+=' sway waybar ruby-fusuma light mako udiskie bemenu wofi-hg stow yay'
|
|
|
|
pkgs+=' bemenu wofi-hg j4-dmenu-desktop'
|
2020-04-19 21:17:46 +02:00
|
|
|
# passwords and auth
|
|
|
|
pkgs+=' pass gnupg pam-gnupg'
|
2019-12-26 05:18:19 +01:00
|
|
|
|
2019-12-09 19:25:42 +01:00
|
|
|
# pkgs+=' i3 termite scrot pamixer'
|
2020-04-22 00:36:45 +02:00
|
|
|
pkgs+=' nemo cinnamon-translations thunar redshift-wlr-gamma-control-git '
|
2020-04-19 21:17:46 +02:00
|
|
|
pkgs+=' pkgfile alacritty neovim moreutils htop-vim-git'
|
2019-11-26 03:02:36 +01:00
|
|
|
# Audio
|
|
|
|
pkgs+=' pulseaudio pavolume-git'
|
|
|
|
# Fonts
|
2020-04-19 21:41:24 +02:00
|
|
|
pkgs+=' ttf-hack inter-font otf-fira-code ttf-material-wifi-icons-git'
|
2019-11-26 03:02:36 +01:00
|
|
|
if $FULL_INSTALL; then
|
|
|
|
# Screenshot
|
|
|
|
pkgs+=' grim slurp wl-clipboard wf-recorder-git'
|
2020-04-19 21:17:46 +02:00
|
|
|
pkgs+=' httpie jq'
|
2019-11-26 03:02:36 +01:00
|
|
|
# Theme
|
|
|
|
pkgs+=' materia-custom-accent papirus-icon-theme'
|
|
|
|
pkgs+=' papirus-folders-git capitaine-cursors '
|
|
|
|
# Terminal
|
|
|
|
pkgs+=' tmux ranger atool p7zip tree'
|
2020-04-19 21:41:24 +02:00
|
|
|
pkgs+=' neofetch powerline-fonts'
|
2019-11-26 03:02:36 +01:00
|
|
|
pkgs+=' lolcat cmatrix'
|
2020-04-24 21:37:17 +02:00
|
|
|
# extra font for ranger
|
|
|
|
pkgs+=' otf-nerd-fonts-fira-code'
|
2019-11-26 03:02:36 +01:00
|
|
|
# Network
|
2019-12-26 05:18:19 +01:00
|
|
|
pkgs+=' wget curl bluez-utils rsync rclone nmap gnu-netcat tor mtr speedtest-cli'
|
|
|
|
pkgs+=' openssh sshfs fail2ban'
|
2019-11-26 03:02:36 +01:00
|
|
|
# Browser
|
|
|
|
pkgs+=' qutebrowser youtube-dl'
|
|
|
|
# Email
|
2019-12-26 05:18:19 +01:00
|
|
|
pkgs+=' neomutt isync'
|
2019-11-26 03:02:36 +01:00
|
|
|
# Files
|
2019-12-09 19:25:42 +01:00
|
|
|
pkgs+=' syncthing nextcloud-client '
|
|
|
|
pkgs+=' deluge deezloader-remix-bin smloadr'
|
2019-11-26 03:02:36 +01:00
|
|
|
# Media
|
2020-04-02 19:11:51 +02:00
|
|
|
pkgs+=' imv mpv mpd mpc ncmpcpp mpv-mpris mpdris2 playerctl'
|
2019-12-09 19:25:42 +01:00
|
|
|
pkgs+=' blender gimp kdenlive picard image_optim'
|
2019-11-26 03:02:36 +01:00
|
|
|
# Office
|
2019-12-01 17:36:00 +01:00
|
|
|
pkgs+=' libreoffice-fresh libreoffice-fresh-pt-br hunspell-pt-br papirus-libreoffice-theme'
|
2019-11-26 03:02:36 +01:00
|
|
|
# Programing
|
|
|
|
pkgs+=' code neovim python-pynvim neovim-symlinks ipython how2'
|
2019-12-01 17:36:00 +01:00
|
|
|
pkgs+=' gdb clang'
|
2019-11-26 03:02:36 +01:00
|
|
|
# Virt
|
|
|
|
pkgs+=' qemu'
|
|
|
|
# Gtk
|
|
|
|
pkgs+=' gtk3-nocsd-git'
|
|
|
|
# Qt
|
|
|
|
pkgs+=' qt5-base qt5-wayland qt5ct kvantum-qt5'
|
|
|
|
# Chat
|
|
|
|
pkgs+=' discord telegram-desktop telegram-cli-git'
|
|
|
|
# Gaming
|
|
|
|
pkgs+=' steam lutris gamemode lutris-wine-meta wine wine-mono winetricks'
|
|
|
|
if [ "$VIDEO_DRIVER" == "i915" ];then
|
|
|
|
pkgs+=' xf86-video-intel '
|
|
|
|
pkgs+=' lib32-mesa vulkan-intel lib32-vulkan-intel vulkan-icd-loader lib32-vulkan-icd-loader'
|
|
|
|
elif [ "$VIDEO_DRIVER" == "radeon" ];then
|
|
|
|
pkgs+=' xf86-video-ati'
|
|
|
|
pkgs+=' lib32-mesa vulkan-radeon lib32-vulkan-radeon vulkan-icd-loader lib32-vulkan-icd-loader'
|
|
|
|
elif [ "$VIDEO_DRIVER" == "nouveau" ];then
|
|
|
|
pkgs+=' xf86-video-nouveau'
|
|
|
|
pkgs+=' nvidia nvidia-utils lib32-nvidia-utils nvidia-settings vulkan-icd-loader lib32-vulkan-icd-loader'
|
2020-01-10 04:16:50 +01:00
|
|
|
elif [ "$VIDEO_DRIVER" == "vesa" ];then
|
2019-11-26 03:02:36 +01:00
|
|
|
packages+=' xf86-video-vesa'
|
|
|
|
fi
|
|
|
|
fi
|
2019-12-26 11:44:59 +01:00
|
|
|
}
|
2019-11-24 08:18:07 +01:00
|
|
|
#}}}
|
2019-11-24 08:01:32 +01:00
|
|
|
# Initial Setup{{{
|
|
|
|
# Base install{{{
|
2019-12-09 19:25:42 +01:00
|
|
|
setup() {
|
2019-11-23 02:25:47 +01:00
|
|
|
local boot_dev="$DRIVE"1
|
|
|
|
local lvm_dev="$DRIVE"2
|
|
|
|
|
2019-12-26 15:30:45 +01:00
|
|
|
echo 'Cleaning disk'
|
|
|
|
disk_clean
|
|
|
|
|
2019-11-23 02:25:47 +01:00
|
|
|
echo 'Creating partitions'
|
|
|
|
partition_drive "$DRIVE"
|
|
|
|
|
2020-01-10 04:16:50 +01:00
|
|
|
if "$ENCRYPT_DRIVE";then
|
2019-11-23 02:25:47 +01:00
|
|
|
local lvm_part="/dev/mapper/lvm"
|
|
|
|
|
2020-01-10 04:16:50 +01:00
|
|
|
if [ -z "$DRIVE_PASSPHRASE" ];then
|
2019-11-23 02:25:47 +01:00
|
|
|
echo 'Enter a passphrase to encrypt the disk:'
|
2019-12-26 17:25:34 +01:00
|
|
|
read -s DRIVE_PASSPHRASE
|
2019-11-23 02:25:47 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo 'Encrypting partition'
|
|
|
|
encrypt_drive "$lvm_dev" "$DRIVE_PASSPHRASE" lvm
|
|
|
|
|
|
|
|
else
|
|
|
|
local lvm_part="$lvm_dev"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo 'Setting up LVM'
|
|
|
|
setup_lvm "$lvm_part" vg00
|
|
|
|
|
|
|
|
echo 'Formatting filesystems'
|
|
|
|
format_filesystems "$boot_dev"
|
|
|
|
|
|
|
|
echo 'Mounting filesystems'
|
|
|
|
mount_filesystems "$boot_dev"
|
|
|
|
|
2020-04-18 04:17:35 +02:00
|
|
|
echo 'Setting repos'
|
|
|
|
set_repos
|
|
|
|
|
2019-11-23 02:25:47 +01:00
|
|
|
echo 'Installing base system'
|
|
|
|
install_base
|
|
|
|
|
2019-12-26 11:44:59 +01:00
|
|
|
echo 'Setting fstab'
|
|
|
|
set_fstab
|
|
|
|
|
2019-11-23 02:25:47 +01:00
|
|
|
echo 'Chrooting into installed system to continue setup...'
|
2019-12-26 16:25:57 +01:00
|
|
|
cp "$0" "/mnt/setup.sh"
|
|
|
|
chmod +x "/mnt/setup.sh"
|
|
|
|
arch-chroot /mnt "./setup.sh"
|
2019-11-23 02:25:47 +01:00
|
|
|
|
2020-01-10 04:16:50 +01:00
|
|
|
if [ -f "/mnt/setup.sh" ];then
|
2019-11-23 02:25:47 +01:00
|
|
|
echo 'ERROR: Something failed inside the chroot, not unmounting filesystems so you can investigate.'
|
|
|
|
echo 'Make sure you unmount everything before you try to run this script again.'
|
|
|
|
else
|
|
|
|
echo 'Unmounting filesystems'
|
|
|
|
unmount_filesystems
|
|
|
|
echo 'Done! Reboot system.'
|
|
|
|
fi
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-12-26 15:30:45 +01:00
|
|
|
# Remove old LVMs{{{
|
|
|
|
disk_clean(){
|
|
|
|
echo 'cleaning disk'
|
2019-12-26 15:47:04 +01:00
|
|
|
|
2019-12-26 15:30:45 +01:00
|
|
|
umount -R /mnt || true
|
2019-12-26 15:47:04 +01:00
|
|
|
swapoff -a
|
|
|
|
|
2019-12-26 15:51:13 +01:00
|
|
|
pvs "$DRIVE"2 || return 0
|
2019-12-26 15:47:04 +01:00
|
|
|
|
2019-12-26 15:30:45 +01:00
|
|
|
for vg in $(pvs -o vg_name --nohead "$DRIVE"2)
|
|
|
|
do
|
2019-12-26 15:31:08 +01:00
|
|
|
vgremove "$vg" --yes
|
2019-12-26 15:30:45 +01:00
|
|
|
done
|
2019-12-26 15:47:04 +01:00
|
|
|
|
2019-12-26 15:44:48 +01:00
|
|
|
pvremove "$DRIVE"2
|
2019-12-26 15:30:45 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 08:01:32 +01:00
|
|
|
# Partition Drive{{{
|
2019-12-09 19:25:42 +01:00
|
|
|
partition_drive() {
|
2019-11-24 07:54:02 +01:00
|
|
|
local dev="$1"; shift
|
2019-11-23 02:25:47 +01:00
|
|
|
|
2019-11-24 07:54:02 +01:00
|
|
|
# 100 MB /boot partition, everything else under LVM
|
2019-12-01 17:36:00 +01:00
|
|
|
if $IS_BIOS;then
|
2020-04-17 06:54:35 +02:00
|
|
|
parted \
|
|
|
|
--align optimal \
|
|
|
|
--script "$dev" \
|
2019-12-26 06:20:30 +01:00
|
|
|
mklabel msdos \
|
2019-12-26 05:59:39 +01:00
|
|
|
mkpart primary fat32 1M 100M \
|
|
|
|
mkpart primary ext4 100M 100% \
|
|
|
|
set 1 boot on \
|
|
|
|
set 2 lvm on
|
|
|
|
else
|
2020-04-17 06:54:35 +02:00
|
|
|
parted \
|
|
|
|
--align optimal \
|
|
|
|
--script "$dev" \
|
2019-12-26 05:59:39 +01:00
|
|
|
mklabel gpt \
|
|
|
|
mkpart boot 1 100M \
|
|
|
|
mkpart lvm 100M 100% \
|
2020-04-17 06:54:35 +02:00
|
|
|
set 1 boot on \
|
2019-12-26 05:59:39 +01:00
|
|
|
set 2 lvm on
|
2019-12-01 17:36:00 +01:00
|
|
|
fi
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-12-26 05:18:19 +01:00
|
|
|
# Encrypt_drive {{{
|
2019-11-24 08:01:32 +01:00
|
|
|
encrypt_drive() {
|
2019-11-24 07:54:02 +01:00
|
|
|
local dev="$1"; shift
|
|
|
|
local passphrase="$1"; shift
|
|
|
|
local name="$1"; shift
|
|
|
|
|
2019-12-26 15:30:45 +01:00
|
|
|
/bin/echo -en "$passphrase" | cryptsetup luksFormat "$dev"
|
|
|
|
/bin/echo -en "$passphrase" | cryptsetup luksOpen "$dev" lvm
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 08:01:32 +01:00
|
|
|
# setup_lvm{{{
|
|
|
|
setup_lvm() {
|
2019-11-24 07:54:02 +01:00
|
|
|
local partition="$1"; shift
|
|
|
|
local volgroup="$1"; shift
|
2019-12-26 13:42:32 +01:00
|
|
|
|
2020-05-03 05:07:58 +02:00
|
|
|
local d_size=$(lsblk --noheadings --nodeps --bytes --raw --output SIZE $DRIVE)
|
2019-11-23 02:25:47 +01:00
|
|
|
|
2019-11-24 07:54:02 +01:00
|
|
|
pvcreate "$partition"
|
|
|
|
vgcreate "$volgroup" "$partition"
|
2019-11-23 02:25:47 +01:00
|
|
|
|
|
|
|
|
2019-12-26 13:42:32 +01:00
|
|
|
# if the disk has more than
|
2020-01-10 04:16:50 +01:00
|
|
|
if [ "$d_size" -gt $(( 50*10**9 )) ]; then
|
2020-04-17 06:54:35 +02:00
|
|
|
# Create a 4GB swap partition
|
2020-05-03 04:57:04 +02:00
|
|
|
lvcreate --yes -L4G "$volgroup" -n swap
|
2020-04-17 06:54:35 +02:00
|
|
|
|
2019-12-26 13:42:32 +01:00
|
|
|
# Create a 50GB root partition
|
|
|
|
lvcreate --yes -L '50G' "$volgroup" -n root
|
|
|
|
else
|
2020-04-17 06:54:35 +02:00
|
|
|
# Create a swap partition of 10% the disk
|
2020-05-03 04:57:04 +02:00
|
|
|
lvcreate --yes -l '+10%FREE' "$volgroup" -n swap
|
2020-04-17 06:54:35 +02:00
|
|
|
|
2019-12-26 13:42:32 +01:00
|
|
|
# Create root partition on 50% of free space
|
|
|
|
lvcreate --yes -l '+50%FREE' "$volgroup" -n root
|
|
|
|
fi
|
|
|
|
# Use the rest of the space for home
|
2019-11-26 04:45:08 +01:00
|
|
|
lvcreate --yes -l '+100%FREE' "$volgroup" -n home
|
2019-11-24 07:54:02 +01:00
|
|
|
|
|
|
|
# Enable the new volumes
|
|
|
|
vgchange -ay
|
2019-12-26 13:42:32 +01:00
|
|
|
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 08:01:32 +01:00
|
|
|
# format_filesystems #{{{
|
|
|
|
format_filesystems() {
|
2019-11-24 07:54:02 +01:00
|
|
|
local boot_dev="$1"; shift
|
|
|
|
|
2019-11-24 08:54:36 +01:00
|
|
|
mkfs.fat "$boot_dev"
|
2019-11-24 07:54:02 +01:00
|
|
|
mkfs.ext4 -L root /dev/vg00/root
|
|
|
|
mkfs.ext4 -L home /dev/vg00/home
|
|
|
|
mkswap /dev/vg00/swap
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 08:01:32 +01:00
|
|
|
# mount_filesystems #{{{
|
|
|
|
mount_filesystems() {
|
2019-11-24 07:54:02 +01:00
|
|
|
local boot_dev="$1"; shift
|
|
|
|
|
|
|
|
mount /dev/vg00/root /mnt
|
2019-11-26 03:02:36 +01:00
|
|
|
mkdir /mnt/home
|
|
|
|
mount /dev/vg00/home /mnt/home
|
2019-11-24 07:54:02 +01:00
|
|
|
mkdir /mnt/boot
|
|
|
|
mount "$boot_dev" /mnt/boot
|
|
|
|
swapon /dev/vg00/swap
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2020-04-18 04:17:35 +02:00
|
|
|
# set_repos() {{{{
|
|
|
|
set_repos() {
|
|
|
|
# /etc/pacman.conf{{{
|
|
|
|
cat > /etc/pacman.conf <<EOF
|
|
|
|
#
|
|
|
|
# GENERAL OPTIONS
|
|
|
|
#
|
|
|
|
[options]
|
|
|
|
HoldPkg = pacman glibc
|
|
|
|
Architecture = auto
|
|
|
|
|
|
|
|
# Misc options
|
|
|
|
#UseSyslog
|
|
|
|
Color
|
|
|
|
ILoveCandy
|
|
|
|
#TotalDownload
|
|
|
|
CheckSpace
|
|
|
|
#VerbosePkgLists
|
|
|
|
|
|
|
|
SigLevel = Required DatabaseOptional
|
|
|
|
LocalFileSigLevel = Optional
|
|
|
|
#RemoteFileSigLevel = Required
|
|
|
|
|
|
|
|
#
|
|
|
|
# REPOSITORIES
|
|
|
|
#
|
|
|
|
|
|
|
|
#[testing]
|
|
|
|
#Include = /etc/pacman.d/mirrorlist
|
|
|
|
|
|
|
|
[core]
|
|
|
|
Include = /etc/pacman.d/mirrorlist
|
|
|
|
|
|
|
|
[extra]
|
|
|
|
Include = /etc/pacman.d/mirrorlist
|
|
|
|
|
|
|
|
#[community-testing]
|
|
|
|
#Include = /etc/pacman.d/mirrorlist
|
|
|
|
|
|
|
|
[community]
|
|
|
|
Include = /etc/pacman.d/mirrorlist
|
|
|
|
|
|
|
|
|
|
|
|
#[multilib-testing]
|
|
|
|
#Include = /etc/pacman.d/mirrorlist
|
|
|
|
|
|
|
|
[multilib]
|
|
|
|
Include = /etc/pacman.d/mirrorlist
|
|
|
|
|
|
|
|
EOF
|
|
|
|
#}}}
|
|
|
|
# /etc/pacman.d/mirrorlist{{{
|
2020-05-03 05:56:17 +02:00
|
|
|
pacman -Sy reflector --noconfirm
|
|
|
|
|
|
|
|
reflector -c $COUNTRY -f 10 -p http -p https
|
2020-04-18 04:17:35 +02:00
|
|
|
#}}}
|
|
|
|
|
|
|
|
mkdir -p /mnt/etc/pacman.d
|
|
|
|
cp -r /mnt/etc/pacman* /etc/
|
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 08:01:32 +01:00
|
|
|
# install_base #{{{
|
|
|
|
install_base() {
|
2019-11-24 22:26:01 +01:00
|
|
|
pacstrap /mnt $pkgs_base
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-12-26 17:25:34 +01:00
|
|
|
# Set fstab {{{
|
2019-12-26 11:44:59 +01:00
|
|
|
set_fstab() {
|
|
|
|
genfstab -Up /mnt > /mnt/etc/fstab
|
|
|
|
}
|
|
|
|
#}}}
|
2019-12-26 17:25:34 +01:00
|
|
|
# Unmount filesystems #{{{
|
2019-11-24 08:01:32 +01:00
|
|
|
unmount_filesystems() {
|
2019-11-26 03:02:36 +01:00
|
|
|
umount -R /mnt
|
2019-11-24 07:54:02 +01:00
|
|
|
swapoff /dev/vg00/swap
|
|
|
|
vgchange -an
|
2020-01-10 04:16:50 +01:00
|
|
|
if [ -n "$ENCRYPT_DRIVE" ];then
|
2019-11-24 07:54:02 +01:00
|
|
|
cryptsetup luksClose lvm
|
|
|
|
fi
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-12-01 17:36:00 +01:00
|
|
|
# is_bios{{{
|
2019-12-26 15:11:02 +01:00
|
|
|
if ls /sys/firmware/efi/efivars/ &> /dev/null
|
2019-12-01 17:36:00 +01:00
|
|
|
then
|
|
|
|
IS_BIOS=false
|
|
|
|
else
|
|
|
|
IS_BIOS=true
|
|
|
|
fi
|
|
|
|
#}}}
|
2019-11-24 07:54:02 +01:00
|
|
|
#}}}
|
|
|
|
# Configuration{{{
|
2019-11-24 08:01:32 +01:00
|
|
|
# configure() {#{{{
|
|
|
|
configure() {
|
2019-11-24 07:54:02 +01:00
|
|
|
local boot_dev="$DRIVE"1
|
|
|
|
local lvm_dev="$DRIVE"2
|
|
|
|
|
2019-11-23 02:25:47 +01:00
|
|
|
echo 'Setting hostname'
|
|
|
|
set_hostname "$HOSTNAME"
|
|
|
|
|
|
|
|
echo 'Setting timezone'
|
|
|
|
set_timezone "$TIMEZONE"
|
|
|
|
|
|
|
|
echo 'Setting locale'
|
2019-11-24 08:49:22 +01:00
|
|
|
set_locale
|
2019-11-23 02:25:47 +01:00
|
|
|
|
|
|
|
echo 'Setting console keymap'
|
2019-12-04 04:03:28 +01:00
|
|
|
set_inputs
|
2019-11-23 02:25:47 +01:00
|
|
|
|
|
|
|
echo 'Configuring initial ramdisk'
|
|
|
|
set_initcpio
|
|
|
|
|
|
|
|
echo 'Setting initial daemons'
|
|
|
|
set_daemons "$TMP_ON_TMPFS"
|
|
|
|
|
2019-11-24 22:10:50 +01:00
|
|
|
echo 'Configuring Bluetooth'
|
2019-12-09 19:25:42 +01:00
|
|
|
set_bluetooth
|
2019-11-24 22:10:50 +01:00
|
|
|
|
2019-11-23 02:25:47 +01:00
|
|
|
echo 'Configuring bootloader'
|
2019-12-01 17:36:00 +01:00
|
|
|
set_bootctl "$boot_dev" "$lvm_dev"
|
2019-11-23 02:25:47 +01:00
|
|
|
|
|
|
|
echo 'Configuring sudo'
|
|
|
|
set_sudoers
|
|
|
|
|
2019-11-24 22:10:50 +01:00
|
|
|
echo 'Configuring PAM'
|
|
|
|
set_pam
|
2019-11-23 02:25:47 +01:00
|
|
|
|
2020-04-19 21:17:46 +02:00
|
|
|
echo 'Configuring logind'
|
|
|
|
set_logind
|
|
|
|
|
2020-01-10 04:16:50 +01:00
|
|
|
if [ -z "$ROOT_PASSWORD" ];then
|
2019-11-26 05:09:43 +01:00
|
|
|
echo 'Enter the root password:'
|
2019-12-26 17:25:34 +01:00
|
|
|
read -s ROOT_PASSWORD
|
2019-11-26 05:09:43 +01:00
|
|
|
fi
|
|
|
|
|
2019-11-24 22:10:50 +01:00
|
|
|
echo 'Setting root password'
|
|
|
|
set_root_password "$ROOT_PASSWORD"
|
2019-11-23 02:25:47 +01:00
|
|
|
|
2020-01-10 04:16:50 +01:00
|
|
|
if [ -z "$USER_PASSWORD" ];then
|
2019-11-26 05:09:43 +01:00
|
|
|
echo "Enter the password for user $USER_NAME"
|
2019-12-26 17:25:34 +01:00
|
|
|
read -s USER_PASSWORD
|
2019-11-26 05:09:43 +01:00
|
|
|
fi
|
|
|
|
|
2019-11-24 22:10:50 +01:00
|
|
|
echo 'Creating initial user'
|
|
|
|
create_user "$USER_NAME" "$USER_PASSWORD"
|
2019-11-23 02:25:47 +01:00
|
|
|
|
2019-11-24 22:10:50 +01:00
|
|
|
echo 'setting up user'
|
2019-12-26 16:25:57 +01:00
|
|
|
cp $0 "/home/$USER_NAME/setup.sh"
|
|
|
|
chown $USER_NAME "/home/$USER_NAME/setup.sh"
|
|
|
|
su $USER_NAME -c "/home/$USER_NAME/setup.sh"
|
2019-11-24 07:54:02 +01:00
|
|
|
|
2020-04-18 06:17:07 +02:00
|
|
|
shred "/home/$USER_NAME/setup.sh"
|
|
|
|
rm "/home/$USER_NAME/setup.sh"
|
|
|
|
|
2019-11-24 22:10:50 +01:00
|
|
|
echo 'Updating pkgfile database'
|
|
|
|
update_pkgfile
|
|
|
|
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 08:01:32 +01:00
|
|
|
# set_hostname() {#{{{
|
|
|
|
set_hostname() {
|
2019-11-23 02:25:47 +01:00
|
|
|
local hostname="$1"; shift
|
|
|
|
|
2019-12-26 15:30:45 +01:00
|
|
|
/bin/echo "$hostname" > /etc/hostname
|
2019-11-23 02:25:47 +01:00
|
|
|
|
2019-11-24 07:54:02 +01:00
|
|
|
cat > /etc/hosts <<EOF
|
|
|
|
127.0.0.1 localhost.localdomain localhost $hostname
|
|
|
|
::1 localhost.localdomain localhost $hostname
|
|
|
|
EOF
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 08:01:32 +01:00
|
|
|
# set_timezone() {#{{{
|
|
|
|
set_timezone() {
|
2019-11-23 02:25:47 +01:00
|
|
|
local timezone="$1"; shift
|
|
|
|
|
2019-11-24 22:26:01 +01:00
|
|
|
ln -sfT "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
|
2019-12-01 17:36:00 +01:00
|
|
|
|
|
|
|
timedatectl set-ntp on
|
|
|
|
|
2020-01-10 04:16:50 +01:00
|
|
|
hwclock --systohc || echo FAILED TO SET HW CLOCK
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 08:15:00 +01:00
|
|
|
# set_locale() {#{{{
|
|
|
|
set_locale() {
|
2019-11-24 22:33:29 +01:00
|
|
|
cat > /etc/locale.conf <<EOF
|
|
|
|
LANG=$LANG
|
|
|
|
LC_COLLATE=C
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat > /etc/locale.gen <<EOF
|
|
|
|
en_US.UTF-8 UTF-8
|
|
|
|
$LANG UTF-8
|
|
|
|
EOF
|
|
|
|
|
2019-11-23 02:25:47 +01:00
|
|
|
locale-gen
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-12-04 04:03:28 +01:00
|
|
|
# set_inputs() {#{{{
|
|
|
|
set_inputs() {
|
2019-11-24 08:49:22 +01:00
|
|
|
localectl set-keymap $KEYMAP
|
2019-12-04 04:03:28 +01:00
|
|
|
mkdir -p /etc/X11/xorg.conf.d/
|
|
|
|
cat > /etc/X11/xorg.conf.d/30-touchpad.conf <<EOF
|
|
|
|
Section "InputClass"
|
|
|
|
MatchIsTouchpad "on"
|
|
|
|
Identifier "devname"
|
|
|
|
Driver "libinput"
|
|
|
|
Option "Tapping" "on"
|
|
|
|
Option "ClickMethod" "clickfinger"
|
|
|
|
Option "NaturalScrolling" "true"
|
|
|
|
EndSection
|
|
|
|
EOF
|
|
|
|
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 08:01:32 +01:00
|
|
|
# set_initcpio() {#{{{
|
|
|
|
set_initcpio() {
|
2019-11-23 02:25:47 +01:00
|
|
|
local vid
|
|
|
|
|
2020-01-10 04:16:50 +01:00
|
|
|
if [ "$VIDEO_DRIVER" = "i915" ];then
|
2019-11-23 02:25:47 +01:00
|
|
|
vid='i915'
|
2020-01-10 04:16:50 +01:00
|
|
|
elif [ "$VIDEO_DRIVER" = "nouveau" ];then
|
2019-11-23 02:25:47 +01:00
|
|
|
vid='nouveau'
|
2020-01-10 04:16:50 +01:00
|
|
|
elif [ "$VIDEO_DRIVER" = "radeon" ];then
|
2019-11-23 02:25:47 +01:00
|
|
|
vid='radeon'
|
|
|
|
fi
|
|
|
|
|
|
|
|
local encrypt=""
|
2020-01-10 04:16:50 +01:00
|
|
|
if [ -n "$ENCRYPT_DRIVE" ];then
|
2019-12-09 19:25:42 +01:00
|
|
|
encrypt="encrypt keyboard"
|
2019-11-23 02:25:47 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
cat > /etc/mkinitcpio.conf <<EOF
|
|
|
|
# vim:set ft=sh
|
2019-11-24 07:54:02 +01:00
|
|
|
MODULES=(ext4 $vid)
|
2019-11-23 02:25:47 +01:00
|
|
|
|
2019-11-24 07:54:02 +01:00
|
|
|
BINARIES=()
|
2019-11-23 02:25:47 +01:00
|
|
|
|
2019-11-24 07:54:02 +01:00
|
|
|
FILES=()
|
2019-11-23 02:25:47 +01:00
|
|
|
|
2019-12-09 19:25:42 +01:00
|
|
|
HOOKS=(base udev autodetect block $encrypt lvm2 filesystems fsck)
|
2019-11-23 02:25:47 +01:00
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2019-11-24 07:54:02 +01:00
|
|
|
mkinitcpio -P
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 08:01:32 +01:00
|
|
|
# set_daemons() {#{{{
|
|
|
|
set_daemons() {
|
2019-11-23 02:25:47 +01:00
|
|
|
local tmp_on_tmpfs="$1"; shift
|
2020-01-10 04:16:50 +01:00
|
|
|
if [ -z "$tmp_on_tmpfs" ];then
|
2019-11-23 02:25:47 +01:00
|
|
|
systemctl mask tmp.mount
|
|
|
|
fi
|
2020-04-19 21:41:24 +02:00
|
|
|
|
|
|
|
systemctl enable cronie.service netctl.service
|
|
|
|
|
2020-04-20 04:33:16 +02:00
|
|
|
for interface in $(ls -d /sys/class/net/en*);do
|
2020-04-19 21:41:24 +02:00
|
|
|
systemctl enable netctl-ifpluged@$interface
|
|
|
|
done
|
2020-04-20 04:33:16 +02:00
|
|
|
for interface in $(ls -d /sys/class/net/wl*);do
|
2020-04-19 21:41:24 +02:00
|
|
|
systemctl enable netctl-auto@$interface
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
cat > /etc/netctl/interfaces/en-any <<EOF
|
|
|
|
Description='A basic dhcp ethernet connection'
|
|
|
|
Interface=en-any
|
|
|
|
Connection=ethernet
|
|
|
|
IP=dhcp
|
|
|
|
EOF
|
|
|
|
mkdir -p /etc/netctl/interfaces/
|
|
|
|
cat > /etc/netctl/interfaces/en-any <<EOF
|
|
|
|
#!/bin/bash
|
|
|
|
for interface in /sys/class/net/en*; do
|
|
|
|
break;
|
|
|
|
done
|
|
|
|
Interface=$(basename $interface)
|
|
|
|
echo "en-any: using interface $Interface";
|
|
|
|
EOF
|
|
|
|
chmod +x /etc/netctl/interfaces/en-any
|
|
|
|
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 22:10:50 +01:00
|
|
|
# set_bluetooth{{{
|
|
|
|
set_bluetooth() {
|
2019-12-26 12:52:30 +01:00
|
|
|
mkdir -p /etc/bluetooth/
|
|
|
|
cat > /etc/bluetooth/main.conf <<EOF
|
2019-11-24 22:10:50 +01:00
|
|
|
|
|
|
|
[General]
|
|
|
|
DiscoverableTimeout = 0
|
|
|
|
Discoverable = true
|
|
|
|
|
|
|
|
AlwaysPairable = true
|
|
|
|
|
|
|
|
[Policy]
|
|
|
|
AutoEnable=true
|
2019-11-26 03:21:38 +01:00
|
|
|
|
2019-11-24 22:10:50 +01:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
#}}}
|
2019-12-26 05:18:19 +01:00
|
|
|
# set_boot_loader() {{{
|
2019-11-24 08:01:32 +01:00
|
|
|
set_bootctl() {
|
2019-12-01 17:36:00 +01:00
|
|
|
local boot_dev="$1"; shift
|
2019-11-23 02:25:47 +01:00
|
|
|
local lvm_dev="$1"; shift
|
|
|
|
|
2020-04-17 06:54:35 +02:00
|
|
|
local lvm_uuid=$(get_uuid "/dev/vg00/root")
|
2019-11-23 02:25:47 +01:00
|
|
|
|
2019-12-26 12:52:30 +01:00
|
|
|
local k_args="root=UUID=$lvm_uuid"
|
2019-12-09 19:25:42 +01:00
|
|
|
|
2019-12-01 17:36:00 +01:00
|
|
|
if $IS_BIOS;then
|
2019-12-26 12:52:30 +01:00
|
|
|
cat >> /etc/default/grub <<EOF
|
|
|
|
GRUB_CMDLINE_LINUX_DEFAULT="$k_args"
|
|
|
|
# GRUB_CMDLINE_LINUX_DEFAULT="quiet splash loglevel=3 vga=current rd.udev.log_priority=3 rd.systemd.show_status=auto vt.global_cursor_default=0 nmi_watchdog=0 $k_args"
|
|
|
|
EOF
|
2019-12-26 17:50:10 +01:00
|
|
|
|
|
|
|
grub-install "$DRIVE"
|
|
|
|
grub-mkconfig -o /boot/grub/grub.cfg
|
2019-12-26 05:59:39 +01:00
|
|
|
else
|
2019-12-01 17:36:00 +01:00
|
|
|
bootctl install
|
|
|
|
cat > /boot/loader/entries/arch.conf <<EOF
|
2019-11-24 07:54:02 +01:00
|
|
|
title arch
|
2019-11-23 02:25:47 +01:00
|
|
|
|
2019-11-24 07:54:02 +01:00
|
|
|
linux vmlinuz-linux-zen
|
|
|
|
initrd intel-ucode.img
|
|
|
|
initrd initramfs-linux-zen.img
|
2019-11-23 02:25:47 +01:00
|
|
|
|
2019-12-26 12:52:30 +01:00
|
|
|
options $k_args
|
2020-04-17 06:54:35 +02:00
|
|
|
# options quiet splash loglevel=3 vga=current rd.udev.log_priority=3 rd.systemd.show_status=auto vt.global_cursor_default=0 nmi_watchdog=0
|
2019-11-24 07:54:02 +01:00
|
|
|
EOF
|
2019-12-26 05:59:39 +01:00
|
|
|
|
2019-12-26 05:18:19 +01:00
|
|
|
fi
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 08:01:32 +01:00
|
|
|
# set_sudoers() {#{{{
|
|
|
|
set_sudoers() {
|
2019-11-23 02:25:47 +01:00
|
|
|
cat > /etc/sudoers <<EOF
|
|
|
|
##
|
|
|
|
## User privilege specification
|
|
|
|
##
|
|
|
|
root ALL=(ALL) ALL
|
|
|
|
|
|
|
|
## Uncomment to allow members of group wheel to execute any command
|
2019-11-24 07:54:02 +01:00
|
|
|
# %wheel ALL=(ALL) ALL
|
2019-11-23 02:25:47 +01:00
|
|
|
|
|
|
|
## Same thing without a password
|
2019-11-24 07:54:02 +01:00
|
|
|
%wheel ALL=(ALL) NOPASSWD: ALL
|
2019-11-23 02:25:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
## Read drop-in files from /etc/sudoers.d
|
|
|
|
## (the '#' here does not indicate a comment)
|
|
|
|
#includedir /etc/sudoers.d
|
|
|
|
EOF
|
|
|
|
|
|
|
|
chmod 440 /etc/sudoers
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 22:10:50 +01:00
|
|
|
# set_pam{{{
|
|
|
|
set_pam() {
|
2020-04-19 21:17:46 +02:00
|
|
|
cat > /etc/pam.d/system-local-login <<EOF
|
|
|
|
auth include system-login
|
|
|
|
account include system-login
|
|
|
|
password include system-login
|
|
|
|
session include system-login
|
|
|
|
|
|
|
|
auth optional pam_gnupg.so
|
|
|
|
session optional pam_gnupg.so
|
|
|
|
EOF
|
2020-04-25 06:09:57 +02:00
|
|
|
|
2020-04-19 21:17:46 +02:00
|
|
|
}
|
|
|
|
#}}}
|
|
|
|
# set_logind{{{
|
|
|
|
set_logind(){
|
|
|
|
mkdir -p /etc/systemd
|
|
|
|
cat > /etc/systemd <<EOF
|
|
|
|
[Login]
|
|
|
|
HandlePowerKey=suspend
|
|
|
|
HandleSuspendKey=suspend
|
|
|
|
HandleLidSwitch=ignore
|
2019-11-24 22:10:50 +01:00
|
|
|
EOF
|
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 08:01:32 +01:00
|
|
|
# set_root_password() {#{{{
|
|
|
|
set_root_password() {
|
2019-11-23 02:25:47 +01:00
|
|
|
local password="$1"; shift
|
|
|
|
|
2019-12-26 15:30:45 +01:00
|
|
|
/bin/echo -en "$password\n$password" | passwd
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 08:01:32 +01:00
|
|
|
# create_user() {#{{{
|
|
|
|
create_user() {
|
2019-11-23 02:25:47 +01:00
|
|
|
local name="$1"; shift
|
|
|
|
local password="$1"; shift
|
|
|
|
|
2020-04-27 08:53:55 +02:00
|
|
|
useradd -m -s /usr/bin/$USER_SHELL -G adm,systemd-journal,wheel,rfkill,games,network,video,audio,optical,floppy,storage,scanner,power,input "$name"
|
2019-12-26 15:30:45 +01:00
|
|
|
/bin/echo -en "$password\n$password" | passwd "$name"
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 22:10:50 +01:00
|
|
|
# update_pkgfile() {#{{{
|
|
|
|
update_pkgfile() {
|
|
|
|
pkgfile -u
|
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 08:01:32 +01:00
|
|
|
# get_uuid() {#{{{
|
|
|
|
get_uuid() {
|
2019-12-26 17:47:22 +01:00
|
|
|
lsblk --noheadings --nodeps --output UUID "$1"
|
2019-11-24 08:23:12 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-12-26 13:05:09 +01:00
|
|
|
# is_chroot(){{{{
|
|
|
|
is_chroot(){
|
2020-01-10 04:16:50 +01:00
|
|
|
test "$(ls -id / | cut -d' ' -f1)" == "2"
|
2019-12-26 13:05:09 +01:00
|
|
|
}
|
|
|
|
#}}}
|
2019-11-24 07:54:02 +01:00
|
|
|
#}}}
|
2019-11-24 22:10:50 +01:00
|
|
|
# User setup{{{
|
|
|
|
user_setup() {
|
2019-11-23 02:25:47 +01:00
|
|
|
|
2019-11-24 22:10:50 +01:00
|
|
|
echo 'Installing packages'
|
|
|
|
install_aur_packages
|
|
|
|
|
2019-11-26 03:02:36 +01:00
|
|
|
if $REMOVE_PKGS;then
|
2019-11-24 22:10:50 +01:00
|
|
|
echo 'Cleaning packages'
|
|
|
|
clean_packages
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo 'Stowing dotfiles'
|
|
|
|
stow_dots
|
|
|
|
}
|
|
|
|
# Install AUR packages #{{{
|
|
|
|
install_aur_packages() {
|
|
|
|
|
|
|
|
sudo pacman -S --needed git
|
|
|
|
|
|
|
|
# getting yay
|
2019-12-26 05:18:19 +01:00
|
|
|
if ! command -v yay
|
2019-11-24 22:10:50 +01:00
|
|
|
then
|
|
|
|
git clone http://aur.archlinux.org/yay.git ~/yay
|
|
|
|
cd ~/yay
|
|
|
|
makepkg -si --noconfirm
|
|
|
|
cd -
|
|
|
|
fi
|
2019-11-24 08:20:17 +01:00
|
|
|
|
2020-04-18 05:18:28 +02:00
|
|
|
yay -Syu --needed --noconfirm $pkgs || true
|
2019-11-24 22:10:50 +01:00
|
|
|
}
|
|
|
|
#}}}
|
|
|
|
# Clean up packages #{{{
|
|
|
|
clean_packages() {
|
2019-11-26 15:05:25 +01:00
|
|
|
# Mark every package as dependency
|
2019-12-26 05:18:19 +01:00
|
|
|
yay -D --asdeps $(yay -Qqe) > /dev/null
|
2019-11-26 15:05:25 +01:00
|
|
|
# Mark some packages as explicit
|
2019-12-26 05:18:19 +01:00
|
|
|
yay -D --asexplicit $pkgs > /dev/null
|
2019-11-26 15:05:25 +01:00
|
|
|
# Query orphan dependencies
|
2019-11-24 22:10:50 +01:00
|
|
|
TO_REMOVE=$(yay -Qtdq)
|
|
|
|
if [ -n "$TO_REMOVE" ];then
|
2019-11-26 15:05:25 +01:00
|
|
|
# Remove queried packages
|
2019-11-24 22:10:50 +01:00
|
|
|
yay -Rns --noconfirm $TO_REMOVE
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
#}}}
|
|
|
|
# Stow dotfiles{{{
|
|
|
|
stow_dots() {
|
|
|
|
if [ ! -d ~/.dotfiles ];then
|
|
|
|
git clone $DOTFILES_URL ~/.dotfiles
|
|
|
|
fi
|
|
|
|
cd ~/.dotfiles
|
|
|
|
stow */
|
|
|
|
cd -
|
|
|
|
}
|
|
|
|
#}}}
|
2019-12-26 15:09:22 +01:00
|
|
|
#}}}
|
2019-12-26 15:44:48 +01:00
|
|
|
|
2019-12-26 11:44:59 +01:00
|
|
|
set_pkgs
|
2019-11-24 22:10:50 +01:00
|
|
|
if [ ! "$USER" == "root" ];then
|
|
|
|
user_setup
|
2019-12-26 13:05:09 +01:00
|
|
|
elif is_chroot;then
|
2019-11-23 02:25:47 +01:00
|
|
|
configure
|
|
|
|
else
|
|
|
|
setup
|
|
|
|
fi
|
2019-11-24 07:54:02 +01:00
|
|
|
|
2019-11-24 08:23:12 +01:00
|
|
|
# vim:foldmethod=marker
|