use __remote_{exec,copy} instead of plain ssh/scp in remote exec scripts

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2017-08-29 21:49:47 +02:00
parent e9f8cb6f49
commit 04c8415060
2 changed files with 7 additions and 11 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
#!/bin/sh -e
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
# 2011-2017 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
@ -32,8 +32,6 @@ log() {
chroot="$1"; shift
target_host="$__target_host"
scp="scp -o User=root -q"
# postfix target_host with chroot location
code="$(echo "$@" | sed "s|$target_host:|$target_host:$chroot|g")"
@ -43,6 +41,6 @@ log "@: $@"
log "code: $code"
# copy files into chroot
$scp $code
$__remote_copy $code
log "-----"

View File

@ -1,6 +1,6 @@
#!/bin/sh
#!/bin/sh -e
#
# 2011-2013 Steven Armstrong (steven-cdist at armstrong.cc)
# 2011-2017 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
@ -34,11 +34,9 @@ target_host="$__target_host"
# In exec mode the first argument is the __target_host which we already got from env. Get rid of it.
shift
ssh="ssh -o User=root -q $target_host"
# escape ' with '"'"'
code="$(echo "$@" | sed -e "s/'/'\"'\"'/g")"
code="$ssh chroot $chroot sh -c '$code'"
code="chroot $chroot sh -e -c '$code'"
log "target_host: $target_host"
log "chroot: $chroot"
@ -46,6 +44,6 @@ log "@: $@"
log "code: $code"
# Run the code
$code
$__remote_exec $target_host $code
log "-----"