mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
fix(sandbox): harden enforcement validation and backup handling
This commit is contained in:
1 parent
f315dda3f3
commit
0481160f5e
13 files changed
+180
-101
No files matched your search
@@ -42,12 +42,26 @@ grant_kvm_access() {
|
||||
echo "Granted node access to $dev (group '$group_name', gid $dev_gid)"
|
||||
}
|
||||
|
||||
MIN_OPENCODE_VERSION="1.0.137"
|
||||
|
||||
version_gte() {
|
||||
printf '%s\n%s\n' "$2" "$1" | sort -V -C
|
||||
}
|
||||
|
||||
install_opencode() {
|
||||
local opencode_version="${OPENCODE_BUNDLED_VERSION:-}"
|
||||
if [ -z "$opencode_version" ]; then
|
||||
echo "ERROR: OPENCODE_BUNDLED_VERSION is not set; refusing to guess the pinned OpenCode build" >&2
|
||||
return 1
|
||||
fi
|
||||
if [[ ! "$opencode_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "ERROR: OPENCODE_BUNDLED_VERSION='$opencode_version' is not an X.Y.Z version; refusing to download it" >&2
|
||||
return 1
|
||||
fi
|
||||
if ! version_gte "$opencode_version" "$MIN_OPENCODE_VERSION"; then
|
||||
echo "ERROR: OPENCODE_BUNDLED_VERSION=$opencode_version is below the minimum supported $MIN_OPENCODE_VERSION; refusing to download it" >&2
|
||||
return 1
|
||||
fi
|
||||
echo "Installing OpenCode ${opencode_version}..."
|
||||
curl -fsSL "https://github.com/anomalyco/opencode/releases/download/v${opencode_version}/opencode-linux-$(uname -m | sed 's/x86_64/x64/; s/aarch64/arm64/').tar.gz" \
|
||||
-o /tmp/opencode.tar.gz
|
||||
@@ -77,12 +91,6 @@ fi
|
||||
|
||||
echo "Checking OpenCode installation..."
|
||||
|
||||
MIN_OPENCODE_VERSION="1.0.137"
|
||||
|
||||
version_gte() {
|
||||
printf '%s\n%s\n' "$2" "$1" | sort -V -C
|
||||
}
|
||||
|
||||
if ! command -v opencode >/dev/null 2>&1; then
|
||||
echo "OpenCode not found. Installing..."
|
||||
install_opencode
|
||||
|
||||
Reference in new issue
Block a user