Updated global variables.

This commit is contained in:
moony 2023-04-04 19:58:53 -04:00
parent e24640ab31
commit 49978602e1
2 changed files with 61 additions and 43 deletions

0
README.md Normal file

@ -1,11 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Artix Linux Minimal Encrypted Install Script. ### Artix Linux minimal LUKS encryption install script ###
# Coded by Moony ### Developed by Moony ###
# 9d5 until infinity ### From '9d5 until infinity ###
# Proper usage checks.
### PROPER USAGE CHECKS ###
[ -z "$1" ] && echo "Usage: [ -z "$1" ] && echo "Usage:
artix-luks-base-install /dev/sdX encrytption_pw root_pw" && exit artix-luks-base-install /dev/sdX encrytption_pw root_pw" && exit
[ -z "$(ls /sys/firmware/efi/efivars)" ] && echo "EFI only installation; Please boot with EFI." && exit [ -z "$(ls /sys/firmware/efi/efivars)" ] && echo "EFI only installation; Please boot with EFI." && exit
@ -17,75 +18,90 @@ artix-luks-base-install /dev/sdX encrytption_pw root_pw" && exit
# [ -z "$(connmanctl state | grep -e online -e ready)" ] && # [ -z "$(connmanctl state | grep -e online -e ready)" ] &&
# echo "No network connection." && exit # echo "No network connection." && exit
### PARAMETERS ### ### PARAMETERS ###
targetDisk=$1 targetDisk="/dev/sdX" # /dev/sdX
[ -z "$targetDisk" ] && echo "No target disk specified." && exit [ -z "$targetDisk" ] && echo "No target disk specified." && exit
cryptPass=$2
cryptPass="P455w0rd" # Luks password
[ -z "$cryptPass" ] && echo "No encryption password provided." && exit [ -z "$cryptPass" ] && echo "No encryption password provided." && exit
rootPassword=$3
rootPassword="R00TP455W0RD" # Root user password
[ -z "$rootPassword" ] && echo "No root password provided." && exit [ -z "$rootPassword" ] && echo "No root password provided." && exit
volGroup=lvmSystem volGroup=lvmGroup # Lvm Volume Group Name
hostName=vicious hostName=hostname # Computer hostname
##################
echo "+-- Artix Installation Parameters --+" echo "+-- Artix Installation Parameters --+"
echo "Target disk : \"$targetDisk\"" echo "| Target disk path : \"$targetDisk\""
echo "Crypto pass : \"$cryptPass\"" echo "| LUKS pass : \"$cryptPass\""
echo "Cryptvol group: \"$volGroup\"" echo "| CryptVol Group : \"$volGroup\""
echo -n "Correct?" && read -r echo "+-----------------------------------+"
echo -n "Correct: y/n?" && read -r
# Reset/init.
### RESET / INITIALIZE ###
pacman -Sy --noconfirm parted pacman -Sy --noconfirm parted
# swapoff /dev/$volGroup/swap 2>/dev/null # for swap partition. # swapoff /dev/$volGroup/swap 2>/dev/null # If using SWAP partition
swapoff /mnt/swapfile # for swap file. swapoff /mnt/swapfile # If using SWAP file
umount -R /mnt 2>/dev/null umount -R /mnt 2>/dev/null
vgchange -a n 2>/dev/null vgchange -a n 2>/dev/null
cryptsetup close lvm-system 2>/dev/null cryptsetup close lvm-system 2>/dev/null
killall -s 9 cryptsetup 2>/dev/null killall -s 9 cryptsetup 2>/dev/null
### PARTITION THE DISKS ###
set -xe set -xe
# Partition the disk.
parted -s -a optimal "$targetDisk" mklabel gpt parted -s -a optimal "$targetDisk" mklabel gpt
parted -s -a optimal "$targetDisk" mkpart "BOOT" fat32 0% 512MiB parted -s -a optimal "$targetDisk" mkpart "BOOT" fat32 0% 512MiB
parted -s -a optimal "$targetDisk" set 1 esp on parted -s -a optimal "$targetDisk" set 1 esp on
parted -s -a optimal "$targetDisk" mkpart "ROOT" ext4 512MiB 100% parted -s -a optimal "$targetDisk" mkpart "ROOT" ext4 512MiB 100%
# Set up LUKS encrypted container.
### SETUP LUKS ENCRYPTED CONTAINER ###
echo -ne "$cryptPass" | cryptsetup luksFormat "${targetDisk}2" -d - echo -ne "$cryptPass" | cryptsetup luksFormat "${targetDisk}2" -d -
echo -ne "$cryptPass" | cryptsetup open "${targetDisk}2" lvm-system -d - echo -ne "$cryptPass" | cryptsetup open "${targetDisk}2" lvm-system -d -
# Create logical volumes.
### CREATE LVM VOLUMES ###
pvcreate /dev/mapper/lvm-system pvcreate /dev/mapper/lvm-system
vgcreate $volGroup /dev/mapper/$volGroup vgcreate $volGroup /dev/mapper/$volGroup
lvcreate -L 8G $volGroup -n SWAP # For swap partition # lvcreate -L 8G $volGroup -n SWAP # For SWAP partition if a SWAP partition is desired
# lvcreate -L 50G $volGroup -n HOME # For set root partition if a separate home or var partition is desired. # lvcreate -L 50G $volGroup -n HOME # For HOME partition if a separate home or var partition is desired
lvcreate -l 100%FREE $volGroup -n ROOT lvcreate -l 100%FREE $volGroup -n ROOT
# Make filesystems.
### CREATE FILE SYSTEMS ###
mkfs.fat -F32 "${targetDisk}1" mkfs.fat -F32 "${targetDisk}1"
mkswap -f /dev/$volGroup/SWAP # To create a swap partition. # mkswap -f /dev/$volGroup/SWAP # To create a swap partition
mkfs.ext4 -qF /dev/$volGroup/ROOT mkfs.ext4 -qF /dev/$volGroup/ROOT
# mkfs.ext4 -qF /dev/$volGroup/HOME # To create a HOME file system. # mkfs.ext4 -qF /dev/$volGroup/HOME # To create a HOME file system
# Mount filesystems.
mount /dev/$volGroup/ROOT /mnt
# mkdir /mnt/home # Create a HOME folder if using partition.
# mount /dev/$volGroup/HOME /mnt/home # Mount HOME partition if in use.
mkdir /mnt/boot
mount "${targetDisk}1" /mnt/boot
dd if=swap bs=1M of=/mnt/swapfile # Create a SWAP file instead of partition.
# swapon /mnt/swapfile # Turn on the SWAP file.
swapon /dev/$volGroup/SWAP # Turn on SWAP partition.
# Basestrap the system and install lvm hooks. ### ROOT PARTITION ###
mount /dev/$volGroup/ROOT /mnt # Mount ROOT partition
### HOME PARTITION ###
# mkdir /mnt/home # Create a HOME folder if using HOME partition
# mount /dev/$volGroup/HOME /mnt/home # Mount HOME partition if created
mkdir /mnt/boot # Create BOOT path in ROOT directory
mount "${targetDisk}1" /mnt/boot # Mount BOOT partition
dd if=swap bs=1M of=/mnt/swapfile # Create a SWAP file instead of partition
swapon /mnt/swapfile # Turn on the SWAP file
# swapon /dev/$volGroup/SWAP # Turn on SWAP partition.
### INSTALL THE BASE SYSTEM ###
basestrap /mnt openrc elogind-openrc base base-devel connman-openrc connman-gtk neovim basestrap /mnt openrc elogind-openrc base base-devel connman-openrc connman-gtk neovim
basestrap /mnt linux linux-firmware intel-ucode basestrap /mnt linux linux-firmware intel-ucode
fstabgen -U /mnt >/mnt/etc/fstab fstabgen -U /mnt >/mnt/etc/fstab
sed -s 's/^HOOKS=.*/HOOKS=(base udev autodetect modconf block encrypt keyboard keymap lvm2 resume filesystems fsck)/g' -i /mnt/etc/mkinitcpio.conf sed -s 's/^HOOKS=.*/HOOKS=(base udev autodetect modconf block encrypt keyboard keymap lvm2 resume filesystems fsck)/g' -i /mnt/etc/mkinitcpio.conf
basestrap /mnt cryptsetup lvm2 mkinitcpio grub efibootmgr basestrap /mnt cryptsetup lvm2 mkinitcpio grub efibootmgr
# Install grub.
### INSTALL GRUB ###
cryptUUID=$(blkid -s UUID -o value "${targetDisk}2") cryptUUID=$(blkid -s UUID -o value "${targetDisk}2")
swapUUID=$(blkid -s UUID -o value /dev/$volGroup/swap) # For SWAP partition. swapUUID=$(blkid -s UUID -o value /dev/$volGroup/swap) # For SWAP partition.
sed -s "s/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"\ sed -s "s/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"\
@ -95,12 +111,13 @@ sed -s 's/^#GRUB_ENABLE_CRYPTODISK=y/GRUB_ENABLE_CRYPTODISK=y/g' -i /mnt/etc/def
artix-chroot /mnt sh -c 'grub-install --target=x86_64-efi --efi-directory=/boot \ artix-chroot /mnt sh -c 'grub-install --target=x86_64-efi --efi-directory=/boot \
--bootloader-id=grub && grub-mkconfig -o /boot/grub/grub.cfg' --bootloader-id=grub && grub-mkconfig -o /boot/grub/grub.cfg'
# Set root password and sudoers.
### SET THE ROOT PASSWORD AND SUDOERS ###
artix-chroot /mnt sh -c 'echo root:password | chpasswd' artix-chroot /mnt sh -c 'echo root:password | chpasswd'
sed -s 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL \ sed -s 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL \
Defaults rootpw,pwfeedback/g' -i /mnt/etc/sudoers Defaults rootpw,pwfeedback/g' -i /mnt/etc/sudoers
# Set the hostname. ### SET THE HOSTNAME ###
echo "$hostName" >/mnt/etc/hostname echo "$hostName" >/mnt/etc/hostname
echo "$hostName" >/mnt/etc/ echo "$hostName" >/mnt/etc/
echo "127.0.0.1 localhost echo "127.0.0.1 localhost
@ -108,22 +125,23 @@ echo "127.0.0.1 localhost
127.0.1.1 $hostName.vicious.ly $hostName" >>/mnt/etc/hosts 127.0.1.1 $hostName.vicious.ly $hostName" >>/mnt/etc/hosts
artix-chroot /mnt artix-chroot /mnt
# Set locale and default timezone. ### SET LOCALE AND DEFAULT TIMEZONE ###
echo 'LANG="en_US.UTF-8" echo 'LANG="en_US.UTF-8"
LC_COLLATE="C"' >/mnt/etc/locale.conf LC_COLLATE="C"' >/mnt/etc/locale.conf
sed -s 's/#en_US/en_US/g' -i /mnt/etc/locale.gen sed -s 's/#en_US/en_US/g' -i /mnt/etc/locale.gen
artix-chroot /mnt sh -c 'locale-gen' artix-chroot /mnt sh -c 'locale-gen'
artix-chroot /mnt sh -c 'ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime && hwclock -w' artix-chroot /mnt sh -c 'ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime && hwclock -w'
# Perform cleanups. ### PERFORM CLEANUP ###
# swapoff /mnt/swapfile # When using SWAP file. swapoff /mnt/swapfile # When using SWAP file.
swapoff /mnt/$volGroup/SWAP # swapoff /mnt/$volGroup/SWAP # When using SWAP partitition.
umount -R /mnt umount -R /mnt
vgchange -a n vgchange -a n
cryptsetup close $volGroup cryptsetup close $volGroup
### INSTALLATION COMPLETE ###
set +x set +x
echo echo
echo "+-------------------------------------------------------------------------+" echo "+-------------------------------------------------------------------------+"
echo "| Installation completed, you can log in with root password $rootPassword |" echo "| Installation completed, Qyou can log in with root password $rootPassword |"
echo "+-------------------------------------------------------------------------+" echo "+-------------------------------------------------------------------------+"