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
View File

View File

@ -1,11 +1,12 @@
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
# Artix Linux Minimal Encrypted Install Script.
# Coded by Moony
# 9d5 until infinity
### Artix Linux minimal LUKS encryption install script ###
### Developed by Moony ###
### From '9d5 until infinity ###
# Proper usage checks.
### PROPER USAGE CHECKS ###
[ -z "$1" ] && echo "Usage:
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
@ -17,75 +18,90 @@ artix-luks-base-install /dev/sdX encrytption_pw root_pw" && exit
# [ -z "$(connmanctl state | grep -e online -e ready)" ] &&
# echo "No network connection." && exit
### PARAMETERS ###
targetDisk=$1
targetDisk="/dev/sdX" # /dev/sdX
[ -z "$targetDisk" ] && echo "No target disk specified." && exit
cryptPass=$2
cryptPass="P455w0rd" # Luks password
[ -z "$cryptPass" ] && echo "No encryption password provided." && exit
rootPassword=$3
rootPassword="R00TP455W0RD" # Root user password
[ -z "$rootPassword" ] && echo "No root password provided." && exit
volGroup=lvmSystem
hostName=vicious
##################
volGroup=lvmGroup # Lvm Volume Group Name
hostName=hostname # Computer hostname
echo "+-- Artix Installation Parameters --+"
echo "Target disk : \"$targetDisk\""
echo "Crypto pass : \"$cryptPass\""
echo "Cryptvol group: \"$volGroup\""
echo -n "Correct?" && read -r
echo "| Target disk path : \"$targetDisk\""
echo "| LUKS pass : \"$cryptPass\""
echo "| CryptVol Group : \"$volGroup\""
echo "+-----------------------------------+"
echo -n "Correct: y/n?" && read -r
# Reset/init.
### RESET / INITIALIZE ###
pacman -Sy --noconfirm parted
# swapoff /dev/$volGroup/swap 2>/dev/null # for swap partition.
swapoff /mnt/swapfile # for swap file.
# swapoff /dev/$volGroup/swap 2>/dev/null # If using SWAP partition
swapoff /mnt/swapfile # If using SWAP file
umount -R /mnt 2>/dev/null
vgchange -a n 2>/dev/null
cryptsetup close lvm-system 2>/dev/null
killall -s 9 cryptsetup 2>/dev/null
### PARTITION THE DISKS ###
set -xe
# Partition the disk.
parted -s -a optimal "$targetDisk" mklabel gpt
parted -s -a optimal "$targetDisk" mkpart "BOOT" fat32 0% 512MiB
parted -s -a optimal "$targetDisk" set 1 esp on
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 open "${targetDisk}2" lvm-system -d -
# Create logical volumes.
### CREATE LVM VOLUMES ###
pvcreate /dev/mapper/lvm-system
vgcreate $volGroup /dev/mapper/$volGroup
lvcreate -L 8G $volGroup -n SWAP # For swap partition
# lvcreate -L 50G $volGroup -n HOME # For set root partition if a separate home or var partition is desired.
# lvcreate -L 8G $volGroup -n SWAP # For SWAP partition if a SWAP 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
# Make filesystems.
### CREATE FILE SYSTEMS ###
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/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 linux linux-firmware intel-ucode
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
basestrap /mnt cryptsetup lvm2 mkinitcpio grub efibootmgr
# Install grub.
### INSTALL GRUB ###
cryptUUID=$(blkid -s UUID -o value "${targetDisk}2")
swapUUID=$(blkid -s UUID -o value /dev/$volGroup/swap) # For SWAP partition.
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 \
--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'
sed -s 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL \
Defaults rootpw,pwfeedback/g' -i /mnt/etc/sudoers
# Set the hostname.
### SET THE HOSTNAME ###
echo "$hostName" >/mnt/etc/hostname
echo "$hostName" >/mnt/etc/
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
artix-chroot /mnt
# Set locale and default timezone.
### SET LOCALE AND DEFAULT TIMEZONE ###
echo 'LANG="en_US.UTF-8"
LC_COLLATE="C"' >/mnt/etc/locale.conf
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 'ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime && hwclock -w'
# Perform cleanups.
# swapoff /mnt/swapfile # When using SWAP file.
swapoff /mnt/$volGroup/SWAP
### PERFORM CLEANUP ###
swapoff /mnt/swapfile # When using SWAP file.
# swapoff /mnt/$volGroup/SWAP # When using SWAP partitition.
umount -R /mnt
vgchange -a n
cryptsetup close $volGroup
### INSTALLATION COMPLETE ###
set +x
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 "+-------------------------------------------------------------------------+"