#!/bin/bash
#check
set -e
#install rsync
workDir=$PWD
installlog=$PWD/install.log
# yum install rsync
if [ -d /etc/init.d/xinetd ]; then
echo "xinetd is installed" | tee -a $installlog
else
yum install -y xinetd
fi
echo "xinetd install done" | tee -a $installlog
if [ -f /etc/xinetd.d/rsync ] ;then
chkconfig rsync on >> $installlog 2>&1
exit
else
yum install rsync -y >> $installlog 2>&1
fi
sed -i '6{s/yes/no/}' /etc/xinetd.d/rsync
service xinetd restart
echo "rsync install done"
cat >>/etc/rsyncd.conf <<EOF
uid = root
gid = root
hosts allow = 10.0.0.1
hosts deny = 0.0.0.0/32
use chroot = no
max connections = 10
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
## 上面这段是全局配置,下面的模块可以有多个
[web] ## 模块名字,自己命名
path = /www/web
comment = rsync files
ignore errors
read only = yes
list = no
auth users = rsyncname
## 同步验证时用什么账号,假如这里没有这项,就是匿名同步,client同步时,不用
secrets file = /etc/rsync.passwd
EOF
touch /etc/rsync.passwd
chmod 600 /etc/rsync.passwd
echo "please edit your name and passwd "
转载于:https://blog.51cto.com/qinyinbolan/1089880