From 04c8415060ddb164fa37ab053abc8e678803d8a8 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 29 Aug 2017 21:49:47 +0200 Subject: [PATCH] use __remote_{exec,copy} instead of plain ssh/scp in remote exec scripts Signed-off-by: Steven Armstrong --- cdist/conf/type/__install_config/files/remote/copy | 8 +++----- cdist/conf/type/__install_config/files/remote/exec | 10 ++++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cdist/conf/type/__install_config/files/remote/copy b/cdist/conf/type/__install_config/files/remote/copy index df6a3f06..176b92bf 100755 --- a/cdist/conf/type/__install_config/files/remote/copy +++ b/cdist/conf/type/__install_config/files/remote/copy @@ -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 "-----" diff --git a/cdist/conf/type/__install_config/files/remote/exec b/cdist/conf/type/__install_config/files/remote/exec index 17375693..e90eb415 100755 --- a/cdist/conf/type/__install_config/files/remote/exec +++ b/cdist/conf/type/__install_config/files/remote/exec @@ -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 "-----"