Formatting
This commit is contained in:
parent
895acd1694
commit
ab01803bc5
@ -127,7 +127,6 @@ log() {
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
get_available_disks() {
|
||||
local available_disks
|
||||
available_disks=()
|
||||
@ -141,7 +140,7 @@ get_available_disks() {
|
||||
available_disks+=("$(echo "${REPLY}" | cut -d " " -f1)")
|
||||
fi
|
||||
|
||||
done <<< "$(lsblk)"
|
||||
done <<<"$(lsblk)"
|
||||
|
||||
local ret_val
|
||||
# Build the array into a string, yes this is less efficient, but easier to modify in the future if something changes
|
||||
@ -161,7 +160,7 @@ list_disks() {
|
||||
log "info" "Available disks"
|
||||
for disk in ${disks}; do
|
||||
printf "%s\n" "${count}.)" "${disk}"
|
||||
count=$(( count + 1 ))
|
||||
count=$((count + 1))
|
||||
done
|
||||
}
|
||||
|
||||
@ -171,7 +170,7 @@ get_num_of_elems() {
|
||||
|
||||
install() {
|
||||
|
||||
if ! host "google.com" > /dev/null; then
|
||||
if ! host "google.com" >/dev/null; then
|
||||
log "error" "Unable to reach google, network is down. This script requires network connectivity with active DNS resolution"
|
||||
exit 1
|
||||
fi
|
||||
@ -183,8 +182,7 @@ install() {
|
||||
log "info" "Querying system for available disks..."
|
||||
available_disks="$(get_available_disks)"
|
||||
disk_count="$(get_num_of_elems "${available_disks}")"
|
||||
disk_count=$(( disk_count - 1))
|
||||
|
||||
disk_count=$((disk_count - 1))
|
||||
|
||||
local disk_selected
|
||||
local install_disk
|
||||
@ -196,7 +194,7 @@ install() {
|
||||
list_disks "${available_disks}"
|
||||
read -rp "Select a disk number to install arch linux to: " disk_selected
|
||||
|
||||
if "${disk_selected}" -eq "${disk_selected}" 2> /dev/null; then
|
||||
if "${disk_selected}" -eq "${disk_selected}" 2>/dev/null; then
|
||||
:
|
||||
else
|
||||
log "error" "A number was not passed"
|
||||
@ -214,7 +212,7 @@ install() {
|
||||
install_path="${DISK_BASE_PATH}/${install_disk}"
|
||||
valid_disk_selected=0
|
||||
fi
|
||||
count=$(( count + 1 ))
|
||||
count=$((count + 1))
|
||||
done
|
||||
fi
|
||||
done
|
||||
@ -236,11 +234,12 @@ install() {
|
||||
sfdisk --delete "${install_path}" >/dev/null
|
||||
log "info" "Wiped partitions on $(important "${install_disk}")"
|
||||
log "info" "Securely erasing remaining data on $(important "${install_disk}")"
|
||||
echo YES | cryptsetup open --type plain -d /dev/urandom "${install_path}" to_be_wiped > /dev/null || exit
|
||||
echo YES | cryptsetup open --type plain -d /dev/urandom "${install_path}" to_be_wiped >/dev/null || exit
|
||||
dd bs=1M if=/dev/zero of=/dev/mapper/to_be_wiped status=progress
|
||||
cryptsetup close to_be_wiped || exit
|
||||
log "info" "Writing new partitions to $(important "${install_disk}")"
|
||||
(echo n
|
||||
(
|
||||
echo n
|
||||
echo
|
||||
echo
|
||||
echo +512M
|
||||
@ -251,7 +250,8 @@ install() {
|
||||
echo
|
||||
echo 8300
|
||||
echo w
|
||||
echo Y) | gdisk "${install_path}" > /dev/null
|
||||
echo Y
|
||||
) | gdisk "${install_path}" >/dev/null
|
||||
log "info" "Wrote partitions"
|
||||
log "info" "Encrypting $(important "${install_disk}"), if you are prompted type $(important "YES")"
|
||||
cryptsetup -y -v luksFormat "${install_path}p2" || exit
|
||||
@ -267,16 +267,16 @@ install() {
|
||||
mount "${install_path}p1" /mnt/boot
|
||||
local mem_amount_kb
|
||||
mem_amount_kb="$(grep MemTotal /proc/meminfo | tr -s " " | cut -d " " -f2)"
|
||||
mem_amount_mb=$(( mem_amount_kb / 1024 ))
|
||||
mem_amount_mb=$((mem_amount_kb / 1024))
|
||||
|
||||
# Space to swap is taken from fedora guidelines:
|
||||
# https://docs.fedoraproject.org/en-US/Fedora/22/html/Installation_Guide/sect-installation-gui-manual-partitioning-recommended.html
|
||||
if (( mem_amount_mb < 2048 )); then
|
||||
mem_amount_kb=$(( mem_amount_kb * 3 / 1024 ))
|
||||
elif (( mem_amount_mb < 8192 )); then
|
||||
mem_amount_kb=$(( mem_amount_kb * 2 / 1024 ))
|
||||
elif (( mem_amount_mb < 65536 )); then
|
||||
mem_amount_kb=$((mem_amount_kb * 3/2 / 1024 ))
|
||||
if ((mem_amount_mb < 2048)); then
|
||||
mem_amount_kb=$((mem_amount_kb * 3 / 1024))
|
||||
elif ((mem_amount_mb < 8192)); then
|
||||
mem_amount_kb=$((mem_amount_kb * 2 / 1024))
|
||||
elif ((mem_amount_mb < 65536)); then
|
||||
mem_amount_kb=$((mem_amount_kb * 3 / 2 / 1024))
|
||||
fi
|
||||
|
||||
log "info" "Creating swap file with memory amount: $(important "${mem_amount_kb}") mebibytes"
|
||||
@ -297,10 +297,10 @@ install() {
|
||||
pacstrap /mnt base base-devel linux linux-headers linux-firmware neovim
|
||||
log "info" "Finished installing packages"
|
||||
log "info" "Generating fstab"
|
||||
genfstab -U /mnt >> /mnt/etc/fstab
|
||||
genfstab -U /mnt >>/mnt/etc/fstab
|
||||
log "info" "Finished generating fstab"
|
||||
log "info" "Switching to new installation and finishing up install"
|
||||
arch-chroot /mnt << __END_CHROOT_CMDS__
|
||||
arch-chroot /mnt <<__END_CHROOT_CMDS__
|
||||
echo -e "toor\ntoor\n" | passwd
|
||||
|
||||
echo "arch" > /etc/hostname
|
||||
@ -334,4 +334,3 @@ main() {
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user