1-get-initial-setup-working #2
20
setup.sh
20
setup.sh
@ -7,6 +7,10 @@ declare zpool_name zfs_arch_dataset_name
|
|||||||
zpool_name='zpool'
|
zpool_name='zpool'
|
||||||
zfs_arch_dataset_name='archlinux'
|
zfs_arch_dataset_name='archlinux'
|
||||||
|
|
||||||
|
# https://unix.stackexchange.com/a/48550
|
||||||
|
set -E
|
||||||
|
trap '[ "$?" -ne 77 ] || exit 77' ERR
|
||||||
|
|
||||||
function set_ntp () {
|
function set_ntp () {
|
||||||
timedatectl set-ntp true
|
timedatectl set-ntp true
|
||||||
}
|
}
|
||||||
@ -56,8 +60,8 @@ function get_parts () {
|
|||||||
parts="$(get_partitions | jq --raw-output '.[][] | select(.parttype=="c12a7328-f81f-11d2-ba4b-00a0c93ec93b") | .path')" || exit 1
|
parts="$(get_partitions | jq --raw-output '.[][] | select(.parttype=="c12a7328-f81f-11d2-ba4b-00a0c93ec93b") | .path')" || exit 1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf -- '%s\n' 'Unknown partition type '"'"'"${parttype}"'"'"', exiting 1 ...'
|
>2 printf -- '%s\n' 'Unknown partition type '"'"'"${parttype}"'"'"', exiting 1 ...'
|
||||||
exit 1
|
exit 77
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
printf -- '%s' "${parts}"
|
printf -- '%s' "${parts}"
|
||||||
@ -72,8 +76,8 @@ function we_have_exactly_one_part () {
|
|||||||
if [[ "$(wc -c <<<"${parts_list}")" -gt '1' ]]; then
|
if [[ "$(wc -c <<<"${parts_list}")" -gt '1' ]]; then
|
||||||
case "${parts_count}" in
|
case "${parts_count}" in
|
||||||
0)
|
0)
|
||||||
printf -- '%s\n' 'No '"${parttype^^}"' partition found. Exiting 1 ...'
|
>2 printf -- '%s\n' 'No '"${parttype^^}"' partition found. Exiting 1 ...'
|
||||||
exit 1
|
exit 77
|
||||||
;;
|
;;
|
||||||
1)
|
1)
|
||||||
return 0
|
return 0
|
||||||
@ -82,8 +86,8 @@ function we_have_exactly_one_part () {
|
|||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
printf -- '%s\n' 'Partition list does not look valid. Cowardly exiting 1 ...'
|
>2 printf -- '%s\n' 'Partition list does not look valid. Cowardly exiting 1 ...'
|
||||||
exit 1
|
exit 77
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,8 +98,8 @@ function get_drive_id () {
|
|||||||
printf -- '%s' "${drive_id}"
|
printf -- '%s' "${drive_id}"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
printf -- '%s\n' 'Not exactly one '"'${1:?}'"' partition entry in /dev/disk/by-id, exiting 1 ...'
|
>2 printf -- '%s\n' 'Not exactly one '"'${1:?}'"' partition entry in /dev/disk/by-id, exiting 1 ...'
|
||||||
exit 1
|
exit 77
|
||||||
}
|
}
|
||||||
|
|
||||||
function select_part () {
|
function select_part () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user