mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-09-02 03:23:18 +02:00
fix(tools): stop a failed deploy from wiping the existing install (#16312)
This commit is contained in:
+29
-28
@@ -2576,11 +2576,6 @@ _deploy_unpacked_archive() {
|
|||||||
local archive="$1" target="$2" workdir="$3"
|
local archive="$1" target="$2" workdir="$3"
|
||||||
local filename="${archive##*/}"
|
local filename="${archive##*/}"
|
||||||
|
|
||||||
mkdir -p "$target"
|
|
||||||
if [[ "${CLEAN_INSTALL:-0}" == "1" ]]; then
|
|
||||||
find "${target:?}" -mindepth 1 -delete
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$filename" == *.zip ]]; then
|
if [[ "$filename" == *.zip ]]; then
|
||||||
ensure_dependencies unzip
|
ensure_dependencies unzip
|
||||||
unzip -q "$archive" -d "$workdir" || {
|
unzip -q "$archive" -d "$workdir" || {
|
||||||
@@ -2607,38 +2602,44 @@ _deploy_unpacked_archive() {
|
|||||||
return 65
|
return 65
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local top_entries inner_dir
|
local top_entries inner_dir source_dir
|
||||||
top_entries=$(find "$workdir" -mindepth 1 -maxdepth 1)
|
top_entries=$(find "$workdir" -mindepth 1 -maxdepth 1)
|
||||||
if [[ "$(echo "$top_entries" | wc -l)" -eq 1 && -d "$top_entries" ]]; then
|
if [[ "$(echo "$top_entries" | wc -l)" -eq 1 && -d "$top_entries" ]]; then
|
||||||
inner_dir="$top_entries"
|
inner_dir="$top_entries"
|
||||||
shopt -s dotglob nullglob
|
source_dir="$inner_dir"
|
||||||
if compgen -G "$inner_dir/*" >/dev/null; then
|
|
||||||
cp -r "$inner_dir"/* "$target/" || {
|
|
||||||
msg_error "Failed to copy contents from $inner_dir to $target"
|
|
||||||
shopt -u dotglob nullglob
|
|
||||||
return 252
|
|
||||||
}
|
|
||||||
else
|
|
||||||
msg_error "Inner directory is empty: $inner_dir"
|
|
||||||
shopt -u dotglob nullglob
|
|
||||||
return 252
|
|
||||||
fi
|
|
||||||
shopt -u dotglob nullglob
|
|
||||||
else
|
else
|
||||||
shopt -s dotglob nullglob
|
source_dir="$workdir"
|
||||||
if compgen -G "$workdir/*" >/dev/null; then
|
fi
|
||||||
cp -r "$workdir"/* "$target/" || {
|
|
||||||
msg_error "Failed to copy contents to $target"
|
shopt -s dotglob nullglob
|
||||||
shopt -u dotglob nullglob
|
if ! compgen -G "$source_dir/*" >/dev/null; then
|
||||||
return 252
|
if [[ -n "$inner_dir" ]]; then
|
||||||
}
|
msg_error "Inner directory is empty: $inner_dir"
|
||||||
else
|
else
|
||||||
msg_error "Unpacked archive is empty"
|
msg_error "Unpacked archive is empty"
|
||||||
shopt -u dotglob nullglob
|
|
||||||
return 252
|
|
||||||
fi
|
fi
|
||||||
shopt -u dotglob nullglob
|
shopt -u dotglob nullglob
|
||||||
|
return 252
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# <target> is only touched once the payload is known good. Wiping earlier left
|
||||||
|
# CLEAN_INSTALL callers with an empty target directory whenever the download
|
||||||
|
# was truncated, the archive was unreadable, or it unpacked to nothing.
|
||||||
|
mkdir -p "$target"
|
||||||
|
if [[ "${CLEAN_INSTALL:-0}" == "1" ]]; then
|
||||||
|
find "${target:?}" -mindepth 1 -delete
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! cp -r "$source_dir"/* "$target/"; then
|
||||||
|
if [[ -n "$inner_dir" ]]; then
|
||||||
|
msg_error "Failed to copy contents from $inner_dir to $target"
|
||||||
|
else
|
||||||
|
msg_error "Failed to copy contents to $target"
|
||||||
|
fi
|
||||||
|
shopt -u dotglob nullglob
|
||||||
|
return 252
|
||||||
|
fi
|
||||||
|
shopt -u dotglob nullglob
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user