Update build.func
Some checks failed
Bump build.func Revision / bump-revision (push) Has been cancelled
Some checks failed
Bump build.func Revision / bump-revision (push) Has been cancelled
This commit is contained in:
parent
e2c8e71c55
commit
afecb023cc
148
misc/build.func
148
misc/build.func
@ -2,7 +2,7 @@
|
|||||||
# Copyright (c) 2021-2025 community-scripts ORG
|
# Copyright (c) 2021-2025 community-scripts ORG
|
||||||
# Author: tteck (tteckster) | MickLesk | michelroegl-brunner
|
# Author: tteck (tteckster) | MickLesk | michelroegl-brunner
|
||||||
# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
|
# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE
|
||||||
# Revision:
|
# Revision:
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# variables()
|
# variables()
|
||||||
@ -33,93 +33,93 @@ variables() {
|
|||||||
# - Local cache: /usr/local/community-scripts/core
|
# - Local cache: /usr/local/community-scripts/core
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
FUNC_DIR="/usr/local/community-scripts/core"
|
# FUNC_DIR="/usr/local/community-scripts/core"
|
||||||
mkdir -p "$FUNC_DIR"
|
# mkdir -p "$FUNC_DIR"
|
||||||
|
|
||||||
BUILD_URL="https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func"
|
# BUILD_URL="https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func"
|
||||||
BUILD_REV="$FUNC_DIR/build.rev"
|
# BUILD_REV="$FUNC_DIR/build.rev"
|
||||||
|
|
||||||
# --- Step 1: fetch build.func content once, compute hash ---
|
# # --- Step 1: fetch build.func content once, compute hash ---
|
||||||
build_content="$(curl -fsSL "$BUILD_URL")" || {
|
# build_content="$(curl -fsSL "$BUILD_URL")" || {
|
||||||
echo "❌ Failed to fetch build.func"
|
# echo "❌ Failed to fetch build.func"
|
||||||
exit 1
|
# exit 1
|
||||||
}
|
# }
|
||||||
|
|
||||||
newhash=$(printf "%s" "$build_content" | sha256sum | awk '{print $1}')
|
# newhash=$(printf "%s" "$build_content" | sha256sum | awk '{print $1}')
|
||||||
oldhash=$(cat "$BUILD_REV" 2>/dev/null || echo "")
|
# oldhash=$(cat "$BUILD_REV" 2>/dev/null || echo "")
|
||||||
|
|
||||||
# --- Step 2: if build.func changed, offer update for core files ---
|
# # --- Step 2: if build.func changed, offer update for core files ---
|
||||||
if [ "$newhash" != "$oldhash" ]; then
|
# if [ "$newhash" != "$oldhash" ]; then
|
||||||
echo "⚠️ build.func changed!"
|
# echo "⚠️ build.func changed!"
|
||||||
|
|
||||||
while true; do
|
# while true; do
|
||||||
read -rp "Refresh local core files? [y/N/diff]: " ans
|
# read -rp "Refresh local core files? [y/N/diff]: " ans
|
||||||
case "$ans" in
|
# case "$ans" in
|
||||||
[Yy]*)
|
# [Yy]*)
|
||||||
echo "$newhash" >"$BUILD_REV"
|
# echo "$newhash" >"$BUILD_REV"
|
||||||
|
|
||||||
update_func_file() {
|
# update_func_file() {
|
||||||
local file="$1"
|
# local file="$1"
|
||||||
local url="https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/$file"
|
# local url="https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/$file"
|
||||||
local local_path="$FUNC_DIR/$file"
|
# local local_path="$FUNC_DIR/$file"
|
||||||
|
|
||||||
echo "⬇️ Downloading $file ..."
|
# echo "⬇️ Downloading $file ..."
|
||||||
curl -fsSL "$url" -o "$local_path" || {
|
# curl -fsSL "$url" -o "$local_path" || {
|
||||||
echo "❌ Failed to fetch $file"
|
# echo "❌ Failed to fetch $file"
|
||||||
exit 1
|
# exit 1
|
||||||
}
|
# }
|
||||||
echo "✔️ Updated $file"
|
# echo "✔️ Updated $file"
|
||||||
}
|
# }
|
||||||
|
|
||||||
update_func_file core.func
|
# update_func_file core.func
|
||||||
update_func_file error_handler.func
|
# update_func_file error_handler.func
|
||||||
update_func_file tools.func
|
# update_func_file tools.func
|
||||||
break
|
# break
|
||||||
;;
|
# ;;
|
||||||
[Dd]*)
|
# [Dd]*)
|
||||||
for file in core.func error_handler.func tools.func; do
|
# for file in core.func error_handler.func tools.func; do
|
||||||
local_path="$FUNC_DIR/$file"
|
# local_path="$FUNC_DIR/$file"
|
||||||
url="https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/$file"
|
# url="https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/$file"
|
||||||
remote_tmp="$(mktemp)"
|
# remote_tmp="$(mktemp)"
|
||||||
|
|
||||||
curl -fsSL "$url" -o "$remote_tmp" || continue
|
# curl -fsSL "$url" -o "$remote_tmp" || continue
|
||||||
|
|
||||||
if [ -f "$local_path" ]; then
|
# if [ -f "$local_path" ]; then
|
||||||
echo "🔍 Diff for $file:"
|
# echo "🔍 Diff for $file:"
|
||||||
diff -u "$local_path" "$remote_tmp" || echo "(no differences)"
|
# diff -u "$local_path" "$remote_tmp" || echo "(no differences)"
|
||||||
else
|
# else
|
||||||
echo "📦 New file $file will be installed"
|
# echo "📦 New file $file will be installed"
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
rm -f "$remote_tmp"
|
# rm -f "$remote_tmp"
|
||||||
done
|
# done
|
||||||
;;
|
# ;;
|
||||||
*)
|
# *)
|
||||||
echo "❌ Skipped updating local core files"
|
# echo "❌ Skipped updating local core files"
|
||||||
break
|
# break
|
||||||
;;
|
# ;;
|
||||||
esac
|
# esac
|
||||||
done
|
# done
|
||||||
else
|
# else
|
||||||
echo "✔️ build.func unchanged → using existing local core files"
|
# echo "✔️ build.func unchanged → using existing local core files"
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
# --- Step 3: always source local versions of the core files ---
|
# # --- Step 3: always source local versions of the core files ---
|
||||||
source "$FUNC_DIR/core.func"
|
# source "$FUNC_DIR/core.func"
|
||||||
source "$FUNC_DIR/error_handler.func"
|
# source "$FUNC_DIR/error_handler.func"
|
||||||
source "$FUNC_DIR/tools.func"
|
# source "$FUNC_DIR/tools.func"
|
||||||
|
|
||||||
# --- Step 4: finally, source build.func directly from memory ---
|
# # --- Step 4: finally, source build.func directly from memory ---
|
||||||
# (no tmp file needed)
|
# # (no tmp file needed)
|
||||||
source <(printf "%s" "$build_content")
|
# source <(printf "%s" "$build_content")
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# # ------------------------------------------------------------------------------
|
||||||
# Load core + error handler functions from community-scripts repo
|
# # Load core + error handler functions from community-scripts repo
|
||||||
#
|
# #
|
||||||
# - Prefer curl if available, fallback to wget
|
# # - Prefer curl if available, fallback to wget
|
||||||
# - Load: core.func, error_handler.func, api.func
|
# # - Load: core.func, error_handler.func, api.func
|
||||||
# - Initialize error traps after loading
|
# # - Initialize error traps after loading
|
||||||
# ------------------------------------------------------------------------------
|
# # ------------------------------------------------------------------------------
|
||||||
|
|
||||||
source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/api.func)
|
source <(curl -fsSL https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/api.func)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user