#!/bin/sh # Start the X session once per boot, through poky's xserver-nodm chain: # /etc/xserver-nodm/Xserver -> xinit -> /etc/X11/Xsession -> x-session-manager. # Run from /etc/inittab under busybox init, or from /.bashrc when bash is PID 1. # `brintos-x11-start --programs' prints what the pre-warm below runs, and exits. # What the pre-warm runs. The window manager is the selected session's alone: # matchbox-session stays installed beside the default icewm-session, and its # window manager runs only when it is the one chosen. programs() { (. /etc/default/xserver-nodm; echo "$XSERVER") echo /usr/bin/xkbcomp /usr/bin/dbus-launch /usr/bin/dbus-daemon \ /usr/libexec/at-spi-bus-launcher /usr/bin/x-session-manager case "$(readlink -f /usr/bin/x-session-manager)" in */icewm-session) echo /usr/bin/icewm /usr/bin/icewmbg ;; */matchbox-session) echo /usr/bin/matchbox-window-manager ;; *) echo /usr/bin/x-window-manager ;; esac echo /usr/bin/x-terminal-emulator } [ "$1" = --programs ] && { programs; exit 0; } # The opt-out xserver-nodm's own init script honours. for x in $(cat /proc/cmdline); do [ "$x" = "x11=false" ] && exit 0 done # Once per boot. /tmp is a tmpfs, so the stamp goes with a reboot; set -C makes # the create atomic, so two callers cannot both start a server. (set -C; : > /tmp/.brintos-x11-started) 2>/dev/null || exit 0 # Xorg will not start without its log file, and /var/log points into # /var/volatile, which nothing on this image mounts yet (BRINTOS-2993 owns the # volatiles). Once something does, this block does nothing. if [ ! -d /var/log/ ]; then mount -t tmpfs -o mode=0755,nodev,nosuid tmpfs /var/volatile && mkdir -p /var/volatile/log /var/volatile/tmp fi LOG=/var/log/xserver-nodm.log [ -d /var/log/ ] || LOG=/tmp/xserver-nodm.log # BRINTOS-WORKAROUND: brintos/linux#153 remove -- programs started together can still take each other's staged libraries (an interrupted staging read), and refuse to start. # The session starts the server, xkbcomp, dbus, the window manager and a # terminal within a second or two, all of them staging for the first time this # boot. A library is staged once per boot, so starting each program once, one # after another, leaves nothing for the session to race on. Scripts are # skipped: they stage only the shell, and running one would start its session. for p in $(programs); do [ -x "$p" ] || continue # dd, not head -c: an image with BusyBox's head alone has no -c. [ "$(dd if="$p" bs=2 count=1 2>/dev/null)" = "#!" ] && continue case "$(readlink -f "$p")" in */Xorg|*/xkbcomp|*/xterm) v=-version ;; */at-spi-bus-launcher) v=--help ;; *) v=--version ;; esac env -u DISPLAY "$p" $v /dev/null 2>&1 done /etc/xserver-nodm/Xserver >"$LOG" 2>&1