From 9fc5e7c078b99af1fe586fc78962136223f271ea Mon Sep 17 00:00:00 2001 From: Mathias Date: Fri, 18 Jul 2025 11:03:55 +0200 Subject: [PATCH] Test os configuration --- os/build-iso.sh | 449 ++++++++++++++++++++++++++++++++++++++++++++++++ os/install.sh | 422 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 871 insertions(+) create mode 100755 os/build-iso.sh create mode 100644 os/install.sh diff --git a/os/build-iso.sh b/os/build-iso.sh new file mode 100755 index 0000000..226ad3e --- /dev/null +++ b/os/build-iso.sh @@ -0,0 +1,449 @@ +#!/bin/bash + +# OpenWall ISO Builder +# Creates a custom Debian ISO with OpenWall Dashboard pre-installed +# Uses Docker to build the ISO in a clean environment + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Configuration +ISO_NAME="openwall-dashboard" +ISO_VERSION="1.0.0" +DEBIAN_VERSION="bookworm" +BUILD_DIR="$(pwd)/iso-build" +OUTPUT_DIR="$(pwd)/dist" +DOCKER_IMAGE="openwall-iso-builder" + +echo -e "${BLUE}OpenWall ISO Builder${NC}" +echo -e "${BLUE}===================${NC}" + +# Check if Docker is installed and running +if ! command -v docker &> /dev/null; then + echo -e "${RED}Docker is not installed. Please install Docker first.${NC}" + exit 1 +fi + +if ! docker info &> /dev/null; then + echo -e "${RED}Docker is not running. Please start Docker first.${NC}" + exit 1 +fi + +# Clean previous builds +echo -e "${YELLOW}Cleaning previous builds...${NC}" +rm -rf "$BUILD_DIR" "$OUTPUT_DIR" +mkdir -p "$BUILD_DIR" "$OUTPUT_DIR" + +# Create Dockerfile for ISO building +echo -e "${YELLOW}Creating Docker build environment...${NC}" +cat > "$BUILD_DIR/Dockerfile" << EOF +FROM debian:${DEBIAN_VERSION} + +# Install required packages for ISO building +RUN apt-get update && apt-get install -y \\ + debootstrap \\ + squashfs-tools \\ + xorriso \\ + isolinux \\ + syslinux-efi \\ + grub-pc-bin \\ + grub-efi-amd64-bin \\ + grub-efi-ia32-bin \\ + mtools \\ + dosfstools \\ + curl \\ + wget \\ + git \\ + rsync \\ + && rm -rf /var/lib/apt/lists/* + +# Set working directory +WORKDIR /build + +# Copy build scripts +COPY build-iso.sh /build/ +COPY install.sh /build/ +COPY . /build/openwall/ + +RUN chmod +x /build/build-iso.sh + +# Build the ISO +CMD ["/build/build-iso.sh"] +EOF + +# Create the main ISO build script +cat > "$BUILD_DIR/build-iso.sh" << 'EOF' +#!/bin/bash + +set -e + +# Configuration +ISO_NAME="openwall-dashboard" +ISO_VERSION="1.0.0" +DEBIAN_VERSION="bookworm" +WORK_DIR="/build" +CHROOT_DIR="${WORK_DIR}/chroot" +ISO_DIR="${WORK_DIR}/iso" +OUTPUT_ISO="${WORK_DIR}/${ISO_NAME}-${ISO_VERSION}.iso" + +echo "Building OpenWall Dashboard ISO..." + +# Create directories +mkdir -p "${CHROOT_DIR}" "${ISO_DIR}" + +# Bootstrap Debian base system +echo "Bootstrapping Debian base system..." +debootstrap --arch=amd64 --variant=minbase "${DEBIAN_VERSION}" "${CHROOT_DIR}" http://deb.debian.org/debian/ + +# Mount necessary filesystems +mount --bind /dev "${CHROOT_DIR}/dev" +mount --bind /dev/pts "${CHROOT_DIR}/dev/pts" +mount --bind /proc "${CHROOT_DIR}/proc" +mount --bind /sys "${CHROOT_DIR}/sys" + +# Create cleanup function +cleanup() { + echo "Cleaning up mounts..." + umount -lf "${CHROOT_DIR}/dev/pts" 2>/dev/null || true + umount -lf "${CHROOT_DIR}/dev" 2>/dev/null || true + umount -lf "${CHROOT_DIR}/proc" 2>/dev/null || true + umount -lf "${CHROOT_DIR}/sys" 2>/dev/null || true +} +trap cleanup EXIT + +# Copy OpenWall files into chroot +echo "Copying OpenWall files..." +mkdir -p "${CHROOT_DIR}/opt/openwall-installer" +cp -r /build/openwall/* "${CHROOT_DIR}/opt/openwall-installer/" +cp /build/install.sh "${CHROOT_DIR}/opt/openwall-installer/" + +# Configure chroot environment +cat > "${CHROOT_DIR}/etc/apt/sources.list" << SOURCES +deb http://deb.debian.org/debian/ ${DEBIAN_VERSION} main non-free-firmware +deb-src http://deb.debian.org/debian/ ${DEBIAN_VERSION} main non-free-firmware +deb http://security.debian.org/debian-security ${DEBIAN_VERSION}-security main non-free-firmware +deb-src http://security.debian.org/debian-security ${DEBIAN_VERSION}-security main non-free-firmware +deb http://deb.debian.org/debian/ ${DEBIAN_VERSION}-updates main non-free-firmware +deb-src http://deb.debian.org/debian/ ${DEBIAN_VERSION}-updates main non-free-firmware +SOURCES + +# Configure hostname +echo "openwall-dashboard" > "${CHROOT_DIR}/etc/hostname" + +# Create chroot setup script +cat > "${CHROOT_DIR}/setup-system.sh" << 'SETUP' +#!/bin/bash + +set -e + +export DEBIAN_FRONTEND=noninteractive +export LC_ALL=C + +echo "Setting up OpenWall Dashboard system..." + +# Update package lists +apt-get update + +# Install essential packages +apt-get install -y \ + linux-image-amd64 \ + live-boot \ + systemd-sysv \ + locales \ + keyboard-configuration \ + console-setup \ + sudo \ + network-manager \ + openssh-server \ + curl \ + wget \ + git \ + nano \ + htop \ + firmware-linux-free \ + firmware-linux-nonfree + +# Configure locales +echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen +locale-gen +echo "LANG=en_US.UTF-8" > /etc/default/locale + +# Create openwall user +useradd -m -s /bin/bash -G sudo openwall +echo "openwall:openwall" | chpasswd +echo "root:openwall" | chpasswd + +# Configure sudo +echo "openwall ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/openwall + +# Configure automatic login +mkdir -p /etc/systemd/system/getty@tty1.service.d +cat > /etc/systemd/system/getty@tty1.service.d/override.conf << AUTOLOGIN +[Service] +ExecStart= +ExecStart=-/sbin/agetty --autologin openwall --noclear %I \$TERM +AUTOLOGIN + +# Create OpenWall installation service +cat > /etc/systemd/system/openwall-install.service << SERVICE +[Unit] +Description=OpenWall Dashboard Installation +After=network-online.target +Wants=network-online.target + +[Service] +Type=oneshot +User=root +ExecStart=/opt/openwall-installer/install.sh +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target +SERVICE + +# Enable the installation service +systemctl enable openwall-install.service + +# Create post-install script for user +mkdir -p /home/openwall +cat > /home/openwall/welcome.sh << WELCOME +#!/bin/bash + +echo "==================================================" +echo " Welcome to OpenWall Dashboard Live System!" +echo "==================================================" +echo "" +echo "This system will automatically install and configure" +echo "the OpenWall Dashboard on first boot." +echo "" +echo "Default credentials:" +echo " Username: openwall" +echo " Password: openwall" +echo "" +echo "The dashboard will start automatically after installation." +echo "" +echo "To reinstall manually, run:" +echo " sudo /opt/openwall-installer/install.sh" +echo "" +echo "==================================================" +echo "" +WELCOME + +chmod +x /home/openwall/welcome.sh +chown openwall:openwall /home/openwall/welcome.sh + +# Add welcome message to bashrc +echo "/home/openwall/welcome.sh" >> /home/openwall/.bashrc + +# Configure network +systemctl enable NetworkManager + +# Clean up +apt-get clean +rm -rf /var/lib/apt/lists/* +rm -f /setup-system.sh + +echo "System setup completed!" +SETUP + +chmod +x "${CHROOT_DIR}/setup-system.sh" + +# Run setup in chroot +echo "Running system setup in chroot..." +chroot "${CHROOT_DIR}" /setup-system.sh + +# Create live boot configuration +echo "Setting up live boot configuration..." +mkdir -p "${ISO_DIR}/live" + +# Create filesystem image +echo "Creating filesystem image..." +mksquashfs "${CHROOT_DIR}" "${ISO_DIR}/live/filesystem.squashfs" -comp xz -e boot + +# Copy kernel and initrd +cp "${CHROOT_DIR}/boot/vmlinuz-"* "${ISO_DIR}/live/vmlinuz" +cp "${CHROOT_DIR}/boot/initrd.img-"* "${ISO_DIR}/live/initrd" + +# Create GRUB configuration +mkdir -p "${ISO_DIR}/boot/grub" +cat > "${ISO_DIR}/boot/grub/grub.cfg" << GRUB +set timeout=10 +set default=0 + +menuentry "OpenWall Dashboard Live" { + linux /live/vmlinuz boot=live components quiet splash + initrd /live/initrd +} + +menuentry "OpenWall Dashboard Live (Safe Mode)" { + linux /live/vmlinuz boot=live components nomodeset + initrd /live/initrd +} +GRUB + +# Create isolinux configuration +mkdir -p "${ISO_DIR}/isolinux" +cp /usr/lib/ISOLINUX/isolinux.bin "${ISO_DIR}/isolinux/" +cp /usr/lib/syslinux/modules/bios/menu.c32 "${ISO_DIR}/isolinux/" +cp /usr/lib/syslinux/modules/bios/libutil.c32 "${ISO_DIR}/isolinux/" +cp /usr/lib/syslinux/modules/bios/ldlinux.c32 "${ISO_DIR}/isolinux/" + +cat > "${ISO_DIR}/isolinux/isolinux.cfg" << ISOLINUX +UI menu.c32 +PROMPT 0 +TIMEOUT 100 + +MENU TITLE OpenWall Dashboard Live + +LABEL live + MENU LABEL OpenWall Dashboard Live + KERNEL /live/vmlinuz + APPEND initrd=/live/initrd boot=live components quiet splash + +LABEL safe + MENU LABEL OpenWall Dashboard Live (Safe Mode) + KERNEL /live/vmlinuz + APPEND initrd=/live/initrd boot=live components nomodeset +ISOLINUX + +# Create EFI boot configuration +mkdir -p "${ISO_DIR}/EFI/boot" +grub-mkstandalone \ + --format=x86_64-efi \ + --output="${ISO_DIR}/EFI/boot/bootx64.efi" \ + --locales="" \ + --fonts="" \ + "boot/grub/grub.cfg=${ISO_DIR}/boot/grub/grub.cfg" + +# Create the ISO +echo "Creating ISO image..." +xorriso -as mkisofs \ + -iso-level 3 \ + -full-iso9660-filenames \ + -volid "OpenWall Dashboard" \ + -eltorito-boot isolinux/isolinux.bin \ + -eltorito-catalog isolinux/boot.cat \ + -no-emul-boot \ + -boot-load-size 4 \ + -boot-info-table \ + --eltorito-alt-boot \ + -e EFI/boot/bootx64.efi \ + -no-emul-boot \ + -append_partition 2 0xef "${ISO_DIR}/EFI/boot/bootx64.efi" \ + -output "${OUTPUT_ISO}" \ + -graft-points \ + "${ISO_DIR}" + +echo "ISO created: ${OUTPUT_ISO}" +EOF + +chmod +x "$BUILD_DIR/build-iso.sh" + +# Copy project files +echo -e "${YELLOW}Copying project files...${NC}" +cp -r "$(dirname "$0")/../dashboard" "$BUILD_DIR/" +cp -r "$(dirname "$0")/../server" "$BUILD_DIR/" +cp "$(dirname "$0")/install.sh" "$BUILD_DIR/" + +# Create README for the ISO +cat > "$BUILD_DIR/README.md" << 'EOF' +# OpenWall Dashboard Live ISO + +This ISO contains a complete Debian-based live system with the OpenWall Dashboard pre-configured. + +## Features + +- **Live Boot**: Boots directly from USB/DVD without installation +- **Auto-Installation**: Automatically installs and configures OpenWall Dashboard on first boot +- **Touch Support**: Optimized for touch displays +- **9:16 Display**: Configured for portrait orientation displays +- **Wayland Session**: Modern display server with touch support +- **Kiosk Mode**: Runs in fullscreen kiosk mode + +## Boot Options + +- **OpenWall Dashboard Live**: Normal boot with all features +- **OpenWall Dashboard Live (Safe Mode)**: Boot with minimal graphics drivers + +## Default Credentials + +- **Username**: openwall +- **Password**: openwall + +## Usage + +1. Flash the ISO to a USB drive or burn to DVD +2. Boot from the USB/DVD +3. The system will automatically start and install the dashboard +4. The dashboard will be available in fullscreen mode + +## Manual Installation + +If you need to reinstall or configure manually: + +```bash +sudo /opt/openwall-installer/install.sh +``` + +## Network Configuration + +The system uses NetworkManager for network configuration. Connect to WiFi or Ethernet as needed. + +## System Information + +- **Base OS**: Debian Bookworm +- **Display Server**: Wayland (Sway compositor) +- **Application**: Electron-based dashboard +- **Backend**: Node.js Express server with SQLite + +EOF + +# Build the Docker image and create ISO +echo -e "${YELLOW}Building Docker image...${NC}" +docker build -t "$DOCKER_IMAGE" "$BUILD_DIR" + +echo -e "${YELLOW}Creating ISO (this may take a while)...${NC}" +docker run --rm --privileged \ + -v "$OUTPUT_DIR:/output" \ + "$DOCKER_IMAGE" \ + bash -c " + /build/build-iso.sh && + cp /build/*.iso /output/ + " + +# Check if ISO was created successfully +if [ -f "$OUTPUT_DIR/${ISO_NAME}-${ISO_VERSION}.iso" ]; then + echo -e "${GREEN}ISO created successfully!${NC}" + echo -e "${GREEN}========================${NC}" + echo "" + echo -e "${BLUE}ISO Information:${NC}" + echo -e "• File: ${OUTPUT_DIR}/${ISO_NAME}-${ISO_VERSION}.iso" + echo -e "• Size: $(du -h "$OUTPUT_DIR/${ISO_NAME}-${ISO_VERSION}.iso" | cut -f1)" + echo "" + echo -e "${YELLOW}Usage:${NC}" + echo -e "1. Flash to USB: ${BLUE}dd if=${OUTPUT_DIR}/${ISO_NAME}-${ISO_VERSION}.iso of=/dev/sdX bs=4M status=progress${NC}" + echo -e "2. Or use tools like Balena Etcher, Rufus, etc." + echo -e "3. Boot from USB and follow the on-screen instructions" + echo "" + echo -e "${YELLOW}Features:${NC}" + echo -e "• Live boot with auto-installation" + echo -e "• Touch display support (9:16 ratio)" + echo -e "• Wayland session with Sway compositor" + echo -e "• Kiosk mode dashboard" + echo -e "• Default user: openwall/openwall" +else + echo -e "${RED}ISO creation failed!${NC}" + exit 1 +fi + +# Clean up Docker image +echo -e "${YELLOW}Cleaning up...${NC}" +docker rmi "$DOCKER_IMAGE" 2>/dev/null || true + +echo -e "${GREEN}Build completed successfully!${NC}" diff --git a/os/install.sh b/os/install.sh new file mode 100644 index 0000000..409d5e7 --- /dev/null +++ b/os/install.sh @@ -0,0 +1,422 @@ +#!/bin/bash + +# OpenWall Dashboard Installer for Debian +# Installs and configures the dashboard app for touch displays with 9:16 ratio +# Supports Wayland session with auto-start + +set -e + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +# Configuration +APP_USER="openwall" +APP_DIR="/opt/openwall" +DISPLAY_WIDTH="1080" +DISPLAY_HEIGHT="1920" +SERVICE_NAME="openwall-dashboard" + +echo -e "${BLUE}OpenWall Dashboard Installer${NC}" +echo -e "${BLUE}==============================${NC}" + +# Check if running as root +if [[ $EUID -ne 0 ]]; then + echo -e "${RED}This script must be run as root${NC}" + exit 1 +fi + +# Update system +echo -e "${YELLOW}Updating system packages...${NC}" +apt update && apt upgrade -y + +# Install required packages +echo -e "${YELLOW}Installing required packages...${NC}" +apt install -y \ + curl \ + wget \ + git \ + build-essential \ + python3 \ + python3-pip \ + nodejs \ + npm \ + wayland-protocols \ + wayland-utils \ + weston \ + sway \ + swaylock \ + swayidle \ + xwayland \ + libdrm2 \ + libinput-tools \ + udev \ + systemd \ + xinput \ + x11-xserver-utils \ + mesa-utils \ + vulkan-tools \ + libgl1-mesa-dri \ + libgles2-mesa \ + libegl1-mesa \ + firefox-esr \ + chromium \ + fonts-liberation \ + fonts-dejavu-core \ + unclutter \ + xdotool + +# Install Node.js LTS +echo -e "${YELLOW}Installing Node.js LTS...${NC}" +curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - +apt install -y nodejs + +# Install pnpm +echo -e "${YELLOW}Installing pnpm...${NC}" +npm install -g pnpm + +# Create application user +echo -e "${YELLOW}Creating application user...${NC}" +if ! id "$APP_USER" &>/dev/null; then + useradd -m -s /bin/bash "$APP_USER" + usermod -aG video,input,audio "$APP_USER" +fi + +# Create application directory +echo -e "${YELLOW}Setting up application directory...${NC}" +mkdir -p "$APP_DIR" +chown "$APP_USER:$APP_USER" "$APP_DIR" + +# Copy application files +echo -e "${YELLOW}Installing application files...${NC}" +if [ -d "$(dirname "$0")/../dashboard" ]; then + cp -r "$(dirname "$0")/../dashboard/"* "$APP_DIR/" + cp -r "$(dirname "$0")/../server" "$APP_DIR/" + chown -R "$APP_USER:$APP_USER" "$APP_DIR" +else + echo -e "${RED}Dashboard directory not found. Please run this script from the OpenWall project root.${NC}" + exit 1 +fi + +# Install application dependencies +echo -e "${YELLOW}Installing application dependencies...${NC}" +cd "$APP_DIR" +sudo -u "$APP_USER" pnpm install + +# Install server dependencies +cd "$APP_DIR/server" +sudo -u "$APP_USER" npm install + +# Create Wayland session configuration +echo -e "${YELLOW}Configuring Wayland session...${NC}" +cat > /usr/share/wayland-sessions/openwall.desktop << EOF +[Desktop Entry] +Name=OpenWall Dashboard +Comment=OpenWall Touch Dashboard Session +Exec=/opt/openwall/start-session.sh +Type=Application +DesktopNames=openwall +EOF + +# Create session start script +cat > "$APP_DIR/start-session.sh" << 'EOF' +#!/bin/bash + +# OpenWall Dashboard Session Starter +export XDG_RUNTIME_DIR="/run/user/$(id -u)" +export XDG_SESSION_TYPE=wayland +export XDG_CURRENT_DESKTOP=openwall +export QT_QPA_PLATFORM=wayland +export GDK_BACKEND=wayland +export MOZ_ENABLE_WAYLAND=1 + +# Start Wayland compositor (Sway) +exec sway --config /opt/openwall/sway-config +EOF + +chmod +x "$APP_DIR/start-session.sh" + +# Create Sway configuration for dashboard +cat > "$APP_DIR/sway-config" << EOF +# OpenWall Dashboard Sway Configuration +# Optimized for touch displays with 9:16 ratio + +# Set display configuration +output * { + mode ${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}@60Hz + scale 1 + transform normal + bg #000000 solid_color +} + +# Input configuration for touch +input type:touch { + events enabled + tap enabled + natural_scroll enabled + dwt disabled +} + +# Input configuration for touchpad +input type:touchpad { + events enabled + tap enabled + natural_scroll enabled + dwt enabled + accel_profile adaptive + pointer_accel 0.3 +} + +# Disable window decorations and gaps +default_border none +default_floating_border none +gaps inner 0 +gaps outer 0 + +# Hide cursor after 3 seconds +seat * hide_cursor 3000 + +# Disable screen timeout +exec swayidle timeout 0 '' before-sleep 'true' + +# Start the dashboard application +exec /opt/openwall/start-dashboard.sh +EOF + +# Create dashboard start script +cat > "$APP_DIR/start-dashboard.sh" << 'EOF' +#!/bin/bash + +# Start the backend server +cd /opt/openwall/server +node index.js & + +# Wait for server to start +sleep 3 + +# Start the dashboard in fullscreen +cd /opt/openwall +pnpm run electron -- --kiosk --touch-events --disable-pinch --overscroll-history-navigation=0 --disable-features=TranslateUI +EOF + +chmod +x "$APP_DIR/start-dashboard.sh" + +# Update Electron main process for kiosk mode +cat > "$APP_DIR/src/main/index.js" << 'EOF' +import { app, shell, BrowserWindow, screen } from 'electron' +import { join } from 'path' +import { electronApp, optimizer, is } from '@electron-toolkit/utils' +import icon from '../../resources/icon.png?asset' + +function createWindow() { + // Get the primary display + const primaryDisplay = screen.getPrimaryDisplay() + const { width, height } = primaryDisplay.workAreaSize + + // Create the browser window in kiosk mode for touch displays + const mainWindow = new BrowserWindow({ + width: width, + height: height, + show: false, + fullscreen: true, + kiosk: true, + frame: false, + autoHideMenuBar: true, + webPreferences: { + preload: join(__dirname, '../preload/index.js'), + sandbox: false, + nodeIntegration: false, + contextIsolation: true, + webSecurity: false + } + }) + + // Disable zoom and context menu for touch interface + mainWindow.webContents.on('before-input-event', (event, input) => { + if (input.control && (input.key === '+' || input.key === '-' || input.key === '=')) { + event.preventDefault() + } + }) + + mainWindow.webContents.on('context-menu', (event) => { + event.preventDefault() + }) + + mainWindow.on('ready-to-show', () => { + mainWindow.show() + mainWindow.setFullScreen(true) + }) + + mainWindow.webContents.setWindowOpenHandler((details) => { + shell.openExternal(details.url) + return { action: 'deny' } + }) + + // Load the app + if (is.dev && process.env['ELECTRON_RENDERER_URL']) { + mainWindow.loadURL(process.env['ELECTRON_RENDERER_URL']) + } else { + mainWindow.loadFile(join(__dirname, '../renderer/index.html')) + } +} + +app.whenReady().then(() => { + electronApp.setAppUserModelId('com.openwall.dashboard') + + app.on('browser-window-created', (_, window) => { + optimizer.watchWindowShortcuts(window) + }) + + createWindow() + + app.on('activate', function () { + if (BrowserWindow.getAllWindows().length === 0) createWindow() + }) +}) + +app.on('window-all-closed', () => { + if (process.platform !== 'darwin') app.quit() +}) +EOF + +# Create systemd service for auto-start +echo -e "${YELLOW}Creating systemd service...${NC}" +cat > "/etc/systemd/system/${SERVICE_NAME}.service" << EOF +[Unit] +Description=OpenWall Dashboard Service +After=graphical-session.target +Wants=graphical-session.target + +[Service] +Type=simple +User=${APP_USER} +Group=${APP_USER} +WorkingDirectory=${APP_DIR} +Environment=HOME=/home/${APP_USER} +Environment=XDG_RUNTIME_DIR=/run/user/1001 +ExecStart=${APP_DIR}/start-dashboard.sh +Restart=always +RestartSec=10 + +[Install] +WantedBy=graphical-session.target +EOF + +# Create udev rules for touch input +echo -e "${YELLOW}Configuring touch input...${NC}" +cat > /etc/udev/rules.d/99-openwall-touch.rules << 'EOF' +# OpenWall touch input configuration +SUBSYSTEM=="input", ATTRS{name}=="*touch*", ENV{LIBINPUT_CALIBRATION_MATRIX}="1 0 0 0 1 0" +SUBSYSTEM=="input", ATTRS{name}=="*Touch*", ENV{LIBINPUT_CALIBRATION_MATRIX}="1 0 0 0 1 0" +EOF + +# Configure X11 display settings (fallback) +echo -e "${YELLOW}Configuring display settings...${NC}" +cat > /etc/X11/xorg.conf.d/99-openwall-display.conf << EOF +Section "Monitor" + Identifier "HDMI-1" + Option "PreferredMode" "${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}" + Option "Position" "0 0" + Option "Rotate" "normal" +EndSection + +Section "Screen" + Identifier "Default Screen" + Monitor "HDMI-1" + DefaultDepth 24 + SubSection "Display" + Depth 24 + Modes "${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}" + EndSubSection +EndSection +EOF + +# Create auto-login configuration +echo -e "${YELLOW}Configuring auto-login...${NC}" +mkdir -p /etc/systemd/system/getty@tty1.service.d +cat > /etc/systemd/system/getty@tty1.service.d/override.conf << EOF +[Service] +ExecStart= +ExecStart=-/sbin/agetty --autologin ${APP_USER} --noclear %I \$TERM +EOF + +# Configure user session to start Wayland +echo -e "${YELLOW}Configuring user session...${NC}" +mkdir -p "/home/${APP_USER}/.config/systemd/user" +cat > "/home/${APP_USER}/.config/systemd/user/openwall-session.service" << EOF +[Unit] +Description=OpenWall Dashboard Session +After=graphical-session.target + +[Service] +Type=exec +ExecStart=/opt/openwall/start-session.sh +Restart=always +RestartSec=5 + +[Install] +WantedBy=default.target +EOF + +# Set up user environment +cat > "/home/${APP_USER}/.profile" << 'EOF' +# OpenWall Dashboard Environment +export XDG_SESSION_TYPE=wayland +export XDG_CURRENT_DESKTOP=openwall +export QT_QPA_PLATFORM=wayland +export GDK_BACKEND=wayland +export MOZ_ENABLE_WAYLAND=1 + +# Auto-start Wayland session on login +if [ -z "$DISPLAY" ] && [ "$XDG_VTNR" = "1" ]; then + exec /opt/openwall/start-session.sh +fi +EOF + +chown -R "${APP_USER}:${APP_USER}" "/home/${APP_USER}" + +# Enable services +echo -e "${YELLOW}Enabling services...${NC}" +systemctl daemon-reload +systemctl enable "${SERVICE_NAME}.service" + +# Enable user service +sudo -u "$APP_USER" systemctl --user enable openwall-session.service + +# Build the application +echo -e "${YELLOW}Building application...${NC}" +cd "$APP_DIR" +sudo -u "$APP_USER" pnpm run build + +# Set file permissions +chown -R "$APP_USER:$APP_USER" "$APP_DIR" +chmod +x "$APP_DIR"/*.sh + +# Reload udev rules +udevadm control --reload-rules +udevadm trigger + +echo -e "${GREEN}Installation completed successfully!${NC}" +echo -e "${GREEN}==============================${NC}" +echo "" +echo -e "${BLUE}Installation Summary:${NC}" +echo -e "• Application installed to: ${APP_DIR}" +echo -e "• User created: ${APP_USER}" +echo -e "• Display configured for: ${DISPLAY_WIDTH}x${DISPLAY_HEIGHT} (9:16 ratio)" +echo -e "• Wayland session: openwall" +echo -e "• Service: ${SERVICE_NAME}" +echo "" +echo -e "${YELLOW}Next steps:${NC}" +echo -e "1. Reboot the system: ${BLUE}reboot${NC}" +echo -e "2. The dashboard will start automatically on boot" +echo -e "3. Access the dashboard at the configured display" +echo "" +echo -e "${YELLOW}Manual control:${NC}" +echo -e "• Start service: ${BLUE}systemctl start ${SERVICE_NAME}${NC}" +echo -e "• Stop service: ${BLUE}systemctl stop ${SERVICE_NAME}${NC}" +echo -e "• View logs: ${BLUE}journalctl -u ${SERVICE_NAME} -f${NC}" +echo "" +echo -e "${GREEN}Reboot now to start the OpenWall Dashboard!${NC}"