mirror of
https://github.com/flynx/proxmox-utils.git
synced 2025-12-25 12:52:04 +00:00
Compare commits
9 Commits
5689ef211c
...
c9a200d42e
| Author | SHA1 | Date | |
|---|---|---|---|
| c9a200d42e | |||
| 6c109415e7 | |||
| f1ef650bd5 | |||
| f1f6075328 | |||
| 1642faf351 | |||
| 7b44e5e5f0 | |||
| 6fb0002145 | |||
| 551da5ded3 | |||
| 339b4c578a |
31
.pct-helpers
31
.pct-helpers
@ -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
0
check-status
Normal file → Executable file
2
gate-traefik/make.sh
Normal file → Executable file
2
gate-traefik/make.sh
Normal file → Executable file
@ -3,6 +3,8 @@
|
||||
|
||||
source ../.pct-helpers
|
||||
|
||||
PATH=$PATH:$(dirname "$(pwd)")
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
||||
|
||||
0
make-shares
Normal file → Executable file
0
make-shares
Normal file → Executable file
0
ns/make.sh
Normal file → Executable file
0
ns/make.sh
Normal file → Executable file
12
pct-mclone
Normal file → Executable file
12
pct-mclone
Normal file → Executable 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
71
pct-push-r
Executable 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
0
update-status
Normal file → Executable file
Loading…
x
Reference in New Issue
Block a user