-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathrsync_send
More file actions
executable file
·33 lines (30 loc) · 1.1 KB
/
Copy pathrsync_send
File metadata and controls
executable file
·33 lines (30 loc) · 1.1 KB
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
#!/bin/bash
###########################
#rsync_tmp='/usr/local/opencdn/conf_rsync,ocdn.me,ocdn_nginx,ocdn'
rsync_tmp='/usr/local/opencdn/nginx,ocdn.me,ocdn_nginx,ocdn'
OPENCDN_CONF_FILE="/usr/local/opencdn/conf/opencdn.conf"
OPENCDN_LOG_PATH="/var/log/opencdn"
if [ ! -f "$OPENCDN_CONF_FILE" ]
then
echo "$OPENCDN_CONF_FILE does not exist !"
exit 1
fi
i=1
cat $OPENCDN_CONF_FILE | sed '/^#/D' | grep -i "Node[0-9]" | while read NodeIP
do
Node[$i]=`echo "$NodeIP" | awk -F = '{print $2}'`
# echo "Node$i : ${Node[$i]}"
item=`echo "$rsync_tmp" | sed "s/ocdn.me/${Node[$i]}/"`
# echo $item
dir=`echo $item | awk -F"," '{print $1}'`
host=`echo $item | awk -F"," '{print $2}'`
module=`echo $item | awk -F"," '{print $3}'`
user=`echo $item | awk -F"," '{print $4}'`
/usr/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $dir \
| while read files
do
/usr/bin/rsync -vzrtp --delete --progress --password-file=/etc/rsyncd.pwd $dir ${user}@$host::$module
echo "${files} was rsyncd" >> ${OPENCDN_LOG_PATH}/rsync.error 2>&1
done &
let i=$i+1
done