mirror of
https://github.com/flynx/proxmox-utils.git
synced 2025-10-29 11:10:09 +00:00
moved pct-push-r out of .pct-helpers
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
5689ef211c
commit
339b4c578a
27
.pct-helpers
27
.pct-helpers
@ -126,33 +126,6 @@ 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 :
|
# vim:set ts=4 sw=4 nowrap :
|
||||||
|
|||||||
12
pct-mclone
12
pct-mclone
@ -49,24 +49,24 @@ running=$(pct list | grep "running\s*$host\s*$")
|
|||||||
|
|
||||||
# error checking...
|
# error checking...
|
||||||
if [ -z $id ] || [ -z $to ] ; then
|
if [ -z $id ] || [ -z $to ] ; then
|
||||||
echo ERR need both id and target id
|
echo ERR need both id and target id 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ $id = $to ] ; then
|
if [ $id = $to ] ; then
|
||||||
echo ERR need id and target id must be different
|
echo ERR need id and target id must be different 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [ -e $ct ] ; then
|
if ! [ -e $ct ] ; then
|
||||||
echo ERR $ct does not exist.
|
echo ERR $ct does not exist. 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ -e ${CT_DIR}/${to}.conf ] ; then
|
if [ -e ${CT_DIR}/${to}.conf ] ; then
|
||||||
echo ERR $to already exists.
|
echo ERR $to already exists. 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if ! [ -z $tpl ] && [ -e ${CT_DIR}/${tpl}.conf ] ; then
|
if ! [ -z $tpl ] && [ -e ${CT_DIR}/${tpl}.conf ] ; then
|
||||||
echo ERR $to already exists.
|
echo ERR $to already exists. 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ IFS=$'\n' mounts=($(cat $ct | grep 'mp[0-9]*:'))
|
|||||||
# check...
|
# check...
|
||||||
for mp in ${mounts[@]} ; do
|
for mp in ${mounts[@]} ; do
|
||||||
if ! [ $(grep ": $SHARE_ROOT" <<< $mp) ] ; then
|
if ! [ $(grep ": $SHARE_ROOT" <<< $mp) ] ; then
|
||||||
echo "ERR mountpoint: \"$mp\" heeds to handled manually."
|
echo "ERR mountpoint: \"$mp\" heeds to handled manually." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
51
pct-push-r
Normal file
51
pct-push-r
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/bash
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
-h|--help)
|
||||||
|
echo "Recursively push a directory to a CT creating the necessary paths"
|
||||||
|
echo
|
||||||
|
echo "Usage:"
|
||||||
|
echo " `basename $0` ID FROM TO"
|
||||||
|
echo
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
echo "Unknown option: $1"
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [[ $# < 3 ]] ; then
|
||||||
|
echo ERR need both id and target id 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
id=$1
|
||||||
|
from=$2
|
||||||
|
to=$3
|
||||||
|
|
||||||
|
IFS=$'\n'
|
||||||
|
|
||||||
|
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 :
|
||||||
Loading…
x
Reference in New Issue
Block a user