It looks the below logic can be further improved to
if [ -n "$use_root_partition" ]; then src_lv_suffix=_$use_root_partition else src_lv_suffix=$timestamp fi
if [ -n "$save_root_partition" ]; then boot_lv_suffix=_$save_root_partition else boot_lv_suffix= fi
local base_path=/dev/mapper/os-openeuler_aarch64_20.03 SRC_LV="${base_path}${src_lv_suffix}" BOOT_LV="${base_path}${boot_lv_suffix}"
if [ -n "$use_root_partition" ]; then check_src_lv ${SRC_LV} else rsync_src_lv ${SRC_LV} fi
snapshot_boot_lv boot_from_lv
Thanks, Fengguang
- no_save_no_use()
- {
export SRC_LV="/dev/mapper/os-openeuler_aarch64_20.03_${timestamp}"
export BOOT_LV="/dev/mapper/os-openeuler_aarch64_20.03"
rsync_src_lv ${SRC_LV}
- }
- only_save()
- {
export SRC_LV="/dev/mapper/os-openeuler_aarch64_20.03_${timestamp}"
export BOOT_LV="/dev/mapper/os-openeuler_aarch64_20.03_${save_root_partition}"
rsync_src_lv ${SRC_LV}
- }
- only_use()
- {
export SRC_LV="/dev/mapper/os-openeuler_aarch64_20.03_${use_root_partition}"
export BOOT_LV="/dev/mapper/os-openeuler_aarch64_20.03"
check_src_lv ${SRC_LV}
- }
- save_and_use()
- {
export SRC_LV="/dev/mapper/os-openeuler_aarch64_20.03_${use_root_partition}"
export BOOT_LV="/dev/mapper/os-openeuler_aarch64_20.03_${save_root_partition}"
check_src_lv ${SRC_LV}
- }
- main()
- {
[ -z ${use_root_partition} ] && [ -z ${save_root_partition} ] && no_save_no_use
[ -z ${use_root_partition} ] && [ -n ${save_root_partition} ] && only_save
[ -n ${use_root_partition} ] && [ -z ${save_root_partition} ] && only_use
[ -n ${use_root_partition} ] && [ -n ${save_root_partition} ] && save_and_use
snapshot_boot_lv
boot_from_lv
- }
- main()
- execute the job
-- 2.23.0