new tool: args2env
[hband-tools.git] / user-tools / rsync-semichroot
blob824d57b7a151ae8800984f1e9cd66dbb5b4f9566
1 #!/bin/bash
4 semi_chroot=$1
5 set -- $SSH_ORIGINAL_COMMAND
6 declare -a argv
7 declare -a opts
9 opts=(-logDtpre.is)
12 while [ -n "$1" ]
14 case "$1" in
15 -[!-' ']*)
16 pos=1
17 while [ $pos -lt ${#1} ]
19 case "${1:$pos:1}" in
20 R) opts+=(--relative) ;;
21 v) opts+=(--verbose) ;;
22 L) opts+=(--copy-links) ;;
23 u) opts+=(--update) ;;
24 z) opts+=(--compress) ;;
25 esac
26 let pos++
27 done
29 --sender|--delete|--relative|--verbose|--copy-links|--update|--compress|--del|--delete*)
30 opts+=($1)
32 -*)
33 true
36 argv+=($1)
38 esac
39 shift
40 done
43 cmd=${argv[0]}
45 if [ "$cmd" = rsync ]
46 then
47 echo Running semi-chroot rsync --server "${opts[@]}" . "$semi_chroot/${argv[2]}" >&2
48 exec /usr/bin/rsync --server "${opts[@]}" . "$semi_chroot/${argv[2]}"
49 else
50 echo "Only rsync (server side) command is permitted. Sleeping." >&2
51 sleep infinity