Chapter 1 - Appendix : A Starter Script
This section presents a starter script which you can use to get going.
Starter Script
#!/usr/local/bin/php
<?php
$LOGLEVEL=4;
$Automated_Agent_PrivKey="./ssh/tlalockeys";
$Node_OS=trim(`uname -s`);
$Node_OSVersion=trim(`uname -r`);
$Node_Name=trim(`hostname`);
$Node_Platform=trim(`uname -p`);
$File_Repositories=array("repo_user@10.10.10.100:Tlaloc/");
$Package_Repositories=array("ftp://repo_user:mypassword@10.10.10.100/$Node_OSVersion/packages/$Node_Platform/");
require 'Tlaloc.php';
$File=new Tlaloc_File($File_Repositories,$Automated_Agent_PrivKey,array("*.old","*.LCK"));
$Package=new Package($Package_Repositories);
$User=new User();
$Service = new Service($File);
if (preg_match("/^.*\.servers\.domain\.ext$/",$Node_Name)) {
// we are part of the *.servers.domain.ext group
require 'recipes/base_servers.php';
}
if (preg_match("/ns\-[0-9]*\.dmz\..*/",$Node_Name) ) {
// We are a name server in the DMZ, authoritative for DNS & NTP service.
// ie: ns-[01].dmz.*
require 'recipes/dns_authoritative.php';
}
if (preg_match("/app\-[0-9]*\.dmz\..*/",$Node_Name) ) {
// We are an app web server in the DMZ
// ie: app-[01].dmz.*
$File->Replace_Line("/etc/ntpd.conf","^Server ","Server ntp.dmz.domain.com");
$Service->Start("ntpd");
$Package->Install("mini_sendmail");
$Package->Install("php");
$Service->Setup("nginx");
}