diff --git a/install.sh b/install.sh index 829a37d..d236b83 100755 --- a/install.sh +++ b/install.sh @@ -150,9 +150,16 @@ echo "Building project from: $PROJECT_DIR" cd "$PROJECT_DIR" dotnet restore dotnet build -c Release -# Publish as framework-dependent, not self-contained +# Publish as framework-dependent, not self-contained, ensuring static content is included dotnet publish -c Release -o $INSTALL_DIR/publish --no-self-contained -f net7.0 -p:PublishSingleFile=false +# Ensure the wwwroot folder is properly copied +echo "Copying static web content..." +if [ -d "$PROJECT_DIR/src/Web/wwwroot" ]; then + mkdir -p "$INSTALL_DIR/publish/wwwroot" + cp -r "$PROJECT_DIR/src/Web/wwwroot/"* "$INSTALL_DIR/publish/wwwroot/" +fi + # Copy configuration cp "$CONFIG_DIR/appsettings.json" "$INSTALL_DIR/publish/appsettings.json" diff --git a/src/Api/Program.cs b/src/Api/Program.cs index 31463ef..07020f0 100644 --- a/src/Api/Program.cs +++ b/src/Api/Program.cs @@ -43,6 +43,8 @@ if (app.Environment.IsDevelopment()) app.UseSwaggerUI(); } +// Configure static files to serve index.html as the default file +app.UseDefaultFiles(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); diff --git a/test-installation.sh b/test-installation.sh index 5340f38..afe7374 100755 --- a/test-installation.sh +++ b/test-installation.sh @@ -77,6 +77,37 @@ fi echo -e "${GREEN}✓${NC} Runtime configuration file found" +# Check for static web content +if [ ! -d "$PUBLISH_DIR/wwwroot" ]; then + echo -e "${RED}ERROR: wwwroot directory not found. Static content is missing!${NC}" + echo -e "${YELLOW}Creating wwwroot directory and copying static content...${NC}" + + # Try to find the wwwroot directory in the source + WWWROOT_SOURCE=$(find $INSTALL_DIR -path "*/Web/wwwroot" -type d 2>/dev/null | head -n 1) + + if [ -n "$WWWROOT_SOURCE" ]; then + # Found the static content, copy it + mkdir -p "$PUBLISH_DIR/wwwroot" + cp -r "$WWWROOT_SOURCE/"* "$PUBLISH_DIR/wwwroot/" + echo -e "${GREEN}✓${NC} Static content copied from $WWWROOT_SOURCE" + + # Restart the service to apply changes + systemctl restart transmission-rss-manager + echo -e "${YELLOW}Service restarted. Please try accessing the web interface again.${NC}" + else + echo -e "${RED}Could not find source wwwroot directory to copy static content from.${NC}" + echo -e "${YELLOW}Please copy static content manually to $PUBLISH_DIR/wwwroot${NC}" + fi +else + # Check if index.html exists + if [ ! -f "$PUBLISH_DIR/wwwroot/index.html" ]; then + echo -e "${RED}ERROR: index.html not found in wwwroot directory!${NC}" + ls -la "$PUBLISH_DIR/wwwroot" + else + echo -e "${GREEN}✓${NC} Static content found (wwwroot/index.html exists)" + fi +fi + # Check web service response echo -e "${YELLOW}Checking web service (this may take a few seconds)...${NC}" for i in {1..15}; do @@ -86,6 +117,19 @@ for i in {1..15}; do WEB_OK=true break fi + + # If root URL doesn't work, try direct access to index.html + if [ "$i" -eq 5 ]; then + echo -e "${YELLOW}Root path not responding, trying explicit index.html...${NC}" + HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5000/index.html 2>/dev/null || echo "000") + if [ "$HTTP_STATUS" = "200" ] || [ "$HTTP_STATUS" = "302" ]; then + echo -e "${GREEN}✓${NC} Web service is responsive at /index.html (HTTP $HTTP_STATUS)" + echo -e "${YELLOW}Access the app at http://localhost:5000/index.html${NC}" + WEB_OK=true + break + fi + fi + sleep 1 done