#!/bin/bash # shellcheck disable=SC1091 source "${AGENT_PATH}/common.sh" _check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "KIOSK_URL" "KIOSK_USER" # Check if URL is set if [ -z "$KIOSK_URL" ] || [ "$KIOSK_URL" = "" ]; then _die "KIOSK_URL is not set in config/service.env! Please set the URL to display." fi # Check if user is set if [ -z "$KIOSK_USER" ] || [ "$KIOSK_USER" = "" ]; then _die "KIOSK_USER is not set in config/service.env! Please set the user account for the kiosk." fi _check_docker_installed || _die "Docker test failed, aborting installation..." # Detect system type echo "Detecting system type..." SYSTEM_TYPE="" if [ -f "/proc/device-tree/model" ]; then MODEL=$(cat /proc/device-tree/model 2>/dev/null | tr -d '\0') if echo "$MODEL" | grep -qi "raspberry"; then SYSTEM_TYPE="rpi" echo " Detected: Raspberry Pi ($MODEL)" fi fi if [ -z "$SYSTEM_TYPE" ]; then # Check for Ubuntu on x86_64 (likely Mac Mini or standard PC) if [ -f "/etc/os-release" ]; then . /etc/os-release if [ "$ID" = "ubuntu" ] && [ "$(uname -m)" = "x86_64" ]; then SYSTEM_TYPE="ubuntu" echo " Detected: Ubuntu on x86_64" # Try to detect if it's a Mac Mini if command -v dmidecode >/dev/null 2>&1; then PRODUCT=$(sudo dmidecode -s system-product-name 2>/dev/null || true) if echo "$PRODUCT" | grep -qi "mac"; then echo " Hardware: Mac Mini" fi fi elif [ "$ID" = "raspbian" ] || [ "$ID" = "debian" ] && [ "$(uname -m)" = "aarch64" -o "$(uname -m)" = "armv7l" ]; then SYSTEM_TYPE="rpi" echo " Detected: Raspberry Pi OS" fi fi fi if [ -z "$SYSTEM_TYPE" ]; then echo " Could not auto-detect system type." echo " Please select your system:" echo " 1) Raspberry Pi" echo " 2) Ubuntu (x86_64/Mac Mini)" read -p " Enter choice (1 or 2): " choice case $choice in 1) SYSTEM_TYPE="rpi" ;; 2) SYSTEM_TYPE="ubuntu" ;; *) _die "Invalid choice. Installation cancelled." ;; esac fi echo "" echo "Installing Squash Display kiosk service for $SYSTEM_TYPE..." echo "" echo "WARNING: This will make system-level changes to configure kiosk mode." echo "Changes include:" echo " - Installing Chromium browser and X server packages" echo " - Configuring auto-login for user: ${KIOSK_USER}" echo " - Setting up kiosk scripts" if [ "$SYSTEM_TYPE" = "rpi" ]; then echo " - Configuring GPU memory allocation" echo " - Disabling automatic updates" fi echo " - Configuring display settings" echo "" # Check if running interactively (has a TTY) if [ -t 0 ]; then read -p "Do you want to continue? (yes/no): " confirmation if [ "$confirmation" != "yes" ]; then echo "Installation cancelled." exit 0 fi else echo "Running in non-interactive mode, proceeding with installation..." fi echo "Pulling Docker image..." docker pull "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || _die "Failed to pull image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" # Stop and remove existing container if it exists if _is_container_exists "$CONTAINER_NAME"; then echo "Removing existing container..." bash ./stop.sh 2>/dev/null || true _remove_container "$CONTAINER_NAME" || true fi # Export SYSTEM_TYPE for use in start.sh export SYSTEM_TYPE # Start the setup container (scripts are now embedded in start.sh) bash ./start.sh || _die "Failed to start Squash Display setup" echo "" echo "==========================================" echo "Squash Display installation complete!" echo "==========================================" echo "" echo "Next steps:" echo "1. REBOOT THE SYSTEM for all changes to take effect" echo " sudo reboot" echo "" echo "2. After reboot, the system will:" echo " - Auto-login as user: ${KIOSK_USER}" echo " - Start X server automatically" echo " - Launch Chromium in kiosk mode" echo " - Display: ${KIOSK_URL}" echo "" echo "3. To check status: ds status [server] squashdisplay" echo "4. To reconfigure: ds exec [server] squashdisplay configure" echo "" echo "Troubleshooting:" echo "- Check logs: journalctl -u getty@tty1" echo "- View X server logs: cat /home/${KIOSK_USER}/.local/share/xorg/Xorg.0.log" echo "- Manual test: sudo -u ${KIOSK_USER} startx /home/${KIOSK_USER}/kiosk.sh"