projects
/
mirror
/
dsa-puppet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove zobel-testlun, add adayevskaya
[mirror/dsa-puppet.git]
/
modules
/
roles
/
templates
/
static-mirroring
/
static-update-component.erb
diff --git
a/modules/roles/templates/static-mirroring/static-update-component.erb
b/modules/roles/templates/static-mirroring/static-update-component.erb
index
acb0294
..
2f70cfb
100755
(executable)
--- a/
modules/roles/templates/static-mirroring/static-update-component.erb
+++ b/
modules/roles/templates/static-mirroring/static-update-component.erb
@@
-21,39
+21,58
@@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-componentlist=/etc/static-components.conf
-
-if [ "$#" != 1 ]; then
+usage() {
echo >&2 "Usage: $0 <component>"
exit 1
echo >&2 "Usage: $0 <component>"
exit 1
+}
+
+componentlist=/etc/static-components.conf
+
+if [ "$#" = 1 ]; then
+ component="$1"
+else
+ usage
fi
fi
-component="$1"
if [ "${component%/*}" != "$component" ] ; then
echo >&2 "$0: Invalid component: $component";
exit 1
fi
if [ "${component%/*}" != "$component" ] ; then
echo >&2 "$0: Invalid component: $component";
exit 1
fi
+thishost=$(hostname -f)
srchost="$(awk -v component="$component" '$1 == component {print $2; exit}' "$componentlist")"
srcdir="$(awk -v component="$component" '$1 == component {print $3; exit}' "$componentlist")"
srchost="$(awk -v component="$component" '$1 == component {print $2; exit}' "$componentlist")"
srcdir="$(awk -v component="$component" '$1 == component {print $3; exit}' "$componentlist")"
+inextralist="$(
+ awk -v component="$component" -v host="$thishost" '
+ $1 == component {
+ split($4,extra,",")
+ for (i in extra) {
+ if (host == extra[i]) {
+ printf "%s:%s\n", $2, $3
+ exit
+ }
+ }
+ exit
+ }' "$componentlist"
+ )"
if [ -z "$srchost" ] || [ -z "$srcdir" ]; then
echo >&2 "$0: Invalid component: $component (not found in $componentlist)";
exit 1
fi
if [ -z "$srchost" ] || [ -z "$srcdir" ]; then
echo >&2 "$0: Invalid component: $component (not found in $componentlist)";
exit 1
fi
-if ! [ "$srchost" = "
`hostname -f`
" ]; then
- echo >&2 "Component $component is sourced from $srchost,
not this ho
st."
+if ! [ "$srchost" = "
$thishost" ] && [ -z "$inextralist
" ]; then
+ echo >&2 "Component $component is sourced from $srchost,
and this host is neither that nor in the extra allowed li
st."
exit 1
fi
exit 1
fi
-if ! [ -d "$srcdir" ]; then
+if
[ "$srchost" = "$thishost" ] &&
! [ -d "$srcdir" ]; then
echo >&2 "Component source directory $srcdir does not exist or is not a directory, or is not accessible."
exit 1
fi
if [ "`id -nu`" != "staticsync" ]; then
echo >&2 "Component source directory $srcdir does not exist or is not a directory, or is not accessible."
exit 1
fi
if [ "`id -nu`" != "staticsync" ]; then
- sudo -u staticsync static-update-component "$
component
"
+ sudo -u staticsync static-update-component "$
@
"
else
masters=()
<%=
else
masters=()
<%=
@@
-68,7
+87,7
@@
lines.join("\n")
%>
for master_idx in ${!masters[*]}; do
%>
for master_idx in ${!masters[*]}; do
- ssh -t -o ServerAliveInterval=300 -o PreferredAuthentications=publickey "${masters[$master_idx]}" static-master-update-component "$component"
+ ssh -
o AddressFamily=inet -
t -o ServerAliveInterval=300 -o PreferredAuthentications=publickey "${masters[$master_idx]}" static-master-update-component "$component"
done
fi
done
fi