domniguard-linux-x64 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/domniguard CHANGED
Binary file
package/install.sh ADDED
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if [ "$(uname -s)" != "Linux" ]; then
5
+ echo "domniguard: only Linux is supported" >&2
6
+ exit 1
7
+ fi
8
+
9
+ ARCH_RAW="$(uname -m)"
10
+ case "$ARCH_RAW" in
11
+ x86_64|amd64) ARCH="x64" ;;
12
+ aarch64|arm64) ARCH="arm64" ;;
13
+ *)
14
+ echo "domniguard: unsupported CPU architecture: $ARCH_RAW" >&2
15
+ exit 1
16
+ ;;
17
+ esac
18
+
19
+ PKG="domniguard-linux-${ARCH}"
20
+ # Optional pin: DOMNIGUARD_VERSION=0.1.6 curl ... | sudo bash
21
+ VERSION="${DOMNIGUARD_VERSION:-latest}"
22
+ META_URL="https://registry.npmjs.org/${PKG}/${VERSION}"
23
+
24
+ TMP_DIR="$(mktemp -d)"
25
+ trap 'rm -rf "$TMP_DIR"' EXIT
26
+
27
+ echo "Fetching package metadata from npm registry (${ARCH})..."
28
+ curl -fsSL "$META_URL" -o "$TMP_DIR/meta.json"
29
+
30
+ TARBALL_URL="$(python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); print(d["dist"]["tarball"])' "$TMP_DIR/meta.json" 2>/dev/null || \
31
+ node -e 'const d=require(process.argv[1]); console.log(d.dist.tarball)' "$TMP_DIR/meta.json" 2>/dev/null || \
32
+ grep -oE '"tarball":"[^"]+"' "$TMP_DIR/meta.json" | head -n1 | cut -d'"' -f4)"
33
+
34
+ INTEGRITY="$(python3 -c 'import json,sys; d=json.load(open(sys.argv[1])); print(d["dist"].get("integrity",""))' "$TMP_DIR/meta.json" 2>/dev/null || \
35
+ node -e 'const d=require(process.argv[1]); console.log(d.dist.integrity||"")' "$TMP_DIR/meta.json" 2>/dev/null || \
36
+ grep -oE '"integrity":"sha512-[^"]+"' "$TMP_DIR/meta.json" | head -n1 | cut -d'"' -f4)"
37
+
38
+ if [ -z "$TARBALL_URL" ]; then
39
+ echo "domniguard: failed to resolve tarball URL from registry metadata" >&2
40
+ exit 1
41
+ fi
42
+
43
+ echo "Downloading $TARBALL_URL..."
44
+ curl -fsSL "$TARBALL_URL" -o "$TMP_DIR/pkg.tgz"
45
+
46
+ if [ -n "$INTEGRITY" ] && [[ "$INTEGRITY" == sha512-* ]]; then
47
+ EXPECTED_B64="${INTEGRITY#sha512-}"
48
+ if command -v openssl >/dev/null 2>&1; then
49
+ ACTUAL_B64="$(openssl dgst -sha512 -binary "$TMP_DIR/pkg.tgz" | openssl base64 -A)"
50
+ elif command -v python3 >/dev/null 2>&1; then
51
+ ACTUAL_B64="$(python3 -c 'import base64,hashlib,sys; print(base64.b64encode(hashlib.sha512(open(sys.argv[1],"rb").read()).digest()).decode())' "$TMP_DIR/pkg.tgz")"
52
+ else
53
+ ACTUAL_B64=""
54
+ fi
55
+ if [ -n "$ACTUAL_B64" ] && [ "$ACTUAL_B64" != "$EXPECTED_B64" ]; then
56
+ echo "domniguard: integrity verification failed!" >&2
57
+ exit 1
58
+ fi
59
+ echo "Verified SHA-512 integrity."
60
+ fi
61
+
62
+ tar -xzf "$TMP_DIR/pkg.tgz" -C "$TMP_DIR"
63
+ BIN_PATH="$TMP_DIR/package/bin/domniguard"
64
+ chmod +x "$BIN_PATH"
65
+
66
+ # Existing installs: upgrade binary + unit only (never touch config/secrets).
67
+ if [ -x /usr/local/bin/domniguard ] && [ -f /etc/domniguard/config.yaml ]; then
68
+ echo "Existing install detected — running upgrade..."
69
+ exec "$BIN_PATH" upgrade
70
+ fi
71
+
72
+ exec "$BIN_PATH" setup "$@"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domniguard-linux-x64",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "DOmniGuard Linux x64 binary",
5
5
  "license": "UNLICENSED",
6
6
  "os": [
@@ -10,6 +10,7 @@
10
10
  "x64"
11
11
  ],
12
12
  "files": [
13
- "bin/domniguard"
13
+ "bin/domniguard",
14
+ "install.sh"
14
15
  ]
15
16
  }