Fix Museum server binary issues using Docker approach
This commit is contained in:
parent
e95fd0a705
commit
fc7135d483
142
start.sh
142
start.sh
@ -287,109 +287,69 @@ start_placeholder_server() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Setup and attempt to run Museum server
|
# Setting up and attempting to run the Museum server
|
||||||
echo "==> Setting up Museum server..."
|
echo "==> Setting up Museum server..."
|
||||||
|
|
||||||
# Set GOPATH for Go builds
|
# Try using Docker to pull and run the Museum server
|
||||||
export GOPATH="/app/data/go"
|
|
||||||
export PATH="$GOPATH/bin:$PATH"
|
|
||||||
|
|
||||||
# Check for existing Museum binary
|
|
||||||
MUSEUM_BIN="/app/data/ente/server/museum"
|
MUSEUM_BIN="/app/data/ente/server/museum"
|
||||||
|
MUSEUM_IMAGE="ghcr.io/ente-io/server:latest"
|
||||||
VALID_BINARY=false
|
VALID_BINARY=false
|
||||||
|
|
||||||
if [ -f "$MUSEUM_BIN" ]; then
|
# Check if Docker is available
|
||||||
# Check if the file is a valid binary
|
if command -v docker >/dev/null 2>&1; then
|
||||||
echo "==> Checking if Museum binary is valid..."
|
echo "==> Docker is available, attempting to use Museum server image"
|
||||||
file_type=$(file -b "$MUSEUM_BIN")
|
|
||||||
|
|
||||||
# Log the file type for debugging
|
# Try pulling the Museum server image
|
||||||
echo "==> Museum binary file type: $file_type"
|
if docker pull $MUSEUM_IMAGE; then
|
||||||
|
echo "==> Successfully pulled Museum server image"
|
||||||
# Check file content for debugging
|
|
||||||
echo "==> First few lines of Museum binary:"
|
|
||||||
head -n 3 "$MUSEUM_BIN" || echo "==> Unable to read binary file"
|
|
||||||
|
|
||||||
# Check if it's an ELF executable or contains ELF in the description
|
|
||||||
if [[ "$file_type" == *"ELF"* ]] && [ -x "$MUSEUM_BIN" ]; then
|
|
||||||
echo "==> Found valid Museum binary, using it"
|
|
||||||
VALID_BINARY=true
|
|
||||||
else
|
|
||||||
echo "==> Museum binary exists but is not a valid executable, removing it"
|
|
||||||
rm -f "$MUSEUM_BIN"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$VALID_BINARY" = false ]; then
|
|
||||||
echo "==> No valid Museum binary found, trying to build or download one"
|
|
||||||
|
|
||||||
# Check if Go is installed
|
|
||||||
if command -v go >/dev/null 2>&1; then
|
|
||||||
echo "==> Building Museum server from source..."
|
|
||||||
|
|
||||||
# Navigate to the server directory
|
# Extract the Museum binary from the Docker image
|
||||||
cd "$ENTE_DIR/server"
|
TEMP_CONTAINER=$(docker create $MUSEUM_IMAGE)
|
||||||
|
if [ -n "$TEMP_CONTAINER" ]; then
|
||||||
# Build the Museum server
|
echo "==> Created temporary container to extract Museum binary"
|
||||||
echo "==> Building Museum server..."
|
mkdir -p "$(dirname "$MUSEUM_BIN")"
|
||||||
mkdir -p "$(dirname "$MUSEUM_BIN")"
|
if docker cp "$TEMP_CONTAINER:/app/museum" "$MUSEUM_BIN"; then
|
||||||
go build -o "$MUSEUM_BIN" ./cmd/museum
|
chmod +x "$MUSEUM_BIN"
|
||||||
|
docker rm "$TEMP_CONTAINER" >/dev/null
|
||||||
if [ $? -eq 0 ] && [ -f "$MUSEUM_BIN" ] && [ -x "$MUSEUM_BIN" ]; then
|
echo "==> Successfully extracted Museum binary from Docker image"
|
||||||
echo "==> Successfully built Museum server"
|
VALID_BINARY=true
|
||||||
VALID_BINARY=true
|
else
|
||||||
|
echo "==> Failed to extract Museum binary from container"
|
||||||
|
docker rm "$TEMP_CONTAINER" >/dev/null
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "==> Failed to build Museum server"
|
echo "==> Failed to create temporary container"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "==> Go not found, skipping build"
|
echo "==> Failed to pull Museum server image"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "==> Docker not available, skipping Docker-based Museum binary extraction"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If Docker extraction failed, try building from source
|
||||||
|
if [ "$VALID_BINARY" = false ] && command -v go >/dev/null 2>&1; then
|
||||||
|
echo "==> Building Museum server from source..."
|
||||||
|
|
||||||
# If build failed or Go not available, try downloading
|
# Navigate to the server directory
|
||||||
if [ "$VALID_BINARY" = false ]; then
|
cd "$ENTE_DIR/server"
|
||||||
echo "==> Trying to download Museum binary..."
|
|
||||||
|
# Build the Museum server
|
||||||
# Determine architecture and platform
|
echo "==> Building Museum server..."
|
||||||
ARCH=$(uname -m)
|
mkdir -p "$(dirname "$MUSEUM_BIN")"
|
||||||
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
export GOPATH="/app/data/go"
|
||||||
|
export PATH="$GOPATH/bin:$PATH"
|
||||||
case "$ARCH" in
|
|
||||||
x86_64)
|
# Install required build dependencies
|
||||||
ARCH="amd64"
|
apt-get update -y && apt-get install -y golang-go gcc libsodium-dev pkg-config
|
||||||
;;
|
|
||||||
aarch64|arm64)
|
go build -o "$MUSEUM_BIN" ./cmd/museum
|
||||||
ARCH="arm64"
|
|
||||||
;;
|
if [ $? -eq 0 ] && [ -f "$MUSEUM_BIN" ] && [ -x "$MUSEUM_BIN" ]; then
|
||||||
esac
|
echo "==> Successfully built Museum server"
|
||||||
|
VALID_BINARY=true
|
||||||
# Try downloading from GitHub releases
|
else
|
||||||
URLS=(
|
echo "==> Failed to build Museum server"
|
||||||
"https://github.com/ente-io/ente/releases/latest/download/museum-${OS}-${ARCH}"
|
|
||||||
"https://github.com/ente-io/museum/releases/latest/download/museum-${OS}-${ARCH}"
|
|
||||||
"https://github.com/ente-io/ente/releases/download/latest/museum-${OS}-${ARCH}"
|
|
||||||
)
|
|
||||||
|
|
||||||
for URL in "${URLS[@]}"; do
|
|
||||||
echo "==> Trying to download from: $URL"
|
|
||||||
if curl -L -o "$MUSEUM_BIN" "$URL" && [ -f "$MUSEUM_BIN" ]; then
|
|
||||||
chmod +x "$MUSEUM_BIN"
|
|
||||||
|
|
||||||
# Verify the downloaded file is executable
|
|
||||||
file_type=$(file -b "$MUSEUM_BIN")
|
|
||||||
echo "==> Downloaded file type: $file_type"
|
|
||||||
|
|
||||||
if [[ "$file_type" == *"ELF"* ]] || [[ "$file_type" == *"executable"* ]]; then
|
|
||||||
echo "==> Successfully downloaded Museum binary"
|
|
||||||
VALID_BINARY=true
|
|
||||||
break
|
|
||||||
else
|
|
||||||
echo "==> Downloaded file is not an executable"
|
|
||||||
rm -f "$MUSEUM_BIN"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "==> Failed to download from $URL"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user