#!/bin/bash error_dialog(){ DIALOGRC="${HOME}/.dialogerrrc" dialog --ok-label 'Continue' --nocancel \ --title 'Error' \ --msgbox "${1}" 0 0 } run_in_chroot(){ chroot '/target/' /bin/bash -c "${1}" } validate_pass(){ if [[ "${1}" == "${2}" ]];then return 0 else error_dialog "Passwords do not match" return 1 fi } validate_disk_size(){ if [[ "${root_gb_free}" -gt "10" ]];then return 0 else error_dialog "Requested installation too large for target device" return 1 fi } validate_install_size(){ #provide option to have no home part disk_size=$(printf '( %s / 1048576 ) - 1024\n' `lsblk -bno SIZE -d "${dest_dev}"` | bc) if [[ "${disk_size}" -gt "${root_end}" ]];then return 0 else error_dialog "Requested installation too large for target device" return 1 fi } validate_username(){ if [[ "${1}" =~ ^[a-z_]([a-z0-9_-]{0,31}|[a-z0-9_-]{0,30}\$)$ ]];then return 0 else error_dialog "Bad username format" return 1 fi } sanitize_hostname(){ printf "%s" "${1}" | tr -dc '\-[:alnum:]\n\r' | tr '[:upper:]' '[:lower:]' } encrypt_partition(){ printf "%s" "${3}" | cryptsetup luksFormat "${1}" - printf "%s" "${3}" | cryptsetup luksOpen "${1}" "${2}_crypt" - }