Files
imperial-command-center/scripts/deploy-linux.sh

137 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
# Imperial Command Center - Linux Deployment Script
# This script builds and deploys the kiosk application
set -e
# Configuration
APP_NAME="imperial-command-center"
INSTALL_DIR="/opt/${APP_NAME}"
SERVICE_NAME="${APP_NAME}"
KIOSK_USER="kiosk"
echo "========================================="
echo "Imperial Command Center - Linux Deployer"
echo "========================================="
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root (sudo)"
exit 1
fi
# Build the application
echo ""
echo "[1/6] Building application..."
npm run build:linux
# Find the AppImage
APPIMAGE=$(find release -name "*.AppImage" -type f | head -n 1)
if [ -z "$APPIMAGE" ]; then
echo "Error: AppImage not found in release directory"
exit 1
fi
echo "Found AppImage: $APPIMAGE"
# Create installation directory
echo ""
echo "[2/6] Installing to ${INSTALL_DIR}..."
mkdir -p "${INSTALL_DIR}"
cp "$APPIMAGE" "${INSTALL_DIR}/${APP_NAME}.AppImage"
chmod +x "${INSTALL_DIR}/${APP_NAME}.AppImage"
# Copy environment file if it exists
if [ -f ".env" ]; then
cp .env "${INSTALL_DIR}/.env"
echo "Copied .env file"
fi
# Create kiosk user if it doesn't exist
echo ""
echo "[3/6] Setting up kiosk user..."
if ! id "${KIOSK_USER}" &>/dev/null; then
useradd -m -s /bin/bash "${KIOSK_USER}"
echo "Created user: ${KIOSK_USER}"
else
echo "User ${KIOSK_USER} already exists"
fi
# Set permissions
chown -R "${KIOSK_USER}:${KIOSK_USER}" "${INSTALL_DIR}"
# Create systemd service
echo ""
echo "[4/6] Creating systemd service..."
cat > "/etc/systemd/system/${SERVICE_NAME}.service" << EOF
[Unit]
Description=Imperial Command Center Kiosk
After=graphical.target network.target
Wants=graphical.target
[Service]
Type=simple
User=${KIOSK_USER}
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/${KIOSK_USER}/.Xauthority
WorkingDirectory=${INSTALL_DIR}
ExecStart=${INSTALL_DIR}/${APP_NAME}.AppImage --no-sandbox
Restart=always
RestartSec=5
[Install]
WantedBy=graphical.target
EOF
# Create X session script for autologin
echo ""
echo "[5/6] Configuring kiosk session..."
mkdir -p /home/${KIOSK_USER}/.config/autostart
cat > "/home/${KIOSK_USER}/.xinitrc" << EOF
#!/bin/bash
# Disable screen blanking
xset s off
xset -dpms
xset s noblank
# Hide cursor after 5 seconds of inactivity
unclutter -idle 5 &
# Start the application
exec ${INSTALL_DIR}/${APP_NAME}.AppImage --no-sandbox
EOF
chmod +x "/home/${KIOSK_USER}/.xinitrc"
chown "${KIOSK_USER}:${KIOSK_USER}" "/home/${KIOSK_USER}/.xinitrc"
# Enable and start the service
echo ""
echo "[6/6] Enabling service..."
systemctl daemon-reload
systemctl enable "${SERVICE_NAME}.service"
echo ""
echo "========================================="
echo "Deployment complete!"
echo "========================================="
echo ""
echo "The application has been installed to: ${INSTALL_DIR}"
echo ""
echo "To start the application manually:"
echo " sudo systemctl start ${SERVICE_NAME}"
echo ""
echo "To view logs:"
echo " sudo journalctl -u ${SERVICE_NAME} -f"
echo ""
echo "To configure autologin for kiosk mode, edit:"
echo " /etc/lightdm/lightdm.conf (for LightDM)"
echo " or /etc/gdm3/custom.conf (for GDM)"
echo ""
echo "Add these lines for LightDM autologin:"
echo " [Seat:*]"
echo " autologin-user=${KIOSK_USER}"
echo " autologin-session=openbox"
echo ""