Update system

parent 53413811
......@@ -1066,8 +1066,8 @@ class InstallerWorker(QThread):
# Create fstab
self._create_fstab(target_mount)
# Configure inittab for autologin
self._configure_inittab(target_mount)
# Configure lightdm for autologin (replacing inittab)
self._configure_lightdm(target_mount)
# Generate SSH keys
self._generate_ssh_keys(target_mount)
......@@ -1423,27 +1423,21 @@ class InstallerWorker(QThread):
except subprocess.CalledProcessError as e:
self.log(f"Warning: Could not remove mbetterclient password: {e}")
# Configure mbetterclient user to launch startx on login
self.log("Configuring mbetterclient user to launch startx...")
# Configure mbetterclient user (lightdm handles X session now)
self.log("Configuring mbetterclient user...")
# Create .bashrc for mbetterclient
bashrc_content = '''# X session autolaunch configuration
bashrc_content = '''# User configuration for mbetterclient
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
# SSH session - don't autolaunch
return
fi
# Check if we're on tty1 (autologin terminal)
if [ "$(tty)" = "/dev/tty1" ]; then
# Set XKB environment variables to fix keyboard issues
export XKB_DEFAULT_LAYOUT="us"
export XKB_DEFAULT_MODEL="pc105"
export XKB_DEFAULT_VARIANT=""
export XKB_DEFAULT_OPTIONS=""
# Launch X session (MBetterClient will be started by .xinitrc)
exec startx
fi
# Set XKB environment variables to fix keyboard issues
export XKB_DEFAULT_LAYOUT="us"
export XKB_DEFAULT_MODEL="pc105"
export XKB_DEFAULT_VARIANT=""
export XKB_DEFAULT_OPTIONS=""
'''
bashrc_path = f"{target_mount}/home/mbetterclient/.bashrc"
......@@ -1454,39 +1448,82 @@ fi
except Exception as e:
self.log(f"Warning: Could not create .bashrc: {e}")
# Create .xinitrc for proper X session startup
xinitrc_content = '''#!/bin/sh
# X session initialization for mbetterclient
# Create .xsession for proper X session startup
xsession_content = '''#!/bin/bash
# .xsession script for mbetterclient Kiosk setup (Openbox + Picom)
# Set keyboard layout
setxkbmap us
export PATH=/usr/local/bin:/usr/bin:/bin
export DISPLAY=:0
export QT_QPA_PLATFORM=xcb
# screen don't switch off
xset s off -dpms
# Launch Openbox window manager
exec openbox-session &
# Give Openbox a moment to start
sleep 1
#export QT_QUICK_BACKEND=software
#export QTWEBENGINE_CHROMIUM_FLAGS="--disable-gpu"
#export LIBGL_ALWAYS_SOFTWARE=1
# D-Bus configuration (essential for modern apps)
if which dbus-launch >/dev/null && [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
eval "$(dbus-launch --sh-syntax --exit-with-session)"
fi
xset -dpms; xset s off
# Launch MBetterClient in a terminal
xterm -e '/usr/local/bin/MbetterClient_wrapper.sh --ssl --web-host 0.0.0.0'
# Start Compositor and Window Manager in background
#picom -b --backend glx --config /dev/null &
#openbox &
startxfce4 &
sleep 5
# Launch the Main Kiosk Application (in background for layering monitor to work)
/usr/local/bin/MbetterClient_wrapper.sh --ssl --web-host 0.0.0.0 --debug --start 0 > /tmp/debug.log 2>&1 &
APP_PID=$!
# --- Robust Continuous Window Layering Monitor ---
# This background loop waits for BOTH windows to be present before layering
#(
# while true; do
#
# PLAYER_WIN=$(wmctrl -F -l | grep "MbetterClient - PyQt6 Video Player")
# QWEB_WIN=$(wmctrl -F -l | grep "MbetterClient PyQt6")
#
# if [ -n "$PLAYER_WIN" ] && [ -n "$QWEB_WIN" ]; then
# # Force the Video Player to the bottom layer ('below')
# wmctrl -F -r "MbetterClient - PyQt6 Video Player" -b add,below,skip_taskbar,skip_pager
#
# # Force the QWebEngine window to the normal layer ('normal' or 'above')
# # This ensures it's above the 'below' window
# wmctrl -F -r "MbetterClient PyQt6" -b add,above
# # Optional: Force the debug terminal window to bottom if it appears
# # wmctrl -F -r "debug.log 2>&1" -b add,below,skip_taskbar,skip_pager
# fi
#
# sleep 0.5
#
# # Exit loop if the main application dies
# if ! kill -0 $APP_PID 2>/dev/null; then
# break
# fi
# done
#) &
# --------------------------------------------------
# Wait for the main application process to exit before ending the session
wait $APP_PID
'''
xinitrc_path = f"{target_mount}/home/mbetterclient/.xinitrc"
xsession_path = f"{target_mount}/home/mbetterclient/.xsession"
try:
with open(xinitrc_path, 'w') as f:
f.write(xinitrc_content)
# Make .xinitrc executable
os.chmod(xinitrc_path, 0o755)
self.log("Created .xinitrc for mbetterclient")
with open(xsession_path, 'w') as f:
f.write(xsession_content)
# Make .xsession executable
os.chmod(xsession_path, 0o755)
self.log("Created .xsession for mbetterclient")
except Exception as e:
self.log(f"Warning: Could not create .xinitrc: {e}")
self.log(f"Warning: Could not create .xsession: {e}")
# Set proper ownership
try:
cmd = ['chroot', target_mount, 'chown', 'mbetterclient:mbetterclient',
'/home/mbetterclient/.bashrc', '/home/mbetterclient/.xinitrc']
'/home/mbetterclient/.bashrc', '/home/mbetterclient/.xsession']
clean_env = self._clean_env()
result = subprocess.run(cmd, capture_output=True, text=True, env=clean_env)
if result.returncode != 0:
......@@ -1506,84 +1543,50 @@ xterm -e '/usr/local/bin/MbetterClient_wrapper.sh --ssl --web-host 0.0.0.0'
# Implementation similar to original script
self.log("Fstab created")
def _configure_inittab(self, target_mount):
"""Configure inittab for mbetterclient autologin - same logic as auto-installer.sh"""
def _configure_lightdm(self, target_mount):
"""Configure lightdm.conf for mbetterclient autologin - replacing inittab configuration"""
try:
self.log("Configuring inittab for mbetterclient autologin...")
inittab_content = '''# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $
# The default runlevel.
id:2:initdefault:
# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS
# What to do in single-user mode.
~~:S:wait:/sbin/sulogin
# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevel 2-5 are multi-user.
# Runlevel 6 is reboot.
l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin
# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
# <id>:<runlevels>:<action>:<process>
#
# Autologin for mbetterclient on tty1
1:2345:respawn:/sbin/getty --autologin mbetterclient --noclear 38400 tty1
# Normal getty for other terminals
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6
# Example how to put a getty on a serial line (for a terminal)
#
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
# Example how to put a getty on a modem line.
#
#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3
self.log("Configuring lightdm.conf for mbetterclient autologin...")
lightdm_content = '''[Seat:*]
autologin-user=mbetterclient
autologin-user-timeout=0
greeter-session=lightdm-gtk-greeter
greeter-hide-users=false
greeter-show-manual-login=true
greeter-show-remote-login=false
#user-session=xfce4
display-setup-script=/usr/local/bin/lightdm-display-setup
session-setup-script=/usr/local/bin/lightdm-session-setup
[LightDM]
minimum-display-number=0
minimum-vt=7
lock-memory=true
user-authority-in-system-dir=false
guest-account-script=guest-account
logind-check-graphical=false
log-directory=/var/log/lightdm
run-directory=/run/lightdm
cache-directory=/var/cache/lightdm
sessions-directory=/usr/share/xsessions
remote-sessions-directory=/usr/share/xgreeters
greeters-directory=/usr/share/xgreeters
backup-logs=true
'''
inittab_path = f"{target_mount}/etc/inittab"
lightdm_path = f"{target_mount}/etc/lightdm/lightdm.conf"
try:
with open(inittab_path, 'w') as f:
f.write(inittab_content)
self.log("Configured inittab for mbetterclient autologin")
with open(lightdm_path, 'w') as f:
f.write(lightdm_content)
self.log("Configured lightdm.conf for mbetterclient autologin")
except Exception as e:
self.log(f"Warning: Could not configure inittab: {e}")
self.log(f"Warning: Could not configure lightdm.conf: {e}")
except Exception as e:
self.log(f"Warning: inittab configuration failed: {e}")
self.log(f"Warning: lightdm configuration failed: {e}")
self.log("Inittab configured")
self.log("Lightdm configured")
def _generate_ssh_keys(self, target_mount):
"""Generate SSH host keys"""
......
......@@ -23,11 +23,11 @@ echo "Root password configuration preserved from preseed"
# 3. Keep auto-start X in root's bashrc - it's already correctly configured
# The existing .bashrc will auto-start X when logging into tty1
# 4. Modify xinitrc to launch OpenVPN and MBetterClient
echo "Configuring xinitrc to auto-start OpenVPN and MBetterClient..."
cat > "$TARGET_MOUNT/root/.xinitrc" << 'EOF'
# 4. Modify xsession to launch OpenVPN and MBetterClient
echo "Configuring xsession to auto-start OpenVPN and MBetterClient..."
cat > "$TARGET_MOUNT/root/.xsession" << 'EOF'
#!/bin/bash
# Xinitrc for installed system with OpenVPN and MBetterClient
# Xsession for installed system with OpenVPN and MBetterClient
# Start Openbox window manager in background
openbox &
......@@ -76,7 +76,7 @@ else
fi
EOF
chmod +x "$TARGET_MOUNT/root/.xinitrc"
chmod +x "$TARGET_MOUNT/root/.xsession"
# 5. Remove installer-specific files only
echo "Cleaning up installer-specific files..."
......@@ -120,6 +120,19 @@ elif [ -d "$TARGET_MOUNT/etc/init.d" ]; then
fi
echo "SSH service enabled on installed system"
# 9. Configure fstab - ensure no overlay fs and no tmpfs for /tmp
echo "Configuring fstab for installed system..."
if [ -f "$TARGET_MOUNT/etc/fstab" ]; then
# Comment out overlay line if present
sed -i 's|^overlay / overlay rw 0 0|#overlay / overlay rw 0 0|' "$TARGET_MOUNT/etc/fstab"
# Comment out tmpfs /tmp line if present
sed -i 's|^tmpfs /tmp tmpfs.*|#tmpfs /tmp tmpfs nosuid,nodev 0 0|' "$TARGET_MOUNT/etc/fstab"
fi
# 10. Set /tmp permissions to 1777
echo "Setting /tmp permissions to 1777..."
chmod 1777 "$TARGET_MOUNT/tmp"
echo "Installed system configuration completed!"
echo ""
echo "Installed system will now:"
......
......@@ -6,12 +6,6 @@ case $- in
*) return;;
esac
# Auto-start X on tty1 for live CD
if [ -z "$DISPLAY" ] && [ "$XDG_VTNR" = "1" ] || [ "$(tty)" = "/dev/tty1" ]; then
echo "Starting X session for live CD..."
exec startx
fi
# Standard bashrc below this point
# don't put duplicate lines or lines starting with space in the history.
HISTCONTROL=ignoreboth
......
#!/bin/bash
# Xinitrc for root autologin with auto-installer startup
# Start Openbox window manager in background first
openbox-session &
# Start XFCE4 window manager in background first
startxfce4 &
# Wait for window manager to be ready
sleep 2
......
......@@ -23,36 +23,36 @@ startxfce4 &
sleep 5
# Launch the Main Kiosk Application (in background for layering monitor to work)
/usr/local/bin/MbetterClient_wrapper.sh --ssl --web-host 0.0.0.0 > /tmp/debug.log 2>&1 &
/usr/local/bin/MbetterClient_wrapper.sh --ssl --web-host 0.0.0.0 --debug --start 0 > /tmp/debug.log 2>&1 &
APP_PID=$!
# --- Robust Continuous Window Layering Monitor ---
# This background loop waits for BOTH windows to be present before layering
(
while true; do
PLAYER_WIN=$(wmctrl -F -l | grep "MbetterClient - PyQt6 Video Player")
QWEB_WIN=$(wmctrl -F -l | grep "MbetterClient PyQt6")
if [ -n "$PLAYER_WIN" ] && [ -n "$QWEB_WIN" ]; then
# Force the Video Player to the bottom layer ('below')
wmctrl -F -r "MbetterClient - PyQt6 Video Player" -b add,below,skip_taskbar,skip_pager
# Force the QWebEngine window to the normal layer ('normal' or 'above')
# This ensures it's above the 'below' window
wmctrl -F -r "MbetterClient PyQt6" -b add,above
# Optional: Force the debug terminal window to bottom if it appears
# wmctrl -F -r "debug.log 2>&1" -b add,below,skip_taskbar,skip_pager
fi
sleep 0.5
# Exit loop if the main application dies
if ! kill -0 $APP_PID 2>/dev/null; then
break
fi
done
) &
#(
# while true; do
#
# PLAYER_WIN=$(wmctrl -F -l | grep "MbetterClient - PyQt6 Video Player")
# QWEB_WIN=$(wmctrl -F -l | grep "MbetterClient PyQt6")
#
# if [ -n "$PLAYER_WIN" ] && [ -n "$QWEB_WIN" ]; then
# # Force the Video Player to the bottom layer ('below')
# wmctrl -F -r "MbetterClient - PyQt6 Video Player" -b add,below,skip_taskbar,skip_pager
#
# # Force the QWebEngine window to the normal layer ('normal' or 'above')
# # This ensures it's above the 'below' window
# wmctrl -F -r "MbetterClient PyQt6" -b add,above
# # Optional: Force the debug terminal window to bottom if it appears
# # wmctrl -F -r "debug.log 2>&1" -b add,below,skip_taskbar,skip_pager
# fi
#
# sleep 0.5
#
# # Exit loop if the main application dies
# if ! kill -0 $APP_PID 2>/dev/null; then
# break
# fi
# done
#) &
# --------------------------------------------------
# Wait for the main application process to exit before ending the session
......
#!/bin/bash
# .xsession script for mbetterclient Kiosk setup (Openbox + Picom)
export PATH=/usr/local/bin:/usr/bin:/bin
export DISPLAY=:0
export QT_QPA_PLATFORM=xcb
#export QT_QUICK_BACKEND=software
#export QTWEBENGINE_CHROMIUM_FLAGS="--disable-gpu"
#export LIBGL_ALWAYS_SOFTWARE=1
# D-Bus configuration (essential for modern apps)
if which dbus-launch >/dev/null && [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then
eval "$(dbus-launch --sh-syntax --exit-with-session)"
fi
xset -dpms; xset s off
# Start Compositor and Window Manager in background
#picom -b --backend glx --config /dev/null &
#openbox &
startxfce4 &
sleep 5
# Launch the Main Kiosk Application (in background for layering monitor to work)
/usr/local/bin/MbetterClient_wrapper.sh --ssl --web-host 0.0.0.0 --debug --start 0 > /tmp/debug.log 2>&1 &
APP_PID=$!
# --- Robust Continuous Window Layering Monitor ---
# This background loop waits for BOTH windows to be present before layering
(
while true; do
PLAYER_WIN=$(wmctrl -F -l | grep "MbetterClient - PyQt6 Video Player")
QWEB_WIN=$(wmctrl -F -l | grep "MbetterClient PyQt6")
if [ -n "$PLAYER_WIN" ] && [ -n "$QWEB_WIN" ]; then
# Force the Video Player to the bottom layer ('below')
wmctrl -F -r "MbetterClient - PyQt6 Video Player" -b add,below,skip_taskbar,skip_pager
# Force the QWebEngine window to the normal layer ('normal' or 'above')
# This ensures it's above the 'below' window
wmctrl -F -r "MbetterClient PyQt6" -b add,above
# Optional: Force the debug terminal window to bottom if it appears
# wmctrl -F -r "debug.log 2>&1" -b add,below,skip_taskbar,skip_pager
fi
sleep 0.5
# Exit loop if the main application dies
if ! kill -0 $APP_PID 2>/dev/null; then
break
fi
done
) &
# --------------------------------------------------
# Wait for the main application process to exit before ending the session
wait $APP_PID
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment