author | Tero Marttila <terom@paivola.fi> |
Tue, 20 Mar 2012 12:43:51 +0200 | |
changeset 42 | ef5bcc4145de |
parent 41 | baae373b787e |
child 43 | b2ac0fd85828 |
permissions | -rwxr-xr-x |
2 | 1 |
#!/bin/bash |
2 |
# vim: set ft=sh : |
|
3 |
||
4 |
set -ue |
|
5 |
||
6 |
ROOT=$(pwd) |
|
7 |
||
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
8 |
# resolve $0 |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
9 |
self=$0 |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
10 |
while [ -L $self ]; do |
31
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
11 |
tgt=$(readlink $self) |
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
12 |
|
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
13 |
if [ "${tgt:0:1}" == "/" ]; then |
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
14 |
self=$tgt |
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
15 |
else |
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
16 |
self=$(dirname $self)/$tgt |
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
17 |
fi |
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
18 |
done |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
19 |
|
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
20 |
# bin dir |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
21 |
BIN=$(dirname $self) |
2 | 22 |
|
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
23 |
# data files |
21 | 24 |
DATA=settings |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
25 |
ZONES=zones |
21 | 26 |
SERIALS=$DATA |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
27 |
REPO= |
2 | 28 |
|
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
29 |
# data args |
2 | 30 |
PROCESS_ARGS='--input-charset latin-1' |
31 |
||
32 |
FORWARD_MX=mail |
|
33 |
REVERSE_ZONE=194.197.235 |
|
34 |
REVERSE_DOMAIN=paivola.fi |
|
35 |
||
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
36 |
# external progs |
10 | 37 |
NAMED_CHECKZONE=/usr/sbin/named-checkzone |
31
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
38 |
HG=/usr/bin/hg |
27 | 39 |
RNDC=/usr/sbin/rndc |
10 | 40 |
|
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
41 |
## options |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
42 |
IS_TTY= |
8 | 43 |
|
31
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
44 |
LOG_WARN=y |
8 | 45 |
LOG=y |
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
46 |
LOG_INFO=y |
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
47 |
LOG_SKIP= |
8 | 48 |
LOG_DEBUG= |
49 |
LOG_CMD= |
|
50 |
||
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
51 |
UPDATE_FORCE= |
8 | 52 |
UPDATE_NOOP= |
53 |
UPDATE_DIFF= |
|
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
54 |
SERIAL_NOUPDATE= |
21 | 55 |
COMMIT_SKIP= |
56 |
COMMIT_FORCE= |
|
22 | 57 |
COMMIT_MSG=' ' |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
58 |
|
27 | 59 |
DEPLOY_SKIP= |
60 |
||
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
61 |
function help_args { |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
62 |
local prog=$1 |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
63 |
|
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
64 |
cat <<END |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
65 |
Usage: $prog [options] |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
66 |
|
15 | 67 |
General: |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
68 |
-h display this help text |
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
69 |
-d DIR datadir |
8 | 70 |
|
15 | 71 |
Logging: |
8 | 72 |
-q quiet |
73 |
-v verbose |
|
74 |
-D debug |
|
21 | 75 |
-V debug commands |
8 | 76 |
|
15 | 77 |
Updates: |
9 | 78 |
-p show changes |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
79 |
-F force-updates without checking src mtime |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
80 |
-S do not update serial |
21 | 81 |
-n no-op/mock-update; don't actually change anything; implies -SpC |
82 |
||
83 |
Commit |
|
84 |
-C do not commit changes |
|
85 |
-c commit changes |
|
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
86 |
-m MSG commit message |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
87 |
END |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
88 |
} |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
89 |
|
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
90 |
function parse_args { |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
91 |
OPTIND=1 |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
92 |
|
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
93 |
while getopts 'hd:qvDVpFSnCcm:' opt "$@"; do |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
94 |
case $opt in |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
95 |
h) |
15 | 96 |
help_args $0 |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
97 |
exit 0 |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
98 |
;; |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
99 |
|
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
100 |
d) ROOT="$OPTARG" ;; |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
101 |
|
31
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
102 |
q) |
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
103 |
LOG= |
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
104 |
LOG_WARN= |
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
105 |
;; |
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
106 |
|
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
107 |
v) LOG_SKIP=y ;; |
16 | 108 |
D) |
109 |
LOG_DEBUG=y |
|
110 |
LOG_INFO=y |
|
111 |
;; |
|
21 | 112 |
V) LOG_CMD=y ;; |
113 |
||
9 | 114 |
p) UPDATE_DIFF=y ;; |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
115 |
F) UPDATE_FORCE=y ;; |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
116 |
S) SERIAL_NOUPDATE=y ;; |
8 | 117 |
|
118 |
n) |
|
119 |
UPDATE_NOOP=y |
|
9 | 120 |
# implies -Sp |
121 |
UPDATE_DIFF=y |
|
8 | 122 |
SERIAL_NOUPDATE=y |
21 | 123 |
COMMIT_SKIP=y |
27 | 124 |
DEPLOY_SKIP=y |
8 | 125 |
;; |
126 |
||
21 | 127 |
C) COMMIT_SKIP=y ;; |
128 |
c) COMMIT_FORCE=y ;; |
|
129 |
m) COMMIT_MSG="$OPTARG" ;; |
|
8 | 130 |
|
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
131 |
?) |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
132 |
die |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
133 |
;; |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
134 |
esac |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
135 |
|
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
136 |
done |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
137 |
} |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
138 |
|
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
139 |
## lib |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
140 |
function log_msg { |
2 | 141 |
echo "$*" >&2 |
142 |
} |
|
143 |
||
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
144 |
function log_color { |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
145 |
local code=$1; shift |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
146 |
|
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
147 |
if [ $IS_TTY ]; then |
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
148 |
echo $'\e['${code}'m'"$*"$'\e[00m' >&2 |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
149 |
else |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
150 |
echo "$*" >&2 |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
151 |
fi |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
152 |
} |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
153 |
|
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
154 |
function log_error { |
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
155 |
log_color '31' "$*" |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
156 |
} |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
157 |
|
31
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
158 |
function log_warn { |
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
159 |
[ $LOG_WARN ] && log_color '33' "$*" || true |
31
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
160 |
} |
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
161 |
|
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
162 |
function log { |
8 | 163 |
[ $LOG ] && log_msg "$*" || true |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
164 |
} |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
165 |
|
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
166 |
function log_info { |
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
167 |
[ $LOG_INFO ] && log_color '36' " $*" || true |
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
168 |
} |
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
169 |
|
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
170 |
function log_skip { |
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
171 |
[ $LOG_SKIP ] && log_color '1;34' " $*" || true |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
172 |
} |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
173 |
|
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
174 |
function log_debug { |
8 | 175 |
[ $LOG_DEBUG ] && log_color 32 " $*" || true |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
176 |
} |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
177 |
|
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
178 |
function log_cmd { |
8 | 179 |
[ $LOG_CMD ] && log_color 35 " \$ $*" || true |
180 |
} |
|
181 |
||
182 |
# XXX: broken |
|
183 |
function log_stack { |
|
184 |
local level=1 |
|
185 |
||
186 |
while info=$(caller $level); do |
|
187 |
echo $info | read line sub file |
|
188 |
||
189 |
log_msg "$file:$lineno $sub()" |
|
190 |
||
191 |
level=$(($level + 1)) |
|
192 |
done |
|
193 |
} |
|
194 |
||
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
195 |
function func_caller { |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
196 |
caller 1 | cut -d ' ' -f 2 |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
197 |
} |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
198 |
|
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
199 |
function debug { |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
200 |
printf -v prefix "%s" $(func_caller) |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
201 |
|
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
202 |
log_debug "$prefix: $*" |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
203 |
} |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
204 |
|
8 | 205 |
function fail { |
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
206 |
log_error "$(func_caller): $*" |
8 | 207 |
|
208 |
exit 2 |
|
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
209 |
} |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
210 |
|
2 | 211 |
function die { |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
212 |
log_error "$*" |
2 | 213 |
exit 1 |
214 |
} |
|
215 |
||
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
216 |
function cmd { |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
217 |
log_cmd "$@" |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
218 |
|
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
219 |
"$@" || die "Failed" |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
220 |
} |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
221 |
|
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
222 |
function run_cmd { |
2 | 223 |
local msg=$1; shift |
224 |
||
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
225 |
log_info "$msg... " |
2 | 226 |
|
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
227 |
cmd "$@" |
2 | 228 |
} |
229 |
||
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
230 |
function indent () { |
8 | 231 |
local indent=$1; shift |
232 |
||
18
826103fe3c8c
update: abspath; fixup serials log; indent log_cmd
Tero Marttila <terom@paivola.fi>
parents:
17
diff
changeset
|
233 |
log_cmd "$@" |
826103fe3c8c
update: abspath; fixup serials log; indent log_cmd
Tero Marttila <terom@paivola.fi>
parents:
17
diff
changeset
|
234 |
|
26
d2fdfe98b7b9
update: fix indent leading whitespace; implement update_hosts_meta, but not used - commit workflow becomes a little weird
Tero Marttila <terom@paivola.fi>
parents:
22
diff
changeset
|
235 |
"$@" | sed "s/^/$indent/" |
31
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
236 |
|
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
237 |
return ${PIPESTATUS[0]} |
18
826103fe3c8c
update: abspath; fixup serials log; indent log_cmd
Tero Marttila <terom@paivola.fi>
parents:
17
diff
changeset
|
238 |
} |
826103fe3c8c
update: abspath; fixup serials log; indent log_cmd
Tero Marttila <terom@paivola.fi>
parents:
17
diff
changeset
|
239 |
|
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
240 |
function ensure_dir { |
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
241 |
local dir=$1 |
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
242 |
|
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
243 |
if [ ! -d $ROOT/$dir ]; then |
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
244 |
log_warn "Creating output dir: $dir" |
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
245 |
cmd mkdir $ROOT/$dir |
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
246 |
fi |
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
247 |
} |
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
248 |
|
18
826103fe3c8c
update: abspath; fixup serials log; indent log_cmd
Tero Marttila <terom@paivola.fi>
parents:
17
diff
changeset
|
249 |
function abspath () { |
826103fe3c8c
update: abspath; fixup serials log; indent log_cmd
Tero Marttila <terom@paivola.fi>
parents:
17
diff
changeset
|
250 |
echo "$ROOT/$1" |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
251 |
} |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
252 |
|
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
253 |
## hg |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
254 |
function hg { |
39
57551a87a93e
update: hardcode $REPO in hg
Tero Marttila <terom@paivola.fi>
parents:
38
diff
changeset
|
255 |
local repo=$REPO; shift |
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
256 |
|
31
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
257 |
cmd $HG -R $ROOT/$repo "$@" |
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
258 |
} |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
259 |
|
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
260 |
function hg_modified { |
39
57551a87a93e
update: hardcode $REPO in hg
Tero Marttila <terom@paivola.fi>
parents:
38
diff
changeset
|
261 |
hg id | grep -q '+' |
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
262 |
} |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
263 |
|
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
264 |
function hg_user { |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
265 |
if [ ${SUDO_USER:-} ]; then |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
266 |
echo '-u' "$SUDO_USER" |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
267 |
|
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
268 |
elif [ $HOME ] && [ -e $HOME/.hgrc ]; then |
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
269 |
debug "using .hgrc user" |
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
270 |
echo '' |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
271 |
|
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
272 |
else |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
273 |
echo '-u' "$USER" |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
274 |
fi |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
275 |
} |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
276 |
|
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
277 |
function hg_diff { |
39
57551a87a93e
update: hardcode $REPO in hg
Tero Marttila <terom@paivola.fi>
parents:
38
diff
changeset
|
278 |
hg diff |
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
279 |
} |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
280 |
|
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
281 |
function hg_commit { |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
282 |
local msg=$2 |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
283 |
local user_opt=$(hg_user) |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
284 |
|
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
285 |
debug "$user_opt: $msg" |
39
57551a87a93e
update: hardcode $REPO in hg
Tero Marttila <terom@paivola.fi>
parents:
38
diff
changeset
|
286 |
hg commit $user_opt -m "$msg" |
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
287 |
} |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
288 |
|
2 | 289 |
|
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
290 |
## functions |
8 | 291 |
function check_update { |
292 |
# target |
|
293 |
local dst=$1; shift |
|
294 |
||
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
295 |
debug "$dst" |
8 | 296 |
|
297 |
# need update? |
|
298 |
local update= |
|
299 |
||
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
300 |
if [ ${#@} == 0 ]; then |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
301 |
debug " update: unknown deps" |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
302 |
update=y |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
303 |
|
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
304 |
elif [ ! -e $dst ]; then |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
305 |
debug " update: dest missing" |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
306 |
update=y |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
307 |
|
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
308 |
elif [ $UPDATE_FORCE ]; then |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
309 |
debug " update: forced" |
8 | 310 |
update=y |
311 |
fi |
|
312 |
||
313 |
# check deps |
|
314 |
for dep in "$@"; do |
|
315 |
# don't bother checking if already figured out |
|
316 |
[ $update ] && continue |
|
317 |
||
318 |
# check |
|
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
319 |
if [ ! -e $ROOT/$dep ]; then |
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
320 |
fail "$dst: Missing source: $dep" |
8 | 321 |
|
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
322 |
elif [ $ROOT/$dst -ot $ROOT/$dep ]; then |
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
323 |
debug " update: $dep" |
8 | 324 |
update=y |
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
325 |
else |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
326 |
debug " check: $dep" |
8 | 327 |
fi |
328 |
done |
|
329 |
||
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
330 |
[ ! $update ] && debug " up-to-date" |
8 | 331 |
|
332 |
# return |
|
333 |
[ $update ] |
|
334 |
} |
|
335 |
||
336 |
function do_update { |
|
337 |
local dst=$1; shift |
|
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
338 |
local tmp=$dst.new |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
339 |
|
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
340 |
debug "$dst" |
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
341 |
cmd "$@" > $ROOT/$tmp |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
342 |
|
8 | 343 |
# compare |
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
344 |
if [ -e $ROOT/$dst ] && [ $UPDATE_DIFF ]; then |
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
345 |
debug " changes:" |
8 | 346 |
|
347 |
# terse |
|
32
694dab02a6b0
update: do_update: ignore diff error exit
Tero Marttila <terom@paivola.fi>
parents:
31
diff
changeset
|
348 |
indent " " diff --unified=1 $ROOT/$dst $ROOT/$tmp || true |
8 | 349 |
fi |
350 |
||
351 |
if [ $UPDATE_NOOP ]; then |
|
352 |
# cleanup |
|
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
353 |
debug " no-op" |
8 | 354 |
|
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
355 |
cmd rm $ROOT/$tmp |
8 | 356 |
else |
357 |
# commit |
|
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
358 |
debug " commit" |
8 | 359 |
|
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
360 |
cmd mv $ROOT/$tmp $ROOT/$dst |
8 | 361 |
fi |
362 |
} |
|
363 |
||
364 |
function update { |
|
365 |
local dst=$1; shift; |
|
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
366 |
local msg=$1; shift |
8 | 367 |
|
368 |
local sep= |
|
369 |
local dep=() |
|
370 |
local cmd=() |
|
371 |
||
372 |
for arg in "$@"; do |
|
373 |
if [ $arg == '--' ]; then |
|
374 |
sep=y |
|
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
375 |
fi |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
376 |
|
8 | 377 |
if [ $sep ]; then |
378 |
cmd=("${cmd[@]:-}" "$arg") |
|
379 |
else |
|
380 |
dep=("${dep[@]:-}" "$arg") |
|
381 |
fi |
|
382 |
done |
|
383 |
||
384 |
[ ! $sep ] && fail "Invalid args given: $@" |
|
385 |
||
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
386 |
if check_update $dst "${dep[@]}"; then |
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
387 |
log_info "$msg..." |
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
388 |
|
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
389 |
do_update $dst "${cmd[@]}" |
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
390 |
else |
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
391 |
log_skip "$msg: not changed" |
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
392 |
|
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
393 |
fi |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
394 |
} |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
395 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
396 |
function check_link { |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
397 |
local lnk=$1 |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
398 |
local tgt=$2 |
14
b883ef452cd8
fix handling of initial serial
Tero Marttila <terom@paivola.fi>
parents:
13
diff
changeset
|
399 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
400 |
[ ! -e $ROOT/$lnk ] || [ $(readlink $ROOT/$lnk) != $ROOT/$tgt ] |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
401 |
} |
8 | 402 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
403 |
function do_link { |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
404 |
local lnk=$1 |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
405 |
local tgt=$2 |
8 | 406 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
407 |
cmd ln -sf $ROOT/$tgt $ROOT/$lnk |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
408 |
} |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
409 |
|
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
410 |
## hosts |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
411 |
# copy hosts input zone verbatim |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
412 |
function copy_hosts { |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
413 |
local zone=$1 |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
414 |
local base=$2 |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
415 |
|
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
416 |
if check_update $zone $base; then |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
417 |
log_info "Copying hosts $zone <- $base..." |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
418 |
|
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
419 |
do_update $zone \ |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
420 |
cat $ROOT/$base |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
421 |
else |
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
422 |
log_skip "Copying hosts $zone <- $base: not changed" |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
423 |
fi |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
424 |
} |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
425 |
|
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
426 |
# generate hosts zone from input zone |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
427 |
function update_hosts { |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
428 |
local zone=$1; shift |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
429 |
local base=$1; shift |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
430 |
|
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
431 |
if check_update $zone $base; then |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
432 |
log_info "Generating hosts $zone <- $base..." |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
433 |
|
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
434 |
do_update $zone \ |
40 | 435 |
$BIN/process-zone $PROCESS_ARGS $ROOT/$base "$@" |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
436 |
else |
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
437 |
log_skip "Generating hosts $zone <- $base: not changed" |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
438 |
fi |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
439 |
} |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
440 |
|
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
441 |
## actions |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
442 |
# serial |
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
443 |
function do_update_serial { |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
444 |
local serial=$1 |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
445 |
|
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
446 |
# read |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
447 |
local old=$(test -e $ROOT/$serial && cat $ROOT/$serial || echo '') |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
448 |
|
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
449 |
|
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
450 |
cmd $BIN/update-serial $ROOT/$serial |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
451 |
|
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
452 |
# read |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
453 |
local new=$(cat $ROOT/$serial) |
8 | 454 |
|
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
455 |
debug " $old -> $new" |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
456 |
} |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
457 |
|
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
458 |
function update_serial { |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
459 |
local zone=$1; shift |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
460 |
|
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
461 |
local serial=$SERIALS/$zone.serial |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
462 |
|
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
463 |
# test |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
464 |
if ! check_update $serial "$@"; then |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
465 |
log_skip "Updating $serial: not changed" |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
466 |
|
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
467 |
elif [ $SERIAL_NOUPDATE ]; then |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
468 |
log_skip "Updating $serial: skipped" |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
469 |
|
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
470 |
else |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
471 |
log_info "Updating $serial..." |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
472 |
|
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
473 |
do_update_serial $serial |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
474 |
fi |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
475 |
} |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
476 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
477 |
function link_serial { |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
478 |
local zone=$1 |
36
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
479 |
local base=$2 |
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
480 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
481 |
local lnk=$SERIALS/$zone.serial |
36
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
482 |
local tgt=$SERIALS/$base.serial |
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
483 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
484 |
if check_link $lnk $tgt; then |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
485 |
log_info "Linking $lnk -> $tgt..." |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
486 |
|
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
487 |
do_link $lnk $tgt |
36
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
488 |
|
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
489 |
else |
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
490 |
log_skip "Linking $lnk -> $tgt: not changed" |
36
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
491 |
fi |
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
492 |
} |
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
493 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
494 |
# zone |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
495 |
function copy_zone { |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
496 |
local view=$1 |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
497 |
local zone=$2 |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
498 |
local base=${3:-$zone} |
2 | 499 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
500 |
local out=$ZONES/$view/$zone |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
501 |
local src=$DATA/$base |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
502 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
503 |
if check_update $out $src; then |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
504 |
log_info "Copying $out <- $src..." |
8 | 505 |
|
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
506 |
do_update $out \ |
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
507 |
cat $ROOT/$src |
8 | 508 |
else |
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
509 |
log_skip "Copying $out <- $src: not changed" |
8 | 510 |
fi |
2 | 511 |
} |
512 |
||
513 |
function update_zone { |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
514 |
local view=$1 |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
515 |
local zone=$2 |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
516 |
local base=${3:-$zone} |
8 | 517 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
518 |
local out=$ZONES/$view/$zone |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
519 |
local src=$DATA/$base.zone |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
520 |
local lnk=$ZONES/$base |
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
521 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
522 |
local serial=$SERIALS/$base.serial |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
523 |
|
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
524 |
if check_update $out $src $serial; then |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
525 |
log_info "Generating $out <- $src..." |
8 | 526 |
|
527 |
do_update $out \ |
|
40 | 528 |
$BIN/expand-zone $ROOT/$src \ |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
529 |
--serial $ROOT/$serial \ |
18
826103fe3c8c
update: abspath; fixup serials log; indent log_cmd
Tero Marttila <terom@paivola.fi>
parents:
17
diff
changeset
|
530 |
--expand zones=$(abspath $ZONES) \ |
8 | 531 |
--expand view=$view |
532 |
else |
|
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
533 |
log_skip "Generating $out <- $src: not changed" |
8 | 534 |
fi |
535 |
} |
|
536 |
||
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
537 |
function link_zone { |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
538 |
local view=$1 |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
539 |
local zone=$2 |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
540 |
local base=${3:-$zone} |
36
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
541 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
542 |
local out=$ZONES/$view/$zone |
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
543 |
|
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
544 |
# find tgt |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
545 |
for tgt in $ZONES/$view/$base $ZONES/common/$base; do |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
546 |
[ $tgt != $out ] && [ -e $tgt ] && break |
36
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
547 |
done |
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
548 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
549 |
if check_link $out $tgt; then |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
550 |
log_info "Linking $out -> $tgt..." |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
551 |
|
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
552 |
do_link $out $tgt |
30
1a8bc67b1eb7
update: link_zones for paivola.*.zone -> paivola.zone
Tero Marttila <terom@paivola.fi>
parents:
29
diff
changeset
|
553 |
else |
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
554 |
log_skip "Linking $out -> $tgt: not changed" |
30
1a8bc67b1eb7
update: link_zones for paivola.*.zone -> paivola.zone
Tero Marttila <terom@paivola.fi>
parents:
29
diff
changeset
|
555 |
fi |
1a8bc67b1eb7
update: link_zones for paivola.*.zone -> paivola.zone
Tero Marttila <terom@paivola.fi>
parents:
29
diff
changeset
|
556 |
} |
1a8bc67b1eb7
update: link_zones for paivola.*.zone -> paivola.zone
Tero Marttila <terom@paivola.fi>
parents:
29
diff
changeset
|
557 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
558 |
## Tests |
13 | 559 |
function check_hosts { |
560 |
local hosts=$1; shift 1 |
|
561 |
||
40 | 562 |
local cmd=($BIN/process-zone $PROCESS_ARGS $ROOT/$hosts --check-hosts "$@") |
13 | 563 |
|
564 |
if "${cmd[@]}" -q; then |
|
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
565 |
log_skip "Check $hosts: OK" |
13 | 566 |
else |
567 |
log_error " Check $hosts: Failed" |
|
568 |
||
569 |
indent " " "${cmd[@]}" |
|
570 |
||
571 |
exit 1 |
|
572 |
fi |
|
573 |
} |
|
574 |
||
10 | 575 |
function check_zone { |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
576 |
local view=$1 |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
577 |
local zone=$2 |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
578 |
local origin=$3 |
10 | 579 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
580 |
local src=$ZONES/$view/$zone |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
581 |
|
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
582 |
local cmd=($NAMED_CHECKZONE $origin $ROOT/$src) |
13 | 583 |
|
10 | 584 |
# test |
13 | 585 |
# XXX: checkzone is very specific about the order of arguments, -q must be first |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
586 |
if $NAMED_CHECKZONE -q $origin $ROOT/$src; then |
41
baae373b787e
update: log_skip; simplify update_serial args; check_update tests for deps
Tero Marttila <terom@paivola.fi>
parents:
40
diff
changeset
|
587 |
log_skip "Check $src ($origin): OK" |
10 | 588 |
else |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
589 |
log_error " Check $src ($origin): Failed:" |
10 | 590 |
|
13 | 591 |
indent " " "${cmd[@]}" |
592 |
||
593 |
exit 1 |
|
10 | 594 |
fi |
595 |
} |
|
596 |
||
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
597 |
## Deploy |
27 | 598 |
# deploy new zone data to bind |
599 |
function deploy_zones { |
|
31
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
600 |
indent " rndc: " $RNDC reload |
27 | 601 |
} |
602 |
||
21 | 603 |
# commit data changes |
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
604 |
function commit_data { |
39
57551a87a93e
update: hardcode $REPO in hg
Tero Marttila <terom@paivola.fi>
parents:
38
diff
changeset
|
605 |
local repo=$REPO |
21 | 606 |
|
39
57551a87a93e
update: hardcode $REPO in hg
Tero Marttila <terom@paivola.fi>
parents:
38
diff
changeset
|
607 |
if hg_modified; then |
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
608 |
log_info "Commit changes in $repo:" |
21 | 609 |
|
39
57551a87a93e
update: hardcode $REPO in hg
Tero Marttila <terom@paivola.fi>
parents:
38
diff
changeset
|
610 |
indent " " hg_diff |
21 | 611 |
|
39
57551a87a93e
update: hardcode $REPO in hg
Tero Marttila <terom@paivola.fi>
parents:
38
diff
changeset
|
612 |
hg_commit "$COMMIT_MSG" |
21 | 613 |
else |
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
614 |
log_info "Commit changes in $repo: no changes" |
21 | 615 |
fi |
616 |
} |
|
617 |
||
2 | 618 |
function main { |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
619 |
# test tty |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
620 |
[ -t 1 ] && IS_TTY=y |
31
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
621 |
|
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
622 |
parse_args "$@" |
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
623 |
|
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
624 |
## test env |
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
625 |
[ -d $ROOT/$DATA ] || die "Missing data: $ROOT/$DATA" |
31
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
626 |
ensure_dir $ZONES |
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
627 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
628 |
# output dirs |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
629 |
local views=(internal external) |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
630 |
|
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
631 |
for view in "${views[@]}" "common" "hosts" "includes"; do |
31
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
632 |
ensure_dir $ZONES/$view |
2b7aad3466c6
update: log_warn, -q; ensure_dir; link_zone paivola-reverse; indent error exit
Tero Marttila <terom@paivola.fi>
parents:
30
diff
changeset
|
633 |
done |
28
647f6de0d0ac
update: implement -d for $ROOT
Tero Marttila <terom@paivola.fi>
parents:
27
diff
changeset
|
634 |
|
27 | 635 |
## hosts |
636 |
# test |
|
13 | 637 |
log "Testing hosts..." |
21 | 638 |
check_hosts $DATA/paivola.txt --check-exempt ufc |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
639 |
|
27 | 640 |
# update |
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
641 |
log "Generating host zones..." |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
642 |
# zone base *args |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
643 |
update_hosts $ZONES/hosts/paivola:internal $DATA/paivola.txt --forward-zone --forward-txt --forward-mx $FORWARD_MX |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
644 |
update_hosts $ZONES/hosts/paivola:external $DATA/paivola.txt --forward-zone |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
645 |
update_hosts $ZONES/hosts/194.197.235 $DATA/paivola.txt --reverse-zone $REVERSE_ZONE --reverse-domain $REVERSE_DOMAIN |
36
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
646 |
|
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
647 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
648 |
update_hosts $ZONES/hosts/10 $DATA/pvl.txt --reverse-zone 10 --reverse-domain pvl -q |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
649 |
update_hosts $ZONES/hosts/192.168 $DATA/pvl.txt --reverse-zone 192.168 --reverse-domain pvl -q |
36
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
650 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
651 |
# XXX: unsupported --forward-zone with pvl.txt |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
652 |
# update_hosts $ZONES/hosts/pvl $DATA/pvl.txt --forward-zone |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
653 |
copy_hosts $ZONES/hosts/pvl $DATA/pvl.txt |
2 | 654 |
|
27 | 655 |
## zones |
656 |
# parts |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
657 |
log "Copying zone includes..." |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
658 |
# view zone base |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
659 |
copy_zone includes paivola:internal paivola.zone.internal |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
660 |
copy_zone includes paivola:external paivola.zone.external |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
661 |
copy_zone includes paivola.auto paivola.zone.auto |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
662 |
copy_zone includes paivola.services paivola.zone.services |
2 | 663 |
|
27 | 664 |
# serials |
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
665 |
log "Updating serials..." |
18
826103fe3c8c
update: abspath; fixup serials log; indent log_cmd
Tero Marttila <terom@paivola.fi>
parents:
17
diff
changeset
|
666 |
|
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
667 |
# zone *deps |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
668 |
update_serial pvl $ZONES/hosts/pvl $DATA/pvl.zone |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
669 |
update_serial 10 $ZONES/hosts/10 $DATA/10.zone |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
670 |
update_serial 192.168 $ZONES/hosts/192.168 $DATA/192.168.zone |
36
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
671 |
|
42
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
672 |
update_serial paivola \ |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
673 |
$ZONES/hosts/paivola:* \ |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
674 |
$DATA/paivola.zone \ |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
675 |
$ZONES/includes/paivola:* \ |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
676 |
$ZONES/includes/paivola.* |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
677 |
|
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
678 |
update_serial 194.197.235 \ |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
679 |
$ZONES/hosts/194.197.235 \ |
ef5bcc4145de
debug with func_caller; update_serial deps
Tero Marttila <terom@paivola.fi>
parents:
41
diff
changeset
|
680 |
$DATA/194.197.235.zone |
13 | 681 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
682 |
# zones |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
683 |
log "Updating zones..." |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
684 |
# view zone base |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
685 |
update_zone internal pvl |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
686 |
update_zone internal paivola |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
687 |
update_zone external paivola |
10 | 688 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
689 |
update_zone internal 10 |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
690 |
update_zone internal 192.168 |
36
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
691 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
692 |
update_zone common 194.197.235 |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
693 |
link_zone internal 194.197.235 |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
694 |
link_zone external 194.197.235 |
36
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
695 |
|
27 | 696 |
# test |
10 | 697 |
log "Testing zones..." |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
698 |
# view zone origin |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
699 |
check_zone internal paivola paivola.fi |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
700 |
check_zone external paivola paivola.fi |
36
3208cd6540dc
update: restructure zones/, manage .pvl
Tero Marttila <terom@paivola.fi>
parents:
32
diff
changeset
|
701 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
702 |
check_zone internal 10 10.in-addr.arpa |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
703 |
check_zone internal 192.168 192.168.in-addr.arpa |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
704 |
check_zone common 194.197.235 235.197.194.in-addr.arpa |
10 | 705 |
|
30
1a8bc67b1eb7
update: link_zones for paivola.*.zone -> paivola.zone
Tero Marttila <terom@paivola.fi>
parents:
29
diff
changeset
|
706 |
# extra zones... |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
707 |
local base=paivola |
30
1a8bc67b1eb7
update: link_zones for paivola.*.zone -> paivola.zone
Tero Marttila <terom@paivola.fi>
parents:
29
diff
changeset
|
708 |
local link_zones=(paivola.fi paivola.net paivola.org paivola.info paivola.mobi xn--pivl-load8j.fi) |
1a8bc67b1eb7
update: link_zones for paivola.*.zone -> paivola.zone
Tero Marttila <terom@paivola.fi>
parents:
29
diff
changeset
|
709 |
|
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
710 |
log "Linking zones..." |
30
1a8bc67b1eb7
update: link_zones for paivola.*.zone -> paivola.zone
Tero Marttila <terom@paivola.fi>
parents:
29
diff
changeset
|
711 |
for view in "${views[@]}"; do |
1a8bc67b1eb7
update: link_zones for paivola.*.zone -> paivola.zone
Tero Marttila <terom@paivola.fi>
parents:
29
diff
changeset
|
712 |
for zone in "${link_zones[@]}"; do |
38
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
713 |
link_zone $view $zone $base |
39799fc994e9
update: unify [check/copy/update/link]_[hosts/zone/serial]
Tero Marttila <terom@paivola.fi>
parents:
37
diff
changeset
|
714 |
check_zone $view $zone $zone |
30
1a8bc67b1eb7
update: link_zones for paivola.*.zone -> paivola.zone
Tero Marttila <terom@paivola.fi>
parents:
29
diff
changeset
|
715 |
done |
1a8bc67b1eb7
update: link_zones for paivola.*.zone -> paivola.zone
Tero Marttila <terom@paivola.fi>
parents:
29
diff
changeset
|
716 |
done |
1a8bc67b1eb7
update: link_zones for paivola.*.zone -> paivola.zone
Tero Marttila <terom@paivola.fi>
parents:
29
diff
changeset
|
717 |
|
27 | 718 |
## deploy |
719 |
if [ $DEPLOY_SKIP ]; then |
|
720 |
log "Deploy zones: skipped" |
|
21 | 721 |
|
27 | 722 |
else |
723 |
log "Deploy zones..." |
|
724 |
||
725 |
deploy_zones |
|
726 |
fi |
|
727 |
||
728 |
## commit |
|
21 | 729 |
if [ $COMMIT_SKIP ] && [ ! $COMMIT_FORCE ]; then |
730 |
log "Commit data: skipped" |
|
731 |
||
732 |
else |
|
733 |
log "Commit data..." |
|
39
57551a87a93e
update: hardcode $REPO in hg
Tero Marttila <terom@paivola.fi>
parents:
38
diff
changeset
|
734 |
commit_data |
21 | 735 |
fi |
2 | 736 |
} |
737 |
||
7
f4457348faa0
update: function update { ... }, color logging, update_serial
Tero Marttila <terom@paivola.fi>
parents:
2
diff
changeset
|
738 |
main "$@" |