function afi_part_get_installdisks() { $host_conf = afi_get_host_config(afi_get_const_array_key('AFI_INI_SETTINGS', 'afi_conf_dir'), afi_get_client_profile_name()); foreach ($host_conf['install_disks'] as $afi_install_disk_number => $afi_install_disk) { $afi_install_disks[$afi_install_disk_number]['disk'] = $afi_install_disk; $afi_install_disks[$afi_install_disk_number]['partprefix'] = afi_part_get_partprefix($afi_install_disk); } afi_debug_var("afi_install_disks", $afi_install_disks, 6); return $afi_install_disks; }
function create_repo_config_ks() { $afi_repo_classes = afi_get_const_array_key('AFI_CLIENT_CONF', 'repo_classes'); if (afi_get_const_array_key('AFI_CLIENT_CONF', 'noverifyssl') == 1) { $afi_noverifyssl_string_kickstart = "--noverifyssl"; } else { $afi_noverifyssl_string_kickstart = ""; } $afi_url_conf_dist = afi_get_url_config_ks("url.conf"); $afi_url_proxy_string = ""; if (isset($afi_url_conf_dist['proxy']) && $afi_url_conf_dist['proxy'] != "") { $afi_url_proxy_string = "--proxy=" . $afi_url_conf_dist['proxy']; } print "url --url=" . $afi_url_conf_dist['url'] . " " . $afi_url_proxy_string . " " . $afi_noverifyssl_string_kickstart . "\n"; print "\n"; $afi_repo_conf_dist = afi_get_url_config_ks("repo.conf"); foreach ($afi_repo_conf_dist as $key => $value) { afi_debug_var("afi_repo_conf_dist key", $key, 6); afi_debug_var("afi_repo_conf_dist value", $value, 6); $afi_repo_proxy_string = ""; if (isset($value['proxy']) && $value['proxy'] != "") { $afi_repo_proxy_string = "--proxy=" . $value['proxy']; } $afi_repo_includepkgs_string = ""; if (isset($value['includepkgs']) && $value['includepkgs'] != "") { $afi_repo_includepkgs_string = "--includepkgs=" . $value['includepkgs']; } print "repo --name=" . $key . " --baseurl=" . $value['url'] . " " . $afi_repo_proxy_string . " " . $afi_repo_includepkgs_string . " " . $afi_noverifyssl_string_kickstart . "\n"; } if (is_array($afi_repo_classes)) { foreach ($afi_repo_classes as $repoclassvalue) { $afi_repo_conf_class = afi_get_url_config_ks("/additional/" . $repoclassvalue . ".conf"); foreach ($afi_repo_conf_class as $key => $value) { afi_debug_var("afi_repo_conf_class key", $key, 6); afi_debug_var("afi_repo_conf_class value", $value, 6); $afi_repo_proxy_string = ""; if (isset($value['proxy']) && $value['proxy'] != "") { $afi_repo_proxy_string = "--proxy=" . $value['proxy']; } $afi_repo_includepkgs_string = ""; if (isset($value['includepkgs']) && $value['includepkgs'] != "") { $afi_repo_includepkgs_string = "--includepkgs=" . $value['includepkgs']; } print "repo --name=" . $key . " --baseurl=" . $value['url'] . " " . $afi_repo_proxy_string . " " . $afi_repo_includepkgs_string . " " . $afi_noverifyssl_string_kickstart . "\n"; } } } }
function afi_get_host_config($afi_conf_dir, $hostname) { //load global conf if (file_exists("./defaults/defaults.conf")) { $default_conf_global = parse_ini_file("./defaults/defaults.conf"); } //find host config file $hostconffile = glob("{$afi_conf_dir}/hosts/*/{$hostname}.conf"); afi_debug_var("hostconffile", $hostconffile, 5); if (!$hostconffile || !is_array($hostconffile) || count($hostconffile) != 1) { print "#none or more than one host config file found for {$hostname}\n"; print_r($hostconffile); return NULL; } //determine environment $environment = basename(dirname($hostconffile[0])); if (!isset($environment) || empty($environment) || $environment == "") { print "#no environment set: " . $environment . "\n"; return NULL; } //load environment specific conf if (!file_exists($afi_conf_dir . "/overrides/" . $environment . "/defaults/defaults.conf")) { $default_conf_environment = array(); } else { $default_conf_environment = parse_ini_file($afi_conf_dir . "/overrides/" . $environment . "/defaults/defaults.conf"); } if (!file_exists($hostconffile[0])) { print "#no hostconf file found: " . $hostconffile[0] . "\n"; return NULL; } $host_conf = parse_ini_file("{$hostconffile['0']}"); $host_conf['environment'] = $environment; if (strstr($host_conf['distver'], '.')) { $host_conf['distvershort'] = strstr($host_conf['distver'], '.', true); } else { $host_conf['distvershort'] = $host_conf['distver']; } afi_debug_var("host_conf", $host_conf, 8); //debug afi_debug_var("default_conf_global", $default_conf_global, 6); afi_debug_var("default_conf_environment", $default_conf_environment, 6); afi_debug_var("host_conf", $host_conf, 6); afi_debug_var("environment", $environment, 6); afi_debug_out(PHP_EOL, 6); return array_replace_recursive((array) $default_conf_global, (array) $default_conf_environment, (array) $host_conf); }
function create_ipxe_kernel_string() { $afi_rhel_clones_regex = "/centos|rhel|oracle|scientific|puias|springdale|rosa|stella/"; # client conf opts $afi_dist = afi_get_const_array_key('AFI_CLIENT_CONF', 'dist'); $afi_distver = afi_get_const_array_key('AFI_CLIENT_CONF', 'distver'); $afi_distvershort = afi_get_const_array_key('AFI_CLIENT_CONF', 'distvershort'); $afi_kernel_conf_dist = afi_get_kernel_conf_dist(); # create kernel url $afi_kernel_string = $afi_kernel_conf_dist['kernel']; # ensure that installer uses same interface than iPXE $afi_kernel_string = $afi_kernel_string . " BOOTIF=01-\${netX/mac}"; # dist specific extra kernel parameters # no good magic FIXME $afi_dist_kernel_opts = ""; if (preg_match($afi_rhel_clones_regex, $afi_dist) && preg_match("/^6\\.[0-9]+\$/", $afi_distver)) { $afi_dist_kernel_opts = "ramdisk_size=100000 ksdevice=bootif"; } # # FIXME do not use fai - rather use preseed # if ( (preg_match("/ubuntu|debian/", $afi_dist)) ) { # $afi_dist_kernel_opts ="boot=live fetch=".afi_get_base_url_afi(TRUE)."/faiserver/UBUNTUPRECISE/base.squashfs ip=dhcp FAI_CONFIG_SRC=git+https://gitserver/fai.git FAI_ACTION=install FAI_FLAGS=verbose,sshd"; # } $afi_kernel_string = $afi_kernel_string . " " . $afi_dist_kernel_opts; # define provisioning file switch (true) { case preg_match($afi_rhel_clones_regex, $afi_dist): $afi_provisioning_file_post = "rhel." . $afi_distvershort . ".php"; break; default: $afi_provisioning_file_post = $afi_dist . "." . $afi_distvershort . ".php"; break; } afi_debug_var("{$afi_provisioning_file_post}", $afi_provisioning_file_post, 6); # provisioning parameter for boot switch (true) { case preg_match($afi_rhel_clones_regex, $afi_dist): $afi_provisioning_file_string = "ks=" . afi_get_base_url_afi(TRUE) . "/ks.cfg." . $afi_provisioning_file_post; break; case preg_match("/fedora/", $afi_dist): $afi_provisioning_file_string = "ks=" . afi_get_base_url_afi(TRUE) . "/ks.cfg." . $afi_provisioning_file_post; break; default: $afi_provisioning_file_string = ""; break; } $client_profile_name = afi_get_client_profile_name(); afi_debug_var("client_profile_name", $client_profile_name, 6); $afi_provisioning_file_string = $afi_provisioning_file_string . "?afi_client_profile_name=" . $client_profile_name; afi_debug_var("afi_provisioning_file_string", $afi_provisioning_file_string, 6); $afi_kernel_string = $afi_kernel_string . " " . $afi_provisioning_file_string; if (afi_get_const_array_key('AFI_CLIENT_CONF', 'instsshd') == 1) { if (preg_match($afi_rhel_clones_regex, $afi_dist) && preg_match("/^6\\.[0-9]+\$/", $afi_distver)) { $instsshd_string = "sshd=1"; } else { $instsshd_string = "inst.sshd"; } $afi_kernel_string = $afi_kernel_string . " " . $instsshd_string; } # ssl kernel parameter if (afi_get_const_array_key('AFI_CLIENT_CONF', 'noverifyssl') == 1) { #FIXME replace by call for noverifysslstring (distro dependent) $afi_kernel_string = $afi_kernel_string . " noverifyssl"; } # serial console kernel parameter if (afi_get_const_array_key('AFI_CLIENT_CONF', 'use_serial_console') == 1) { $serial_console_port_linux_kernel = afi_get_const_array_key('AFI_CLIENT_CONF', 'serial_console_port') - 1; $serial_console_port_speed = afi_get_const_array_key('AFI_CLIENT_CONF', 'serial_console_port_speed'); $serial_console_string_linux_kernel = "console=tty0 console=ttyS" . $serial_console_port_linux_kernel . "," . $serial_console_port_speed . "n8"; # no good magic FIXME if (preg_match($afi_rhel_clones_regex, $afi_dist) && preg_match("/^6\\.[0-9]+\$/", $afi_distver)) { $serial_console_string_linux_kernel = "serial " . $serial_console_string_linux_kernel; } $afi_kernel_string = $afi_kernel_string . " " . $serial_console_string_linux_kernel; } # create kernel parameter strings from host conf settings if (afi_get_const_array_key('AFI_CLIENT_CONF', 'ipv6disable') == 1) { #FIXME replace by call for ipv6disable-string (distro dependent) $afi_kernel_string = $afi_kernel_string . " ipv6.disable=1"; } # disable consistent device naming ? if (afi_get_const_array_key('AFI_CLIENT_CONF', 'disableconsistennetworkdevicenaming') == 1) { #FIXME replace by call for disableconsistennetworkdevicenaming-string (distro dependent) $afi_kernel_string = $afi_kernel_string . " biosdevname=0 net.ifnames=0"; } #special kernel boot options $afi_kernel_string = $afi_kernel_string . " " . afi_get_const_array_key('AFI_CLIENT_CONF', 'kernelbootoptions'); return $afi_kernel_string; }