[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Determine file to copy based on classes
From: |
Kai Großjohann |
Subject: |
Determine file to copy based on classes |
Date: |
Sat, 26 Oct 2002 16:47:49 +0200 |
User-agent: |
Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.3.50 (i686-pc-linux-gnu) |
Is there a way to implement something like the following algorithm in
CFengine?
/----
| repository=$CFINPUTS/../files # Repository of config files.
| file=etc/printcap # Config file to consider.
| prio="$HOST laptop desktop linux default"
|
| # Determine subset of $prio that is actually defined in $CFALLCLASSES.
| # Keep same order as in $prio.
| classes=""
| for x in $prio; do
| case :${CFALLCLASSES}: in
| :${x}:)
| classes="${x} ${classes}"
| ;;
| esac
| done
|
| # Now search for an existing file and copy the first file found.
| for c in $classes; do
| if [ -f $repository/$file/$c ]; then
| cp $repository/$file/$c /$file
| exit 0
| fi
| done
\----
What with all this automatic iteration over colon-separated lists and
so on it should be possible. But how?
The above is only meant to convey a general idea. It does not have
to be this exact logic. The issue is I want to write some files in
the repository and CFengine should automatically pick the "right"
one. And I don't want to write a file for each host. (Of course, it
would be easy to copy the file that's named like the host.) Instead,
I want to write files that are named after CFengine classes, and the
most specific file should be preferred.
kai
--
~/.signature is: umop ap!sdn (Frank Nobis)
- Determine file to copy based on classes,
Kai Großjohann <=