added pct-push-r command...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-12-28 14:23:09 +03:00
parent 65b2d7a7fd
commit e31edc255b

View File

@ -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 :