~mdw
/
zoneconf
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e83cb95
)
bin/zoneconf: Abstract out command substitution machinery.
author
Mark Wooding
<mdw@distorted.org.uk>
Sat, 3 Dec 2011 19:26:48 +0000
(19:26 +0000)
committer
Mark Wooding
<mdw@distorted.org.uk>
Sat, 3 Dec 2011 19:29:09 +0000
(19:29 +0000)
bin/zoneconf
patch
|
blob
|
blame
|
history
diff --git
a/bin/zoneconf
b/bin/zoneconf
index
820f62f
..
7ee6d6a
100755
(executable)
--- a/
bin/zoneconf
+++ b/
bin/zoneconf
@@
-1037,6
+1037,17
@@
define-configuration-space toplevel ZONECFG {
###--------------------------------------------------------------------------
### Processing the results.
###--------------------------------------------------------------------------
### Processing the results.
+proc build-command {command args} {
+ ## Return the COMMAND list, after applying the string map ARGS to each item
+ ## in turn.
+
+ set cmd {}
+ foreach item $command {
+ lappend cmd [string map $args $item]
+ }
+ return $cmd
+}
+
proc zone-file-name {view config} {
## Return the relative file name for the zone described by CONFIG, relative
## to the given VIEW. An absolute filename may be derived later, depending
proc zone-file-name {view config} {
## Return the relative file name for the zone described by CONFIG, relative
## to the given VIEW. An absolute filename may be derived later, depending
@@
-1297,14
+1308,11
@@
provided by the named USER"
}
close $chan
}
close $chan
- set cmd {}
- foreach item $zone(checkzone-command) {
- lappend cmd [string map [list \
- "%z" $name \
- "%v" $view \
- "%f" $tmp] \
- $item]
- }
+ ## Check the zone for sanity.
+ set cmd [build-command $zone(checkzone-command) \
+ "%z" $name \
+ "%v" $view \
+ "%f" $tmp]
set rc [catch {
set out [eval exec $cmd]
} msg]
set rc [catch {
set out [eval exec $cmd]
} msg]
@@
-1322,14
+1330,9
@@
provided by the named USER"
file rename -force -- $tmp $zone(file-name)
set cleanup {}
foreach view $matchview {
file rename -force -- $tmp $zone(file-name)
set cleanup {}
foreach view $matchview {
- set cmd {}
- foreach item $zone(reload-command) {
- lappend cmd [string map [list \
- "%v" $view \
- "%z" $zone(name)] \
- $item]
- }
- eval exec $cmd
+ eval exec $cmd [build-command $zone(reload-command) \
+ "%v" $view \
+ "%z" $zone(name)]
}
} {
eval $cleanup
}
} {
eval $cleanup