Compare commits
6 Commits
58da096eab
...
39039ce3fd
Author | SHA1 | Date | |
---|---|---|---|
39039ce3fd | |||
1183f3f025 | |||
be76d6b0f8 | |||
67ea72de51 | |||
9f3ada2a36 | |||
28414af039 |
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
archzbm_settings.env
|
@@ -149,6 +149,8 @@ By default the script configures plain ZFSBootMenu without networking nor an SSH
|
|||||||
|
|
||||||
#### IP address
|
#### IP address
|
||||||
|
|
||||||
|
> IPv6 addresses are untested. Script has been confirmed working with IPv4 addresses.
|
||||||
|
|
||||||
```
|
```
|
||||||
ARCHZBM_NET_CLIENT_IP=''
|
ARCHZBM_NET_CLIENT_IP=''
|
||||||
ARCHZBM_NET_SERVER_IP=''
|
ARCHZBM_NET_SERVER_IP=''
|
||||||
|
229
setup.sh
229
setup.sh
@@ -19,9 +19,10 @@ exec 3>&1
|
|||||||
declare this_script_url
|
declare this_script_url
|
||||||
this_script_url="${SCRIPT_URL:?}"
|
this_script_url="${SCRIPT_URL:?}"
|
||||||
|
|
||||||
declare zpool_name zfs_arch_dataset_name
|
declare zpool_name zfs_arch_dataset_name settings_file
|
||||||
zpool_name='zpool'
|
zpool_name='zpool'
|
||||||
zfs_arch_dataset_name='archlinux'
|
zfs_arch_dataset_name='archlinux'
|
||||||
|
settings_file='archzbm_settings.env'
|
||||||
|
|
||||||
declare -A partition_types
|
declare -A partition_types
|
||||||
partition_types[gpt_zfs]='6a85cf4d-1dd2-11b2-99a6-080020736631'
|
partition_types[gpt_zfs]='6a85cf4d-1dd2-11b2-99a6-080020736631'
|
||||||
@@ -35,6 +36,226 @@ trap '[ "$?" -ne 77 ] || exit 77' ERR
|
|||||||
|
|
||||||
declare zpool_drive efi_drive boot_drive part_schema
|
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
|
||||||
|
-[[:alnum:]]*)
|
||||||
|
>&3 printf -- '%s\n' \
|
||||||
|
'Short options '"'${1}'"' detected. Only known option is' \
|
||||||
|
'literal string '"'"'setup'"'"'. No idea what '"'${1}'"' is.' \
|
||||||
|
'Exiting ...'
|
||||||
|
exit 77
|
||||||
|
;;
|
||||||
|
--*)
|
||||||
|
>&3 printf -- '%s\n' \
|
||||||
|
'Long-form option '"'${1}'"' detected. Only known option is' \
|
||||||
|
'literal string '"'"'setup'"'"'. No idea what '"'${1}'"' is.' \
|
||||||
|
'Exiting ...'
|
||||||
|
exit 77
|
||||||
|
;;
|
||||||
|
setup)
|
||||||
|
setup_env_vars
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
>&3 printf -- '%s\n' \
|
||||||
|
'Argument '"'${1}'"' detected. Only known option is literal' \
|
||||||
|
'string '"'"'setup'"'"'. No idea what '"'${1}'"' is.' \
|
||||||
|
'Exiting ...'
|
||||||
|
exit 77
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
function we_are_changerooted () {
|
function we_are_changerooted () {
|
||||||
if [ "$(stat -c '%d:%i' '/')" != "$(stat -c '%d:%i' '/proc/1/root/.')" ]; then
|
if [ "$(stat -c '%d:%i' '/')" != "$(stat -c '%d:%i' '/proc/1/root/.')" ]; then
|
||||||
return 0
|
return 0
|
||||||
@@ -330,7 +551,6 @@ function load_settings_file () {
|
|||||||
#1.8
|
#1.8
|
||||||
local working_dir settings_file settings_abs
|
local working_dir settings_file settings_abs
|
||||||
working_dir="$(pwd)"
|
working_dir="$(pwd)"
|
||||||
settings_file='archzbm_settings.env'
|
|
||||||
settings_abs="${working_dir}"'/'"${settings_file}"
|
settings_abs="${working_dir}"'/'"${settings_file}"
|
||||||
if [[ -r "${settings_abs}" ]]; then
|
if [[ -r "${settings_abs}" ]]; then
|
||||||
set -a
|
set -a
|
||||||
@@ -1137,6 +1357,9 @@ function finalize_os_setup () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function main () {
|
function main () {
|
||||||
|
if [[ "${#@}" -gt '0' ]]; then
|
||||||
|
arg_parse "${@}"
|
||||||
|
fi
|
||||||
if we_are_changerooted; then
|
if we_are_changerooted; then
|
||||||
install_os_in_chroot #2.2
|
install_os_in_chroot #2.2
|
||||||
else
|
else
|
||||||
@@ -1164,4 +1387,4 @@ function main () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main
|
main "${@}"
|
||||||
|
Reference in New Issue
Block a user