Add script hot swapping functionality

This commit is contained in:
Saverio Miroddi 2021-04-27 13:22:54 +02:00
parent 3cbc9ff207
commit e176be6521

View File

@ -43,6 +43,8 @@ v_suitable_disks=() # (/dev/by-id/disk_id, ...); scope: find_suitable_d
# Note that Linux Mint is "Linuxmint" from v20 onwards. This actually helps, since some operations are # Note that Linux Mint is "Linuxmint" from v20 onwards. This actually helps, since some operations are
# specific to it. # specific to it.
c_hotswap_file=$PWD/install-zfs.hotswap.sh # see hotswap() for an explanation.
c_bpool_name=bpool c_bpool_name=bpool
c_ppa=ppa:jonathonf/zfs c_ppa=ppa:jonathonf/zfs
c_efi_system_partition_size=512 # megabytes c_efi_system_partition_size=512 # megabytes
@ -142,6 +144,8 @@ function invoke {
exit 1 exit 1
fi fi
hot_swap_script
# Invoke it regardless when it's not optional. # Invoke it regardless when it's not optional.
if declare -f "$distro_specific_fx_name" > /dev/null; then if declare -f "$distro_specific_fx_name" > /dev/null; then
@ -155,6 +159,18 @@ function invoke {
fi fi
} }
# Tee-hee-hee!!
#
# This is extremely useful for debugging long procedures. Since bash scripts can't be modified while
# running, this allows the dev to create a snapshot, and if the script fails after that, resume and
# add the hotswap script, so that the new code will be loaded automatically.
#
function hot_swap_script {
if [[ -f $c_hotswap_file ]]; then
source "$c_hotswap_file"
fi
}
function print_step_info_header { function print_step_info_header {
local function_name=$1 local function_name=$1