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 :