SPS · log · files · refs · tags · releases · people · languages · GitHub · file
lib/mkiso/live-plasma
8306 bytes at 2909919 · GitHub
#!/bin/busybox sh
# Plasma live session. Respawned by busybox init on tty1. Open Konsole
# and run setup(1). If Plasma is missing, a shell stays on this tty.
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PATH=/usr/lib64/qt6/bin:/usr/lib/qt6/bin:$PATH
export PATH
export HOME=/root
export XDG_RUNTIME_DIR=/run/user/0
export XDG_SESSION_TYPE=wayland
export XDG_SESSION_CLASS=user
export XDG_SESSION_DESKTOP=KDE
export XDG_CURRENT_DESKTOP=KDE
export DESKTOP_SESSION=plasma
export XDG_CONFIG_DIRS=/etc/xdg
export TERM=${TERM:-linux}
export LANG=${LANG:-C.UTF-8}
export LC_ALL=${LC_ALL:-C.UTF-8}
export FONTCONFIG_PATH=/etc/fonts
export QT_PLUGIN_PATH=/usr/lib64/qt6/plugins
export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib64/qt6/plugins/platforms
export QML2_IMPORT_PATH=/usr/lib64/qt6/qml
export LIBGL_DRIVERS_PATH=/usr/lib64/dri:/usr/lib/dri
export GBM_BACKENDS_PATH=/usr/lib64/gbm:/usr/lib/gbm
export XCURSOR_THEME=breeze_cursors
export MOZ_ENABLE_WAYLAND=1
export MOZ_ALLOW_DOWNGRADE=1
# KWin is the compositor. QT_QPA_PLATFORM=wayland makes Qt try to
# connect to a display that does not exist yet, so kwin_wayland dies
# with "Failed to create wl_display" and plasmashell follows.
unset QT_QPA_PLATFORM
mkdir -p "$XDG_RUNTIME_DIR" /run/dbus /var/lib/dbus /etc/dbus-1 \
/root/.config/kdedefaults /tmp/.X11-unix /tmp/.ICE-unix
chmod 700 "$XDG_RUNTIME_DIR"
chmod 1777 /tmp /tmp/.X11-unix /tmp/.ICE-unix 2>/dev/null || :
# startplasma reads this before KSplash. A missing file logs
# QIODevice::readLineInto ... kdedefaults/package.
# Engine=none skips ksplashqml. Engine=KSplashQML plus a missing
# breeze splash makes plasma_waitforname hang forever: KWin is up
# (black screen, cursor only) and the desktop never appears.
mkdir -p /root/.config /root/.config/kdedefaults /etc/xdg
if [ ! -s /root/.config/kdedefaults/package ]; then
printf '%s\n' 'org.kde.breeze.desktop' >/root/.config/kdedefaults/package
fi
printf '%s\n' '[KSplash]' 'Engine=none' >/root/.config/kdedefaults/ksplashrc
printf '%s\n' '[KSplash]' 'Engine=none' >/root/.config/ksplashrc
# Live runs as root with no PAM stack. kscreenlocker autolock or
# LockOnStart leaves KWin's lock surface up: black screen, cursor only.
if [ ! -s /etc/xdg/kscreenlockerrc ]; then
printf '%s\n' \
'[Daemon]' \
'Autolock=false' \
'LockOnResume=false' \
'LockOnStart=false' \
'Timeout=0' >/etc/xdg/kscreenlockerrc
fi
if [ ! -s /root/.config/kscreenlockerrc ]; then
cp /etc/xdg/kscreenlockerrc /root/.config/kscreenlockerrc
else
grep -q LockOnStart /root/.config/kscreenlockerrc ||
printf '%s\n' 'LockOnStart=false' >>/root/.config/kscreenlockerrc
fi
# Indexing a live overlay is slow and not useful.
if [ ! -s /root/.config/baloofilerc ]; then
printf '%s\n' '[Basic Settings]' 'Indexing-Enabled=false' \
>/root/.config/baloofilerc
fi
# startplasma-wayland prefers systemd --user. The live disc is busybox
# PID 1, so force the classic plasma_session path if we fall back to it.
if [ ! -s /root/.config/startkderc ]; then
printf '%s\n' '[General]' 'systemdBoot=false' >/root/.config/startkderc
fi
if command -v fc-cache >/dev/null 2>&1; then
fc-cache >/dev/null 2>&1 || :
fi
export LIBSEAT_BACKEND=seatd
export SEATD_SOCK=/run/seatd.sock
# Live NVIDIA is nouveau. Keep the proprietary stack unloaded.
modprobe nouveau 2>/dev/null || :
for mod in virtio_gpu virtio_dma_buf bochs cirrus_qemu qxl vmwgfx; do
modprobe "$mod" 2>/dev/null || :
done
if [ ! -e /var/run ]; then
mkdir -p /var
ln -s ../run /var/run
fi
if [ ! -s /etc/machine-id ]; then
if command -v dbus-uuidgen >/dev/null 2>&1; then
dbus-uuidgen --ensure=/etc/machine-id 2>/dev/null || :
fi
fi
if [ ! -e /var/lib/dbus/machine-id ] && [ -s /etc/machine-id ]; then
ln -sf /etc/machine-id /var/lib/dbus/machine-id
fi
# The stock system.conf drops privileges to messagebus. The live passwd
# has no such account, so dbus-daemon --system exits and Plasma cannot
# talk to the bus. Always rewrite this: mkiso copies host /etc/dbus-1,
# which may already contain a system-local.conf without <user>root</user>.
mkdir -p /etc/dbus-1 /run/dbus /var/lib/dbus
printf '%s\n' \
'<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"' \
' "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">' \
'<busconfig>' \
' <user>root</user>' \
'</busconfig>' >/etc/dbus-1/system-local.conf
if command -v dbus-daemon >/dev/null 2>&1; then
if [ ! -S /run/dbus/system_bus_socket ] &&
[ ! -S /var/run/dbus/system_bus_socket ]
then
dbus-daemon --system --nofork --nopidfile --nosyslog \
>/run/sps-dbus.log 2>&1 &
n=0
while [ "$n" -lt 5 ]; do
if [ -S /run/dbus/system_bus_socket ] ||
[ -S /var/run/dbus/system_bus_socket ]
then
break
fi
n=$((n + 1))
sleep 1
done
fi
if [ ! -S /run/dbus/system_bus_socket ] &&
[ ! -S /var/run/dbus/system_bus_socket ]
then
printf '%s\n' "SPS: system D-Bus is not running; Plasma will fail."
printf '%s\n' "SPS: dbus-daemon log:"
cat /run/sps-dbus.log 2>/dev/null || :
printf '%s\n' "SPS: use tty2 (Ctrl-Alt-F2) for a shell."
fi
else
printf '%s\n' "SPS: dbus-daemon is not on PATH; Plasma needs it."
fi
if [ -x /usr/lib/polkit-1/polkitd ]; then
/usr/lib/polkit-1/polkitd --no-debug >/run/sps-polkitd.log 2>&1 &
fi
if command -v seatd >/dev/null 2>&1; then
seatd -g video >/dev/null 2>&1 &
n=0
while [ "$n" -lt 5 ]; do
[ -S /run/seatd.sock ] && break
n=$((n + 1))
sleep 1
done
fi
# kwin_wayland needs a KMS node. GPU modules are loaded in the
# initramfs and again in live-rc; wait briefly so Plasma does not
# race the first DRM probe.
n=0
while [ "$n" -lt 5 ]; do
if [ -e /dev/dri/card0 ] || [ -e /dev/dri/card1 ]; then
break
fi
n=$((n + 1))
sleep 1
done
if [ ! -e /dev/dri/card0 ] && [ ! -e /dev/dri/card1 ]; then
printf '%s\n' "SPS: no /dev/dri/card0; KWin cannot start a compositor."
printf '%s\n' "SPS: use tty2 (Ctrl-Alt-F2) for a shell."
ls /dev/dri 2>/dev/null || :
fi
# Prefer a real KMS device. simpledrm plus virtio_gpu leaves KWin on the
# firmware framebuffer: black screen with a cursor that appears immediately.
sps_drm=
for sps_card in /sys/class/drm/card[0-9] /sys/class/drm/card[1-9][0-9]
do
[ -e "$sps_card" ] || continue
sps_node=/dev/dri/${sps_card##*/}
[ -e "$sps_node" ] || continue
sps_drv=
if [ -L "$sps_card/device/driver" ]; then
sps_drv=$(readlink "$sps_card/device/driver")
sps_drv=${sps_drv##*/}
fi
case $sps_drv in
simple-framebuffer|simpledrm) continue ;;
esac
sps_drm=$sps_node
break
done
if [ -n "$sps_drm" ]; then
export KWIN_DRM_DEVICES=$sps_drm
fi
for sps_vt in /sys/class/vtconsole/vtcon*
do
[ -w "$sps_vt/bind" ] || continue
printf '%s\n' 0 >"$sps_vt/bind" 2>/dev/null || :
done
if [ ! -e /usr/lib64/gbm/dri_gbm.so ] && [ ! -e /usr/lib/gbm/dri_gbm.so ]
then
printf '%s\n' "SPS: Mesa GBM backend dri_gbm.so is missing; KWin cannot use DRM."
fi
if ! ls /usr/lib64/libSPIRV-Tools.so* >/dev/null 2>&1
then
printf '%s\n' "SPS: libSPIRV-Tools.so is missing; Mesa GBM will fail to open DRI."
fi
# Give the user a console they can see if Wayland dies.
chvt 1 2>/dev/null || :
# startplasma-wayland starts kwin, then waits on kded/ksmserver before
# plasmashell. That hang is a black compositor with an instant cursor.
# Drive KWin ourselves and exec plasmashell as the session.
if command -v kwin_wayland >/dev/null 2>&1 &&
[ -x /etc/sps/live-plasma-session ]
then
if command -v dbus-run-session >/dev/null 2>&1; then
exec dbus-run-session -- kwin_wayland --drm --xwayland \
--no-lockscreen \
--exit-with-session /etc/sps/live-plasma-session \
>>/run/plasma.log 2>&1
fi
exec kwin_wayland --drm --xwayland --no-lockscreen \
--exit-with-session /etc/sps/live-plasma-session \
>>/run/plasma.log 2>&1
fi
if command -v startplasma-wayland >/dev/null 2>&1; then
# startplasma needs a *session* bus. The system bus above is not that.
if command -v dbus-run-session >/dev/null 2>&1; then
exec dbus-run-session -- startplasma-wayland \
>>/run/plasma.log 2>&1
fi
if command -v dbus-launch >/dev/null 2>&1; then
eval "$(dbus-launch --sh-syntax)"
exec startplasma-wayland
fi
exec startplasma-wayland
fi
printf '%s\n' "Plasma is not on this image; dropping to a shell on tty1."
printf '%s\n' "Run setup from here, or use tty2 / ttyS0."
exec /bin/sh