Use rsync for release unpack so install can be re-run safely
- Replace mv flatten with rsync merge into /home/www/callcenter - Drop stale rubix/ extract dirs before unzip after a failed run
This commit is contained in:
+23
-6
@@ -133,16 +133,33 @@ fi
|
||||
ZIP_URL="https://${GITEA_HOST}/${GITEA_OWNER}/${GITEA_REPO}/archive/${TAG}.zip"
|
||||
echo "[install-rubix] downloading ${TAG} ..."
|
||||
|
||||
# Remove leftover extract dir from a failed previous run (safe: only rubix-* names).
|
||||
for stale in rubix rubix-*; do
|
||||
if [[ -d "${stale}" ]]; then
|
||||
echo "[install-rubix] removing stale extract dir ${stale}/"
|
||||
rm -rf "${stale}"
|
||||
fi
|
||||
done
|
||||
|
||||
wget --header="Authorization: token ${GITEA_TOKEN}" -O rubix.zip "${ZIP_URL}"
|
||||
unzip -oq rubix.zip
|
||||
|
||||
TOP="$(find . -maxdepth 1 -type d ! -name '.' | head -1)"
|
||||
TOP=""
|
||||
for candidate in rubix rubix-*; do
|
||||
if [[ -d "${candidate}" ]]; then
|
||||
TOP="${candidate}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ -z "${TOP}" ]]; then
|
||||
TOP="$(find . -maxdepth 1 -mindepth 1 -type d | head -1)"
|
||||
fi
|
||||
if [[ -n "${TOP}" ]]; then
|
||||
echo "[install-rubix] flatten ${TOP}/ into ${RUBIX_INSTALL_PATH}"
|
||||
shopt -s dotglob
|
||||
mv "${TOP}"/* .
|
||||
rmdir "${TOP}"
|
||||
shopt -u dotglob
|
||||
echo "[install-rubix] syncing ${TOP}/ into ${RUBIX_INSTALL_PATH} (re-runs merge over existing files)"
|
||||
rsync -a "${TOP}/" ./
|
||||
rm -rf "${TOP}"
|
||||
else
|
||||
echo "[install-rubix] WARN: no top-level folder in zip — files left as extracted" >&2
|
||||
fi
|
||||
|
||||
rm -f rubix.zip
|
||||
|
||||
Reference in New Issue
Block a user