krebs.backup network-ssh-port: fail if cannot find port

This commit is contained in:
tv 2016-04-17 04:13:32 +02:00
parent 453384b60b
commit affb69250d
3 changed files with 9 additions and 6 deletions

View File

@ -120,11 +120,11 @@ let
dst_exec() { dst_exec() {
exec ssh -F /dev/null \ exec ssh -F /dev/null \
-i "$identity" \ -i "$identity" \
''${dst_port:+-p $dst_port} \ -p $dst_port \
"$dst_user@$dst_host" \ "$dst_user@$dst_host" \
-T "exec$(printf ' %q' "$@")" -T "exec$(printf ' %q' "$@")"
} }
rsh="ssh -F /dev/null -i $identity ''${dst_port:+-p $dst_port}" rsh="ssh -F /dev/null -i $identity -p $dst_port"
local_rsync() { local_rsync() {
rsync "$@" rsync "$@"
} }
@ -146,7 +146,7 @@ let
dst_exec() { dst_exec() {
exec "$@" exec "$@"
} }
rsh="ssh -F /dev/null -i $identity ''${src_port:+-p $src_port}" rsh="ssh -F /dev/null -i $identity -p $src_port"
local_rsync() { local_rsync() {
mkdir -m 0700 -p ${shell.escape plan.dst.path}/current mkdir -m 0700 -p ${shell.escape plan.dst.path}/current
flock -n ${shell.escape plan.dst.path} rsync "$@" flock -n ${shell.escape plan.dst.path} rsync "$@"
@ -231,6 +231,9 @@ let
${concatStringsSep ";;\n" (mapAttrsToList ${concatStringsSep ";;\n" (mapAttrsToList
(_: net: "(${head net.aliases}) echo ${toString net.ssh.port}") (_: net: "(${head net.aliases}) echo ${toString net.ssh.port}")
host.nets)};; host.nets)};;
(*)
echo network-ssh-port: unhandled case: ${word} >&2
exit 1
esac esac
''; '';

View File

@ -218,7 +218,7 @@ let
(filter (hasSuffix ".${cfg.search-domain}") (filter (hasSuffix ".${cfg.search-domain}")
longs); longs);
add-port = a: add-port = a:
if net.ssh.port != null if net.ssh.port != 22
then "[${a}]:${toString net.ssh.port}" then "[${a}]:${toString net.ssh.port}"
else a; else a;
in in

View File

@ -117,8 +117,8 @@ types // rec {
type = submodule { type = submodule {
options = { options = {
port = mkOption { port = mkOption {
type = nullOr int; type = int;
default = null; default = 22;
}; };
}; };
}; };