use openrsync to copy files, duh

This commit is contained in:
Aaron Bieber 2019-10-21 06:58:21 -06:00
parent 8f485ccb4f
commit 7d6e339e08
Signed by: qbit
GPG Key ID: 279160AB1BE1236B
3 changed files with 37 additions and 1 deletions

View File

@ -128,6 +128,7 @@ diff(1),
encrypt(1), encrypt(1),
fw\_update(1), fw\_update(1),
ksh(1), ksh(1),
openrsync(1),
pkg\_add(1), pkg\_add(1),
pkg\_delete(1), pkg\_delete(1),
pkg\_info(1), pkg\_info(1),

View File

@ -27,6 +27,7 @@ SNAPSHOT=""
FORCE=0 FORCE=0
SSH_CTL_PATH="/tmp/boxctl-%r@%h:%p" SSH_CTL_PATH="/tmp/boxctl-%r@%h:%p"
SSH_OPTS="-o ControlMaster=auto -o ControlPersist=60s -o ControlPath=${SSH_CTL_PATH}" SSH_OPTS="-o ControlMaster=auto -o ControlPersist=60s -o ControlPath=${SSH_CTL_PATH}"
RSYNC_OPTS="--rsync-path=/usr/bin/openrsync -Dlrt"
while getopts "fh:mnu:sv" arg; do while getopts "fh:mnu:sv" arg; do
case $arg in case $arg in
@ -98,6 +99,27 @@ expand_v() {
fi fi
} }
rsync_verbose() {
local _opt=""
if [ $VERBOSITY -ge 2 ]; then
_opt="$V"
fi
if [ $DRY == 1 ]; then
echo openrsync ${RSYNC_OPTS} $_opt "$1" "$2"
else
openrsync ${RSYNC_OPTS} $_opt "$1" "$2"
fi
}
rsync_quiet() {
if [ $DRY == 1 ]; then
echo openrsync ${RSYNC_OPTS} "$1" "$2"
else
openrsync ${RSYNC_OPTS} "$1" "$2" >/dev/null
fi
}
ssh_verbose() { ssh_verbose() {
local _opt="" local _opt=""
if [ $VERBOSITY -ge 4 ]; then if [ $VERBOSITY -ge 4 ]; then
@ -141,6 +163,18 @@ scp_quiet() {
} }
_rsync() {
local _src _dest
_src=$1
_dest="$(dirname $2)"
if [ $VERBOSITY -gt 2 ]; then
rsync_verbose "$_src" "$_dest"
else
rsync_quiet "$_src" "$_dest"
fi
}
_scp() { _scp() {
local _src _dest local _src _dest
_src=$1 _src=$1
@ -215,7 +249,7 @@ EOF
msg 2 "\t\tchmod ${_mode} $_dest" msg 2 "\t\tchmod ${_mode} $_dest"
_ssh ${RUN_USER}@${SERVER} "mkdir -p ${_dir}" _ssh ${RUN_USER}@${SERVER} "mkdir -p ${_dir}"
_scp $_src "${RUN_USER}@${SERVER}:$_dest" _rsync $_src "${RUN_USER}@${SERVER}:$_dest"
_ssh ${RUN_USER}@${SERVER} "/sbin/chown ${_owner}:${_group} \ _ssh ${RUN_USER}@${SERVER} "/sbin/chown ${_owner}:${_group} \
$_dest; /bin/chmod ${_mode} $_dest" $_dest; /bin/chmod ${_mode} $_dest"
done done

View File

@ -116,6 +116,7 @@ the run.
.Xr encrypt 1 , .Xr encrypt 1 ,
.Xr fw_update 1 , .Xr fw_update 1 ,
.Xr ksh 1 , .Xr ksh 1 ,
.Xr openrsync 1 ,
.Xr pkg_add 1 , .Xr pkg_add 1 ,
.Xr pkg_delete 1 , .Xr pkg_delete 1 ,
.Xr pkg_info 1 , .Xr pkg_info 1 ,