Torrent-Manager/test-installation.sh
MasterDraco 5d6faef880 fix: Ensure static web content is properly deployed and served
- Added UseDefaultFiles middleware to serve index.html by default
- Explicitly copy wwwroot contents during installation
- Added checks in test script to verify static content
- Added fallback to /index.html endpoint if root path doesn't respond
- Enhanced test script to diagnose and fix common deployment issues

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-03-12 22:27:19 +00:00

158 lines
5.8 KiB
Bash
Executable File

#!/bin/bash
# Transmission RSS Manager Test Script
# This script checks if the Transmission RSS Manager is installed and running correctly
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${GREEN}Transmission RSS Manager Test Script${NC}"
echo -e "${YELLOW}This script will check if your installation is working correctly${NC}"
echo
# Check if service is installed
if [ ! -f "/etc/systemd/system/transmission-rss-manager.service" ]; then
echo -e "${RED}ERROR: Service file not found. Installation seems incomplete.${NC}"
exit 1
fi
echo -e "${GREEN}${NC} Service file found"
# Check if service is running
if systemctl is-active --quiet transmission-rss-manager; then
echo -e "${GREEN}${NC} Service is running"
else
echo -e "${YELLOW}⚠ Service is not running. Attempting to start...${NC}"
sudo systemctl start transmission-rss-manager
sleep 2
if systemctl is-active --quiet transmission-rss-manager; then
echo -e "${GREEN}${NC} Service successfully started"
else
echo -e "${RED}ERROR: Failed to start service. Checking logs...${NC}"
echo
echo -e "${YELLOW}Service Logs:${NC}"
sudo journalctl -u transmission-rss-manager -n 20 --no-pager
exit 1
fi
fi
# Check application files
INSTALL_DIR="/opt/transmission-rss-manager"
PUBLISH_DIR="$INSTALL_DIR/publish"
if [ ! -d "$PUBLISH_DIR" ]; then
echo -e "${RED}ERROR: Application directory not found at $PUBLISH_DIR${NC}"
exit 1
fi
echo -e "${GREEN}${NC} Application directory found"
# Check for main DLL
APP_DLL=$(find $INSTALL_DIR/publish -name "TransmissionRssManager.dll" 2>/dev/null)
if [ -z "$APP_DLL" ]; then
echo -e "${RED}ERROR: Main application DLL not found${NC}"
exit 1
fi
echo -e "${GREEN}${NC} Application files found"
# Check for config file
CONFIG_DIR="/etc/transmission-rss-manager"
if [ ! -f "$CONFIG_DIR/appsettings.json" ]; then
echo -e "${RED}ERROR: Configuration file not found at $CONFIG_DIR/appsettings.json${NC}"
exit 1
fi
echo -e "${GREEN}${NC} Configuration file found"
# Check for runtime config file
APP_NAME=$(basename "$APP_DLL" .dll)
if [ ! -f "$PUBLISH_DIR/$APP_NAME.runtimeconfig.json" ]; then
echo -e "${RED}ERROR: Runtime configuration file not found${NC}"
exit 1
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
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5000 2>/dev/null || echo "000")
if [ "$HTTP_STATUS" = "200" ] || [ "$HTTP_STATUS" = "302" ]; then
echo -e "${GREEN}${NC} Web service is responsive (HTTP $HTTP_STATUS)"
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
if [ -z "$WEB_OK" ]; then
echo -e "${RED}⚠ Web service is not responding. This might be normal if your app doesn't serve content on the root path.${NC}"
echo -e "${YELLOW}Trying to check API/health endpoint instead...${NC}"
HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:5000/api/config 2>/dev/null || echo "000")
if [ "$HTTP_STATUS" = "200" ] || [ "$HTTP_STATUS" = "302" ] || [ "$HTTP_STATUS" = "401" ] || [ "$HTTP_STATUS" = "404" ]; then
echo -e "${GREEN}${NC} API endpoint is responsive (HTTP $HTTP_STATUS)"
else
echo -e "${RED}ERROR: Web service does not appear to be working (HTTP $HTTP_STATUS).${NC}"
echo -e "${YELLOW}Checking service logs:${NC}"
sudo journalctl -u transmission-rss-manager -n 20 --no-pager
exit 1
fi
fi
# Installation successful
echo
echo -e "${GREEN}✅ Transmission RSS Manager appears to be installed and running correctly!${NC}"
echo -e "${YELLOW}Web interface: http://localhost:5000${NC}"
echo -e "${YELLOW}Configuration: $CONFIG_DIR/appsettings.json${NC}"
echo
echo -e "To view logs: ${YELLOW}sudo journalctl -u transmission-rss-manager -f${NC}"
echo -e "To restart: ${YELLOW}sudo systemctl restart transmission-rss-manager${NC}"