mirror of
https://github.com/henrygd/beszel.git
synced 2025-12-17 18:56:17 +01:00
fix: resolve mipsle architecture detection for install script (#1176)
- Add proper endianness detection using ELF header inspection - Prevent mipsle devices from downloading incorrect mips binaries - Maintain backward compatibility for all other architectures
This commit is contained in:
@@ -161,6 +161,53 @@ run_rc_command "$1"
|
|||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Detect system architecture
|
||||||
|
detect_architecture() {
|
||||||
|
local arch=$(uname -m)
|
||||||
|
|
||||||
|
if [ "$arch" = "mips" ]; then
|
||||||
|
detect_mips_endianness
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$arch" in
|
||||||
|
x86_64)
|
||||||
|
arch="amd64"
|
||||||
|
;;
|
||||||
|
armv6l|armv7l)
|
||||||
|
arch="arm"
|
||||||
|
;;
|
||||||
|
aarch64)
|
||||||
|
arch="arm64"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "$arch"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Detect MIPS endianness using ELF header
|
||||||
|
detect_mips_endianness() {
|
||||||
|
local bins="/bin/sh /bin/ls /usr/bin/env"
|
||||||
|
local bin_to_check endian
|
||||||
|
|
||||||
|
for bin_to_check in $bins; do
|
||||||
|
if [ -f "$bin_to_check" ]; then
|
||||||
|
# The 6th byte in ELF header: 01 = little, 02 = big
|
||||||
|
endian=$(hexdump -n 1 -s 5 -e '1/1 "%02x"' "$bin_to_check" 2>/dev/null)
|
||||||
|
if [ "$endian" = "01" ]; then
|
||||||
|
echo "mipsle"
|
||||||
|
return
|
||||||
|
elif [ "$endian" = "02" ]; then
|
||||||
|
echo "mips"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Final fallback
|
||||||
|
echo "mips"
|
||||||
|
}
|
||||||
|
|
||||||
# Default values
|
# Default values
|
||||||
PORT=45876
|
PORT=45876
|
||||||
UNINSTALL=false
|
UNINSTALL=false
|
||||||
@@ -556,7 +603,7 @@ fi
|
|||||||
echo "Downloading and installing the agent..."
|
echo "Downloading and installing the agent..."
|
||||||
|
|
||||||
OS=$(uname -s | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')
|
OS=$(uname -s | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/')
|
||||||
ARCH=$(uname -m | sed -e 's/x86_64/amd64/' -e 's/armv6l/arm/' -e 's/armv7l/arm/' -e 's/aarch64/arm64/')
|
ARCH=$(detect_architecture)
|
||||||
FILE_NAME="beszel-agent_${OS}_${ARCH}.tar.gz"
|
FILE_NAME="beszel-agent_${OS}_${ARCH}.tar.gz"
|
||||||
|
|
||||||
# Determine version to install
|
# Determine version to install
|
||||||
|
|||||||
Reference in New Issue
Block a user