mirror of
https://github.com/tommytran732/Arch-Setup-Script
synced 2024-11-25 02:51:32 -05:00
Compare commits
No commits in common. "7fd0563729d296ed7dc9495d8c7d5ec6d73a6565" and "f400b8b0b2638e9a193343cd0970b5a30b2a0964" have entirely different histories.
7fd0563729
...
f400b8b0b2
98
install.sh
98
install.sh
@ -177,14 +177,17 @@ pacman -Sy
|
|||||||
## Installing curl
|
## Installing curl
|
||||||
pacman -S --noconfirm curl
|
pacman -S --noconfirm curl
|
||||||
|
|
||||||
## Wipe the disk
|
## Formatting the disk
|
||||||
sgdisk --zap-all "${disk}"
|
wipefs -af "${disk}" &>/dev/null
|
||||||
|
sgdisk -Zo "${disk}" &>/dev/null
|
||||||
|
|
||||||
## Creating a new partition scheme.
|
## Creating a new partition scheme.
|
||||||
output "Creating new partition scheme on ${disk}."
|
output "Creating new partition scheme on ${disk}."
|
||||||
sgdisk -g "${disk}"
|
parted -s "${disk}" \
|
||||||
sgdisk -I -n 1:0:+512M -t 1:ef00 -c 1:'ESP' "${disk}"
|
mklabel gpt \
|
||||||
sgdisk -I -n 2:0:0 -c 2:'rootfs' "${disk}"
|
mkpart ESP fat32 1MiB 513MiB \
|
||||||
|
set 1 esp on \
|
||||||
|
mkpart rootfs 513MiB 100%
|
||||||
|
|
||||||
ESP='/dev/disk/by-partlabel/ESP'
|
ESP='/dev/disk/by-partlabel/ESP'
|
||||||
|
|
||||||
@ -198,12 +201,12 @@ partprobe "${disk}"
|
|||||||
|
|
||||||
## Formatting the ESP as FAT32.
|
## Formatting the ESP as FAT32.
|
||||||
output 'Formatting the EFI Partition as FAT32.'
|
output 'Formatting the EFI Partition as FAT32.'
|
||||||
mkfs.fat -F 32 -s 2 "${ESP}"
|
mkfs.fat -F 32 -s 2 "${ESP}" &>/dev/null
|
||||||
|
|
||||||
## Creating a LUKS Container for the root partition.
|
## Creating a LUKS Container for the root partition.
|
||||||
if [ "${use_luks}" = '1' ]; then
|
if [ "${use_luks}" = '1' ]; then
|
||||||
output 'Creating LUKS Container for the root partition.'
|
output 'Creating LUKS Container for the root partition.'
|
||||||
echo -n "${luks_password}" | cryptsetup luksFormat --pbkdf pbkdf2 "${cryptroot}" -d -
|
echo -n "${luks_password}" | cryptsetup luksFormat --pbkdf pbkdf2 "${cryptroot}" -d - &>/dev/null
|
||||||
echo -n "${luks_password}" | cryptsetup open "${cryptroot}" cryptroot -d -
|
echo -n "${luks_password}" | cryptsetup open "${cryptroot}" cryptroot -d -
|
||||||
BTRFS='/dev/mapper/cryptroot'
|
BTRFS='/dev/mapper/cryptroot'
|
||||||
else
|
else
|
||||||
@ -212,35 +215,35 @@ fi
|
|||||||
|
|
||||||
## Formatting the partition as BTRFS.
|
## Formatting the partition as BTRFS.
|
||||||
output 'Formatting the rootfs as BTRFS.'
|
output 'Formatting the rootfs as BTRFS.'
|
||||||
mkfs.btrfs "${BTRFS}"
|
mkfs.btrfs "${BTRFS}" &>/dev/null
|
||||||
mount "${BTRFS}" /mnt
|
mount "${BTRFS}" /mnt
|
||||||
|
|
||||||
## Creating BTRFS subvolumes.
|
## Creating BTRFS subvolumes.
|
||||||
output 'Creating BTRFS subvolumes.'
|
output 'Creating BTRFS subvolumes.'
|
||||||
|
|
||||||
btrfs su cr /mnt/@
|
btrfs su cr /mnt/@ &>/dev/null
|
||||||
btrfs su cr /mnt/@/.snapshots
|
btrfs su cr /mnt/@/.snapshots &>/dev/null
|
||||||
mkdir -p /mnt/@/.snapshots/1
|
mkdir -p /mnt/@/.snapshots/1 &>/dev/null
|
||||||
btrfs su cr /mnt/@/.snapshots/1/snapshot
|
btrfs su cr /mnt/@/.snapshots/1/snapshot &>/dev/null
|
||||||
btrfs su cr /mnt/@/boot/
|
btrfs su cr /mnt/@/boot/ &>/dev/null
|
||||||
btrfs su cr /mnt/@/home
|
btrfs su cr /mnt/@/home &>/dev/null
|
||||||
btrfs su cr /mnt/@/root
|
btrfs su cr /mnt/@/root &>/dev/null
|
||||||
btrfs su cr /mnt/@/srv
|
btrfs su cr /mnt/@/srv &>/dev/null
|
||||||
btrfs su cr /mnt/@/var_log
|
btrfs su cr /mnt/@/var_log &>/dev/null
|
||||||
btrfs su cr /mnt/@/var_log_journal
|
btrfs su cr /mnt/@/var_log_journal &>/dev/null
|
||||||
btrfs su cr /mnt/@/var_crash
|
btrfs su cr /mnt/@/var_crash &>/dev/null
|
||||||
btrfs su cr /mnt/@/var_cache
|
btrfs su cr /mnt/@/var_cache &>/dev/null
|
||||||
btrfs su cr /mnt/@/var_tmp
|
btrfs su cr /mnt/@/var_tmp &>/dev/null
|
||||||
btrfs su cr /mnt/@/var_spool
|
btrfs su cr /mnt/@/var_spool &>/dev/null
|
||||||
btrfs su cr /mnt/@/var_lib_libvirt_images
|
btrfs su cr /mnt/@/var_lib_libvirt_images &>/dev/null
|
||||||
btrfs su cr /mnt/@/var_lib_machines
|
btrfs su cr /mnt/@/var_lib_machines &>/dev/null
|
||||||
if [ "${install_mode}" = 'desktop' ]; then
|
if [ "${install_mode}" = 'desktop' ]; then
|
||||||
btrfs su cr /mnt/@/var_lib_gdm
|
btrfs su cr /mnt/@/var_lib_gdm &>/dev/null
|
||||||
btrfs su cr /mnt/@/var_lib_AccountsService
|
btrfs su cr /mnt/@/var_lib_AccountsService &>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${use_luks}" = '1' ]; then
|
if [ "${use_luks}" = '1' ]; then
|
||||||
btrfs su cr /mnt/@/cryptkey
|
btrfs su cr /mnt/@/cryptkey &>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Disable CoW on subvols we are not taking snapshots of
|
## Disable CoW on subvols we are not taking snapshots of
|
||||||
@ -326,14 +329,7 @@ fi
|
|||||||
mkdir -p /mnt/boot/efi
|
mkdir -p /mnt/boot/efi
|
||||||
mount -o nodev,nosuid,noexec "${ESP}" /mnt/boot/efi
|
mount -o nodev,nosuid,noexec "${ESP}" /mnt/boot/efi
|
||||||
|
|
||||||
## Pacstrap
|
## Check the microcode to install.
|
||||||
output 'Installing the base system (it may take a while).'
|
|
||||||
|
|
||||||
output "You may see an error when mkinitcpio tries to generate a new initramfs."
|
|
||||||
output "It is okay. The script will regenerate the initramfs later in the installation process."
|
|
||||||
|
|
||||||
pacstrap /mnt apparmor base chrony efibootmgr firewalld grub grub-btrfs inotify-tools linux-firmware linux-hardened linux-lts nano reflector sbctl snapper sudo zram-generator
|
|
||||||
|
|
||||||
if [ "${virtualization}" = 'none' ]; then
|
if [ "${virtualization}" = 'none' ]; then
|
||||||
CPU=$(grep vendor_id /proc/cpuinfo)
|
CPU=$(grep vendor_id /proc/cpuinfo)
|
||||||
if [[ "${CPU}" == *"AuthenticAMD"* ]]; then
|
if [[ "${CPU}" == *"AuthenticAMD"* ]]; then
|
||||||
@ -341,10 +337,16 @@ if [ "${virtualization}" = 'none' ]; then
|
|||||||
else
|
else
|
||||||
microcode=intel-ucode
|
microcode=intel-ucode
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pacstrap /mnt "${microcode}"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
## Pacstrap
|
||||||
|
output 'Installing the base system (it may take a while).'
|
||||||
|
|
||||||
|
output "You may see an error when mkinitcpio tries to generate a new initramfs."
|
||||||
|
output "It is okay. The script will regenerate the initramfs later in the installation process."
|
||||||
|
|
||||||
|
pacstrap /mnt apparmor base chrony efibootmgr firewalld grub grub-btrfs inotify-tools linux-firmware linux-hardened linux-lts "${microcode}" nano reflector sbctl snapper sudo zram-generator
|
||||||
|
|
||||||
if [ "${network_daemon}" = 'networkmanager' ]; then
|
if [ "${network_daemon}" = 'networkmanager' ]; then
|
||||||
pacstrap /mnt networkmanager
|
pacstrap /mnt networkmanager
|
||||||
fi
|
fi
|
||||||
@ -435,8 +437,8 @@ fi
|
|||||||
|
|
||||||
## Add keyfile to the initramfs to avoid double password.
|
## Add keyfile to the initramfs to avoid double password.
|
||||||
if [ "${use_luks}" = '1' ]; then
|
if [ "${use_luks}" = '1' ]; then
|
||||||
dd bs=512 count=4 if=/dev/random of=/mnt/cryptkey/.root.key iflag=fullblock
|
dd bs=512 count=4 if=/dev/random of=/mnt/cryptkey/.root.key iflag=fullblock &>/dev/null
|
||||||
chmod 000 /mnt/cryptkey/.root.key
|
chmod 000 /mnt/cryptkey/.root.key &>/dev/null
|
||||||
echo -n "${luks_password}" | cryptsetup luksAddKey /dev/disk/by-partlabel/rootfs /mnt/cryptkey/.root.key -d -
|
echo -n "${luks_password}" | cryptsetup luksAddKey /dev/disk/by-partlabel/rootfs /mnt/cryptkey/.root.key -d -
|
||||||
sed -i 's#FILES=()#FILES=(/cryptkey/.root.key)#g' /mnt/etc/mkinitcpio.conf
|
sed -i 's#FILES=()#FILES=(/cryptkey/.root.key)#g' /mnt/etc/mkinitcpio.conf
|
||||||
sed -i "s#module\.sig_enforce=1#module.sig_enforce=1 rd.luks.key=/cryptkey/.root.key#g" /mnt/etc/default/grub
|
sed -i "s#module\.sig_enforce=1#module.sig_enforce=1 rd.luks.key=/cryptkey/.root.key#g" /mnt/etc/default/grub
|
||||||
@ -515,20 +517,20 @@ arch-chroot /mnt /bin/bash -e <<EOF
|
|||||||
|
|
||||||
# Setting up timezone.
|
# Setting up timezone.
|
||||||
# Temporarily hardcoding here
|
# Temporarily hardcoding here
|
||||||
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
|
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime &>/dev/null
|
||||||
|
|
||||||
# Setting up clock.
|
# Setting up clock.
|
||||||
hwclock --systohc
|
hwclock --systohc
|
||||||
|
|
||||||
# Generating locales.my keys aren't even on
|
# Generating locales.my keys aren't even on
|
||||||
echo 'Generating locales.'
|
echo "Generating locales."
|
||||||
locale-gen
|
locale-gen
|
||||||
|
|
||||||
# Create SecureBoot keys. This isn't strictly necessary, but certain things like linux-hardened preset expects it and mkinitcpio will fail without it, sooo...
|
# Create SecureBoot keys. This isn't strictly necessary, but certain things like linux-hardened preset expects it and mkinitcpio will fail without it, sooo...
|
||||||
sbctl create-keys
|
sbctl create-keys
|
||||||
|
|
||||||
# Generating a new initramfs.
|
# Generating a new initramfs.
|
||||||
echo 'Creating a new initramfs.'
|
echo "Creating a new initramfs."
|
||||||
chmod 600 /boot/initramfs-linux*
|
chmod 600 /boot/initramfs-linux*
|
||||||
mkinitcpio -P
|
mkinitcpio -P
|
||||||
|
|
||||||
@ -541,22 +543,17 @@ arch-chroot /mnt /bin/bash -e <<EOF
|
|||||||
grub-mkconfig -o /boot/grub/grub.cfg
|
grub-mkconfig -o /boot/grub/grub.cfg
|
||||||
|
|
||||||
# Adding user with sudo privilege
|
# Adding user with sudo privilege
|
||||||
echo 'Adding $username with root privilege.'
|
echo "Adding $username with root privilege."
|
||||||
useradd -m $username
|
useradd -m $username
|
||||||
usermod -aG wheel $username
|
usermod -aG wheel $username
|
||||||
|
|
||||||
if [ "${install_mode}" = 'desktop' ]; then
|
if [ "${install_mode}" = 'desktop' ]; then
|
||||||
# Setting up dconf
|
# Setting up dconf
|
||||||
echo 'Setting up dconf.'
|
echo "Setting up dconf."
|
||||||
dconf update
|
dconf update
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use systemd-resolved for DNS resolution
|
|
||||||
rm /etc/resolv.conf
|
|
||||||
ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
|
|
||||||
|
|
||||||
# Snapper configuration
|
# Snapper configuration
|
||||||
echo 'Configuring Snapper.'
|
|
||||||
umount /.snapshots
|
umount /.snapshots
|
||||||
rm -r /.snapshots
|
rm -r /.snapshots
|
||||||
snapper --no-dbus -c root create-config /
|
snapper --no-dbus -c root create-config /
|
||||||
@ -567,7 +564,7 @@ arch-chroot /mnt /bin/bash -e <<EOF
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
## Set user password.
|
## Set user password.
|
||||||
[ -n "$username" ] && echo "Setting user password for ${username}." && echo -e "${user_password}\n${user_password}" | arch-chroot /mnt passwd "$username"
|
[ -n "$username" ] && echo "Setting user password for ${username}." && echo -e "${user_password}\n${user_password}" | arch-chroot /mnt passwd "$username" &>/dev/null
|
||||||
|
|
||||||
## Give wheel user sudo access.
|
## Give wheel user sudo access.
|
||||||
sed -i 's/# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/g' /mnt/etc/sudoers
|
sed -i 's/# %wheel ALL=(ALL:ALL) ALL/%wheel ALL=(ALL:ALL) ALL/g' /mnt/etc/sudoers
|
||||||
@ -582,7 +579,6 @@ systemctl enable reflector.timer --root=/mnt
|
|||||||
systemctl enable snapper-timeline.timer --root=/mnt
|
systemctl enable snapper-timeline.timer --root=/mnt
|
||||||
systemctl enable snapper-cleanup.timer --root=/mnt
|
systemctl enable snapper-cleanup.timer --root=/mnt
|
||||||
systemctl enable systemd-oomd --root=/mnt
|
systemctl enable systemd-oomd --root=/mnt
|
||||||
systemctl enable systemd-resolved --root=/mnt
|
|
||||||
systemctl disable systemd-timesyncd --root=/mnt
|
systemctl disable systemd-timesyncd --root=/mnt
|
||||||
|
|
||||||
if [ "${network_daemon}" = 'networkmanager' ]; then
|
if [ "${network_daemon}" = 'networkmanager' ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user