-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathsasynx
executable file
·65 lines (59 loc) · 1.57 KB
/
sasynx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
init ()
{ source sasynx.conf
while getopts 's:r:a:T:bectdz' o;do
case "$o" in
s) SETFILE="${OPTARG}" ;;
r) MYCLONE="${OPTARG}" ;;
a) ACTION="${OPTARG}" ;;
T) TIMEOUT="timeout ${OPTARG}" ;;
b) BAK_FILES="true" ;;
e) ECH0="echo" ;;
c) CHAIN="true" ;;
t) CHAIN="false" ;;
d) DEDUPE="true" ;;
z) SIZEUP="true" ;;
esac
done
shift "$(($OPTIND - 1))"
args="$@"
syncsets=(${args%% -*})
ARGS=" ${args/${syncsets[@]}/}"
}
backup ()
{ if ${BAK_FILES,,} && [ ! -z "${j#*:}" ] && [ ! $ACTION == "move" ];then
BAK="--backup-dir="$( sed "s/:/:$BAK_DIR\//g"<<<"$j" );else unset BAK;fi
}
dedup_sizup ()
{ (if [[ $DEDUPE == "true" ]];then $ECH0 rclone dedupe -vP newest $1;fi)&
(if [[ $SIZEUP == "true" ]];then $ECH0 $sizeup $1;fi)&
}
groups ()
{ for s in "${syncsets[@]}";do
source $SETDIR/$SETFILE $s
[[ -v group ]] && tmpset+=(${group[@]}) || tmpset+=($s)
done
syncsets=("${tmpset[@]:-'No set specified'}")
}
main ()
{
#> sasynx.tmp
for s in "${syncsets[@]}";do
source $SETDIR/$SETFILE $s
for i in "${src[@]}"; do i=$i$src_dir;last_dest="$i"
dedup_sizup "$i"
for j in "${dest[@]}"; do j=$j${dest_dir:-$src_dir}
if [[ $CHAIN == "true" && ${#src[@]} -eq 1 ]];then i=$last_dest;last_dest=$j;fi;
backup
echo $TIMEOUT $MYCLONE $ACTION $i $j $BAK $FLAGS $flags $ARGS
$ECH0 $TIMEOUT $MYCLONE $ACTION $i $j $BAK $FLAGS $flags $ARGS
dedup_sizup "$j"
done
done
done
# [ -z "$exe" ] && $exe
$exe
}
init "$@"
groups "$@"
main