Add MBetterClient Executable Customization to USB Creator

 ENHANCED USB CREATOR with MBetterClient Replacement:
- Added optional MBetterClient executable selection (checkbox controlled)
- Replace default MBetterClient with custom version in ISO
- Updates multiple locations in ISO structure for comprehensive replacement
- Validation and file existence checking
- Enhanced confirmation dialog showing all customizations

TECHNICAL DETAILS:
+ MBetterClient selection UI group with browse functionality
+ replace_mbetter_client() method replaces executable in all ISO locations
+ Updated WorkerThread to handle MBetterClient parameter
+ Enhanced validation logic for executable file checking
+ Updated confirmation dialog to show all optional configurations

USER WORKFLOW:
1. Select ISO file (required)
2. Choose USB device (required)
3. Set root password (optional)
4. Add OpenVPN config (optional)
5. Replace MBetterClient executable (optional)
6. Create customized USB with all configurations

This completes the USB creator tool with full customization capabilities.
parent cb1dcaef
...@@ -31,13 +31,14 @@ class WorkerThread(QThread): ...@@ -31,13 +31,14 @@ class WorkerThread(QThread):
status = pyqtSignal(str) status = pyqtSignal(str)
finished = pyqtSignal(bool, str) finished = pyqtSignal(bool, str)
def __init__(self, iso_file, usb_device, root_password, openvpn_config, openvpn_keys): def __init__(self, iso_file, usb_device, root_password, openvpn_config, openvpn_keys, mbetter_client):
super().__init__() super().__init__()
self.iso_file = iso_file self.iso_file = iso_file
self.usb_device = usb_device self.usb_device = usb_device
self.root_password = root_password self.root_password = root_password
self.openvpn_config = openvpn_config self.openvpn_config = openvpn_config
self.openvpn_keys = openvpn_keys self.openvpn_keys = openvpn_keys
self.mbetter_client = mbetter_client
def run(self): def run(self):
try: try:
...@@ -77,6 +78,9 @@ class WorkerThread(QThread): ...@@ -77,6 +78,9 @@ class WorkerThread(QThread):
if self.openvpn_config: if self.openvpn_config:
self.add_openvpn_config(iso_extract) self.add_openvpn_config(iso_extract)
if self.mbetter_client:
self.replace_mbetter_client(iso_extract)
self.progress.emit(50) self.progress.emit(50)
# Write to USB device # Write to USB device
...@@ -138,6 +142,29 @@ class WorkerThread(QThread): ...@@ -138,6 +142,29 @@ class WorkerThread(QThread):
for key_file in self.openvpn_keys: for key_file in self.openvpn_keys:
shutil.copy2(key_file, vpn_dir) shutil.copy2(key_file, vpn_dir)
def replace_mbetter_client(self, iso_dir):
# Replace MBetterClient executable in the ISO
mbetter_paths = [
"config/includes.chroot/usr/local/bin/MbetterClient",
"config/includes.binary/MbetterClient",
"usr/local/bin/MbetterClient"
]
for mbetter_path in mbetter_paths:
full_path = os.path.join(iso_dir, mbetter_path)
dir_path = os.path.dirname(full_path)
# Create directory if it doesn't exist
os.makedirs(dir_path, exist_ok=True)
# Copy the new MBetterClient executable
shutil.copy2(self.mbetter_client, full_path)
# Make executable
os.chmod(full_path, 0o755)
self.status.emit(f"Updated MBetterClient at {mbetter_path}")
def write_to_usb(self, source_dir): def write_to_usb(self, source_dir):
if platform.system() == "Windows": if platform.system() == "Windows":
self.write_usb_windows(source_dir) self.write_usb_windows(source_dir)
...@@ -180,6 +207,7 @@ class USBCreatorApp(QMainWindow): ...@@ -180,6 +207,7 @@ class USBCreatorApp(QMainWindow):
self.root_password = "" self.root_password = ""
self.openvpn_config = "" self.openvpn_config = ""
self.openvpn_key_files = [] self.openvpn_key_files = []
self.mbetter_client = ""
self.worker_thread = None self.worker_thread = None
self.init_ui() self.init_ui()
...@@ -212,6 +240,9 @@ class USBCreatorApp(QMainWindow): ...@@ -212,6 +240,9 @@ class USBCreatorApp(QMainWindow):
# OpenVPN Configuration (Optional) # OpenVPN Configuration (Optional)
layout.addWidget(self.create_vpn_group()) layout.addWidget(self.create_vpn_group())
# MBetterClient Configuration (Optional)
layout.addWidget(self.create_mbetter_group())
# Progress and Status # Progress and Status
layout.addWidget(self.create_progress_group()) layout.addWidget(self.create_progress_group())
...@@ -293,6 +324,27 @@ class USBCreatorApp(QMainWindow): ...@@ -293,6 +324,27 @@ class USBCreatorApp(QMainWindow):
return group return group
def create_mbetter_group(self):
group = QGroupBox("MBetterClient Executable (Optional)")
group.setCheckable(True)
group.setChecked(False)
layout = QFormLayout(group)
# MBetterClient executable file
client_layout = QHBoxLayout()
self.mbetter_label = QLabel("No executable selected (will use default)")
self.mbetter_button = QPushButton("Browse...")
self.mbetter_button.clicked.connect(self.browse_mbetter_client)
client_layout.addWidget(self.mbetter_label)
client_layout.addWidget(self.mbetter_button)
layout.addRow("Executable File:", client_layout)
info_label = QLabel("Replace the default MBetterClient with your custom version")
info_label.setStyleSheet("color: gray; font-size: 10px;")
layout.addRow(info_label)
return group
def create_progress_group(self): def create_progress_group(self):
group = QGroupBox("Progress") group = QGroupBox("Progress")
layout = QVBoxLayout(group) layout = QVBoxLayout(group)
...@@ -405,6 +457,15 @@ class USBCreatorApp(QMainWindow): ...@@ -405,6 +457,15 @@ class USBCreatorApp(QMainWindow):
self.openvpn_key_files = file_paths self.openvpn_key_files = file_paths
self.vpn_keys_label.setText(f"{len(file_paths)} key files selected") self.vpn_keys_label.setText(f"{len(file_paths)} key files selected")
def browse_mbetter_client(self):
file_path, _ = QFileDialog.getOpenFileName(
self, "Select MBetterClient Executable", "",
"Executable Files (*.exe *.bin);;All Files (*)"
)
if file_path:
self.mbetter_client = file_path
self.mbetter_label.setText(os.path.basename(file_path))
def create_usb(self): def create_usb(self):
# Validate inputs # Validate inputs
if not self.iso_file: if not self.iso_file:
...@@ -449,6 +510,18 @@ class USBCreatorApp(QMainWindow): ...@@ -449,6 +510,18 @@ class USBCreatorApp(QMainWindow):
self.openvpn_config = "" self.openvpn_config = ""
self.openvpn_key_files = [] self.openvpn_key_files = []
# Get MBetterClient configuration
mbetter_group = self.findChild(QGroupBox, "MBetterClient Executable (Optional)")
if mbetter_group and mbetter_group.isChecked():
if not self.mbetter_client:
QMessageBox.warning(self, "Error", "Please select a MBetterClient executable")
return
if not os.path.exists(self.mbetter_client):
QMessageBox.warning(self, "Error", "MBetterClient executable not found")
return
else:
self.mbetter_client = ""
# Confirm operation # Confirm operation
msg = f"This will erase all data on {self.usb_device}.\n\n" msg = f"This will erase all data on {self.usb_device}.\n\n"
msg += f"ISO: {os.path.basename(self.iso_file)}\n" msg += f"ISO: {os.path.basename(self.iso_file)}\n"
...@@ -457,6 +530,8 @@ class USBCreatorApp(QMainWindow): ...@@ -457,6 +530,8 @@ class USBCreatorApp(QMainWindow):
msg += "Custom root password: Yes\n" msg += "Custom root password: Yes\n"
if self.openvpn_config: if self.openvpn_config:
msg += f"OpenVPN config: {os.path.basename(self.openvpn_config)}\n" msg += f"OpenVPN config: {os.path.basename(self.openvpn_config)}\n"
if self.mbetter_client:
msg += f"Custom MBetterClient: {os.path.basename(self.mbetter_client)}\n"
msg += "\nContinue?" msg += "\nContinue?"
reply = QMessageBox.question(self, "Confirm USB Creation", msg, reply = QMessageBox.question(self, "Confirm USB Creation", msg,
...@@ -469,7 +544,7 @@ class USBCreatorApp(QMainWindow): ...@@ -469,7 +544,7 @@ class USBCreatorApp(QMainWindow):
self.worker_thread = WorkerThread( self.worker_thread = WorkerThread(
self.iso_file, self.usb_device, self.root_password, self.iso_file, self.usb_device, self.root_password,
self.openvpn_config, self.openvpn_key_files self.openvpn_config, self.openvpn_key_files, self.mbetter_client
) )
self.worker_thread.progress.connect(self.progress_bar.setValue) self.worker_thread.progress.connect(self.progress_bar.setValue)
self.worker_thread.status.connect(self.update_status) self.worker_thread.status.connect(self.update_status)
......
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