From 528a6eed66a38945b06db431f0cf661e9d671be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20D=C3=BCren?= Date: Fri, 14 Mar 2025 21:30:04 +0100 Subject: [PATCH] Update start.sh to handle different repository structures --- start.sh | 42 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/start.sh b/start.sh index 3e20f75..ebe8f00 100644 --- a/start.sh +++ b/start.sh @@ -83,16 +83,46 @@ sed -i \ -e "s|%%S3_PREFIX%%|${S3_PREFIX:-ente/}|g" \ /app/data/config/config.yaml -# Change to server directory -cd /app/code/server +# Find the correct server directory +SERVER_DIR="" +for dir in "/app/code/server" "/app/code/packages/server"; do + if [ -f "$dir/package.json" ]; then + SERVER_DIR="$dir" + break + fi +done -# Run database migrations -echo "==> Running database migrations" -NODE_ENV=production yarn run db-migrate +if [ -z "$SERVER_DIR" ]; then + echo "==> ERROR: Could not find server directory with package.json" + echo " Server directory structure may have changed." + echo " Please check the ente repository structure." + exit 1 +fi + +echo "==> Found server directory at $SERVER_DIR" + +# Change to server directory +cd "$SERVER_DIR" + +# Run database migrations if the script exists +if grep -q "\"db-migrate\"" package.json; then + echo "==> Running database migrations" + NODE_ENV=production yarn run db-migrate || { + echo "==> WARNING: Database migration failed, but continuing anyway" + } +else + echo "==> Skipping database migrations (script not found)" +fi # Change ownership to cloudron user chown -R cloudron:cloudron /app/data # Start the server echo "==> Starting Ente server" -exec /usr/local/bin/gosu cloudron:cloudron NODE_ENV=production CONFIG_PATH=/app/data/config/config.yaml yarn run serve \ No newline at end of file +if grep -q "\"serve\"" package.json; then + exec /usr/local/bin/gosu cloudron:cloudron NODE_ENV=production CONFIG_PATH=/app/data/config/config.yaml yarn run serve +else + echo "==> ERROR: Could not find 'serve' script in package.json" + echo " Please check the ente repository structure." + exit 1 +fi \ No newline at end of file