Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,9 @@ def __init__(self):
self.reqparse.add_argument(
"net_filter", type=str, default="ID_NET_NAME", location="json"
)
self.reqparse.add_argument(
"custom_script", type=str, default=None, location="json"
)
super(ProxmoxJobs, self).__init__()

def post(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,7 @@ def generate_first_boot_script(
eai_host_ip=EAIHOST_IP,
answerfile_dir=ANSWERFILEDIR,
dryrun=DRYRUN,
custom_script=None,
):
"""
Generate first-boot script that will mark the job as finished.
Expand All @@ -1755,14 +1756,26 @@ def generate_first_boot_script(
:param eai_host_ip: (str) EAI host IP address
:param answerfile_dir: (str) path to answer files directory
:param dryrun: (bool) dry run flag
:param custom_script: (str) optional custom script to run before network wait
:return: (str) path to generated script file
"""
logger.info(f"Generating first-boot script for job completion")

# Build custom script section if provided
custom_section = ""
if custom_script and custom_script.strip():
custom_section = f"""
# Custom user script
{custom_script.strip()}

"""
logger.info(f"Including custom script in first-boot")
mainlog.info(f"{jobid} Including custom script in first-boot")

script_content = f"""#!/bin/bash
# Proxmox first-boot script to mark installation as complete
# Job ID: {jobid}

{custom_section}
# Wait for network to be available
sleep 10

Expand Down Expand Up @@ -2056,7 +2069,10 @@ def process_proxmox_submission(jobid_list, logger_list, mainlog, form_data):

# Generate first-boot script
mainlog.info(f"{jobid} Generating first-boot script for server {hostname}")
first_boot_script_path = generate_first_boot_script(jobid, logger, mainlog)
custom_script = form_data.get("custom_script", None)
first_boot_script_path = generate_first_boot_script(
jobid, logger, mainlog, custom_script=custom_script
)

# Prepare ISO with answer file and first-boot script
mainlog.info(f"{jobid} Preparing Proxmox ISO for server {hostname}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ <h1>Step 1</h1>
<tr>
<td>Network Interface: </td>
<td><input type="text" name="interface" value='eno1' required></td>
<td>Network interface name (e.g., eno1, eth0)</td>
<td>Network interface name (e.g., eno1, ens1f0np0)</td>
</tr>
<tr>
<td>Network Filter: </td>
Expand All @@ -89,6 +89,14 @@ <h1>Step 1</h1>
</td>
<td>Network interface filter type for auto-detection</td>
</tr>
<tr>
<td>Custom First-Boot Script: </td>
<td>
<textarea name="custom_script" id="custom_script" rows="6" cols="40" placeholder="# Optional custom script to run on first boot"></textarea>
</td>
<td>Optional bash script to execute on first boot.<BR>
"#!/bin/bash" is inserted as the first line automatically, so only bash commands are valid.</td>
</tr>
</table>

<h1>Step 2</h1>
Expand Down
6 changes: 6 additions & 0 deletions auto-installer_docker/nginx/static/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ components:
type: string
enum: ['ID_NET_NAME_SLOT', 'ID_NET_NAME_PATH', 'ID_NET_NAME_ONBOARD', 'ID_VENDOR_ID', 'ID_MODEL_ID', 'ID_PATH', 'ID_BUS', 'ID_PCI_CLASS_FROM_DATABASE', 'ID_PCI_SUBCLASS_FROM_DATABASE']
default: ID_NET_NAME_SLOT
custom_script:
type: string
description: Optional custom bash script to run on first boot.
example: |
echo "Custom setup script"
# Your custom commands here
hosts:
type: array
items:
Expand Down