Refactor pv installation into ensure_pv function (#7642)
Moved pv installation logic into a reusable ensure_pv function in both haos-vm.sh and umbrel-os-vm.sh. This improves code clarity and avoids duplicate code for checking and installing the pv package.
This commit is contained in:
parent
31be78878f
commit
600e739005
|
|
@ -205,6 +205,15 @@ function exit-script() {
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ensure_pv() {
|
||||||
|
if ! command -v pv &>/dev/null; then
|
||||||
|
msg_info "Installing required package: pv"
|
||||||
|
apt-get update -qq &>/dev/null
|
||||||
|
apt-get install -y pv &>/dev/null
|
||||||
|
msg_ok "Installed pv"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function default_settings() {
|
function default_settings() {
|
||||||
BRANCH="$stable"
|
BRANCH="$stable"
|
||||||
VMID=$(get_valid_nextid)
|
VMID=$(get_valid_nextid)
|
||||||
|
|
@ -448,8 +457,8 @@ check_root
|
||||||
arch_check
|
arch_check
|
||||||
pve_check
|
pve_check
|
||||||
ssh_check
|
ssh_check
|
||||||
|
ensure_pv
|
||||||
start_script
|
start_script
|
||||||
|
|
||||||
post_to_api_vm
|
post_to_api_vm
|
||||||
|
|
||||||
msg_info "Validating Storage"
|
msg_info "Validating Storage"
|
||||||
|
|
@ -505,10 +514,6 @@ else
|
||||||
msg_ok "Using cached image ${CL}${BL}$(basename "$CACHE_FILE")${CL}"
|
msg_ok "Using cached image ${CL}${BL}$(basename "$CACHE_FILE")${CL}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v pv &>/dev/null; then
|
|
||||||
apt-get update -qq &>/dev/null && apt-get install -y pv &>/dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
msg_info "Creating Home Assistant OS VM shell"
|
msg_info "Creating Home Assistant OS VM shell"
|
||||||
qm create "$VMID" -machine q35 -bios ovmf -agent 1 -tablet 0 -localtime 1 ${CPU_TYPE} \
|
qm create "$VMID" -machine q35 -bios ovmf -agent 1 -tablet 0 -localtime 1 ${CPU_TYPE} \
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,15 @@ function exit-script() {
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ensure_pv() {
|
||||||
|
if ! command -v pv &>/dev/null; then
|
||||||
|
msg_info "Installing required package: pv"
|
||||||
|
apt-get update -qq &>/dev/null
|
||||||
|
apt-get install -y pv &>/dev/null
|
||||||
|
msg_ok "Installed pv"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function default_settings() {
|
function default_settings() {
|
||||||
VMID=$(get_valid_nextid)
|
VMID=$(get_valid_nextid)
|
||||||
MACHINE="q35"
|
MACHINE="q35"
|
||||||
|
|
@ -432,6 +441,7 @@ check_root
|
||||||
arch_check
|
arch_check
|
||||||
pve_check
|
pve_check
|
||||||
ssh_check
|
ssh_check
|
||||||
|
ensure_pv
|
||||||
start_script
|
start_script
|
||||||
|
|
||||||
msg_info "Validating Storage"
|
msg_info "Validating Storage"
|
||||||
|
|
@ -472,10 +482,6 @@ else
|
||||||
msg_ok "Using cached Umbrel OS image"
|
msg_ok "Using cached Umbrel OS image"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v pv &>/dev/null; then
|
|
||||||
apt-get update -qq &>/dev/null && apt-get install -y pv &>/dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
qm create "$VMID" -machine q35 -bios ovmf -agent 1 -tablet 0 -localtime 1 ${CPU_TYPE} \
|
qm create "$VMID" -machine q35 -bios ovmf -agent 1 -tablet 0 -localtime 1 ${CPU_TYPE} \
|
||||||
-cores "$CORE_COUNT" -memory "$RAM_SIZE" -name "$HN" -tags community-script \
|
-cores "$CORE_COUNT" -memory "$RAM_SIZE" -name "$HN" -tags community-script \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user