Update system

parent 53413811
...@@ -1066,8 +1066,8 @@ class InstallerWorker(QThread): ...@@ -1066,8 +1066,8 @@ class InstallerWorker(QThread):
# Create fstab # Create fstab
self._create_fstab(target_mount) self._create_fstab(target_mount)
# Configure inittab for autologin # Configure lightdm for autologin (replacing inittab)
self._configure_inittab(target_mount) self._configure_lightdm(target_mount)
# Generate SSH keys # Generate SSH keys
self._generate_ssh_keys(target_mount) self._generate_ssh_keys(target_mount)
...@@ -1423,27 +1423,21 @@ class InstallerWorker(QThread): ...@@ -1423,27 +1423,21 @@ class InstallerWorker(QThread):
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
self.log(f"Warning: Could not remove mbetterclient password: {e}") self.log(f"Warning: Could not remove mbetterclient password: {e}")
# Configure mbetterclient user to launch startx on login # Configure mbetterclient user (lightdm handles X session now)
self.log("Configuring mbetterclient user to launch startx...") self.log("Configuring mbetterclient user...")
# Create .bashrc for mbetterclient # Create .bashrc for mbetterclient
bashrc_content = '''# X session autolaunch configuration bashrc_content = '''# User configuration for mbetterclient
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
# SSH session - don't autolaunch # SSH session - don't autolaunch
return return
fi fi
# Check if we're on tty1 (autologin terminal) # Set XKB environment variables to fix keyboard issues
if [ "$(tty)" = "/dev/tty1" ]; then export XKB_DEFAULT_LAYOUT="us"
# Set XKB environment variables to fix keyboard issues export XKB_DEFAULT_MODEL="pc105"
export XKB_DEFAULT_LAYOUT="us" export XKB_DEFAULT_VARIANT=""
export XKB_DEFAULT_MODEL="pc105" export XKB_DEFAULT_OPTIONS=""
export XKB_DEFAULT_VARIANT=""
export XKB_DEFAULT_OPTIONS=""
# Launch X session (MBetterClient will be started by .xinitrc)
exec startx
fi
''' '''
bashrc_path = f"{target_mount}/home/mbetterclient/.bashrc" bashrc_path = f"{target_mount}/home/mbetterclient/.bashrc"
...@@ -1454,39 +1448,82 @@ fi ...@@ -1454,39 +1448,82 @@ fi
except Exception as e: except Exception as e:
self.log(f"Warning: Could not create .bashrc: {e}") self.log(f"Warning: Could not create .bashrc: {e}")
# Create .xinitrc for proper X session startup # Create .xsession for proper X session startup
xinitrc_content = '''#!/bin/sh xsession_content = '''#!/bin/bash
# X session initialization for mbetterclient # .xsession script for mbetterclient Kiosk setup (Openbox + Picom)
# Set keyboard layout export PATH=/usr/local/bin:/usr/bin:/bin
setxkbmap us export DISPLAY=:0
export QT_QPA_PLATFORM=xcb
# screen don't switch off
xset s off -dpms
# Launch Openbox window manager #export QT_QUICK_BACKEND=software
exec openbox-session & #export QTWEBENGINE_CHROMIUM_FLAGS="--disable-gpu"
# Give Openbox a moment to start #export LIBGL_ALWAYS_SOFTWARE=1
sleep 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 # Start Compositor and Window Manager in background
xterm -e '/usr/local/bin/MbetterClient_wrapper.sh --ssl --web-host 0.0.0.0' #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: try:
with open(xinitrc_path, 'w') as f: with open(xsession_path, 'w') as f:
f.write(xinitrc_content) f.write(xsession_content)
# Make .xinitrc executable # Make .xsession executable
os.chmod(xinitrc_path, 0o755) os.chmod(xsession_path, 0o755)
self.log("Created .xinitrc for mbetterclient") self.log("Created .xsession for mbetterclient")
except Exception as e: 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 # Set proper ownership
try: try:
cmd = ['chroot', target_mount, 'chown', 'mbetterclient:mbetterclient', cmd = ['chroot', target_mount, 'chown', 'mbetterclient:mbetterclient',
'/home/mbetterclient/.bashrc', '/home/mbetterclient/.xinitrc'] '/home/mbetterclient/.bashrc', '/home/mbetterclient/.xsession']
clean_env = self._clean_env() clean_env = self._clean_env()
result = subprocess.run(cmd, capture_output=True, text=True, env=clean_env) result = subprocess.run(cmd, capture_output=True, text=True, env=clean_env)
if result.returncode != 0: if result.returncode != 0:
...@@ -1506,84 +1543,50 @@ xterm -e '/usr/local/bin/MbetterClient_wrapper.sh --ssl --web-host 0.0.0.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 # Implementation similar to original script
self.log("Fstab created") self.log("Fstab created")
def _configure_inittab(self, target_mount): def _configure_lightdm(self, target_mount):
"""Configure inittab for mbetterclient autologin - same logic as auto-installer.sh""" """Configure lightdm.conf for mbetterclient autologin - replacing inittab configuration"""
try: try:
self.log("Configuring inittab for mbetterclient autologin...") self.log("Configuring lightdm.conf for mbetterclient autologin...")
inittab_content = '''# /etc/inittab: init(8) configuration. lightdm_content = '''[Seat:*]
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $ autologin-user=mbetterclient
autologin-user-timeout=0
# The default runlevel. greeter-session=lightdm-gtk-greeter
id:2:initdefault: greeter-hide-users=false
greeter-show-manual-login=true
# Boot-time system configuration/initialization script. greeter-show-remote-login=false
# This is run first except when booting in emergency (-b) mode. #user-session=xfce4
si::sysinit:/etc/init.d/rcS display-setup-script=/usr/local/bin/lightdm-display-setup
session-setup-script=/usr/local/bin/lightdm-session-setup
# What to do in single-user mode.
~~:S:wait:/sbin/sulogin [LightDM]
minimum-display-number=0
# /etc/init.d executes the S and K scripts upon change minimum-vt=7
# of runlevel. lock-memory=true
# user-authority-in-system-dir=false
# Runlevel 0 is halt. guest-account-script=guest-account
# Runlevel 1 is single-user. logind-check-graphical=false
# Runlevel 2-5 are multi-user. log-directory=/var/log/lightdm
# Runlevel 6 is reboot. run-directory=/run/lightdm
cache-directory=/var/cache/lightdm
l0:0:wait:/etc/init.d/rc 0 sessions-directory=/usr/share/xsessions
l1:1:wait:/etc/init.d/rc 1 remote-sessions-directory=/usr/share/xgreeters
l2:2:wait:/etc/init.d/rc 2 greeters-directory=/usr/share/xgreeters
l3:3:wait:/etc/init.d/rc 3 backup-logs=true
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
''' '''
inittab_path = f"{target_mount}/etc/inittab" lightdm_path = f"{target_mount}/etc/lightdm/lightdm.conf"
try: try:
with open(inittab_path, 'w') as f: with open(lightdm_path, 'w') as f:
f.write(inittab_content) f.write(lightdm_content)
self.log("Configured inittab for mbetterclient autologin") self.log("Configured lightdm.conf for mbetterclient autologin")
except Exception as e: 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: 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): def _generate_ssh_keys(self, target_mount):
"""Generate SSH host keys""" """Generate SSH host keys"""
......
...@@ -23,11 +23,11 @@ echo "Root password configuration preserved from preseed" ...@@ -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 # 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 # The existing .bashrc will auto-start X when logging into tty1
# 4. Modify xinitrc to launch OpenVPN and MBetterClient # 4. Modify xsession to launch OpenVPN and MBetterClient
echo "Configuring xinitrc to auto-start OpenVPN and MBetterClient..." echo "Configuring xsession to auto-start OpenVPN and MBetterClient..."
cat > "$TARGET_MOUNT/root/.xinitrc" << 'EOF' cat > "$TARGET_MOUNT/root/.xsession" << 'EOF'
#!/bin/bash #!/bin/bash
# Xinitrc for installed system with OpenVPN and MBetterClient # Xsession for installed system with OpenVPN and MBetterClient
# Start Openbox window manager in background # Start Openbox window manager in background
openbox & openbox &
...@@ -76,7 +76,7 @@ else ...@@ -76,7 +76,7 @@ else
fi fi
EOF EOF
chmod +x "$TARGET_MOUNT/root/.xinitrc" chmod +x "$TARGET_MOUNT/root/.xsession"
# 5. Remove installer-specific files only # 5. Remove installer-specific files only
echo "Cleaning up installer-specific files..." echo "Cleaning up installer-specific files..."
...@@ -120,6 +120,19 @@ elif [ -d "$TARGET_MOUNT/etc/init.d" ]; then ...@@ -120,6 +120,19 @@ elif [ -d "$TARGET_MOUNT/etc/init.d" ]; then
fi fi
echo "SSH service enabled on installed system" 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 "Installed system configuration completed!"
echo "" echo ""
echo "Installed system will now:" echo "Installed system will now:"
......
...@@ -6,12 +6,6 @@ case $- in ...@@ -6,12 +6,6 @@ case $- in
*) return;; *) return;;
esac 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 # Standard bashrc below this point
# don't put duplicate lines or lines starting with space in the history. # don't put duplicate lines or lines starting with space in the history.
HISTCONTROL=ignoreboth HISTCONTROL=ignoreboth
......
#!/bin/bash #!/bin/bash
# Xinitrc for root autologin with auto-installer startup # Xinitrc for root autologin with auto-installer startup
# Start Openbox window manager in background first # Start XFCE4 window manager in background first
openbox-session & startxfce4 &
# Wait for window manager to be ready # Wait for window manager to be ready
sleep 2 sleep 2
......
...@@ -23,36 +23,36 @@ startxfce4 & ...@@ -23,36 +23,36 @@ startxfce4 &
sleep 5 sleep 5
# Launch the Main Kiosk Application (in background for layering monitor to work) # 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=$! APP_PID=$!
# --- Robust Continuous Window Layering Monitor --- # --- Robust Continuous Window Layering Monitor ---
# This background loop waits for BOTH windows to be present before layering # This background loop waits for BOTH windows to be present before layering
( #(
while true; do # while true; do
#
PLAYER_WIN=$(wmctrl -F -l | grep "MbetterClient - PyQt6 Video Player") # PLAYER_WIN=$(wmctrl -F -l | grep "MbetterClient - PyQt6 Video Player")
QWEB_WIN=$(wmctrl -F -l | grep "MbetterClient PyQt6") # QWEB_WIN=$(wmctrl -F -l | grep "MbetterClient PyQt6")
#
if [ -n "$PLAYER_WIN" ] && [ -n "$QWEB_WIN" ]; then # if [ -n "$PLAYER_WIN" ] && [ -n "$QWEB_WIN" ]; then
# Force the Video Player to the bottom layer ('below') # # Force the Video Player to the bottom layer ('below')
wmctrl -F -r "MbetterClient - PyQt6 Video Player" -b add,below,skip_taskbar,skip_pager # 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') # # Force the QWebEngine window to the normal layer ('normal' or 'above')
# This ensures it's above the 'below' window # # This ensures it's above the 'below' window
wmctrl -F -r "MbetterClient PyQt6" -b add,above # wmctrl -F -r "MbetterClient PyQt6" -b add,above
# Optional: Force the debug terminal window to bottom if it appears # # 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 # # wmctrl -F -r "debug.log 2>&1" -b add,below,skip_taskbar,skip_pager
fi # fi
#
sleep 0.5 # sleep 0.5
#
# Exit loop if the main application dies # # Exit loop if the main application dies
if ! kill -0 $APP_PID 2>/dev/null; then # if ! kill -0 $APP_PID 2>/dev/null; then
break # break
fi # fi
done # done
) & #) &
# -------------------------------------------------- # --------------------------------------------------
# Wait for the main application process to exit before ending the session # 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