feat: add Raspberry Pi kiosk deployment scripts
This commit is contained in:
parent
6380a89808
commit
5cab565dc7
3 changed files with 132 additions and 26 deletions
|
|
@ -1,35 +1,72 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Configuration
|
set -e
|
||||||
|
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||||
URL="http://localhost:3000"
|
URL="http://localhost:3000"
|
||||||
USER_NAME=$(whoami)
|
USER_NAME=$(whoami)
|
||||||
AUTOSTART_DIR="/home/$USER_NAME/.config/autostart"
|
AUTOSTART_DIR="/home/$USER_NAME/.config/autostart"
|
||||||
DESKTOP_FILE="$AUTOSTART_DIR/kiosk.desktop"
|
DESKTOP_FILE="$AUTOSTART_DIR/walldash-kiosk.desktop"
|
||||||
|
KIOSK_WRAPPER="$SCRIPT_DIR/start-kiosk.sh"
|
||||||
|
|
||||||
|
# Ensure the wrapper is executable
|
||||||
|
chmod +x "$KIOSK_WRAPPER"
|
||||||
|
|
||||||
|
# Install unclutter if missing (hides the mouse cursor)
|
||||||
|
if ! command -v unclutter &>/dev/null; then
|
||||||
|
echo "Installing unclutter..."
|
||||||
|
sudo apt-get install -y unclutter
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install curl if missing (used by the wrapper to wait for the server)
|
||||||
|
if ! command -v curl &>/dev/null; then
|
||||||
|
echo "Installing curl..."
|
||||||
|
sudo apt-get install -y curl
|
||||||
|
fi
|
||||||
|
|
||||||
# Create autostart directory if it doesn't exist
|
# Create autostart directory if it doesn't exist
|
||||||
mkdir -p "$AUTOSTART_DIR"
|
mkdir -p "$AUTOSTART_DIR"
|
||||||
|
|
||||||
# Create the .desktop file for Chromium kiosk mode
|
# Create the .desktop file pointing at our wrapper script
|
||||||
cat <<DESKTOPTEMPLATE > "$DESKTOP_FILE"
|
cat > "$DESKTOP_FILE" <<DESKTOP
|
||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Type=Application
|
Type=Application
|
||||||
Name=Walldash Kiosk
|
Name=Walldash Kiosk
|
||||||
Exec=chromium-browser --noerrdialogs --disable-infobars --kiosk $URL
|
Exec=$KIOSK_WRAPPER
|
||||||
X-GNOME-Autostart-enabled=true
|
X-GNOME-Autostart-enabled=true
|
||||||
DESKTOPTEMPLATE
|
DESKTOP
|
||||||
|
|
||||||
# Disable screen blanking and screensaver
|
echo "Created autostart entry: $DESKTOP_FILE"
|
||||||
# This configuration may vary depending on the display manager (X11, Wayland)
|
|
||||||
# For Raspberry Pi OS (Standard X11):
|
# Disable screen blanking / DPMS for LXDE-pi (X11)
|
||||||
if [ -f "/etc/xdg/lxsession/LXDE-pi/autostart" ]; then
|
LXDE_AUTOSTART="/etc/xdg/lxsession/LXDE-pi/autostart"
|
||||||
sudo sed -i 's/@xscreensaver -no-splash/# @xscreensaver -no-splash/' /etc/xdg/lxsession/LXDE-pi/autostart
|
if [ -f "$LXDE_AUTOSTART" ]; then
|
||||||
echo "@xset s off" | sudo tee -a /etc/xdg/lxsession/LXDE-pi/autostart
|
# Avoid duplicate entries
|
||||||
echo "@xset -dpms" | sudo tee -a /etc/xdg/lxsession/LXDE-pi/autostart
|
for line in "@xset s off" "@xset -dpms" "@xset s noblank"; do
|
||||||
echo "@xset s noblank" | sudo tee -a /etc/xdg/lxsession/LXDE-pi/autostart
|
grep -qF "$line" "$LXDE_AUTOSTART" || echo "$line" | sudo tee -a "$LXDE_AUTOSTART" > /dev/null
|
||||||
|
done
|
||||||
|
# Disable screensaver if present
|
||||||
|
sudo sed -i 's/^@xscreensaver/# @xscreensaver/' "$LXDE_AUTOSTART"
|
||||||
|
echo "Updated $LXDE_AUTOSTART for screen blanking."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Optional: Install unclutter to hide mouse cursor
|
# Disable screen blanking for Wayfire / Labwc (Pi OS Bookworm Wayland)
|
||||||
# sudo apt-get update && sudo apt-get install -y unclutter
|
WAYFIRE_INI="$HOME/.config/wayfire.ini"
|
||||||
# echo "@unclutter -idle 0.1 -root" >> /etc/xdg/lxsession/LXDE-pi/autostart
|
if [ -f "$WAYFIRE_INI" ]; then
|
||||||
|
if ! grep -q '\[idle\]' "$WAYFIRE_INI"; then
|
||||||
|
cat >> "$WAYFIRE_INI" <<'INI'
|
||||||
|
|
||||||
echo "Kiosk setup complete. Chromium will launch $URL on the next login."
|
[idle]
|
||||||
|
toggle = <super> KEY_Z
|
||||||
|
screensaver_timeout = -1
|
||||||
|
dpms_timeout = -1
|
||||||
|
INI
|
||||||
|
echo "Disabled idle/screensaver in $WAYFIRE_INI."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Kiosk setup complete."
|
||||||
|
echo "Chromium will open $URL automatically on the next login."
|
||||||
|
echo "To test now, run: $KIOSK_WRAPPER"
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Configuration
|
set -e
|
||||||
|
|
||||||
SERVICE_NAME="walldash"
|
SERVICE_NAME="walldash"
|
||||||
USER_NAME=$(whoami)
|
USER_NAME=$(whoami)
|
||||||
DIR_PATH=$(pwd)
|
# Use the project directory relative to this script, not wherever the script is called from
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
||||||
BUN_PATH=$(which bun)
|
BUN_PATH=$(which bun)
|
||||||
|
|
||||||
if [ -z "$BUN_PATH" ]; then
|
if [ -z "$BUN_PATH" ]; then
|
||||||
|
|
@ -14,16 +17,20 @@ fi
|
||||||
# Create systemd service file
|
# Create systemd service file
|
||||||
cat <<SERVICETEMPLATE | sudo tee /etc/systemd/system/$SERVICE_NAME.service
|
cat <<SERVICETEMPLATE | sudo tee /etc/systemd/system/$SERVICE_NAME.service
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Walldash Express Dashboard Server
|
Description=Walldash Dashboard Server
|
||||||
After=network.target
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=$BUN_PATH run src/server.ts
|
ExecStart=$BUN_PATH run src/server.ts
|
||||||
WorkingDirectory=$DIR_PATH
|
WorkingDirectory=$PROJECT_DIR
|
||||||
Restart=always
|
Restart=always
|
||||||
|
RestartSec=5
|
||||||
User=$USER_NAME
|
User=$USER_NAME
|
||||||
Environment=NODE_ENV=production
|
Environment=NODE_ENV=production
|
||||||
Environment=PORT=3000
|
Environment=PORT=3000
|
||||||
|
StandardOutput=journal
|
||||||
|
StandardError=journal
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
@ -32,7 +39,8 @@ SERVICETEMPLATE
|
||||||
# Reload and enable service
|
# Reload and enable service
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl enable $SERVICE_NAME.service
|
sudo systemctl enable $SERVICE_NAME.service
|
||||||
sudo systemctl start $SERVICE_NAME.service
|
sudo systemctl restart $SERVICE_NAME.service
|
||||||
|
|
||||||
echo "Walldash service setup complete and started."
|
echo "Walldash service installed and started."
|
||||||
echo "Check status with: systemctl status $SERVICE_NAME.service"
|
echo "Check status : systemctl status $SERVICE_NAME.service"
|
||||||
|
echo "Follow logs : journalctl -u $SERVICE_NAME.service -f"
|
||||||
|
|
|
||||||
61
scripts/start-kiosk.sh
Executable file
61
scripts/start-kiosk.sh
Executable file
|
|
@ -0,0 +1,61 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Wrapper launched by the autostart .desktop entry.
|
||||||
|
# Waits for the walldash server, then runs Chromium in kiosk mode.
|
||||||
|
# If Chromium exits or crashes, it restarts automatically.
|
||||||
|
|
||||||
|
URL="http://localhost:3000"
|
||||||
|
DISPLAY="${DISPLAY:-:0}"
|
||||||
|
export DISPLAY
|
||||||
|
|
||||||
|
# Detect chromium binary
|
||||||
|
if command -v chromium-browser &>/dev/null; then
|
||||||
|
CHROMIUM=chromium-browser
|
||||||
|
elif command -v chromium &>/dev/null; then
|
||||||
|
CHROMIUM=chromium
|
||||||
|
else
|
||||||
|
echo "ERROR: chromium / chromium-browser not found" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Disable screen blanking / DPMS
|
||||||
|
xset s off
|
||||||
|
xset -dpms
|
||||||
|
xset s noblank
|
||||||
|
|
||||||
|
# Hide mouse cursor (requires unclutter)
|
||||||
|
if command -v unclutter &>/dev/null; then
|
||||||
|
unclutter -idle 0.5 -root &
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Wait until the walldash server is accepting connections
|
||||||
|
echo "Waiting for $URL ..."
|
||||||
|
until curl -sf "$URL" -o /dev/null; do
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
echo "Server ready."
|
||||||
|
|
||||||
|
# Remove stale Chromium crash/exit flags so it doesn't show the "restore" prompt
|
||||||
|
CHROMIUM_PROFILE="$HOME/.config/chromium/Default"
|
||||||
|
if [ -f "$CHROMIUM_PROFILE/Preferences" ]; then
|
||||||
|
sed -i 's/"exit_type":"Crashed"/"exit_type":"Normal"/' "$CHROMIUM_PROFILE/Preferences"
|
||||||
|
sed -i 's/"exited_cleanly":false/"exited_cleanly":true/' "$CHROMIUM_PROFILE/Preferences"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run Chromium in a loop so a crash restarts it automatically
|
||||||
|
while true; do
|
||||||
|
$CHROMIUM \
|
||||||
|
--noerrdialogs \
|
||||||
|
--disable-infobars \
|
||||||
|
--kiosk \
|
||||||
|
--no-first-run \
|
||||||
|
--disable-default-apps \
|
||||||
|
--disable-component-update \
|
||||||
|
--check-for-update-interval=31536000 \
|
||||||
|
--disable-features=TranslateUI \
|
||||||
|
--disable-pinch \
|
||||||
|
--overscroll-history-navigation=0 \
|
||||||
|
--autoplay-policy=no-user-gesture-required \
|
||||||
|
"$URL"
|
||||||
|
echo "Chromium exited — restarting in 5 s..."
|
||||||
|
sleep 5
|
||||||
|
done
|
||||||
Loading…
Reference in a new issue