From e31edc255b7844ba04140d7a82ba79217bd65f3d Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 28 Dec 2023 14:23:09 +0300 Subject: [PATCH] added pct-push-r command... Signed-off-by: Alex A. Naanou --- .pct-helpers | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.pct-helpers b/.pct-helpers index a81c059..6e9439c 100644 --- a/.pct-helpers +++ b/.pct-helpers @@ -13,14 +13,16 @@ CT_DIR=${CT_DIR:=/etc/pve/lxc/} # #QUIET= #DRY_RUN= +ECHO_PREFIX="### " @(){ if [ -z $DRY_RUN ] ; then ! [ $QUIET ] \ - && echo "### $@" + && echo "${ECHO_PREFIX}$@" $@ else echo $@ fi + return $? } @@ -124,5 +126,33 @@ hostname2ct(){ } +#---------------------------------------------------------------------- + +pct-push-r(){ + local id=$1 + local from=$2 + local to=$3 + + local IFS=$'\n' + + local dirs=($(find "$from" -type d)) + for dir in "${dirs[@]}" ; do + if [[ "$dir" == "${to}" ]] ; then + continue + fi + dir=${dir#${from}} + lxc-attach $id -- mkdir -p "${to}/${dir}" + done + + local files=($(find "$from" -type f)) + for file in "${files[@]}" ; do + file=${file#${from}} + [ $QUIET ] \ + || echo "copy: \"${from}/${file}\" -> $id:\"${to}/${file}\"" + pct push $id "${from}/${file}" "${to}/${file}" + done +} + + #---------------------------------------------------------------------- # vim:set ts=4 sw=4 nowrap :