feat(iso): Add setup function to generate answer file (#21)
This commit is contained in:
parent
9f3ada2a36
commit
67ea72de51
188
setup.sh
188
setup.sh
@ -36,6 +36,194 @@ trap '[ "$?" -ne 77 ] || exit 77' ERR
|
||||
|
||||
declare zpool_drive efi_drive boot_drive part_schema
|
||||
|
||||
function setup_env_vars () {
|
||||
printf -- '%s\n' \
|
||||
'We will go over a series of questions to create an answer file with' \
|
||||
'options you want the script to use.' \
|
||||
'' \
|
||||
'Current working directory is:'\
|
||||
"$(pwd)" \
|
||||
'' \
|
||||
'After we'"'"'re done answer file will be written to current working dir:' \
|
||||
'./'"${settings_file}" \
|
||||
'' \
|
||||
'Press <Ctrl>+C to abort this process. No answer file will' \
|
||||
'be written to ./'"${settings_file}"' if you abort the script.' \
|
||||
'' \
|
||||
'When done rerun the same command you just did without '"'"'setup'"'"' argument.' \
|
||||
''
|
||||
read -u3 -n 1 -s -r -p "Press any key to begin questionnaire"
|
||||
echo
|
||||
echo '----------------------------------------'
|
||||
echo
|
||||
|
||||
echo "Do you want compressed datasets?"
|
||||
select arg_compressed in "Compressed" "Uncompressed"; do
|
||||
case "${arg_compressed}" in
|
||||
Compressed)
|
||||
break
|
||||
;;
|
||||
Uncompressed)
|
||||
ARCHZBM_ZFSPROPS_NO_COMPRESSION='true'
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done <&3 && echo
|
||||
|
||||
echo "Do you want encrypted datasets?"
|
||||
select arg_encrypted in "Encrypted" "Unencrypted"; do
|
||||
case "${arg_encrypted}" in
|
||||
Encrypted)
|
||||
break
|
||||
;;
|
||||
Unencrypted)
|
||||
ARCHZBM_ZFSPROPS_NO_ENCRYPTION='true'
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done <&3 && echo
|
||||
|
||||
if [[ "${arg_encrypted}" = 'Encrypted' ]]; then
|
||||
echo "Do you want a custom dataset decryption password?"
|
||||
select arg_custom_dataset_pw in "Yes" "No"; do
|
||||
case "${arg_custom_dataset_pw}" in
|
||||
Yes)
|
||||
want_custom_dataset_pw='true'
|
||||
break
|
||||
;;
|
||||
No)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done <&3 && echo
|
||||
|
||||
if [[ "${want_custom_dataset_pw}" ]]; then
|
||||
read -u3 -p 'Please type password, confirm with <Enter>: ' -s ARCHZBM_ZPOOL_PASSWORD
|
||||
echo
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Do you want a custom 'root' user password?"
|
||||
select arg_custom_root_pw in "Yes" "No"; do
|
||||
case "${arg_custom_root_pw}" in
|
||||
Yes)
|
||||
want_custom_root_pw='true'
|
||||
break
|
||||
;;
|
||||
No)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done <&3 && echo
|
||||
|
||||
if [[ "${want_custom_root_pw}" ]]; then
|
||||
read -u3 -p 'Please type password, confirm with <Enter>: ' -s ARCHZBM_ROOT_PASSWORD
|
||||
echo
|
||||
echo
|
||||
fi
|
||||
|
||||
echo "Do you want an SSH daemon in ZFSBootMenu?"
|
||||
select arg_ssh_in_zbm in "Yes" "No"; do
|
||||
case "${arg_ssh_in_zbm}" in
|
||||
Yes)
|
||||
want_ssh_in_zbm='true'
|
||||
break
|
||||
;;
|
||||
No)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done <&3 && echo
|
||||
|
||||
if [[ "${want_ssh_in_zbm}" ]]; then
|
||||
echo "How do you want to assign an IP address in ZFSBootMenu?"
|
||||
select arg_ip_autoconf_method in "Statically" "Dynamically, DHCP" "Dynamically, BOOTP" "Dynamically, RARP"; do
|
||||
case "${arg_ip_autoconf_method}" in
|
||||
'Statically')
|
||||
ARCHZBM_NET_AUTOCONF='none'
|
||||
break
|
||||
;;
|
||||
'Dynamically, DHCP')
|
||||
ARCHZBM_NET_AUTOCONF='dhcp'
|
||||
break
|
||||
;;
|
||||
'Dynamically, BOOTP')
|
||||
ARCHZBM_NET_AUTOCONF='bootp'
|
||||
break
|
||||
;;
|
||||
'Dynamically, RARP')
|
||||
ARCHZBM_NET_AUTOCONF='rarp'
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done <&3 && echo
|
||||
|
||||
read -u3 -p 'Which device to configure (eth0 is a good guess): ' ARCHZBM_NET_DEVICE
|
||||
echo
|
||||
|
||||
if [[ "${arg_ip_autoconf_method}" = 'Statically' ]]; then
|
||||
read -u3 -p 'Interface IP address: ' ARCHZBM_NET_CLIENT_IP
|
||||
echo
|
||||
|
||||
read -u3 -p 'Netmask: ' ARCHZBM_NET_NETMASK
|
||||
echo
|
||||
|
||||
read -u3 -p 'Gateway IP address: ' ARCHZBM_NET_GATEWAY_IP
|
||||
echo
|
||||
fi
|
||||
|
||||
echo "Do you want a custom SSH listening port?"
|
||||
select arg_custom_ssh_port in "Yes (let me specify)" "No (keep port 22)"; do
|
||||
case "${arg_custom_ssh_port}" in
|
||||
'Yes (let me specify)')
|
||||
want_custom_ssh_port='true'
|
||||
break
|
||||
;;
|
||||
'No (keep port 22)')
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done <&3 && echo
|
||||
|
||||
if [[ "${want_custom_ssh_port}" ]]; then
|
||||
read -u3 -p 'Please type SSH port, confirm with <Enter>: ' ARCHZBM_SSH_PORT
|
||||
echo
|
||||
fi
|
||||
|
||||
echo "Do you want the SSH daemon to use a custom keepalive send interval?"
|
||||
select arg_custom_ssh_keepalive_intvl in "Yes (let me specify)" "No (keep 1)"; do
|
||||
case "${arg_custom_ssh_keepalive_intvl}" in
|
||||
'Yes (let me specify)')
|
||||
want_custom_keepalive_intvl='true'
|
||||
break
|
||||
;;
|
||||
'No (keep 1)')
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done <&3 && echo
|
||||
|
||||
if [[ "${want_custom_keepalive_intvl}" ]]; then
|
||||
read -u3 -p 'Please type server keepalive send interval, confirm with <Enter>: ' ARCHZBM_SSH_KEEPALIVE_INTVL
|
||||
echo
|
||||
fi
|
||||
|
||||
if [[ "${want_custom_keepalive_intvl}" ]]; then
|
||||
read -u3 -p 'Please type SSH pub keys on one line separated by double-commas (,,) and confirm with <Enter>: ' ARCHZBM_SSH_AUTH_KEYS
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
|
||||
for env_var in 'ARCHZBM_ZFSPROPS_NO_COMPRESSION' 'ARCHZBM_ZFSPROPS_NO_ENCRYPTION' 'ARCHZBM_ZPOOL_PASSWORD' 'ARCHZBM_ROOT_PASSWORD' 'ARCHZBM_NET_AUTOCONF' 'ARCHZBM_NET_DEVICE' 'ARCHZBM_NET_CLIENT_IP' 'ARCHZBM_NET_NETMASK' 'ARCHZBM_NET_GATEWAY_IP' 'ARCHZBM_SSH_PORT' 'ARCHZBM_SSH_KEEPALIVE_INTVL' 'ARCHZBM_SSH_AUTH_KEYS'; do
|
||||
if [[ "${!env_var}" ]]; then
|
||||
printf -- '%s='"'"'%s'"'"'\n' \
|
||||
"${env_var}" "${!env_var}" \
|
||||
>> "${settings_file}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function arg_parse () {
|
||||
[[ "${1}" ]] && while :; do
|
||||
case "${1}" in
|
||||
|
Loading…
x
Reference in New Issue
Block a user