README.md: - Update Essential files section with dual-mode default behavior - Update dual-mode display section with port 9999 as Remote HD - Update Display Modes table to include port 9999 and dual-mode note WIKI.md: - Add Remote HD Mode (Port 9999) section with full HD details - Update Start Script Options table with dev:9999 and dual-mode - Clarify port usage (8888 kiosk, 9090 legacy remote, 9999 remote HD) install_everything.sh: - Add dual-mode server information to startup message
177 lines
5.6 KiB
Bash
Executable File
177 lines
5.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# TCK RTU - Install Everything Script
|
|
# This script installs all prerequisites and starts the application
|
|
# Usage: bash <(curl -sL https://raw.githubusercontent.com/REPO_URL/main/install_everything.sh)
|
|
# Or: ./install_everything.sh
|
|
|
|
set -e
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
CYAN='\033[0;36m'
|
|
NC='\033[0m'
|
|
BOLD='\033[1m'
|
|
|
|
echo -e "${CYAN}${BOLD}"
|
|
echo "╔══════════════════════════════════════════════════════╗"
|
|
echo "║ TCK RTU - Automated Installation Script ║"
|
|
echo "╚══════════════════════════════════════════════════════╝"
|
|
echo -e "${NC}"
|
|
|
|
# Configuration
|
|
APP_DIR="/opt/tck_rtu"
|
|
REPO_URL="${REPO_URL:-https://github.com/your-repo/tck_rtu.git}"
|
|
|
|
# Detect if running as root
|
|
if [ "$EUID" -eq 0 ]; then
|
|
IS_ROOT=true
|
|
else
|
|
IS_ROOT=false
|
|
fi
|
|
|
|
# Function to install system dependencies
|
|
install_system_deps() {
|
|
echo -e "${BLUE}[1/5] Installing system dependencies...${NC}"
|
|
|
|
if command -v apt-get &> /dev/null; then
|
|
# Debian/Ubuntu
|
|
if [ "$IS_ROOT" = true ]; then
|
|
apt-get update
|
|
apt-get install -y curl git nginx
|
|
else
|
|
echo -e "${YELLOW}Not running as root. System deps must be installed manually:${NC}"
|
|
echo " sudo apt-get update"
|
|
echo " sudo apt-get install -y curl git nginx"
|
|
fi
|
|
elif command -v yum &> /dev/null; then
|
|
# RHEL/CentOS
|
|
if [ "$IS_ROOT" = true ]; then
|
|
yum install -y curl git nginx
|
|
else
|
|
echo -e "${YELLOW}Not running as root. Run manually: sudo yum install -y curl git nginx${NC}"
|
|
fi
|
|
elif command -v pacman &> /dev/null; then
|
|
# Arch
|
|
if [ "$IS_ROOT" = true ]; then
|
|
pacman -S --noconfirm curl git nginx
|
|
else
|
|
echo -e "${YELLOW}Not running as root. Run manually: sudo pacman -S --noconfirm curl git nginx${NC}"
|
|
fi
|
|
fi
|
|
|
|
echo -e "${GREEN}System dependencies check complete.${NC}"
|
|
}
|
|
|
|
# Function to install Node.js
|
|
install_node() {
|
|
echo -e "${BLUE}[2/5] Installing Node.js...${NC}"
|
|
|
|
if command -v node &> /dev/null; then
|
|
NODE_VERSION=$(node -v)
|
|
echo -e "${GREEN}Node.js already installed: $NODE_VERSION${NC}"
|
|
return
|
|
fi
|
|
|
|
if [ "$IS_ROOT" = true ]; then
|
|
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
|
apt-get install -y nodejs
|
|
else
|
|
echo -e "${YELLOW}Node.js not found. Please install manually:${NC}"
|
|
echo " curl -fsSL https://deb.nodesource.com/setup_20.x | sudo bash -"
|
|
echo " sudo apt-get install -y nodejs"
|
|
fi
|
|
|
|
echo -e "${GREEN}Node.js installation complete.${NC}"
|
|
}
|
|
|
|
# Function to clone or update repository
|
|
setup_repo() {
|
|
echo -e "${BLUE}[3/5] Setting up repository...${NC}"
|
|
|
|
if [ -d "$APP_DIR" ]; then
|
|
echo -e "${YELLOW}Directory $APP_DIR already exists. Updating...${NC}"
|
|
cd "$APP_DIR"
|
|
git pull origin main 2>/dev/null || git pull
|
|
else
|
|
echo -e "Cloning repository to $APP_DIR..."
|
|
if [ "$IS_ROOT" = true ]; then
|
|
mkdir -p "$APP_DIR"
|
|
git clone "$REPO_URL" "$APP_DIR"
|
|
else
|
|
echo -e "${YELLOW}Cannot create $APP_DIR without root. Using current directory.${NC}"
|
|
if [ ! -d "sample_interface" ]; then
|
|
echo "Please ensure the repository is cloned first."
|
|
exit 1
|
|
fi
|
|
APP_DIR=$(pwd)
|
|
fi
|
|
fi
|
|
|
|
cd "$APP_DIR"
|
|
echo -e "${GREEN}Repository setup complete.${NC}"
|
|
}
|
|
|
|
# Function to install npm dependencies
|
|
install_npm_deps() {
|
|
echo -e "${BLUE}[4/5] Installing npm dependencies...${NC}"
|
|
|
|
if [ ! -d "$APP_DIR/sample_interface" ]; then
|
|
echo -e "${RED}Error: sample_interface not found in $APP_DIR${NC}"
|
|
exit 1
|
|
fi
|
|
|
|
cd "$APP_DIR/sample_interface"
|
|
|
|
if [ -d "node_modules" ]; then
|
|
echo -e "${YELLOW}node_modules exists. Updating...${NC}"
|
|
npm update
|
|
else
|
|
npm install
|
|
fi
|
|
|
|
echo -e "${GREEN}NPM dependencies installed.${NC}"
|
|
}
|
|
|
|
# Function to start the application
|
|
start_app() {
|
|
echo -e "${BLUE}[5/5] Starting application...${NC}"
|
|
echo ""
|
|
|
|
cd "$APP_DIR"
|
|
|
|
# Make start.sh executable
|
|
chmod +x start.sh
|
|
|
|
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
echo -e "${GREEN}Installation complete!${NC}"
|
|
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
echo ""
|
|
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
echo -e "${GREEN} Dual-mode servers will be available:${NC}"
|
|
echo -e "${GREEN} - Kiosk (port 8888): 7\" touchscreen display${NC}"
|
|
echo -e "${GREEN} - Remote HD (port 9999): Full HD desktop access${NC}"
|
|
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
echo ""
|
|
echo -e "Starting TCK RTU in dual-mode..."
|
|
echo ""
|
|
|
|
# Run start.sh (starts dual-mode by default)
|
|
./start.sh
|
|
}
|
|
|
|
# Main execution
|
|
main() {
|
|
install_system_deps
|
|
install_node
|
|
setup_repo
|
|
install_npm_deps
|
|
start_app
|
|
}
|
|
|
|
# Run main
|
|
main
|