macros.cfg specifies preprocessor text substitutions. Use macros to hide lower-level implementation details, also to write all-purpose, one-size-fits-all higher-level configurations. For ease of management, we have modularized this file into various #include files.
This is an elaborate samples macros.cfg file, with many specialized macros. A typical macros.cfg might be much simpler than this.
///////////////////////////////////////////////////////////////////////////////
//
// PIKT macros.cfg -- preprocessor text substitutions
//
///////////////////////////////////////////////////////////////////////////////
//
// it should be emphasized that this file (and all the other sample
// PIKT configuration files) serves at least the following purposes:
//
// --it is actual, though aliased, production code/data for our site
// --it is a sample set that the new user can refer to when creating his/her
// own configuration
// --it demos what PIKT can do
// --it is input for the PIKT validation self-tests
//
// if this file (and others) looks awfully complex in places, remember that
// this needn't be so: you can dispense with #ifdef directives entirely if
// you wish, and there is no law forcing you to use #if directives anywhere,
// or even macros for that matter; make your config files as simple or as
// complex as you wish
//
///////////////////////////////////////////////////////////////////////////////
//
// in earlier versions of PIKT, hostname was a standard macro that you had to
// define like so:
//
// hostname
// #if vienna
// vienna
// #elif madrid1
// madrid1
// ...
// #else
// unknown
// #endif
//
// not only is this a pain to set up, it is onerous to have to add or
// subtract new #elif clauses as machines come and go
//
// PIKT now supports several pre-defined, built-in macros:
//
// =piktdir resolves to the PIKT home directory
// =pikthostname resolves to the active host in the current
// piktc action
// =piktmaster resolves to the PIKT master control machine
// =pikthosts resolves to the list of PIKT host systems
// defined in systems.cfg
// =piktopsystems resolves to the list of operating systems
// specified in systems.cfg
// =piktnever resolves to a special timing string that
// signals piktd to bypass the current alert
//
// so, for example, you would now use =pikthostname where before you would
// use =hostname (that macro now resolves to the unix hostname command),
// except that you don't have to maintain the pikthostname definition
// yourself
//
// the following built-in macros are intended for PIKT.conf management:
//
// =piktuid resolves to the uid (as specified in keys.conf)
// for the current host
// =piktgid resolves to the gid (as specified in keys.conf)
// for the current host
// =piktprivate_key resolves to the private_key (as specified in
// keys.conf) for the current host
//
// the following built-in macros are useful for document formatting (and
// are especially important when defining other macros):
//
// =piktnullchar resolves to the null character
// (also: =_)
// =piktspacechar resolves to the space character
// =pikttabchar resolves to the tab character
// =piktnewlinechar resolves to the newline character
//
// these ten (eleven) macro identifiers are reserved and cannot be overridden
//
// additional pre-defined, built-in macros will appear in future PIKT
// versions as warranted
//
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// these macrodefs are all standard; leave them unchanged
bindir =piktdir/bin
etcdir =piktdir/etc
lokdir =piktdir/etc
cfgdir =piktdir/lib/configs
altdir =piktdir/lib/alerts
prgdir =piktdir/lib/programs
objdir =piktdir/lib/objects
hstdir =piktdir/var/histories
logdir =piktdir/var/log
stgdir =cfgdir/staging
difdir =cfgdir/diffing
piktfiltyp bin etc lok cfg alt prg fil obj hst log
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// standard includes; modify the individual include files in the macros
// directory as needed/indicated
#include <macros/adm/files_pikt_macros.cfg>
#include <macros/adm/unixcmds_macros.cfg>
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// standard constants macros
KB 1024
MB (=KB * =KB)
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// edit everything that follows as needed
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// debug macros
tracerule(S)
#ifdef debug
"rule $text(#rule()): " . (S)
#elsedef
(S)
#endifdef
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// exec process macros - process execution
#include <macros/adm/exec_process_macros.cfg>
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// output macros - script output
#include <macros/adm/output_macros.cfg>
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// input macros - script input
#include <macros/adm/input_macros.cfg>
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// data input macros - script data input
#include <macros/adm/data_input_macros.cfg>
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// pikt mail macros - pikt mail routing
#include <macros/adm/pikt_mail_macros.cfg>
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// date & time macros - date & time shortcuts
#include <macros/adm/date_time_macros.cfg>
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// scheduling macros
///////////////////////////////////////////////////////////////////////////////
offhours(H) // between 10 PM and 6 AM
((H) >= 22 || (H) < 6)
allhours(H) // any time of the day or night
#true()
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// text macros - text shortcuts
#include <macros/adm/text_macros.cfg>
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// counting macros
// assume 0 (zero) default value
incr(N) if ! #defined((N))
set (N) = 1
else
set (N) += 1
fi
decr(N) if ! #defined((N))
set (N) = -1
else
set (N) -= 1
fi
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// conditional macros - logical conditions
#include <macros/adm/condition_macros.cfg>
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// process macros - process shortcuts
#include <macros/adm/process_macros.cfg>
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// log macros
///////////////////////////////////////////////////////////////////////////////
notlogmsg ( #inputlength()
&& ($left($inline,3) !~ "=months")
)
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// file & disk macros - file & disk management
#include <macros/adm/file_disk_macros.cfg>
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// path macros - directory & file paths
#include <macros/adm/path_macros.cfg>
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// nis macros
nismaster nantes
nisserver
#include <systems/nisserver_systems.cfg>
domain_name egbdf.uppity.edu // so as not to conflict with
// =domainname def in
// unixcmds_*_macros.cfg file
ypservers /var/yp/binding/=domain_name/ypservers
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// accts macros
sysadmins brahms|bach|soler|purcell3
dbadmins leoncavallo|schubert|smetana|borodin
compsys schubert|smetana
nobody nobody|nobody4|noaccess
lockouts staff|faculty|student|gift|ftp|ph|class|http|gopher|operator
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// page macros
///////////////////////////////////////////////////////////////////////////////
page(M, R, H) // send a page message (M) to recipients (pager phone alias)
// (R) but only during hours (H)
// sample use: =page($host is sick/down, =pagesysadmins,
=allhours(#now()))
if (H)
=execwait "echo '(M)' | =mailx -s '(M)' (R)"
fi
///////////////////////////////////////////////////////////////////////////////
pagesysadmins pagejohann\@egbdf pagebrahms\@egbdf pageantonio\@egbdf
pagedbadmins pageruggero\@egbdf pagebedrich\@egbdf pageschubert\@egbdf
pagetest pagebrahms\@egbdf
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// backup macros
backup_alarms DumpDatesProblemsWarning
DumpDatesOutdatedWarning
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// systems macros
// note that the macros/sicksys_macros.cfg and macros/downsys_macros.cfg
// are actually softlinks to the corresponding systems/*_systems.cfg files
misscritsys
#include <systems/misscritsys_systems.cfg>
sicksys
=piktnullchar // placeholder to ensure stanza content even if
// the following #include/#verbatim file is empty
#verbatim <macros/sicksys_macros.cfg>
downsys
=piktnullchar // placeholder to ensure stanza content even if
// the following #include/#verbatim file is empty
#verbatim <macros/downsys_macros.cfg>
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// networking macros
addr2host(A) // for the given ipaddr (A), return the associated host (as
// resolved by nslookup)
// (A) is the ipaddr (e.g., 123.111.222.111)
$trim($command("=nslookup (A) 2>/dev/null | =grep '^Name:' |
=cut -d: -f2"))
///////////////////////////////////////////////////////////////////////////////
host2addr(H) // for the given host (H), return the associated addr (as
// resolved by nslookup)
// (H) is the host (e.g., hamburg.uppity.edu)
$trim($command("=nslookup (H) 2>/dev/null | =grep '^Address:' |
=tail +2 | =cut -d: -f2"))
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// network macros
ip_address_piktmaster // the ip addr, in dotted decimal, of the master
// control machine
123.111.222.101
ethernet_address_piktmaster 11:22:33:dd:ee:ff
ip_address_local_domains // the ip addrs, in dotted decimal, of our
// local domains
123.111.130|123.101.202|123.111.135|123.100.200
ip_address_sysadmins 123.111.222.102 // hamburg
123.111.222.103 // cadiz
123.111.222.104 // trondheim
// in our files/hosts_deny_files.cfg, for the file /etc/hosts.deny, we might
// have something like:
//
// #if vienna
// ALL : ALL EXCEPT 111.222.100.200 =ip_address_sysadmins
//
// ...
//
// we might have something similar in our files/hosts_allow_files.cfg;
// we might also use =ip_address_sysadmins when monitoring access logs,
// filtering out the connects from =ip_address_sysadmins, and reporting
// all the rest
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// dns stuff
nameddir /var/lib/named
zondir =nameddir/master
zonttl $TTL 3600
namedfiles
db.earlymusicradio.com
db.earlymusicradio.net
db.earlymusicradio.org
db.earlymusicchicago.com
db.earlymusicchicago.org
db.earlymusichicago.com
db.earlymusichicago.org
db.pikt.net
db.pikt.org
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
#include <macros/doc_macros.cfg>
#include <macros/html_macros.cfg>
#include <macros/adm/httpd_macros.cfg>
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
[For more examples, see Samples.]
Home |
FAQ |
News |
Intro |
Samples |
Tutorial |
Reference |
Software |
Authors |
Licensing |
SiteSearch
Links |
SiteIndex |
Pikt-Users |
Pikt-Workers |
Contribute |
ContactUs |
Top of Page
Page best viewed at 1024x768.
Page last updated 2005-06-22.
This site is
PIKT®
powered.
PIKT® is a registered trademark of the University of Chicago.
Copyright © 1998-2005 Robert Osterlund. All rights reserved.
|