Refactor rebuild process and enhance service management in rebuild-solution.sh
This commit is contained in:
+44
-8
@@ -25,8 +25,42 @@ PUBLISH_DIR="/opt/jellyfin"
|
||||
LOG_DIR="/var/log/jellyfin"
|
||||
CONFIG_DIR="/etc/jellyfin"
|
||||
|
||||
# --- Functions ---
|
||||
build_and_publish() {
|
||||
echo "Building and publishing the .NET project..."
|
||||
|
||||
# Restore, build, and publish the .NET project
|
||||
if ! dotnet restore "$SOLUTION_FILE" -r linux-x64 || \
|
||||
! dotnet build "$SOLUTION_FILE" --configuration Release || \
|
||||
! dotnet publish "Jellyfin.Server/Jellyfin.Server.csproj" --configuration Release --self-contained true -r linux-x64 --output "$PUBLISH_DIR"; then
|
||||
echo "Error: Build or publish failed." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Project built and published successfully to the '$PUBLISH_DIR' directory."
|
||||
return 0
|
||||
}
|
||||
|
||||
# --- Service Management ---
|
||||
SERVICE_NAME="jellyfin.service"
|
||||
|
||||
|
||||
# Check if Jellyfin service is running and stop it
|
||||
if systemctl is-active --quiet "$SERVICE_NAME"; then
|
||||
echo "Jellyfin service is running. Stopping it now..."
|
||||
sudo systemctl stop "$SERVICE_NAME"
|
||||
echo "Jellyfin service stopped."
|
||||
fi
|
||||
|
||||
# --- Script ---
|
||||
|
||||
# Stop Jellyfin service if it's running
|
||||
if systemctl is-active --quiet "$SERVICE_NAME"; then
|
||||
echo "Jellyfin service is running. Stopping it now..."
|
||||
sudo systemctl stop "$SERVICE_NAME"
|
||||
echo "Jellyfin service stopped."
|
||||
fi
|
||||
|
||||
echo "Logging in to Gitea and fetching latest changes..."
|
||||
|
||||
# Use Git to pull the latest changes.
|
||||
@@ -38,14 +72,11 @@ git pull origin "$BRANCH"
|
||||
|
||||
echo "Latest changes fetched successfully."
|
||||
|
||||
echo "Building and publishing the .NET project..."
|
||||
|
||||
# Restore, build, and publish the .NET project
|
||||
dotnet restore "$SOLUTION_FILE" -r linux-x64
|
||||
dotnet build "$SOLUTION_FILE" --configuration Release
|
||||
dotnet publish "Jellyfin.Server/Jellyfin.Server.csproj" --configuration Release --self-contained true -r linux-x64 --output "$PUBLISH_DIR"
|
||||
|
||||
echo "Project built and published successfully to the '$PUBLISH_DIR' directory."
|
||||
# Attempt to build and publish. If it fails, exit.
|
||||
if ! build_and_publish; then
|
||||
echo "Build and publish failed. Not starting Jellyfin service."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Checking for required directories..."
|
||||
|
||||
@@ -61,3 +92,8 @@ fi
|
||||
|
||||
echo "Directory check complete."
|
||||
|
||||
# Restart Jellyfin service
|
||||
echo "Restarting Jellyfin service..."
|
||||
sudo systemctl start "$SERVICE_NAME"
|
||||
echo "Jellyfin service restarted successfully."
|
||||
|
||||
|
||||
@@ -91,7 +91,9 @@ done
|
||||
|
||||
set -e # Exit on error
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
||||
PROJECT_ROOT="$(dirname "$(dirname "$SCRIPT_DIR")")"
|
||||
PROGRAM_DIR="$PROJECT_ROOT" # Assuming program directory is the project root
|
||||
SQL_DIR="$PROGRAM_DIR/sql/diagnostics"
|
||||
|
||||
# Load database configuration
|
||||
source "./db-config.sh"
|
||||
@@ -116,7 +118,7 @@ invoke_diagnostic_report() {
|
||||
local output_file="$1"
|
||||
write_color_output "\nRunning comprehensive diagnostics..." "$CYAN"
|
||||
|
||||
if PGPASSWORD=$DB_PASS $PSQL_PATH -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -f "$PROJECT_ROOT/sql/diagnostics.sql" > "$output_file" 2>&1; then
|
||||
if PGPASSWORD=$DB_PASS $PSQL_PATH -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -f "$SQL_DIR/diagnostics.sql" > "$output_file" 2>&1; then
|
||||
write_color_output "[OK] Diagnostics completed: $output_file" "$GREEN"
|
||||
else
|
||||
write_color_output "[WARN] Diagnostics completed with warnings" "$YELLOW"
|
||||
@@ -127,7 +129,7 @@ invoke_query_analysis() {
|
||||
local output_file="$1"
|
||||
write_color_output "\nAnalyzing slow queries..." "$CYAN"
|
||||
|
||||
if PGPASSWORD=$DB_PASS $PSQL_PATH -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -f "$PROJECT_ROOT/sql/query-analysis.sql" > "$output_file" 2>&1; then
|
||||
if PGPASSWORD=$DB_PASS $PSQL_PATH -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -f "$SQL_DIR/query-analysis.sql" > "$output_file" 2>&1; then
|
||||
write_color_output "[OK] Query analysis completed: $output_file" "$GREEN"
|
||||
else
|
||||
write_color_output "[WARN] Query analysis completed with warnings" "$YELLOW"
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Linux script to rebuild the Jellyfin solution properly
|
||||
# This script cleans and rebuilds in the correct order to resolve CS0006 metadata errors
|
||||
|
||||
echo -e "\e[36mStarting Jellyfin solution rebuild...\e[0m"
|
||||
|
||||
# Step 1: Clean the solution
|
||||
echo -e "\n\e[33m[1/3] Cleaning solution...\e[0m"
|
||||
dotnet clean Jellyfin.sln --configuration Debug
|
||||
|
||||
# Remove obj and bin directories to ensure clean state
|
||||
echo -e "\n\e[33m[2/3] Removing build artifacts...\e[0m"
|
||||
find . -name bin -type d -exec rm -rf {} +
|
||||
find . -name obj -type d -exec rm -rf {} +
|
||||
|
||||
# Step 3: Restore NuGet packages
|
||||
echo -e "\n\e[33m[3/3] Restoring NuGet packages...\e[0m"
|
||||
dotnet restore Jellyfin.sln
|
||||
|
||||
# Step 4: Build the solution
|
||||
echo -e "\n\e[33m[4/4] Building solution...\e[0m"
|
||||
dotnet build Jellyfin.sln --configuration Debug --no-restore
|
||||
|
||||
echo -e "\n\e[32mBuild complete!\e[0m"
|
||||
echo -e "\e[36mIf you still see errors, try building specific projects in this order:\e[0m"
|
||||
echo -e "\e[90m 1. Jellyfin.Database.Implementations\e[0m"
|
||||
echo -e "\e[90m 2. Jellyfin.Database.Providers.Postgres\e[0m"
|
||||
echo -e "\e[90m 3. Jellyfin.Server.Implementations\e[0m"
|
||||
echo -e "\e[90m 4. Emby.Server.Implementations\e[0m"
|
||||
echo -e "\e[90m 5. Jellyfin.Server\e[0m"
|
||||
Reference in New Issue
Block a user