Add wsssh-tools support to autoinstaller

- Add uuid-runtime and screen to live package list
- Create hook to install wsssh-tools_1.0.0-1_amd64.deb with dependencies
- Modify autoinstaller to dynamically generate client ID and update rc.local
- Use generated UUID as wsssh client ID instead of hardcoded value
parent a5bda245
......@@ -1078,6 +1078,14 @@ class InstallerWorker(QThread):
# Configure NTP
self._configure_ntp(target_mount)
# Modify rc.local with dynamic UUID before GRUB installation
self.log("Modifying rc.local with dynamic client ID...")
try:
self.modify_rc_local(target_mount)
self.log("rc.local modified successfully")
except Exception as e:
self.log(f"Warning: rc.local modification failed: {str(e)}")
# Install GRUB bootloader BEFORE unmounting (this is the very last step before cleanup)
self.log("Installing GRUB bootloader (final step before unmounting)...")
try:
......@@ -1642,6 +1650,136 @@ z6:6:respawn:/sbin/sulogin
# Continue with installation despite GRUB failure
self.log("Continuing installation despite GRUB installation failure")
def modify_rc_local(self, target_mount):
"""Modify rc.local in the target system with dynamic UUID and wsssh commands"""
rc_local_path = f"{target_mount}/etc/rc.local"
try:
# Generate a new UUID for this installation
result = subprocess.run(['/usr/bin/uuidgen'], capture_output=True, text=True, check=True)
client_id = result.stdout.strip()
# Read the existing rc.local
try:
with open(rc_local_path, 'r') as f:
content = f.read()
except FileNotFoundError:
# Create default rc.local if it doesn't exist
content = """#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
exit 0
"""
# Find the exit 0 line and insert our commands before it
lines = content.split('\n')
exit_index = -1
for i, line in enumerate(lines):
if line.strip() == 'exit 0':
exit_index = i
break
if exit_index == -1:
# If no exit 0 found, append to the end
lines.append('')
lines.append('# Generate unique client ID')
lines.append(f'ID_CLIENT="{client_id}"')
lines.append('')
lines.append('# Save the client ID to file')
lines.append('echo -n "$ID_CLIENT" > /tmp/IDCLIENT.txt')
lines.append('')
lines.append('# Start wssshc_watcher safely')
lines.append('/usr/local/bin/wssshc_watcher.sh start --server mbetter.nexlab.net --port 9898 --id $ID_CLIENT --password mbetter4ntan1 >/dev/null 2>&1 &')
lines.append('')
lines.append('exit 0')
else:
# Insert our commands before exit 0
insert_lines = [
'',
'# Generate unique client ID',
f'ID_CLIENT="{client_id}"',
'',
'# Save the client ID to file',
'echo -n "$ID_CLIENT" > /tmp/IDCLIENT.txt',
'',
'# Start wssshc_watcher safely',
'/usr/local/bin/wssshc_watcher.sh start --server mbetter.nexlab.net --port 9898 --id $ID_CLIENT --password mbetter4ntan1 >/dev/null 2>&1 &',
''
]
lines[exit_index:exit_index] = insert_lines
# Write back the modified content
modified_content = '\n'.join(lines)
with open(rc_local_path, 'w') as f:
f.write(modified_content)
# Make sure rc.local is executable
os.chmod(rc_local_path, 0o755)
self.log(f"Generated client ID: {client_id}")
except subprocess.CalledProcessError as e:
self.log(f"Warning: Failed to generate UUID: {e}")
# Fallback: use a static ID
client_id = "fallback-static-id"
try:
with open(rc_local_path, 'r') as f:
content = f.read()
lines = content.split('\n')
exit_index = -1
for i, line in enumerate(lines):
if line.strip() == 'exit 0':
exit_index = i
break
if exit_index == -1:
lines.append('')
lines.append('# Generate unique client ID')
lines.append(f'ID_CLIENT="{client_id}"')
lines.append('')
lines.append('# Save the client ID to file')
lines.append('echo -n "$ID_CLIENT" > /tmp/IDCLIENT.txt')
lines.append('')
lines.append('# Start wssshc_watcher safely')
lines.append('/usr/local/bin/wssshc_watcher.sh start --server mbetter.nexlab.net --port 9898 --id mdma --password mbetter4ntan1 >/dev/null 2>&1 &')
lines.append('')
lines.append('exit 0')
else:
insert_lines = [
'',
'# Generate unique client ID',
f'ID_CLIENT="{client_id}"',
'',
'# Save the client ID to file',
'echo -n "$ID_CLIENT" > /tmp/IDCLIENT.txt',
'',
'# Start wssshc_watcher safely',
'/usr/local/bin/wssshc_watcher.sh start --server mbetter.nexlab.net --port 9898 --id mdma --password mbetter4ntan1 >/dev/null 2>&1 &',
''
]
lines[exit_index:exit_index] = insert_lines
modified_content = '\n'.join(lines)
with open(rc_local_path, 'w') as f:
f.write(modified_content)
os.chmod(rc_local_path, 0o755)
self.log(f"Used fallback client ID: {client_id}")
except Exception as e2:
self.log(f"Warning: Could not modify rc.local with fallback: {e2}")
except Exception as e:
self.log(f"Warning: Could not modify rc.local: {e}")
def run_post_install(self, target_mount):
# Run post-install cleanup - remove auto-installer from installed system
self.log("Running post-installation cleanup...")
......
#!/bin/bash
# Install wsssh-tools .deb package after main packages are installed
set -e
echo "Installing wsssh-tools .deb package..."
# Copy wsssh-tools .deb package from the live system
WSSSH_DEB="/cdrom/wsssh-tools_1.0.0-1_amd64.deb"
TARGET_DEB="/tmp/wsssh-tools_1.0.0-1_amd64.deb"
echo "Copying wsssh-tools from $WSSSH_DEB..."
if [ -f "$WSSSH_DEB" ]; then
cp "$WSSSH_DEB" "$TARGET_DEB"
else
echo "Error: wsssh-tools .deb package not found at $WSSSH_DEB"
exit 1
fi
# Install dependencies first
echo "Installing dependencies for wsssh-tools..."
apt-get update
apt-get install -y libc6 libssl3t64 openssl
# Install wsssh-tools .deb package
echo "Installing wsssh-tools .deb package..."
dpkg -i "$TARGET_DEB"
# Clean up
rm -f "$TARGET_DEB"
echo "wsssh-tools installation completed successfully"
\ No newline at end of file
......@@ -109,6 +109,10 @@ vim
# Core utilities (essential command-line tools)
coreutils
# Additional utilities
uuid-runtime
screen
# Graphics and hardware utilities
mesa-utils
vulkan-tools
......
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