Listing 7 Services post-install script
<? require("post.inc"); ?>
#!/bin/bash
# Enable/disable services
<?
if (! $host) {
crit_err("Host not specified!");
}
// Get the list of services to enable/disable from the configs
$enable = get_host_var($host, "services", "enable");
$enable_add = get_host_var($host, "services", "enable_add");
$enable_remove = get_host_var($host, "services", "enable_remove");
$disable = get_host_var($host, "services", "disable");
$disable_add = get_host_var($host, "services", "disable_add");
$disable_remove = get_host_var($host, "services", "disable_remove");
$services = split(" ", $enable);
$aservices = split(" ", $enable_add);
$rservices = split(" ", $enable_remove);
$all_services = array_merge($services, $aservices);
foreach ($all_services as $svc) {
if ($svc) {
// Make sure this service hasn't been removed from the list of
// services to enable
if (! in_array($svc, $rservices) ) {
print "echo \"Enabling service $svc\"\n" .
"/sbin/chkconfig --levels 2345 $svc on\n";
}
}
}
print "\n";
$services = split(" ", $disable);
$aservices = split(" ", $disable_add);
$rservices = split(" ", $disable_remove);
$all_services = array_merge($services, $aservices);
foreach ($all_services as $svc) {
if ($svc) {
if (! in_array($svc, $rservices) ) {
print "echo \"Disabling service $svc\"\n" .
"/sbin/chkconfig --levels 2345 $svc off\n";
}
}
}
?>
|