A Little Configuration Management

Let's do a little configuration management.  Create a new file, /pikt/lib/configs/files.cfg, and give it the content:

///////////////////////////////////////////////////////////////////////////
//
// PIKT files.cfg
//
///////////////////////////////////////////////////////////////////////////

motd            path "/etc/motd" mode 644 uid 0 gid 0

// a standard blurb

        To read this message in full, use the command:  more /etc/motd
        To suppress display of this message, use the command:
                touch ~/.hushlogin

///////////////////////////////////////////////////////////////////////////

Note:  The whitespace before each "To ..." should be exactly one tab.  The preprocessor trims the first whitespace and applies the rest of the line exactly as written, so if a line in files.cfg begins with 8 spaces, 7 spaces will begin each line in the target file, which is probably not what you want.

Before installing your PIKT-managed motd file, diff it against any existing motd file:

/pikt/bin/piktc -fv +F motd +H mysystem

processing mysystem...
fetching file(s)...
motd fetched
diffing file(s)...
diff -r /pikt/lib/configs/staging/etc/motd
                /pikt/lib/configs/diffing/etc/motd
1,2c1
< To read this message in full, use the command:  more /etc/motd
< To suppress display of this message, use the command:  touch ~/.hushlogin
---
> Sun Microsystems Inc. SunOS 5.8       Generic April 2001

Oh, we have a difference!  Let's add what we're missing to our files.cfg:
///////////////////////////////////////////////////////////////////////////

motd            path "/etc/motd" mode 644 uid 0 gid 0

// a standard blurb

        Sun Microsystems Inc. SunOS 5.8       Generic April 2001

        To read this message in full, use the command:  more /etc/motd
        To suppress display of this message, use the command:
                touch ~/.hushlogin

///////////////////////////////////////////////////////////////////////////

(It goes without saying that you should add whatever is appropriate to your own situation.)

Note: The second line above (the one after the "Sun Microsystems...") is a single tab (then end-of-line).  When installed, this will create a blank line at that position.

Redo the diff:

/pikt/bin/piktc -fv +F motd +H mysystem

processing mysystem...
fetching file(s)...
motd fetched
diffing file(s)...
diff -r /pikt/lib/configs/staging/etc/motd
                /pikt/lib/configs/diffing/etc/motd
2,4c1
< 
< To read this message in full, use the command:  more /etc/motd
< To suppress display of this message, use the command:  touch ~/.hushlogin
---

Good enough.

When incorporating system configuration files into your PIKT configuration, your goal should initially be to match exactly what's on disk, so your 'piktc -f' commands should initially report no diffs.  Only after you are certain you've captured your configuration file(s) exactly should you begin applying significant changes in the files.cfg.

Finally, install your motd with the command

/pikt/bin/piktc -iv +F motd +H mysystem

processing mysystem...
installing file(s)...
motd installed

Check that the ownerships and permissions are as specified:
ls -l /etc/motd
-rw-r--r--   1 root     root          198 Sep 26 18:13 /etc/motd

And verify directly the contents of the motd file:
cat /etc/motd
Sun Microsystems Inc. SunOS 5.8       Generic April 2001

To read this message in full, use the command:  more /etc/motd
To suppress display of this message, use the command:  touch ~/.hushlogin

Before we leave this topic, let's see a listing of all PIKT pieces we've put in place so far:
/pikt/bin/piktc -lv +A all +F all +H mysystem

processing mysystem...
listing file(s)...
Critical.alt found
Debug.alt found
listing file(s)...
motd found

This is a rather trivial example, but it demonstrates the general technique.  Later, you will probably want to begin managing other system configuration files, for example inetd.conf, syslog.conf, and others, from the central PIKT configuration.

Before you move on to the concluding section of the Tutorial, remember to kill the piktd and piktc_svc daemons using the following commands:

/pikt/bin/piktc -k +H mysystem
/pikt/bin/piktc -K +H mysystem


prev page 1st page next page
 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2018-01-02.   This site is PIKT® powered.
Copyright © 1998-2018 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
Learn how to
develop a PIKT
configuration
, also
develop & test
Pikt scripts