openmux 0.1.2 → 0.1.3
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/openmux +88 -11
- package/package.json +1 -1
package/bin/openmux
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
set -euo pipefail
|
|
3
3
|
|
|
4
4
|
# openmux npm bin wrapper
|
|
5
|
-
#
|
|
5
|
+
# Downloads binary on first run if missing, then executes
|
|
6
|
+
|
|
7
|
+
REPO="monotykamary/openmux"
|
|
6
8
|
|
|
7
9
|
# Find the package directory - check multiple possible locations
|
|
8
10
|
find_package_dir() {
|
|
@@ -44,7 +46,89 @@ find_package_dir() {
|
|
|
44
46
|
echo ""
|
|
45
47
|
}
|
|
46
48
|
|
|
49
|
+
get_version() {
|
|
50
|
+
local pkg_json="$1/package.json"
|
|
51
|
+
if [[ -f "$pkg_json" ]]; then
|
|
52
|
+
grep '"version"' "$pkg_json" | head -1 | sed 's/.*"version": *"\([^"]*\)".*/\1/'
|
|
53
|
+
else
|
|
54
|
+
echo ""
|
|
55
|
+
fi
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
get_platform() {
|
|
59
|
+
local os arch
|
|
60
|
+
os="$(uname -s)"
|
|
61
|
+
arch="$(uname -m)"
|
|
62
|
+
|
|
63
|
+
case "$os" in
|
|
64
|
+
Darwin) os="darwin" ;;
|
|
65
|
+
Linux) os="linux" ;;
|
|
66
|
+
*) echo ""; return ;;
|
|
67
|
+
esac
|
|
68
|
+
|
|
69
|
+
case "$arch" in
|
|
70
|
+
x86_64|amd64) arch="x64" ;;
|
|
71
|
+
arm64|aarch64) arch="arm64" ;;
|
|
72
|
+
*) echo ""; return ;;
|
|
73
|
+
esac
|
|
74
|
+
|
|
75
|
+
echo "${os}-${arch}"
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
download_binary() {
|
|
79
|
+
local package_dir="$1"
|
|
80
|
+
local dist_dir="$package_dir/dist"
|
|
81
|
+
local version="v$(get_version "$package_dir")"
|
|
82
|
+
local platform="$(get_platform)"
|
|
83
|
+
|
|
84
|
+
if [[ -z "$version" || "$version" == "v" ]]; then
|
|
85
|
+
echo "Error: Could not determine openmux version" >&2
|
|
86
|
+
return 1
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
if [[ -z "$platform" ]]; then
|
|
90
|
+
echo "Error: Unsupported platform" >&2
|
|
91
|
+
return 1
|
|
92
|
+
fi
|
|
93
|
+
|
|
94
|
+
local url="https://github.com/$REPO/releases/download/$version/openmux-$version-$platform.tar.gz"
|
|
95
|
+
|
|
96
|
+
echo "Downloading openmux $version for $platform..."
|
|
97
|
+
echo "From: $url"
|
|
98
|
+
|
|
99
|
+
mkdir -p "$dist_dir"
|
|
100
|
+
local tmp_file="$dist_dir/download.tar.gz"
|
|
101
|
+
|
|
102
|
+
# Download
|
|
103
|
+
if command -v curl &>/dev/null; then
|
|
104
|
+
curl -fsSL "$url" -o "$tmp_file" || return 1
|
|
105
|
+
elif command -v wget &>/dev/null; then
|
|
106
|
+
wget -q "$url" -O "$tmp_file" || return 1
|
|
107
|
+
else
|
|
108
|
+
echo "Error: curl or wget required" >&2
|
|
109
|
+
return 1
|
|
110
|
+
fi
|
|
111
|
+
|
|
112
|
+
# Extract
|
|
113
|
+
echo "Extracting..."
|
|
114
|
+
tar -xzf "$tmp_file" -C "$dist_dir"
|
|
115
|
+
rm -f "$tmp_file"
|
|
116
|
+
|
|
117
|
+
# Make executable
|
|
118
|
+
chmod +x "$dist_dir/openmux-bin" 2>/dev/null || true
|
|
119
|
+
chmod +x "$dist_dir/openmux" 2>/dev/null || true
|
|
120
|
+
|
|
121
|
+
echo "Ready!"
|
|
122
|
+
echo ""
|
|
123
|
+
}
|
|
124
|
+
|
|
47
125
|
PACKAGE_DIR="$(find_package_dir)"
|
|
126
|
+
|
|
127
|
+
if [[ -z "$PACKAGE_DIR" ]]; then
|
|
128
|
+
echo "Error: Could not find openmux package directory" >&2
|
|
129
|
+
exit 1
|
|
130
|
+
fi
|
|
131
|
+
|
|
48
132
|
DIST_DIR="$PACKAGE_DIR/dist"
|
|
49
133
|
|
|
50
134
|
# Determine library extension based on OS
|
|
@@ -54,16 +138,9 @@ case "$(uname -s)" in
|
|
|
54
138
|
*) echo "Unsupported OS" >&2; exit 1 ;;
|
|
55
139
|
esac
|
|
56
140
|
|
|
57
|
-
#
|
|
58
|
-
if [[
|
|
59
|
-
|
|
60
|
-
echo "Package dir: ${PACKAGE_DIR:-not found}" >&2
|
|
61
|
-
echo "Expected binary at: $DIST_DIR/openmux-bin" >&2
|
|
62
|
-
echo "" >&2
|
|
63
|
-
echo "Try reinstalling: npm install -g openmux" >&2
|
|
64
|
-
echo "Or run postinstall manually:" >&2
|
|
65
|
-
echo " node \"\$PACKAGE_DIR/scripts/postinstall.cjs\"" >&2
|
|
66
|
-
exit 1
|
|
141
|
+
# Download binary if missing
|
|
142
|
+
if [[ ! -x "$DIST_DIR/openmux-bin" ]]; then
|
|
143
|
+
download_binary "$PACKAGE_DIR" || exit 1
|
|
67
144
|
fi
|
|
68
145
|
|
|
69
146
|
# Set library path and execute
|