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_debug_var($varname, $var, $lvl = 1) { if (is_object($var)) { return; } $debug = afi_get_const_array_key('AFI_INI_SETTINGS', 'afi_app_debug'); if (!isset($debug)) { $debug = 0; } if ($debug <= $lvl) { return; } if (!isset($var)) { print "\n# DEBUG {$lvl} {$varname}: *NotSet* "; return; } if (is_array($var)) { print "\n# DEBUG {$lvl} {$varname}: "; array_walk_recursive($var, 'print_var_recursive'); } else { print "\n# DEBUG {$lvl} {$varname}: " . (string) $var . " "; } }
if (is_array($host_conf['post_classes'])) { foreach ($host_conf['post_classes'] as $postclassvalue) { print "# Trying to load " . $postclassvalue . ".chroot\n"; afi_require_file_and_override("post/{$postclassvalue}.chroot"); print "# End " . $postclassvalue . ".chroot \n"; print "\n"; } } print "# End postclasses - chroot\n"; print "\n"; if (afi_get_const_array_key('AFI_CLIENT_CONF', 'dist') == "oracle") { print "# hacky workaround to remove grub entry for kernel (we only want kernel-uek on oracle linux)\n"; print "for KERNEL in /boot/vmlinuz-2.6.32*; do /sbin/grubby --remove-kernel=\"\$KERNEL\";done\n"; print "\n"; } if (afi_get_const_array_key('AFI_CLIENT_CONF', 'unset_install_when_successfully_installed') === "1") { print "echo \"#unsetting host install to prevent install loop\"\n"; print afi_get_unset_url_command() . "\n"; } ?> } AFI_POST_LOG_DIR="/var/log/install/afi_post" mkdir -p "$AFI_POST_LOG_DIR" cp $0 "$AFI_POST_LOG_DIR/afi_post.script" chmod -x "$AFI_POST_LOG_DIR/afi_post.script" main 2>&1|tee "$AFI_POST_LOG_DIR/afi_post_nochroot_second.log"
function afi_part_get_installdisks_space() { $host_conf = afi_get_host_config(afi_get_const_array_key('AFI_INI_SETTINGS', 'afi_conf_dir'), afi_get_client_profile_name()); return implode(" ", $host_conf['install_disks']); }
function afi_unset_host_install() { $afi_conf_dir = afi_get_const_array_key('AFI_INI_SETTINGS', 'afi_conf_dir'); $hostname = afi_get_client_profile_name(); $afi_environment = afi_get_const_array_key('AFI_CLIENT_CONF', 'environment'); $installsymlink = $afi_conf_dir . "/hosts/" . $afi_environment . "/install/" . $hostname . ".conf"; if (file_exists($installsymlink)) { if (is_link($installsymlink)) { unlink($installsymlink); } } $afi_unset_url = afi_get_base_url_afi(TRUE) . "/unset_host_install.php"; }
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; }
<?php #### require_once libraries #### require_once './lib/libdebug.php'; require_once './lib/libconf.php'; #### process ini file #### $afi_ini = parse_ini_file("./afi.ini"); afi_set_const_array("AFI_INI_SETTINGS", parse_ini_file("./afi.ini")); #### host config #### #create host config afi_set_const_array('AFI_CLIENT_CONF', afi_get_host_config(afi_get_const_array_key('AFI_INI_SETTINGS', 'afi_conf_dir'), afi_get_client_profile_name())); # check if host config worked if (!afi_get_const_array_key('AFI_CLIENT_CONF', 'environment') || afi_get_const_array_key('AFI_CLIENT_CONF', 'environment') == "") { print "error loading host_conf\n"; exit(1); }