massive improvement
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
# Transmission RSS Manager Modular Installer
|
||||
# Main installer script that coordinates the installation process
|
||||
|
||||
# Set script to exit on error
|
||||
set -e
|
||||
|
||||
# Text formatting
|
||||
BOLD='\033[1m'
|
||||
GREEN='\033[0;32m'
|
||||
@@ -25,38 +28,112 @@ fi
|
||||
# Get current directory
|
||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
||||
|
||||
# Check for installation type
|
||||
IS_UPDATE=false
|
||||
if [ -f "${SCRIPT_DIR}/config.json" ]; then
|
||||
IS_UPDATE=true
|
||||
echo -e "${YELLOW}Existing installation detected. Running in update mode.${NC}"
|
||||
echo -e "${GREEN}Your existing configuration will be preserved.${NC}"
|
||||
else
|
||||
echo -e "${GREEN}Fresh installation. Will create new configuration.${NC}"
|
||||
fi
|
||||
export IS_UPDATE
|
||||
|
||||
# Check if required module files exist
|
||||
REQUIRED_MODULES=(
|
||||
"${SCRIPT_DIR}/modules/config-module.sh"
|
||||
"${SCRIPT_DIR}/modules/utils-module.sh"
|
||||
"${SCRIPT_DIR}/modules/dependencies-module.sh"
|
||||
"${SCRIPT_DIR}/modules/file-creator-module.sh"
|
||||
"${SCRIPT_DIR}/modules/service-setup-module.sh"
|
||||
)
|
||||
|
||||
for module in "${REQUIRED_MODULES[@]}"; do
|
||||
if [ ! -f "$module" ]; then
|
||||
echo -e "${RED}Error: Required module file not found: $module${NC}"
|
||||
echo -e "${YELLOW}Please run the install-script.sh first to generate module files.${NC}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Source the module files
|
||||
source "${SCRIPT_DIR}/modules/config.sh"
|
||||
source "${SCRIPT_DIR}/modules/utils.sh"
|
||||
source "${SCRIPT_DIR}/modules/dependencies.sh"
|
||||
source "${SCRIPT_DIR}/modules/file_creator.sh"
|
||||
source "${SCRIPT_DIR}/modules/service_setup.sh"
|
||||
source "${SCRIPT_DIR}/modules/utils-module.sh" # Load utilities first for logging
|
||||
source "${SCRIPT_DIR}/modules/config-module.sh"
|
||||
source "${SCRIPT_DIR}/modules/dependencies-module.sh"
|
||||
source "${SCRIPT_DIR}/modules/file-creator-module.sh"
|
||||
source "${SCRIPT_DIR}/modules/service-setup-module.sh"
|
||||
|
||||
# Function to handle cleanup on error
|
||||
function cleanup_on_error() {
|
||||
log "ERROR" "Installation failed: $1"
|
||||
log "INFO" "Cleaning up..."
|
||||
|
||||
# Add any cleanup steps here if needed
|
||||
|
||||
log "INFO" "You can try running the installer again after fixing the issues."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Set trap for error handling
|
||||
trap 'cleanup_on_error "$BASH_COMMAND"' ERR
|
||||
|
||||
# Execute the installation steps in sequence
|
||||
echo -e "${YELLOW}Starting installation process...${NC}"
|
||||
log "INFO" "Starting installation process..."
|
||||
|
||||
# Step 1: Gather configuration from user
|
||||
gather_configuration
|
||||
log "INFO" "Gathering configuration..."
|
||||
gather_configuration || {
|
||||
log "ERROR" "Configuration gathering failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Step 2: Install dependencies
|
||||
install_dependencies
|
||||
log "INFO" "Installing dependencies..."
|
||||
install_dependencies || {
|
||||
log "ERROR" "Dependency installation failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Step 3: Create installation directories
|
||||
create_directories
|
||||
log "INFO" "Creating directories..."
|
||||
create_directories || {
|
||||
log "ERROR" "Directory creation failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Step 4: Create configuration files and scripts
|
||||
create_config_files
|
||||
log "INFO" "Creating configuration files..."
|
||||
create_config_files || {
|
||||
log "ERROR" "Configuration file creation failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Step 5: Create service files and install the service
|
||||
setup_service
|
||||
log "INFO" "Setting up service..."
|
||||
setup_service || {
|
||||
log "ERROR" "Service setup failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Step 6: Final setup and permissions
|
||||
finalize_setup
|
||||
log "INFO" "Finalizing setup..."
|
||||
finalize_setup || {
|
||||
log "ERROR" "Setup finalization failed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo -e "${GREEN}Installation completed successfully!${NC}"
|
||||
echo -e "You can access the RSS Manager at ${BOLD}http://localhost:${PORT}${NC} or ${BOLD}http://your-server-ip:${PORT}${NC}"
|
||||
echo
|
||||
echo -e "The service is ${BOLD}automatically started${NC} and will ${BOLD}start on boot${NC}."
|
||||
echo -e "To manually control the service, use: ${BOLD}sudo systemctl [start|stop|restart] ${SERVICE_NAME}${NC}"
|
||||
# Installation complete
|
||||
echo
|
||||
echo -e "${BOLD}Thank you for installing Transmission RSS Manager Enhanced Edition!${NC}"
|
||||
echo -e "${BOLD}${GREEN}==================================================${NC}"
|
||||
echo -e "${BOLD}${GREEN} Installation Complete! ${NC}"
|
||||
echo -e "${BOLD}${GREEN}==================================================${NC}"
|
||||
echo -e "You can access the web interface at: ${BOLD}http://localhost:$PORT${NC} or ${BOLD}http://your-server-ip:$PORT${NC}"
|
||||
echo -e "You may need to configure your firewall to allow access to port $PORT"
|
||||
echo
|
||||
echo -e "${BOLD}Useful Commands:${NC}"
|
||||
echo -e " To check the service status: ${YELLOW}systemctl status $SERVICE_NAME${NC}"
|
||||
echo -e " To view logs: ${YELLOW}journalctl -u $SERVICE_NAME${NC}"
|
||||
echo -e " To restart the service: ${YELLOW}systemctl restart $SERVICE_NAME${NC}"
|
||||
echo
|
||||
echo -e "Thank you for installing Transmission RSS Manager!"
|
||||
echo -e "${BOLD}==================================================${NC}"
|
||||
|
||||
Reference in New Issue
Block a user