summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2016-05-20 18:01:39 +0200
committerSimon Rettberg2016-05-20 18:01:39 +0200
commitb3e8408fae7dc4869cd14d684ad7ae4127bf7465 (patch)
treeeb56852d94df49f5e7987b506484d95999d99c56
parent[ad] Mount-cifs: Try different mount options (smb3 etc) (diff)
downloadtmlite-bwlp-b3e8408fae7dc4869cd14d684ad7ae4127bf7465.tar.gz
tmlite-bwlp-b3e8408fae7dc4869cd14d684ad7ae4127bf7465.tar.xz
tmlite-bwlp-b3e8408fae7dc4869cd14d684ad7ae4127bf7465.zip
[ipxe] Also create usb image
-rw-r--r--data/ipxe-embed.template8
-rw-r--r--src/main/java/org/openslx/taskmanager/tasks/CompileIPxe.java32
2 files changed, 31 insertions, 9 deletions
diff --git a/data/ipxe-embed.template b/data/ipxe-embed.template
index 2a5b7c2..8ef845f 100644
--- a/data/ipxe-embed.template
+++ b/data/ipxe-embed.template
@@ -2,12 +2,12 @@
ifopen
set net0.dhcp/next-server %ipaddress% ||
set net0.dhcp/filename ipxelinux.0 ||
-set net0.dhcp/210:string / ||
-set net0.dhcp/209:string pxelinux.cfg/default ||
+clear net0.dhcp/210:string ||
+#set net0.dhcp/209:string pxelinux.cfg/default ||
set next-server %ipaddress%
set filename ipxelinux.0
-set 210:string /
-set 209:string pxelinux.cfg/default
+clear 210:string
+#set 209:string pxelinux.cfg/default
imgload pxelinux.0
boot pxelinux.0
diff --git a/src/main/java/org/openslx/taskmanager/tasks/CompileIPxe.java b/src/main/java/org/openslx/taskmanager/tasks/CompileIPxe.java
index b5a5da1..975496c 100644
--- a/src/main/java/org/openslx/taskmanager/tasks/CompileIPxe.java
+++ b/src/main/java/org/openslx/taskmanager/tasks/CompileIPxe.java
@@ -52,7 +52,7 @@ public class CompileIPxe extends AbstractTask
@Override
protected boolean execute()
{
- if (!isRunning.compareAndSet( false, true )) {
+ if ( !isRunning.compareAndSet( false, true ) ) {
status.error = "Another operation is already in progress.";
return false;
}
@@ -123,20 +123,42 @@ public class CompileIPxe extends AbstractTask
return false;
}
// Substitution
- template = template.replace( "%ipaddress%", this.ipaddress );
+ String hybridEmbed = template.replace( "%ipaddress%", this.ipaddress );
+ String usbEmbed = template.replaceFirst( "^ifopen$", "ifopen net0\n"
+ + "set net0/ip 0.0.0.0\n"
+ + "set net0/netmask 255.255.255.255\n"
+ + ":retry_dhcp\n"
+ + "dhcp net0 && goto dhcp_ok ||\n"
+ + "echo DHCP not successful, trying again in 10s...\n"
+ + "sleep 10\n"
+ + "goto retry_dhcp\n"
+ + ":dhcp_ok\n"
+ + "clear net0/ip\n"
+ + "clear net0/netmask\n" );
// Write out
try {
- FileUtils.writeStringToFile( new File( "/opt/openslx/ipxe/ipxelinux.ipxe" ), template, StandardCharsets.UTF_8 );
+ FileUtils.writeStringToFile( new File( "/opt/openslx/ipxe/ipxelinux.ipxe" ), hybridEmbed, StandardCharsets.UTF_8 );
+ FileUtils.writeStringToFile( new File( "/opt/openslx/ipxe/usb.ipxe" ), usbEmbed, StandardCharsets.UTF_8 );
} catch ( IOException e ) {
status.error = e.toString();
return false;
}
// Compile
- if ( 0 != Exec.syncAt( 120, "/opt/openslx/ipxe/src", "make", "EMBED=../ipxelinux.ipxe,../pxelinux.0", "bin/undionly.kkkpxe" ) ) {
- status.error = "Compiling ipxelinux.0 failed";
+ if ( 0 != Exec.syncAt( 240, "/opt/openslx/ipxe/src", "make", "EMBED=../ipxelinux.ipxe,../pxelinux.0", "bin/undionly.kkkpxe" ) ) {
+ status.error = "Compiling ipxelinux.0 failed";
+ return false;
+ }
+ if ( 0 != Exec.syncAt( 240, "/opt/openslx/ipxe/src", "make", "EMBED=../usb.ipxe,../pxelinux.0", "bin/ipxe.usb" ) ) {
+ FileUtils.deleteQuietly( new File( "/opt/openslx/ipxe/openslx-bootstick.raw" ) );
+ status.error = "Compiling ipxe usb image failed";
return false;
}
try {
+ FileUtils.copyFile( new File( "/opt/openslx/ipxe/src/bin/ipxe.usb" ), new File( "/opt/openslx/ipxe/openslx-bootstick.raw" ) );
+ } catch ( Exception e ) {
+ status.error = "Warning: could not create bootstick image";
+ }
+ try {
FileUtils.copyFile( new File( "/opt/openslx/ipxe/src/bin/undionly.kkkpxe" ), new File( "/srv/openslx/tftp/ipxelinux.0" ) );
} catch ( Exception e ) {
status.error = e.toString();