Update pve-privilege-converter.sh

This commit is contained in:
CanbiZ 2025-05-22 11:00:28 +02:00
parent 08fb1cce8b
commit c976dd4184

View File

@ -57,7 +57,7 @@ select_backup_storage() {
} }
backup_container() { backup_container() {
msg_info "Backing up container $CONTAINER_ID" msg_custom "Backing up container $CONTAINER_ID"
vzdump_output=$(mktemp) vzdump_output=$(mktemp)
vzdump "$CONTAINER_ID" --compress zstd --storage "$BACKUP_STORAGE" --mode snapshot | tee "$vzdump_output" vzdump "$CONTAINER_ID" --compress zstd --storage "$BACKUP_STORAGE" --mode snapshot | tee "$vzdump_output"
BACKUP_PATH=$(awk '/tar.zst/ {print $NF}' "$vzdump_output" | tr -d "'") BACKUP_PATH=$(awk '/tar.zst/ {print $NF}' "$vzdump_output" | tr -d "'")
@ -72,10 +72,10 @@ backup_container() {
select_target_storage() { select_target_storage() {
echo -e "\nSelect target storage for new container:\n" echo -e "\nSelect target storage for new container:\n"
target_storages=$(pvesm status --content images | awk '{if(NR>1)print $1}') mapfile -t target_storages < <(pvesm status --content images | awk 'NR > 1 {print $1}')
PS3="Enter number of target storage: " PS3="Enter number of target storage: "
select opt in $target_storages; do select opt in "${target_storages[@]}"; do
if [[ -n "$opt" ]]; then if [[ -n "$opt" ]]; then
TARGET_STORAGE="$opt" TARGET_STORAGE="$opt"
break break
@ -106,7 +106,7 @@ perform_conversion() {
UNPRIVILEGED=false UNPRIVILEGED=false
fi fi
msg_info "Restoring as $(if $UNPRIVILEGED; then echo privileged; else echo unprivileged; fi) container" msg_custom "Restoring as $(if $UNPRIVILEGED; then echo privileged; else echo unprivileged; fi) container"
restore_opts=("$NEW_CONTAINER_ID" "$BACKUP_PATH" --storage "$TARGET_STORAGE") restore_opts=("$NEW_CONTAINER_ID" "$BACKUP_PATH" --storage "$TARGET_STORAGE")
if $UNPRIVILEGED; then if $UNPRIVILEGED; then
restore_opts+=(--unprivileged false) restore_opts+=(--unprivileged false)
@ -140,7 +140,7 @@ manage_states() {
pct start "$NEW_CONTAINER_ID" pct start "$NEW_CONTAINER_ID"
msg_ok "New container started" msg_ok "New container started"
else else
msg_info "Skipped container state change" msg_custom "Skipped container state change"
fi fi
} }
@ -149,7 +149,7 @@ cleanup_files() {
if [[ ${cleanup:-Y} =~ ^[Yy] ]]; then if [[ ${cleanup:-Y} =~ ^[Yy] ]]; then
rm -f "$BACKUP_PATH" && msg_ok "Removed backup archive" rm -f "$BACKUP_PATH" && msg_ok "Removed backup archive"
else else
msg_info "Retained backup archive" msg_custom "Retained backup archive"
fi fi
} }