diff --git a/setup.sh b/setup.sh index c6404b7..c606a9e 100644 --- a/setup.sh +++ b/setup.sh @@ -36,6 +36,17 @@ trap '[ "$?" -ne 77 ] || exit 77' ERR declare zpool_drive efi_drive boot_drive part_schema +function calculate_prefix_from_netmask () { + # https://stackoverflow.com/a/50419919 + c='0' + x='0'"$(printf -- '%o' ${1//./ })" + while [ "${x}" -gt '0' ]; do + # Modulo then bitwise-shift x and store as new x + let c+="$(( x % 2 ))" 'x>>=1' + done + printf -- '%s' '/'"${c}"; +} + function setup_env_vars () { printf -- '%s\n' \ 'We will go over a series of questions to create an answer file with' \