#!/usr/bin/php -q # # This program is intended to install machine-specific configuration files # after using SystemImager to install a system. It does so by copying # a machine-specific file to the appropriate file name. For example, # after figuring out that we are on box "bar" and we need a "/etc/foo" # file and a file named "/etc/foo.bar" exists, this script will do some # thinking, and then execute: # # cp -f /etc/foo.bar /etc/foo # # To run this program on boot, make sure MachineConf is in your /sbin # directory and add the following line to the top of your # /etc/rc.d/rc file: # # action $"Enabling machine-specific configuration files: " /sbin/MachineConf # ########################################################################## # MAC Addresses for all the machines we need to consider $Machine["00:03:CE:01:A6:10"] = "vmpbox1"; $Machine["00:03:CE:01:B1:10"] = "vmpwww"; # This is the list of files we want to check for $file[] = "/etc/dhcpd.conf"; #$file[] = "/etc/exports"; # Let's find out which machine we're on $exec = exec("/sbin/ifconfig | /bin/grep HWaddr", $result); for ($i = 0; $i < count($result); $i++) { $array = explode("HWaddr ", $result[$i]); $MAC = trim($array[1]); if ($This_Machine = $Machine[$MAC]) break; } # Now if a file doesn't exist, enable the file by copying the # machine-specific file to the right location for ($i = 0; $i < count($file); $i++) { $filename = $file[$i] . "." . $This_Machine; if (file_exists($filename)) { $exec = exec("/bin/cp -f $filename $file[$i]"); } } ?>