Compare commits

..

9 Commits

Author SHA1 Message Date
c9a200d42e updated x-bits...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2023-12-30 16:05:41 +00:00
6c109415e7 tweak...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2023-12-30 18:57:07 +03:00
f1ef650bd5 fix...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2023-12-30 18:51:53 +03:00
f1f6075328 fix...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2023-12-30 18:49:55 +03:00
1642faf351 minor fix...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2023-12-30 18:46:16 +03:00
7b44e5e5f0 minor fix...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2023-12-30 18:41:35 +03:00
6fb0002145 reworked path handling...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2023-12-30 18:37:35 +03:00
551da5ded3 tweaks...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2023-12-30 18:05:58 +03:00
339b4c578a moved pct-push-r out of .pct-helpers
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2023-12-30 17:52:29 +03:00
8 changed files with 87 additions and 29 deletions

View File

@ -128,29 +128,14 @@ 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
normpath(){
echo $1 \
| sed \
-e 's/\/\+/\//g' \
-e 's/\/.\//\//g' \
-e 's/[^\/]\+\/\.\.//g' \
-e 's/\/\+/\//g' \
-e 's/\/\.$/\//g'
}

0
check-status Normal file → Executable file
View File

2
gate-traefik/make.sh Normal file → Executable file
View File

@ -3,6 +3,8 @@
source ../.pct-helpers
PATH=$PATH:$(dirname "$(pwd)")
#----------------------------------------------------------------------

0
make-shares Normal file → Executable file
View File

0
ns/make.sh Normal file → Executable file
View File

12
pct-mclone Normal file → Executable file
View File

@ -49,24 +49,24 @@ running=$(pct list | grep "running\s*$host\s*$")
# error checking...
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
fi
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
fi
if ! [ -e $ct ] ; then
echo ERR $ct does not exist.
echo ERR $ct does not exist. 1>&2
exit 1
fi
if [ -e ${CT_DIR}/${to}.conf ] ; then
echo ERR $to already exists.
echo ERR $to already exists. 1>&2
exit 1
fi
if ! [ -z $tpl ] && [ -e ${CT_DIR}/${tpl}.conf ] ; then
echo ERR $to already exists.
echo ERR $to already exists. 1>&2
exit 1
fi
@ -75,7 +75,7 @@ IFS=$'\n' mounts=($(cat $ct | grep 'mp[0-9]*:'))
# check...
for mp in ${mounts[@]} ; do
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
fi
done

71
pct-push-r Executable file
View File

@ -0,0 +1,71 @@
#!/usr/bin/bash
#----------------------------------------------------------------------
#
#----------------------------------------------------------------------
# XXX
source $(dirname "$0")/.pct-helpers
#----------------------------------------------------------------------
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
IFS=$'\n'
#----------------------------------------------------------------------
id=$1
from=$2
to=$3
#----------------------------------------------------------------------
wd=$(pwd)
# get from path relative to working directory...
if [[ ${from:0:1} != '/' ]] ; then
from="$(normpath "${wd}/${from}")"
fi
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
files=($(find "$from" -type f))
for file in "${files[@]}" ; do
file=${file#${from}}
f=$(normpath "${from}/${file}")
t=$(normpath "${to}/${file}")
[ $QUIET ] \
|| echo "copy: \"${f#${wd}/}\" -> $id:\"$t\""
pct push $id "$f" "$t"
done
#----------------------------------------------------------------------
# vim:set ts=4 sw=4 nowrap :

0
update-status Normal file → Executable file
View File