Implement system status and update functionality

- Add system status card to dashboard with uptime and version display
- Implement version checking against git repository
- Add one-click update functionality
- Update footer and version references to 2.0.0
- Add server endpoints for status, update checking, and update application

🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-03-05 00:01:09 +00:00
parent 4a7d8336a5
commit 57342e0450
8 changed files with 569 additions and 191 deletions

View File

@@ -88,18 +88,10 @@ function gather_configuration() {
fi
fi
# Get and validate port
while true; do
read -p "Web interface port [$PORT]: " input_port
if [ -z "$input_port" ]; then
break
elif validate_port "$input_port"; then
PORT="$input_port"
break
else
log "WARN" "Invalid port number. Port must be between 1 and 65535."
fi
done
# Using fixed port 3000 to avoid permission issues with ports below 1024
log "INFO" "Using port 3000 for the web interface"
log "INFO" "This is to avoid permission issues with ports below 1024 (like port 80)"
PORT=3000
# Get user
read -p "Run as user [$USER]: " input_user
@@ -233,6 +225,43 @@ function gather_configuration() {
# Set Transmission download dir for configuration
TRANSMISSION_DOWNLOAD_DIR=$REMOTE_DOWNLOAD_DIR
else
# Local Transmission selected
echo -e "${YELLOW}You've selected to use a local Transmission installation.${NC}"
# Check if Transmission is already installed
if command -v transmission-daemon &> /dev/null; then
echo -e "${GREEN}Transmission is already installed on this system.${NC}"
else
echo -e "${YELLOW}NOTE: Transmission does not appear to be installed on this system.${NC}"
echo -e "${YELLOW}You will be prompted to install it during the dependency installation step.${NC}"
fi
# Get and validate port
while true; do
read -p "Local Transmission port [9091]: " input_trans_port
if [ -z "$input_trans_port" ]; then
break
elif validate_port "$input_trans_port"; then
TRANSMISSION_PORT="$input_trans_port"
break
else
log "WARN" "Invalid port number. Port must be between 1 and 65535."
fi
done
# Get credentials if any
read -p "Local Transmission username (leave empty if authentication is disabled) []: " input_trans_user
TRANSMISSION_USER=${input_trans_user:-$TRANSMISSION_USER}
if [ -n "$input_trans_user" ]; then
# Use read -s for password to hide it
read -s -p "Local Transmission password []: " input_trans_pass
echo # Add a newline after the password input
if [ -n "$input_trans_pass" ]; then
TRANSMISSION_PASS="$input_trans_pass"
fi
fi
read -p "Transmission download directory [/var/lib/transmission-daemon/downloads]: " input_trans_dir
if [ -n "$input_trans_dir" ]; then
if [[ ! "$input_trans_dir" =~ ^/ ]]; then
@@ -342,4 +371,4 @@ function gather_configuration() {
log "INFO" "Configuration gathering complete"
echo -e "${GREEN}Configuration complete!${NC}"
echo
}
}

View File

@@ -35,9 +35,61 @@ function install_dependencies() {
log "INFO" "Node.js is already installed."
fi
# Check if we need to install Transmission (only if local transmission was selected)
if [ "$TRANSMISSION_HOST" = "localhost" ] || [ "$TRANSMISSION_HOST" = "127.0.0.1" ]; then
if ! command_exists transmission-daemon; then
log "INFO" "Local Transmission installation selected, but transmission-daemon is not installed."
read -p "Would you like to install Transmission now? (y/n): " install_transmission
if [[ "$install_transmission" =~ ^[Yy]$ ]]; then
log "INFO" "Installing Transmission..."
if ! apt-get install -y transmission-daemon; then
log "ERROR" "Failed to install Transmission"
log "WARN" "You will need to install Transmission manually before using this application."
else
# Stop transmission-daemon to allow configuration changes
systemctl stop transmission-daemon
# Set default settings
TRANSMISSION_SETTINGS_DIR="/var/lib/transmission-daemon/info"
if [ -f "$TRANSMISSION_SETTINGS_DIR/settings.json" ]; then
# Backup original settings
cp "$TRANSMISSION_SETTINGS_DIR/settings.json" "$TRANSMISSION_SETTINGS_DIR/settings.json.bak"
# Update RPC settings to allow our app to connect
sed -i 's/"rpc-authentication-required": true,/"rpc-authentication-required": false,/g' "$TRANSMISSION_SETTINGS_DIR/settings.json"
sed -i 's/"rpc-whitelist-enabled": true,/"rpc-whitelist-enabled": false,/g' "$TRANSMISSION_SETTINGS_DIR/settings.json"
log "INFO" "Transmission has been configured for local access."
else
log "WARN" "Could not find Transmission settings file. You may need to configure Transmission manually."
fi
# Start transmission-daemon
systemctl start transmission-daemon
log "INFO" "Transmission has been installed and started."
fi
else
log "WARN" "Transmission installation skipped. You will need to install it manually."
fi
else
log "INFO" "Transmission is already installed."
fi
fi
# Install additional dependencies
log "INFO" "Installing additional dependencies..."
apt-get install -y unrar unzip p7zip-full nginx
# Try to install unrar-free if unrar is not available
if ! apt-get install -y unrar 2>/dev/null; then
log "INFO" "unrar not available, trying unrar-free instead..."
apt-get install -y unrar-free
fi
# Install other dependencies
apt-get install -y unzip p7zip-full
# Try to install nginx
apt-get install -y nginx || log "WARN" "Nginx installation failed, web interface may not be accessible"
else
log "ERROR" "This installer requires apt-get package manager"
log "INFO" "Please install the following dependencies manually:"
@@ -47,19 +99,37 @@ function install_dependencies() {
log "INFO" "- unzip"
log "INFO" "- p7zip-full"
log "INFO" "- nginx"
if [ "$TRANSMISSION_HOST" = "localhost" ] || [ "$TRANSMISSION_HOST" = "127.0.0.1" ]; then
log "INFO" "- transmission-daemon"
fi
exit 1
fi
# Check if all dependencies were installed successfully
local dependencies=("node" "npm" "unrar" "unzip" "7z" "nginx")
local dependencies=("node" "npm" "unzip" "nginx")
local missing_deps=()
# Add transmission to dependencies check if local installation was selected
if [ "$TRANSMISSION_HOST" = "localhost" ] || [ "$TRANSMISSION_HOST" = "127.0.0.1" ]; then
dependencies+=("transmission-daemon")
fi
for dep in "${dependencies[@]}"; do
if ! command_exists "$dep"; then
missing_deps+=("$dep")
fi
done
# Check for either unrar or unrar-free
if ! command_exists "unrar" && ! command_exists "unrar-free"; then
missing_deps+=("unrar")
fi
# Check for either 7z or 7za (from p7zip-full)
if ! command_exists "7z" && ! command_exists "7za"; then
missing_deps+=("p7zip")
fi
if [ ${#missing_deps[@]} -eq 0 ]; then
log "INFO" "All dependencies installed successfully."
else
@@ -75,6 +145,11 @@ function install_dependencies() {
log "INFO" "To install nginx manually: sudo apt-get install nginx"
fi
if [[ " ${missing_deps[*]} " =~ " transmission-daemon " ]]; then
log "INFO" "To install Transmission manually: sudo apt-get install transmission-daemon"
log "INFO" "After installation, you may need to configure it by editing /var/lib/transmission-daemon/info/settings.json"
fi
exit 1
fi
}
@@ -106,4 +181,4 @@ function create_directories() {
done
log "INFO" "Directories created successfully."
}
}