refactor cprs (rsync) for ACL and using sudo

master
Kebler Network System Administrator 2021-02-18 07:31:28 -08:00
parent ca7d7a5a0d
commit 256186376d
2 changed files with 7 additions and 4 deletions

View File

@ -1 +1 @@
alias aud="acluserdir" alias aud="acladduserdir"

View File

@ -3,11 +3,14 @@
# present working directory to supplied destination # present working directory to supplied destination
module_load confirm module_load confirm
function cprs () { function cprs () {
local usesudo
local cmd
[[ $1 == "-s" ]] && usesudo='sudo' && shift
[ $# -ne 2 ] && echo two directories source and destination need to be passed && return 1 [ $# -ne 2 ] && echo two directories source and destination need to be passed && return 1
[ ! -d "$1" ] && echo source: $1 is not a directory && return 1 [ ! -d "$1" ] && echo source: $1 is not a directory && return 1
[ ! -d "$2" ] && echo destination: $2 is not a directory && return 1 cmd="$usesudo rsync --exclude *[C]ache* --exclude node_modules --progress -aAru $1 $2"
echo Command to run: rsync --progress -a -r -u "$1" "$2" echo $cmd
confirm Do you want to start the rsync copy? || return 0 confirm Do you want to start the rsync copy? || return 0
echo copying..... echo copying.....
rsync --exclude *[C]ache* --progress -a -r -u "$1" "$2" eval $cmd
} }