fix: install.sh — sleep-safe, auto-display, fresh-machine install
- install.sh now has 8 steps: 1) Detect arch, 2) Install deps, 3) Disable sleep/lock/screensaver, 4) Detect display, 5) Setup dummy + force DUMMY0 primary, 6) Start Xorg/Xvfb, 7) Download+install RustDesk (with apt fallback), 8) Install systemd unit rustdesk-headless.service - New systemd unit: rustdesk-headless.service * Forces DUMMY0 as primary via ExecStartPre (no monitor selection dialog) * Restart=always — survives any crash * Wants=display-manager.service — starts after graphical session - Sleep-safe changes: * Mask sleep.target suspend.target hibernate.target hybrid-sleep.target * logind.conf: HandleLidSwitch=ignore, IdleAction=ignore * GNOME screensaver: gsettings lock-enabled false, idle-delay 0 * X11: xset s off -dpms - Fresh machine fixes: * dpkg --force-depends --force-confnew (installs even with missing deps) * apt-get install -f after dpkg (fixes broken deps) * Fallback to 'apt-get install rustdesk' from repo if .deb download fails * Added libva-drm2 libva-x11-2 (fresh systems often miss these) - Output at end: * ID, Password, Display (:0 DUMMY0 primary), Sleep/Lock status * Monitor status via xrandr --listmonitors Fixes #7
This commit is contained in:
18
config/systemd/rustdesk-headless-inhibit.service
Normal file
18
config/systemd/rustdesk-headless-inhibit.service
Normal file
@@ -0,0 +1,18 @@
|
||||
[Unit]
|
||||
Description=Inhibit system sleep while RustDesk is active
|
||||
After=rustdesk-headless.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/bin/bash -c '\
|
||||
while true; do \
|
||||
if pgrep -f "/usr/share/rustdesk/rustdesk --server" >/dev/null; then \
|
||||
systemd-inhibit --what=sleep:idle:handle-lid-switch --who="RustDesk" --why="Remote access active" sleep 60; \
|
||||
else \
|
||||
sleep 5; \
|
||||
fi; \
|
||||
done'
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
40
config/systemd/rustdesk-headless.service
Normal file
40
config/systemd/rustdesk-headless.service
Normal file
@@ -0,0 +1,40 @@
|
||||
[Unit]
|
||||
Description=RustDesk Headless Server (auto-display, sleep-safe)
|
||||
After=display-manager.service graphical.target network.target
|
||||
Wants=display-manager.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
Environment="DISPLAY=:0"
|
||||
Environment="XAUTHORITY=/root/.Xauthority"
|
||||
Environment="LIBVA_DRIVER_NAME=none"
|
||||
Environment="VDPAU_DRIVER=none"
|
||||
Environment="LIBGL_ALWAYS_SOFTWARE=1"
|
||||
Environment="LIBGL_ALWAYS_INDIRECT=1"
|
||||
|
||||
# Force DUMMY0 primary before starting
|
||||
ExecStartPre=/bin/bash -c '\
|
||||
for i in 1 2 3 4 5 6 7 8 9 10; do \
|
||||
if xrandr >/dev/null 2>&1; then \
|
||||
if xrandr | grep -q "^DUMMY0"; then \
|
||||
xrandr --output DUMMY0 --mode "1920x1080" --primary 2>/dev/null || true; \
|
||||
exit 0; \
|
||||
fi; \
|
||||
fi; \
|
||||
sleep 1; \
|
||||
done'
|
||||
|
||||
ExecStart=/usr/share/rustdesk/rustdesk --server
|
||||
ExecStartPost=/bin/bash -c 'echo "RustDesk started, ID: $(/usr/share/rustdesk/rustdesk --get-id 2>/dev/null || echo unknown)" >> /tmp/rustdesk-server.log'
|
||||
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
StartLimitInterval=60
|
||||
StartLimitBurst=3
|
||||
|
||||
# Prevent system sleep while RustDesk is active
|
||||
ExecStopPost=/bin/systemctl start --no-block rustdesk-headless-inhibit.service
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user