sync build tree from private myoffice
This commit is contained in:
+31
-11
@@ -4,6 +4,7 @@
|
||||
# GITEA_URL, GITEA_OWNER, GITEA_REPO, RELEASE_TAG (latest|v1.2.3)
|
||||
# API_DIR (default /opt/myoffice/api)
|
||||
# RELEASE_ASSET_URL — optional direct override (skips API resolve)
|
||||
# LOCAL_RELEASE_TAR — optional local .tar.gz (skips download; used when host pushes asset into CT)
|
||||
# GITEA_TOKEN — optional for private release downloads
|
||||
|
||||
set -euo pipefail
|
||||
@@ -14,6 +15,7 @@ GITEA_OWNER="${GITEA_OWNER:-}"
|
||||
GITEA_REPO="${GITEA_REPO:-myoffice_public}"
|
||||
RELEASE_TAG="${RELEASE_TAG:-latest}"
|
||||
RELEASE_ASSET_URL="${RELEASE_ASSET_URL:-}"
|
||||
LOCAL_RELEASE_TAR="${LOCAL_RELEASE_TAR:-}"
|
||||
ASSET_NAME="${ASSET_NAME:-myoffice-publish.tar.gz}"
|
||||
GITEA_TOKEN="${GITEA_TOKEN:-}"
|
||||
|
||||
@@ -69,22 +71,26 @@ resolve_asset_url() {
|
||||
echo "$browser_url"
|
||||
}
|
||||
|
||||
download_and_extract() {
|
||||
local url tar_path staging
|
||||
# Download release asset to a file path (usable on Proxmox host).
|
||||
download_asset_to() {
|
||||
local dest="$1"
|
||||
local url
|
||||
url=$(resolve_asset_url)
|
||||
msg "Downloading release asset: $url"
|
||||
curl_auth -o "$dest" "$url"
|
||||
msg "Saved $dest"
|
||||
}
|
||||
|
||||
extract_tar_to_api() {
|
||||
local tar_path="$1"
|
||||
local staging prod shared_prod prod_bak="" shared_bak="" top_count top_dir only
|
||||
|
||||
mkdir -p "$API_DIR"
|
||||
tar_path="/tmp/${ASSET_NAME}"
|
||||
curl_auth -o "$tar_path" "$url"
|
||||
|
||||
staging=$(mktemp -d /tmp/myoffice-extract.XXXXXX)
|
||||
tar -xzf "$tar_path" -C "$staging"
|
||||
rm -f "$tar_path"
|
||||
|
||||
local prod="${API_DIR}/appsettings.Production.json"
|
||||
local shared_prod="${API_DIR}/appsettings.shared.Production.json"
|
||||
local prod_bak="" shared_bak=""
|
||||
prod="${API_DIR}/appsettings.Production.json"
|
||||
shared_prod="${API_DIR}/appsettings.shared.Production.json"
|
||||
if [[ -f "$prod" ]]; then
|
||||
prod_bak=$(mktemp)
|
||||
cp -a "$prod" "$prod_bak"
|
||||
@@ -94,11 +100,9 @@ download_and_extract() {
|
||||
cp -a "$shared_prod" "$shared_bak"
|
||||
fi
|
||||
|
||||
local top_count top_dir
|
||||
top_count=$(find "$staging" -mindepth 1 -maxdepth 1 | wc -l)
|
||||
top_dir=""
|
||||
if [[ "$top_count" -eq 1 ]]; then
|
||||
local only
|
||||
only=$(find "$staging" -mindepth 1 -maxdepth 1 | head -1)
|
||||
if [[ -d "$only" ]]; then
|
||||
top_dir="$only"
|
||||
@@ -132,6 +136,22 @@ download_and_extract() {
|
||||
msg "App extracted to ${API_DIR}"
|
||||
}
|
||||
|
||||
download_and_extract() {
|
||||
local tar_path
|
||||
|
||||
if [[ -n "$LOCAL_RELEASE_TAR" && -f "$LOCAL_RELEASE_TAR" ]]; then
|
||||
msg "Using local release tar: $LOCAL_RELEASE_TAR"
|
||||
tar_path="$LOCAL_RELEASE_TAR"
|
||||
extract_tar_to_api "$tar_path"
|
||||
return 0
|
||||
fi
|
||||
|
||||
tar_path="/tmp/${ASSET_NAME}"
|
||||
download_asset_to "$tar_path"
|
||||
extract_tar_to_api "$tar_path"
|
||||
rm -f "$tar_path"
|
||||
}
|
||||
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
download_and_extract
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user