Complete autologin system overhaul: console autologin + SSH fixes + ISO tools

Major Changes:
- Replaced LightDM/SLiM with direct console autologin using SysV inittab
- Fixed root account locking that prevented autologin
- Added comprehensive SSH configuration for remote access
- Created robust auto-start X session with auto-installer launch
- Added terminal emulator support (xterm, lxterminal, xfce4-terminal)

Key Features:
- tty1: Auto-login as root → auto-start X → auto-installer appears
- tty2-6: Normal login shells for debugging access
- SSH: Uses root password from ISO creation (not hardcoded)
- Installed system: Auto-login + OpenVPN + MBetterClient with --web-host 0.0.0.0

Tools Added:
- extract_iso.sh / rebuild_iso.sh: Immediate ISO modification workflow
- fix_inittab_in_image.sh: Complete ISO analysis and rebuild
- Enhanced cleanup.sh with --no-cache option for faster rebuilds
- Comprehensive diagnostic tools and logging

Build System:
- SysV init compatible (no systemd dependencies)
- Clean package list (removed display managers, added xinit)
- Proper inittab format compliance (max 4 char ID fields)
- Enhanced post-installation system configuration

Files Modified:
- config/hooks/live/setup-console-autologin.hook.chroot (new)
- config/hooks/live/enable-ssh-root.hook.chroot (enhanced)
- config/hooks/live/run-autologin-debug.hook.chroot (new)
- config/package-lists/live.list.chroot (cleaned, added terminals)
- config/includes.chroot/root/.bashrc (auto-start X)
- config/includes.chroot/root/.xinitrc (auto-installer launch)
- config/includes.binary/setup-installed-system.sh (OpenVPN + MBetterClient)
- config/includes.chroot/usr/local/bin/live-autologin-debug.sh (new)
- Various diagnostic and logging enhancements
parent ea15fed4
# ISO Modification Workflow
Complete workflow for extracting, modifying, and rebuilding ISO images with fixed inittab.
## Step 1: Extract ISO
Extract your ISO and squashfs to a working directory:
```bash
# Install required tools
sudo apt install squashfs-tools genisoimage rsync
# Extract ISO to working directory
sudo ./extract_iso.sh your_image.iso iso_work
```
**What this does:**
- Mounts the ISO
- Copies all ISO contents to `iso_work/iso_contents/`
- Extracts squashfs to `iso_work/squashfs_root/`
- Creates info file for rebuild process
- Removes original squashfs (will be recreated)
## Step 2: Modify Files
Now you can edit any files in the extracted filesystem:
```bash
# Fix inittab directly
sudo nano iso_work/squashfs_root/etc/inittab
# Example of proper inittab format for autologin:
# id:2:initdefault:
# si::sysinit:/etc/init.d/rcS
# 1:23:respawn:/sbin/agetty --autologin root --noclear tty1 linux
# 2:23:respawn:/sbin/agetty --noclear tty2 linux
# 3:23:respawn:/sbin/agetty --noclear tty3 linux
# 4:23:respawn:/sbin/agetty --noclear tty4 linux
# 5:23:respawn:/sbin/agetty --noclear tty5 linux
# 6:23:respawn:/sbin/agetty --noclear tty6 linux
# Or edit any other files:
sudo nano iso_work/squashfs_root/root/.bashrc
sudo nano iso_work/squashfs_root/usr/local/bin/some-script.sh
# etc.
```
## Step 3: Rebuild ISO
Rebuild the ISO with your modifications:
```bash
# Rebuild ISO with modifications
sudo ./rebuild_iso.sh iso_work fixed_image.iso
```
**What this does:**
- Validates your modifications (checks inittab format)
- Creates new squashfs from modified filesystem
- Rebuilds complete ISO with new squashfs
- Preserves boot configuration and structure
- Creates `fixed_image.iso` ready for use
## Example Complete Workflow
```bash
# Extract
sudo ./extract_iso.sh problematic.iso my_work
# Fix inittab (replace line 77 or whatever is problematic)
sudo nano my_work/squashfs_root/etc/inittab
# Rebuild
sudo ./rebuild_iso.sh my_work working.iso
# Test the new ISO
# Boot working.iso - should now autologin correctly
```
## Cleanup
When done, remove the work directory:
```bash
sudo rm -rf iso_work
```
## Key Benefits
- **Immediate fixes**: No need to rebuild from source
- **Selective modification**: Change only what you need
- **Validation**: Scripts check format before rebuilding
- **Safe workflow**: Original files preserved until confirmed working
- **Complete control**: Edit any file in the filesystem
\ No newline at end of file
# Instructions to Switch from LightDM to SLiM
If you want to use SLiM instead of LightDM (which may be more reliable for autologin), follow these steps:
## 1. Update Package List
In `config/package-lists/live.list.chroot`:
```bash
# Comment out lightdm and enable slim:
# lightdm
slim
```
## 2. Files Already Created
The following files are ready for SLiM:
- `config/includes.chroot/etc/slim.conf` - SLiM autologin configuration
- `config/includes.chroot/root/.xinitrc` - Root user session startup with auto-installer
## 3. SLiM Advantages for Autologin
- **Simpler configuration**: Just set `auto_login = yes` and `default_user = root`
- **More reliable autologin**: Less complex than LightDM's PAM setup
- **Lighter weight**: Smaller resource footprint
- **Direct xinitrc integration**: Uses standard `.xinitrc` for session startup
## 4. How SLiM Will Work
1. SLiM starts at boot
2. Automatically logs in as root (no password required)
3. Executes `/root/.xinitrc`
4. Starts Openbox window manager
5. Launches auto-installer in a visible terminal window
## 5. Testing
After switching to SLiM:
1. Rebuild your live CD
2. Boot the system
3. It should automatically login as root and show the auto-installer in a terminal window
## 6. Fallback Option
If SLiM doesn't work, you can always switch back to LightDM. The root account unlock fix should now work with LightDM too.
\ No newline at end of file
#!/bin/bash
# Apply inittab fix during build process
# This script should be run in the chroot environment
if [ -f /etc/inittab ]; then
echo "Backing up original inittab..."
cp /etc/inittab /etc/inittab.original
echo "Applying clean inittab with autologin..."
cat > /etc/inittab << 'INITTAB_EOF'
# /etc/inittab: init(8) configuration.
id:2:initdefault:
si::sysinit:/etc/init.d/rcS
~~:S:wait:/sbin/sulogin
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
z6:6:respawn:/sbin/sulogin
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop
1:23:respawn:/sbin/agetty --autologin root --noclear tty1 linux
2:23:respawn:/sbin/agetty --noclear tty2 linux
3:23:respawn:/sbin/agetty --noclear tty3 linux
4:23:respawn:/sbin/agetty --noclear tty4 linux
5:23:respawn:/sbin/agetty --noclear tty5 linux
6:23:respawn:/sbin/agetty --noclear tty6 linux
INITTAB_EOF
echo "inittab updated successfully!"
fi
#!/bin/bash #!/bin/bash
# Parse command line arguments
NO_CACHE=false
HELP=false
for arg in "$@"; do
case $arg in
--no-cache)
NO_CACHE=true
shift
;;
--help|-h)
HELP=true
shift
;;
*)
echo "Unknown option: $arg"
echo "Use --help for usage information"
exit 1
;;
esac
done
# Show help
if [ "$HELP" = true ]; then
echo "Usage: sudo ./cleanup.sh [OPTIONS]"
echo ""
echo "Cleans up MBetter ISO build configuration and artifacts."
echo ""
echo "Options:"
echo " --no-cache Skip removal of cache directories (preserves build cache)"
echo " --help, -h Show this help message"
echo ""
echo "Examples:"
echo " sudo ./cleanup.sh # Full cleanup including cache"
echo " sudo ./cleanup.sh --no-cache # Cleanup but preserve cache for faster rebuilds"
exit 0
fi
echo "Cleaning up MBetter ISO build configuration..." echo "Cleaning up MBetter ISO build configuration..."
if [ "$NO_CACHE" = true ]; then
echo "Cache preservation enabled (--no-cache)"
fi
# Check if running as root # Check if running as root
if [ "$EUID" -ne 0 ]; then if [ "$EUID" -ne 0 ]; then
echo "ERROR: This script must be run with sudo privileges." echo "ERROR: This script must be run with sudo privileges."
echo "Usage: sudo ./cleanup.sh" echo "Usage: sudo ./cleanup.sh [--no-cache] [--help]"
exit 1 exit 1
fi fi
...@@ -55,10 +96,12 @@ if [ -d ".build" ]; then ...@@ -55,10 +96,12 @@ if [ -d ".build" ]; then
echo "Removed .build directory" echo "Removed .build directory"
fi fi
# Remove cache directory # Remove cache directory (unless --no-cache is specified)
if [ -d "cache" ]; then if [ "$NO_CACHE" = false ] && [ -d "cache" ]; then
rm -rf cache rm -rf cache
echo "Removed cache directory" echo "Removed cache directory"
elif [ "$NO_CACHE" = true ] && [ -d "cache" ]; then
echo "Preserved cache directory (--no-cache enabled)"
fi fi
# Unmount any mounted filesystems in chroot # Unmount any mounted filesystems in chroot
...@@ -200,7 +243,22 @@ done ...@@ -200,7 +243,22 @@ done
echo "PyInstaller cleanup completed" echo "PyInstaller cleanup completed"
# Clean live-build cache and temporary files # Clean live-build cache and temporary files
lb clean if [ "$NO_CACHE" = false ]; then
echo "Running live-build cleanup (removing cache)..."
lb clean
echo "Live-build cache and temporary files removed"
else
echo "Skipping live-build cache cleanup (--no-cache enabled)"
# Still clean build artifacts but preserve cache
if [ -d ".build" ]; then
rm -rf .build
echo "Removed .build directory (preserving cache)"
fi
fi
echo "Cleanup completed. Configuration reset to defaults." echo "Cleanup completed. Configuration reset to defaults."
echo "All build artifacts and PyInstaller files removed." if [ "$NO_CACHE" = false ]; then
\ No newline at end of file echo "All build artifacts, cache, and PyInstaller files removed."
else
echo "Build artifacts and PyInstaller files removed (cache preserved for faster rebuilds)."
fi
\ No newline at end of file
#!/bin/bash #!/bin/bash
sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config # Enable SSH root login with password authentication for live CD
\ No newline at end of file
echo "Configuring SSH for root password login..."
# Enable root login
sed -i 's/#*PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
# Enable password authentication
sed -i 's/#*PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config
# Ensure password authentication is not disabled elsewhere
sed -i 's/#*PubkeyAuthentication.*/PubkeyAuthentication yes/' /etc/ssh/sshd_config
# Allow empty passwords (since root has no password in live CD)
sed -i 's/#*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' /etc/ssh/sshd_config
# Enable PAM (needed for password auth)
sed -i 's/#*UsePAM.*/UsePAM yes/' /etc/ssh/sshd_config
# Disable strict modes that might block login
sed -i 's/#*StrictModes.*/StrictModes no/' /etc/ssh/sshd_config
# Do NOT set a hardcoded password - respect the password set during ISO creation
# The root password for SSH should be the same as set in preseed/build process
echo "Preserving root password from ISO creation for SSH access..."
# Ensure SSH daemon starts at boot
systemctl enable ssh 2>/dev/null || update-rc.d ssh enable 2>/dev/null || true
echo "SSH configuration for live CD completed:"
echo " - Root login enabled"
echo " - Password authentication enabled"
echo " - Root password preserved from ISO creation"
echo " - Console autologin still works (different mechanism)"
echo " - SSH service enabled at boot"
# Show the SSH configuration
echo "Current SSH configuration:"
grep -E "(PermitRootLogin|PasswordAuthentication|PermitEmptyPasswords|UsePAM|StrictModes)" /etc/ssh/sshd_config
echo ""
echo "SSH Access Info:"
echo " SSH to this live CD: ssh root@<ip_address>"
echo " Password: <use the password you set during ISO creation>"
echo " Console: Still auto-login (no password needed)"
\ No newline at end of file
#!/bin/sh
set -e
echo "Setting up autologin diagnostic to run at boot..."
# Make the diagnostic script executable
chmod +x /usr/local/bin/live-autologin-debug.sh
# Add it to run at boot via rc.local
if [ ! -f /etc/rc.local ]; then
cat > /etc/rc.local << 'EOF'
#!/bin/sh -e
# Auto-generated rc.local for live CD debugging
# Run autologin diagnostic
/usr/local/bin/live-autologin-debug.sh
exit 0
EOF
chmod +x /etc/rc.local
else
# Insert before the exit 0 line
sed -i '/exit 0/i\/usr/local/bin/live-autologin-debug.sh' /etc/rc.local
fi
echo "Autologin diagnostic will run at boot and log to /var/log/live-autologin-debug.log"
\ No newline at end of file
...@@ -14,9 +14,12 @@ fi ...@@ -14,9 +14,12 @@ fi
echo "Adding root user to autologin group..." echo "Adding root user to autologin group..."
usermod -a -G autologin root usermod -a -G autologin root
# Only remove password for live CD - this will be temporary for live environment # Configure root account for passwordless autologin in live environment
echo "Configuring root account for passwordless login (live CD only)..." echo "Configuring root account for passwordless login (live CD only)..."
# Remove password completely (this also unlocks the account)
passwd -d root 2>/dev/null || true passwd -d root 2>/dev/null || true
# Ensure account is unlocked
usermod -U root 2>/dev/null || true
# Create nopasswdlogin group for PAM configuration # Create nopasswdlogin group for PAM configuration
if ! getent group nopasswdlogin >/dev/null 2>&1; then if ! getent group nopasswdlogin >/dev/null 2>&1; then
......
#!/bin/sh
set -e
LOG_FILE="/var/log/setup-console-autologin.log"
echo "Setting up SysV console autologin for tty1..." | tee -a "$LOG_FILE"
# Configure root account for passwordless login
echo "Configuring root account for console autologin..." | tee -a "$LOG_FILE"
passwd -d root 2>&1 | tee -a "$LOG_FILE" || true
usermod -U root 2>&1 | tee -a "$LOG_FILE" || true
usermod -s /bin/bash root 2>&1 | tee -a "$LOG_FILE" || true
# Check current root status
echo "Current root status:" | tee -a "$LOG_FILE"
passwd -S root 2>&1 | tee -a "$LOG_FILE" || true
id root 2>&1 | tee -a "$LOG_FILE" || true
# Backup and show original inittab
echo "Original /etc/inittab:" | tee -a "$LOG_FILE"
cp /etc/inittab /etc/inittab.backup 2>/dev/null || true
cat /etc/inittab | tee -a "$LOG_FILE"
# STRICT inittab modification - clean and rebuild only TTY entries
echo "Cleaning and rebuilding TTY entries in /etc/inittab..." | tee -a "$LOG_FILE"
# Create a clean temporary inittab without any TTY entries or comments
cp /etc/inittab /etc/inittab.backup 2>/dev/null || true
grep -v "^[1-6]:" /etc/inittab | grep -v "^#.*tty" | grep -v "^#.*getty" > /etc/inittab.clean
# Add only properly formatted TTY entries
echo "Adding clean TTY entries..." | tee -a "$LOG_FILE"
# Add tty1 with autologin (ID: "1" - 1 character)
if command -v agetty >/dev/null 2>&1; then
echo "1:23:respawn:/sbin/agetty --autologin root --noclear tty1 linux" >> /etc/inittab.clean
echo "Added agetty autologin entry for tty1" | tee -a "$LOG_FILE"
else
echo "1:23:respawn:/sbin/getty -a root 38400 tty1" >> /etc/inittab.clean
echo "Added getty autologin entry for tty1" | tee -a "$LOG_FILE"
fi
# Add tty2-6 with normal login (IDs: "2", "3", "4", "5", "6" - 1 character each)
for tty_num in {2..6}; do
if command -v agetty >/dev/null 2>&1; then
echo "${tty_num}:23:respawn:/sbin/agetty --noclear tty${tty_num} linux" >> /etc/inittab.clean
else
echo "${tty_num}:23:respawn:/sbin/getty 38400 tty${tty_num}" >> /etc/inittab.clean
fi
echo "Added normal login entry for tty${tty_num}" | tee -a "$LOG_FILE"
done
# Replace the original inittab with clean version
mv /etc/inittab.clean /etc/inittab
# Validate every line in inittab for format compliance
echo "Validating inittab format compliance..." | tee -a "$LOG_FILE"
line_num=0
while IFS= read -r line; do
line_num=$((line_num + 1))
# Skip empty lines and comments
if [[ "$line" =~ ^[[:space:]]*$ ]] || [[ "$line" =~ ^[[:space:]]*# ]]; then
continue
fi
# Check if line has proper inittab format (id:runlevels:action:process)
if [[ ! "$line" =~ ^[^:]{1,4}:[^:]*:[^:]*:.+ ]]; then
echo "WARNING: Line $line_num has invalid format: $line" | tee -a "$LOG_FILE"
fi
# Check ID field length specifically
id_field=$(echo "$line" | cut -d: -f1)
if [ ${#id_field} -gt 4 ]; then
echo "ERROR: Line $line_num has ID field too long (${#id_field} chars): $id_field" | tee -a "$LOG_FILE"
fi
done < /etc/inittab
echo "Clean /etc/inittab contents:" | tee -a "$LOG_FILE"
cat /etc/inittab | tee -a "$LOG_FILE"
echo "SysV console autologin setup completed." | tee -a "$LOG_FILE"
\ No newline at end of file
#!/bin/bash #!/bin/bash
# Post-installation setup script for installed system
# Post-installation setup script # This configures the installed system to autologin and launch MBetterClient
# This script runs after the base system is installed
set -e set -e
echo "Setting up installed system for autologin..." TARGET_MOUNT="$1"
if [ -z "$TARGET_MOUNT" ]; then
TARGET_ROOT="${1:-/target}" echo "Usage: $0 /target/mount/point"
exit 1
# Find live media mount point (USB-aware)
LIVE_MOUNT=""
for mount_point in /cdrom /lib/live/mount/medium /run/live/medium /media/* /mnt/*; do
if [ -d "$mount_point" ] && [ -f "$mount_point/lightdm.conf" ]; then
LIVE_MOUNT="$mount_point"
break
fi
done
if [ -z "$LIVE_MOUNT" ]; then
echo "Warning: Could not find live media mount point"
LIVE_MOUNT="/cdrom" # Fallback
fi fi
echo "Using live media mount point: $LIVE_MOUNT" echo "Configuring installed system for autologin with MBetterClient..."
# Copy LightDM configuration to installed system # 1. Keep autologin in inittab - no changes needed, it's already configured correctly
echo "Copying LightDM configuration..."
mkdir -p "$TARGET_ROOT/etc/lightdm"
cp "$LIVE_MOUNT/lightdm.conf" "$TARGET_ROOT/etc/lightdm/lightdm.conf" 2>/dev/null || true
# Copy PAM configurations to installed system # 2. Ensure root password is properly set from preseed or keep existing
echo "Copying PAM configurations..." echo "Configuring root password for installed system..."
mkdir -p "$TARGET_ROOT/etc/pam.d" # The auto-installer already handles setting the root password from preseed at line 371-375
if [ -f "$LIVE_MOUNT/pam.d-lightdm" ]; then # We don't need to change it here, just ensure the account can still autologin
cp "$LIVE_MOUNT/pam.d-lightdm" "$TARGET_ROOT/etc/pam.d/lightdm" echo "Root password configuration preserved from preseed"
fi
if [ -f "$LIVE_MOUNT/pam.d-lightdm-autologin" ]; then
cp "$LIVE_MOUNT/pam.d-lightdm-autologin" "$TARGET_ROOT/etc/pam.d/lightdm-autologin"
fi
if [ -f "$LIVE_MOUNT/pam.d-lightdm-greeter" ]; then
cp "$LIVE_MOUNT/pam.d-lightdm-greeter" "$TARGET_ROOT/etc/pam.d/lightdm-greeter"
fi
# Set up autologin groups in installed system # 3. Keep auto-start X in root's bashrc - it's already correctly configured
echo "Setting up autologin groups..." # The existing .bashrc will auto-start X when logging into tty1
chroot "$TARGET_ROOT" groupadd -r autologin 2>/dev/null || true
chroot "$TARGET_ROOT" groupadd -r nopasswdlogin 2>/dev/null || true
chroot "$TARGET_ROOT" usermod -a -G autologin root
chroot "$TARGET_ROOT" usermod -a -G nopasswdlogin root
# Set up autostart for installed system (MbetterClient)
echo "Setting up autostart for installed system..."
mkdir -p "$TARGET_ROOT/root/.config/openbox"
cat > "$TARGET_ROOT/root/.config/openbox/autostart" << 'EOF'
#!/bin/bash
# Wait a moment for the desktop to fully load # 4. Modify xinitrc to launch OpenVPN and MBetterClient
sleep 3 echo "Configuring xinitrc to auto-start OpenVPN and MBetterClient..."
cat > "$TARGET_MOUNT/root/.xinitrc" << 'EOF'
#!/bin/bash
# Xinitrc for installed system with OpenVPN and MBetterClient
# Start Openbox window manager in background
openbox &
# Wait for X11 to be ready
sleep 2
# Auto-start OpenVPN if configuration files are present
echo "Checking for OpenVPN configurations..."
OPENVPN_STARTED=false
# Check common OpenVPN configuration locations
for config_dir in "/etc/openvpn" "/etc/openvpn/client" "/root/openvpn" "/usr/local/etc/openvpn"; do
if [ -d "$config_dir" ]; then
for config_file in "$config_dir"/*.conf "$config_dir"/*.ovpn; do
if [ -f "$config_file" ]; then
echo "Found OpenVPN configuration: $config_file"
echo "Starting OpenVPN..."
# Start OpenVPN in background
openvpn --config "$config_file" --daemon --log-append /var/log/openvpn.log
OPENVPN_STARTED=true
echo "OpenVPN started with configuration: $config_file"
break 2 # Exit both loops after starting first config
fi
done
fi
done
# We're on an installed system, run normal startup if [ "$OPENVPN_STARTED" = true ]; then
echo "$(date): Installed system detected, running normal startup" >> /var/log/autoinstall.log echo "OpenVPN auto-started successfully"
# Wait a moment for VPN to establish
sleep 3
else
echo "No OpenVPN configurations found"
fi
# Start the MbetterClient # Start MBetterClient if it exists
if [ -x /usr/local/bin/MbetterClient ]; then if [ -x /usr/local/bin/MbetterClient ]; then
/usr/local/bin/MbetterClient --web-host 0.0.0.0 & echo "Starting MBetterClient..."
# Launch MBetterClient in foreground
exec /usr/local/bin/MbetterClient --web-host 0.0.0.0
else
echo "MBetterClient not found, running Openbox only"
# Fallback to just openbox if MBetterClient not found
exec openbox
fi fi
EOF EOF
chmod +x "$TARGET_ROOT/root/.config/openbox/autostart" chmod +x "$TARGET_MOUNT/root/.xinitrc"
# Copy MbetterClient if it exists on the live system # 5. Remove installer-specific files only
echo "Copying MbetterClient..." echo "Cleaning up installer-specific files..."
if [ -x /usr/local/bin/MbetterClient ]; then rm -f "$TARGET_MOUNT/usr/local/bin/auto-installer.sh" 2>/dev/null || true
mkdir -p "$TARGET_ROOT/usr/local/bin" rm -f "$TARGET_MOUNT/usr/local/bin/autologin-diagnostic.sh" 2>/dev/null || true
cp /usr/local/bin/MbetterClient "$TARGET_ROOT/usr/local/bin/"
chmod +x "$TARGET_ROOT/usr/local/bin/MbetterClient"
fi
# Copy VPN configuration to installed system (if exists on USB/CD) # 6. Ensure MBetterClient is executable
echo "Checking for VPN configuration..." if [ -f "$TARGET_MOUNT/usr/local/bin/MbetterClient" ]; then
if [ -d "$LIVE_MOUNT/vpn-config" ]; then chmod +x "$TARGET_MOUNT/usr/local/bin/MbetterClient"
echo "Found VPN configuration, installing to target system..." echo "MbetterClient configured to start automatically"
mkdir -p "$TARGET_ROOT/etc/openvpn"
cp -r "$LIVE_MOUNT/vpn-config"/* "$TARGET_ROOT/etc/openvpn/"
# Set up VPN to start on boot in installed system
cat > "$TARGET_ROOT/etc/systemd/system/mbetter-vpn.service" << 'EOF'
[Unit]
Description=MBetter VPN Connection
After=network-online.target
Wants=network-online.target
[Service]
Type=forking
User=root
ExecStart=/usr/sbin/openvpn --daemon --config /etc/openvpn/client.conf
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
# Enable VPN service in installed system
chroot "$TARGET_ROOT" systemctl enable mbetter-vpn.service
echo "VPN configuration installed and service enabled"
else
echo "No VPN configuration found to install"
fi fi
echo "Installed system setup completed successfully." echo "Installed system configuration completed!"
\ No newline at end of file echo ""
echo "Installed system will now:"
echo " - Auto-login as root (no password prompt)"
echo " - Automatically start X session"
echo " - Auto-start OpenVPN if configuration files are present"
echo " - Launch MBetterClient automatically"
echo " - Respect root password from ISO creation for system access"
echo ""
echo "OpenVPN will be searched in these locations:"
echo " - /etc/openvpn/*.conf or *.ovpn"
echo " - /etc/openvpn/client/*.conf or *.ovpn"
echo " - /root/openvpn/*.conf or *.ovpn"
echo " - /usr/local/etc/openvpn/*.conf or *.ovpn"
echo ""
\ No newline at end of file
[Seat:*]
autologin-user=root
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=openbox-session
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
\ No newline at end of file
#%PAM-1.0
auth requisite pam_nologin.so
auth sufficient pam_succeed_if.so user ingroup nopasswdlogin
@include common-auth
auth optional pam_gnome_keyring.so
@include common-account
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so close
session required pam_limits.so
@include common-session
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so open
session optional pam_gnome_keyring.so auto_start
@include common-password
\ No newline at end of file
#%PAM-1.0
auth required pam_env.so
auth required pam_permit.so
@include common-account
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so close
session required pam_limits.so
@include common-session
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so open
session optional pam_gnome_keyring.so auto_start
\ No newline at end of file
#%PAM-1.0
auth required pam_env.so
auth required pam_permit.so
@include common-account
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so close
session required pam_limits.so
@include common-session
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so open
session optional pam_gnome_keyring.so auto_start
\ No newline at end of file
# Root bashrc for live CD with auto-start X
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) 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
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
\ No newline at end of file
#!/bin/bash
# Xinitrc for root autologin with auto-installer startup
# Start Openbox window manager in background
openbox &
# Wait for X11 to be ready
sleep 2
# Start auto-installer if it exists
if [ -x /usr/local/bin/auto-installer.sh ]; then
# Launch in a visible terminal window
if command -v xterm >/dev/null 2>&1; then
xterm -e '/usr/local/bin/auto-installer.sh' &
elif command -v lxterminal >/dev/null 2>&1; then
lxterminal -e '/usr/local/bin/auto-installer.sh' &
else
# Fallback: run directly (zenity dialogs will still work)
/usr/local/bin/auto-installer.sh &
fi
fi
# Keep X session alive
exec openbox
\ No newline at end of file
#!/bin/bash
# Make script executable
chmod +x "$0" 2>/dev/null || true
# Comprehensive Autologin Diagnostic Script
# Run this script to diagnose autologin issues
LOG_FILE="/var/log/autologin-diagnostic.log"
mkdir -p "$(dirname "$LOG_FILE")"
echo "$(date): ===== AUTOLOGIN DIAGNOSTIC REPORT =====" | tee -a "$LOG_FILE"
# Function to log and display
log_check() {
local title="$1"
local command="$2"
echo "" | tee -a "$LOG_FILE"
echo "=== $title ===" | tee -a "$LOG_FILE"
if [ -n "$command" ]; then
eval "$command" 2>&1 | tee -a "$LOG_FILE"
fi
}
# 1. Check LightDM Configuration
log_check "LIGHTDM CONFIGURATION" "cat /etc/lightdm/lightdm.conf"
# 2. Check if autologin user exists
log_check "ROOT USER STATUS" "id root && passwd -S root"
# 3. Check group memberships
log_check "GROUP MEMBERSHIPS" "
echo 'Root groups:' && groups root
echo 'Autologin group:' && getent group autologin
echo 'NopasswdLogin group:' && getent group nopasswdlogin
"
# 4. Check PAM configurations
log_check "PAM LIGHTDM CONFIG" "cat /etc/pam.d/lightdm"
log_check "PAM LIGHTDM-AUTOLOGIN CONFIG" "
if [ -f /etc/pam.d/lightdm-autologin ]; then
cat /etc/pam.d/lightdm-autologin
else
echo 'ERROR: /etc/pam.d/lightdm-autologin missing!'
fi
"
# 5. Check available X sessions
log_check "AVAILABLE X SESSIONS" "
echo 'X Sessions directory:' && ls -la /usr/share/xsessions/
echo 'Looking for openbox session:' && find /usr -name '*openbox*session*' -o -name 'openbox.desktop' 2>/dev/null
"
# 6. Check if required packages are installed
log_check "INSTALLED PACKAGES" "
echo 'LightDM packages:'
dpkg -l | grep lightdm
echo 'Openbox packages:'
dpkg -l | grep openbox
"
# 7. Check systemd services
log_check "SYSTEMD SERVICES" "
echo 'LightDM service status:'
systemctl status lightdm --no-pager || echo 'LightDM service not running'
echo 'Display manager:'
systemctl get-default
"
# 8. Check for conflicting display managers
log_check "DISPLAY MANAGERS" "
echo 'Installed display managers:'
dpkg -l | grep -E '(gdm|sddm|kdm|xdm|lightdm)'
"
# 9. Check file permissions
log_check "FILE PERMISSIONS" "
echo 'LightDM config permissions:'
ls -la /etc/lightdm/
echo 'PAM config permissions:'
ls -la /etc/pam.d/lightdm*
echo 'Script permissions:'
ls -la /usr/local/bin/lightdm-*
"
# 10. Check logs
log_check "EXISTING LOGS" "
echo 'LightDM logs:'
ls -la /var/log/lightdm/ 2>/dev/null || echo 'No LightDM logs found'
if [ -f /var/log/lightdm/lightdm.log ]; then
echo 'Recent LightDM log entries:'
tail -20 /var/log/lightdm/lightdm.log
fi
"
echo "" | tee -a "$LOG_FILE"
echo "=== RECOMMENDATIONS ===" | tee -a "$LOG_FILE"
# Check for common issues and provide recommendations
if ! getent group autologin | grep -q root; then
echo "ISSUE: Root user not in autologin group" | tee -a "$LOG_FILE"
fi
if ! getent group nopasswdlogin | grep -q root; then
echo "ISSUE: Root user not in nopasswdlogin group" | tee -a "$LOG_FILE"
fi
if [ ! -f /etc/pam.d/lightdm-autologin ]; then
echo "ISSUE: PAM autologin configuration missing" | tee -a "$LOG_FILE"
fi
if ! find /usr/share/xsessions/ -name "*.desktop" | grep -q openbox; then
echo "ISSUE: Openbox session file missing in /usr/share/xsessions/" | tee -a "$LOG_FILE"
fi
if passwd -S root | grep -q "P "; then
echo "ISSUE: Root user still has a password set" | tee -a "$LOG_FILE"
fi
echo "" | tee -a "$LOG_FILE"
echo "$(date): Diagnostic completed. Check $LOG_FILE for details." | tee -a "$LOG_FILE"
\ No newline at end of file
#!/bin/bash
# LightDM Display Setup Script for Debugging
LOG_FILE="/var/log/lightdm/display-setup.log"
mkdir -p "$(dirname "$LOG_FILE")"
echo "$(date): LightDM Display Setup - DISPLAY=$DISPLAY USER=$USER HOME=$HOME" >> "$LOG_FILE"
echo "$(date): Environment variables:" >> "$LOG_FILE"
env >> "$LOG_FILE"
echo "$(date): Display setup completed" >> "$LOG_FILE"
\ No newline at end of file
#!/bin/bash
# LightDM Session Setup Script for Debugging
LOG_FILE="/var/log/lightdm/session-setup.log"
mkdir -p "$(dirname "$LOG_FILE")"
echo "$(date): LightDM Session Setup - USER=$USER HOME=$HOME SESSION=$DESKTOP_SESSION" >> "$LOG_FILE"
echo "$(date): Groups for user $USER:" >> "$LOG_FILE"
groups "$USER" >> "$LOG_FILE" 2>&1
echo "$(date): Autologin group members:" >> "$LOG_FILE"
getent group autologin >> "$LOG_FILE" 2>&1
echo "$(date): NopasswdLogin group members:" >> "$LOG_FILE"
getent group nopasswdlogin >> "$LOG_FILE" 2>&1
echo "$(date): Session setup completed" >> "$LOG_FILE"
\ No newline at end of file
#!/bin/bash
# Comprehensive live CD autologin diagnostic script
# This script will be run during boot to diagnose autologin issues
LOG_FILE="/var/log/live-autologin-debug.log"
mkdir -p "$(dirname "$LOG_FILE")"
echo "$(date): ===== LIVE CD AUTOLOGIN DEBUG =====" | tee -a "$LOG_FILE"
# Check what init system we're actually using
echo "=== INIT SYSTEM ===" | tee -a "$LOG_FILE"
if [ -d /run/systemd/system ]; then
echo "SYSTEMD is active" | tee -a "$LOG_FILE"
systemctl --version 2>&1 | head -1 | tee -a "$LOG_FILE" || true
else
echo "SysV Init is active" | tee -a "$LOG_FILE"
fi
# Check current runlevel
echo "Current runlevel: $(runlevel)" | tee -a "$LOG_FILE"
# Check inittab
echo "=== INITTAB ===" | tee -a "$LOG_FILE"
if [ -f /etc/inittab ]; then
cat /etc/inittab | tee -a "$LOG_FILE"
else
echo "No /etc/inittab found!" | tee -a "$LOG_FILE"
fi
# Check live-boot configurations
echo "=== LIVE-BOOT CONFIG ===" | tee -a "$LOG_FILE"
ls -la /etc/live/ 2>&1 | tee -a "$LOG_FILE" || echo "No /etc/live/" | tee -a "$LOG_FILE"
ls -la /lib/live/ 2>&1 | tee -a "$LOG_FILE" || echo "No /lib/live/" | tee -a "$LOG_FILE"
# Check kernel command line
echo "=== KERNEL COMMAND LINE ===" | tee -a "$LOG_FILE"
cat /proc/cmdline | tee -a "$LOG_FILE"
# Check running processes related to getty/login
echo "=== GETTY PROCESSES ===" | tee -a "$LOG_FILE"
ps aux | grep -E "(getty|login|agetty)" | grep -v grep | tee -a "$LOG_FILE"
# Check TTY status
echo "=== TTY STATUS ===" | tee -a "$LOG_FILE"
who | tee -a "$LOG_FILE"
w | tee -a "$LOG_FILE"
# Check if we're on tty1
echo "=== CURRENT TTY ===" | tee -a "$LOG_FILE"
tty | tee -a "$LOG_FILE"
echo "XDG_VTNR: $XDG_VTNR" | tee -a "$LOG_FILE"
# Check root user status
echo "=== ROOT STATUS ===" | tee -a "$LOG_FILE"
id root | tee -a "$LOG_FILE"
passwd -S root | tee -a "$LOG_FILE"
# Check available getty/login commands
echo "=== AVAILABLE COMMANDS ===" | tee -a "$LOG_FILE"
which getty 2>&1 | tee -a "$LOG_FILE" || echo "getty not found"
which agetty 2>&1 | tee -a "$LOG_FILE" || echo "agetty not found"
which login 2>&1 | tee -a "$LOG_FILE" || echo "login not found"
# Test autologin capability
echo "=== AUTOLOGIN TEST ===" | tee -a "$LOG_FILE"
if command -v agetty >/dev/null 2>&1; then
agetty --help 2>&1 | grep -i autologin | tee -a "$LOG_FILE" || echo "agetty doesn't support autologin"
fi
echo "$(date): Debug completed" | tee -a "$LOG_FILE"
\ No newline at end of file
...@@ -5,11 +5,16 @@ sysvinit ...@@ -5,11 +5,16 @@ sysvinit
openssh-server openssh-server
openvpn openvpn
xserver-xorg xserver-xorg
xinit
openbox openbox
lightdm
debian-keyring debian-keyring
debian-archive-keyring debian-archive-keyring
# Terminal emulators for X11 session
xterm
lxterminal
xfce4-terminal
# Offline installer packages and tools # Offline installer packages and tools
rsync rsync
parted parted
......
...@@ -17,7 +17,7 @@ d-i netcfg/choose_interface select auto ...@@ -17,7 +17,7 @@ d-i netcfg/choose_interface select auto
# d-i netcfg/wireless_key string # d-i netcfg/wireless_key string
# User accounts - predefined (root password set by set_root_password.sh) # User accounts - predefined (root password set by set_root_password.sh)
d-i passwd/root-password-crypted password $1$nd79zICy$cOW00.Bz6yRGeJ/Etk590/ d-i passwd/root-password-crypted password $1$GypdvIgJ$dEchrt9uror61HdjEeH19.
d-i passwd/make-user boolean false d-i passwd/make-user boolean false
# Time configuration - predefined # Time configuration - predefined
......
#!/bin/bash
# Script to extract ISO image and squashfs filesystem to a working directory
# Usage: sudo ./extract_iso.sh <path_to_iso_file> [work_directory]
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
print_status() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
print_header() {
echo -e "${BLUE}================================${NC}"
echo -e "${BLUE}$1${NC}"
echo -e "${BLUE}================================${NC}"
}
# Check for required tools
REQUIRED_TOOLS="unsquashfs rsync"
for tool in $REQUIRED_TOOLS; do
if ! command -v "$tool" >/dev/null 2>&1; then
print_error "Required tool '$tool' not found!"
echo "Install with: apt install squashfs-tools rsync"
exit 1
fi
done
# Check if running as root
if [ "$EUID" -ne 0 ]; then
print_error "This script must be run with sudo privileges."
echo "Usage: sudo $0 <path_to_iso_file> [work_directory]"
exit 1
fi
# Check if ISO file is provided
if [ $# -lt 1 ]; then
print_error "Please provide the path to the ISO file."
echo "Usage: sudo $0 <path_to_iso_file> [work_directory]"
exit 1
fi
ISO_FILE="$1"
WORK_DIR="${2:-$(pwd)/iso_work}"
if [ ! -f "$ISO_FILE" ]; then
print_error "ISO file not found: $ISO_FILE"
exit 1
fi
# Create work directory
if [ -d "$WORK_DIR" ]; then
print_warning "Work directory exists: $WORK_DIR"
echo "Remove it first or specify a different directory"
echo "Usage: sudo $0 <path_to_iso_file> [work_directory]"
exit 1
fi
print_header "Extracting ISO: $ISO_FILE"
print_status "Work directory: $WORK_DIR"
mkdir -p "$WORK_DIR"
ISO_MOUNT="$WORK_DIR/iso_mount"
ISO_EXTRACT="$WORK_DIR/iso_contents"
SQUASHFS_EXTRACT="$WORK_DIR/squashfs_root"
cleanup() {
print_status "Cleaning up mount points..."
umount "$ISO_MOUNT" 2>/dev/null || true
}
trap cleanup EXIT
mkdir -p "$ISO_MOUNT" "$ISO_EXTRACT" "$SQUASHFS_EXTRACT"
# Mount the ISO
print_status "Mounting ISO file..."
mount -o loop "$ISO_FILE" "$ISO_MOUNT"
# Copy ISO contents
print_status "Copying ISO contents..."
rsync -av "$ISO_MOUNT/" "$ISO_EXTRACT/"
# Find the squashfs filesystem
SQUASHFS_FILE=""
SQUASHFS_RELATIVE_PATH=""
for possible_path in "live/filesystem.squashfs" "casper/filesystem.squashfs"; do
if [ -f "$ISO_EXTRACT/$possible_path" ]; then
SQUASHFS_FILE="$ISO_EXTRACT/$possible_path"
SQUASHFS_RELATIVE_PATH="$possible_path"
break
fi
done
if [ -z "$SQUASHFS_FILE" ]; then
print_error "Could not find squashfs filesystem in ISO"
exit 1
fi
print_status "Found squashfs: $SQUASHFS_RELATIVE_PATH"
# Extract squashfs filesystem
print_status "Extracting squashfs filesystem..."
unsquashfs -d "$SQUASHFS_EXTRACT" "$SQUASHFS_FILE"
if [ ! -d "$SQUASHFS_EXTRACT" ]; then
print_error "Failed to extract squashfs filesystem!"
exit 1
fi
# Remove the original squashfs from ISO contents (we'll recreate it)
rm "$SQUASHFS_FILE"
# Create info file for rebuild script
cat > "$WORK_DIR/extraction_info.txt" << EOF
# Extraction information for rebuild script
ISO_ORIGINAL="$ISO_FILE"
WORK_DIR="$WORK_DIR"
ISO_CONTENTS="$ISO_EXTRACT"
SQUASHFS_ROOT="$SQUASHFS_EXTRACT"
SQUASHFS_RELATIVE_PATH="$SQUASHFS_RELATIVE_PATH"
EXTRACTION_DATE="$(date)"
EOF
print_header "EXTRACTION COMPLETE"
print_status "ISO contents extracted to: $ISO_EXTRACT"
print_status "Squashfs root filesystem: $SQUASHFS_EXTRACT"
print_status "Info file created: $WORK_DIR/extraction_info.txt"
print_status ""
print_status "You can now:"
print_status "1. Modify files in: $SQUASHFS_EXTRACT"
print_status "2. Edit inittab: $SQUASHFS_EXTRACT/etc/inittab"
print_status "3. Make any other changes needed"
print_status "4. Run rebuild script to create new ISO"
print_status ""
print_status "Example inittab fix:"
print_status " nano $SQUASHFS_EXTRACT/etc/inittab"
print_status ""
print_status "When ready, run: sudo ./rebuild_iso.sh $WORK_DIR"
\ No newline at end of file
This diff is collapsed.
#!/bin/bash
# Script to rebuild ISO from extracted working directory
# Usage: sudo ./rebuild_iso.sh <work_directory> [output_iso_name]
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
print_status() {
echo -e "${GREEN}[INFO]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
print_header() {
echo -e "${BLUE}================================${NC}"
echo -e "${BLUE}$1${NC}"
echo -e "${BLUE}================================${NC}"
}
# Check for required tools
REQUIRED_TOOLS="mksquashfs genisoimage"
for tool in $REQUIRED_TOOLS; do
if ! command -v "$tool" >/dev/null 2>&1; then
print_error "Required tool '$tool' not found!"
echo "Install with: apt install squashfs-tools genisoimage"
exit 1
fi
done
# Check if running as root
if [ "$EUID" -ne 0 ]; then
print_error "This script must be run with sudo privileges."
echo "Usage: sudo $0 <work_directory> [output_iso_name]"
exit 1
fi
# Check if work directory is provided
if [ $# -lt 1 ]; then
print_error "Please provide the work directory path."
echo "Usage: sudo $0 <work_directory> [output_iso_name]"
exit 1
fi
WORK_DIR="$1"
OUTPUT_ISO="${2:-rebuilt.iso}"
if [ ! -d "$WORK_DIR" ]; then
print_error "Work directory not found: $WORK_DIR"
print_error "Extract an ISO first using: sudo ./extract_iso.sh <iso_file> $WORK_DIR"
exit 1
fi
# Load extraction info
INFO_FILE="$WORK_DIR/extraction_info.txt"
if [ ! -f "$INFO_FILE" ]; then
print_error "Extraction info file not found: $INFO_FILE"
print_error "This doesn't appear to be a valid extracted ISO directory"
exit 1
fi
# Source the extraction info
. "$INFO_FILE"
print_header "Rebuilding ISO from: $WORK_DIR"
print_status "Original ISO was: $ISO_ORIGINAL"
print_status "Output ISO will be: $OUTPUT_ISO"
# Verify required directories exist
if [ ! -d "$ISO_CONTENTS" ]; then
print_error "ISO contents directory not found: $ISO_CONTENTS"
exit 1
fi
if [ ! -d "$SQUASHFS_ROOT" ]; then
print_error "Squashfs root directory not found: $SQUASHFS_ROOT"
exit 1
fi
# Show what modifications are about to be built
print_status "Current squashfs root contains:"
print_status " Files: $(find "$SQUASHFS_ROOT" -type f | wc -l)"
print_status " Size: $(du -sh "$SQUASHFS_ROOT" | cut -f1)"
if [ -f "$SQUASHFS_ROOT/etc/inittab" ]; then
print_status "Found inittab - checking format..."
# Quick validation
line_count=0
error_count=0
while IFS= read -r line; do
line_count=$((line_count + 1))
if [[ "$line" =~ ^[^:]*: ]] && [[ ! "$line" =~ ^[[:space:]]*# ]]; then
id_field=$(echo "$line" | cut -d: -f1)
if [ ${#id_field} -gt 4 ]; then
print_warning "Line $line_count: ID field '$id_field' too long (${#id_field} chars)"
error_count=$((error_count + 1))
fi
fi
done < "$SQUASHFS_ROOT/etc/inittab"
if [ $error_count -gt 0 ]; then
print_warning "Found $error_count potential format issues in inittab"
print_warning "You may want to fix these before rebuilding"
else
print_status "inittab format looks good"
fi
fi
# Confirm rebuild
echo ""
print_warning "This will rebuild the ISO with current modifications."
echo -n "Continue? (y/N): "
read -r confirm
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
print_status "Rebuild cancelled"
exit 0
fi
# Create new squashfs
NEW_SQUASHFS="$WORK_DIR/filesystem.squashfs"
print_header "Creating New Squashfs Filesystem"
print_status "Compressing squashfs root: $SQUASHFS_ROOT"
print_status "Output: $NEW_SQUASHFS"
mksquashfs "$SQUASHFS_ROOT" "$NEW_SQUASHFS" \
-comp xz \
-Xbcj x86 \
-b 1048576 \
-Xdict-size 100% \
-no-progress
if [ ! -f "$NEW_SQUASHFS" ]; then
print_error "Failed to create squashfs filesystem!"
exit 1
fi
print_status "New squashfs created successfully:"
ls -lh "$NEW_SQUASHFS"
# Place the new squashfs in the ISO contents
print_status "Placing new squashfs in ISO structure..."
SQUASHFS_TARGET="$ISO_CONTENTS/$SQUASHFS_RELATIVE_PATH"
mkdir -p "$(dirname "$SQUASHFS_TARGET")"
cp "$NEW_SQUASHFS" "$SQUASHFS_TARGET"
print_status "Squashfs placed at: $SQUASHFS_TARGET"
# Rebuild ISO
print_header "Rebuilding ISO"
print_status "Creating ISO: $OUTPUT_ISO"
# Detect boot configuration
ISOLINUX_BIN=""
BOOT_CAT=""
if [ -f "$ISO_CONTENTS/isolinux/isolinux.bin" ]; then
ISOLINUX_BIN="isolinux/isolinux.bin"
BOOT_CAT="isolinux/boot.cat"
elif [ -f "$ISO_CONTENTS/syslinux/isolinux.bin" ]; then
ISOLINUX_BIN="syslinux/isolinux.bin"
BOOT_CAT="syslinux/boot.cat"
fi
if [ -n "$ISOLINUX_BIN" ]; then
print_status "Using isolinux boot: $ISOLINUX_BIN"
genisoimage -o "$OUTPUT_ISO" \
-b "$ISOLINUX_BIN" \
-c "$BOOT_CAT" \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
-J -R -V "FIXED_LIVE" \
"$ISO_CONTENTS"
else
print_warning "No isolinux found, creating basic ISO"
genisoimage -o "$OUTPUT_ISO" \
-J -R -V "FIXED_LIVE" \
"$ISO_CONTENTS"
fi
if [ -f "$OUTPUT_ISO" ]; then
print_header "SUCCESS: ISO REBUILT"
print_status "Original ISO: $ISO_ORIGINAL"
print_status "Rebuilt ISO: $OUTPUT_ISO"
print_status ""
print_status "Size comparison:"
ls -lh "$ISO_ORIGINAL" "$OUTPUT_ISO" 2>/dev/null || ls -lh "$OUTPUT_ISO"
print_status ""
print_status "You can now test the rebuilt ISO:"
print_status " $OUTPUT_ISO"
print_status ""
print_status "Work directory preserved at: $WORK_DIR"
print_status "(Delete when no longer needed to save space)"
else
print_error "Failed to create new ISO!"
exit 1
fi
\ No newline at end of file
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