Commit 142d741d authored by bmortier's avatar bmortier

Merge branch '1.2.2-fixes-ecolo' into '1.2.3-fixes-ecolo'

merge 1.2.2 fixes ecolo into 1.2.3-fixes-ecolo

See merge request argonaut/argonaut!111
parents c673a1b3 3cb94504
......@@ -5,7 +5,7 @@
# Copyright (c) 2005,2006,2007 by Jan-Marek Glogowski <glogow@fbihome.de>
# Copyright (c) 2008 by Cajus Pollmeier <pollmeier@gonicus.de>
# Copyright (c) 2008,2009, 2010 by Jan Wenzel <wenzel@gonicus.de>
# Copyright (C) 2011-2016 FusionDirectory project
# Copyright (C) 2011-2018 FusionDirectory project
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -49,25 +49,46 @@ sub get_module_info {
}
sub get_module_settings {
return argonaut_get_generic_settings(
my $settings = argonaut_get_generic_settings(
'argonautFuseFAIConfig',
{
'fai_version' => "argonautFuseFaiVersion",
'fai_flags' => "argonautFuseFaiFlags",
'fai4_cmdline' => "argonautFuseFai4Cmdline",
'fai5_cmdline' => "argonautFuseFai5Cmdline",
'fai_hostname' => "argonautFuseFaiForceHostname",
'fai_multiple' => "argonautFuseMultipleReleaseMode",
'nfs_root' => "argonautFuseNfsRoot",
},
$main::config,$main::config->{'client_ip'}
);
# Default values
if (not defined $settings->{'fai_version'}) {
$settings->{'fai_version'} = 4;
}
if (not defined $settings->{'fai4_cmdline'}) {
$settings->{'fai4_cmdline'} = 'ip=dhcp root=/dev/nfs boot=live union=aufs';
}
if (not defined $settings->{'fai_hostname'}) {
$settings->{'fai_hostname'} = 'TRUE';
}
if (not defined $settings->{'fai_multiple'}) {
$settings->{'fai_multiple'} = 'FALSE';
}
return $settings;
}
sub get_pxe_config {
my $class = shift;
my ($filename) = shift || return;
my $settings = get_module_settings();
my $nfs_root = $settings->{'nfs_root'};
my $nfs_opts = "";
my $fai_flags = $settings->{'fai_flags'};
my $union = "aufs";
my $mac = argonaut_get_mac_pxe($filename);
my $result = undef;
# Search for the host to examine the FAI state
......@@ -75,11 +96,17 @@ sub get_pxe_config {
'FAIobject',
{
'status' => 'FAIstate',
'FAIclass' => 'FAIclass',
'hostname' => 'cn',
},
$main::config,"(macAddress=$mac)"
);
if ($infos->{'FAIclass'} =~ m/^(.+) :([^ :]+)$/) {
$infos->{'profile'} = $1;
$infos->{'release'} = $2;
}
if ($infos->{'locked'}) {
# Locked machine: go to 'localboot'
$infos->{'status'} = 'localboot';
......@@ -116,25 +143,40 @@ sub get_pxe_config {
}
# Get kernel and initrd from TFTP root
if ($settings->{'fai_multiple'} eq 'TRUE') {
$infos->{'kernel'} = 'vmlinuz-'.$infos->{'release'}.'-install';
$infos->{'cmdline'} = ' initrd=initrd.img-'.$infos->{'release'}.'-install';
if ($nfs_root !~ m|/$|) {
$nfs_root .= '/';
}
$nfs_root .= $infos->{'release'};
} else {
$infos->{'kernel'} = 'vmlinuz-install';
$infos->{'cmdline'} = ' initrd=initrd.img-install';
}
my $chboot_cmd;
my $output;
my $valid_status = 1;
# Set cmdline
# Add NFS options and root, if available
my $nfsroot_cmdline = (defined $nfs_root && ($nfs_root ne ''));
$infos->{'cmdline'} .= " nfsroot=$nfs_root" if( $nfsroot_cmdline );
if (defined $nfs_opts && ($nfs_opts ne '')) {
$infos->{'cmdline'} .= ' nfsroot=' if( ! $nfsroot_cmdline );
$infos->{'cmdline'} .= ",$nfs_opts";
if ($settings->{'fai_version'} < 5) {
$infos->{'cmdline'} .= " nfsroot=$nfs_root";
$infos->{'cmdline'} .= ' '.$settings->{'fai4_cmdline'};
} else {
$infos->{'cmdline'} .= " root=".$main::config->{'client_ip'}.":".$nfs_root;
$infos->{'cmdline'} .= ' '.$settings->{'fai5_cmdline'};
if ($settings->{'fai_hostname'} ne 'FALSE') {
$infos->{'cmdline'} .= ' HOSTNAME='.$infos->{'hostname'};
}
}
$infos->{'cmdline'} .= " FAI_ACTION=${main::default_mode}";
if ($infos->{'status'} =~ /^(install|install-init)$/) {
$infos->{'kernel'} = 'kernel '.$infos->{'kernel'};
$infos->{'cmdline'} .= " ip=dhcp root=/dev/nfs boot=live union=$union"
. " FAI_ACTION=${main::default_mode} FAI_FLAGS=${fai_flags}";
$infos->{'cmdline'} .= " FAI_FLAGS=${fai_flags}";
} elsif ($infos->{'status'} =~ /^(error:|installing:)/) {
# If we had an error, show an error message
# The only difference is to install is "faierror" on cmdline
......@@ -142,8 +184,7 @@ sub get_pxe_config {
$faierror .= (split( ':', $infos->{'status'} ))[1];
$infos->{'kernel'} = 'kernel '.$infos->{'kernel'};
$infos->{'cmdline'} .= " ip=dhcp root=/dev/nfs boot=live union=$union"
. " FAI_ACTION=${main::default_mode} FAI_FLAGS=${fai_flags} faierror:${faierror}";
$infos->{'cmdline'} .= " FAI_FLAGS=${fai_flags} faierror:${faierror}";
} elsif ($infos->{'status'} eq 'softupdate') {
# Softupdate has to be run by the client, so do a localboot
$infos->{'kernel'} = 'localboot 0';
......@@ -161,8 +202,7 @@ sub get_pxe_config {
}
my $noreboot = join( ',', @sysflags );
$infos->{'kernel'} = 'kernel '.$infos->{'kernel'};
$infos->{'cmdline'} .= " ip=dhcp root=/dev/nfs boot=live union=$union"
. " FAI_ACTION=${main::default_mode} FAI_FLAGS=${noreboot} ";
$infos->{'cmdline'} .= " FAI_FLAGS=${noreboot} ";
} elsif ($infos->{'status'} eq 'localboot') {
$infos->{'kernel'} = 'localboot 0';
......
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