安装rsync脚本
#!/bin/bash
echo ======================================================
read -p "请输入允许同步的IP,多个ip以空格分开:" rsync_ip
echo ======================================================
read -p "请输入要同步的目录:" rsync_data
echo ======================================================
#安装rsync软件
rpm -qa | grep rsync
if [ "$?" == 0 ];
then
echo "rsync已安装"
else
yum install -y rsync
fi
#配置rsync
cat > /etc/rsyncd.conf<<EOF
uid = root
gid = root
use chroot = no
max connections = 300
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /data/logs/rsyncd.log
[rsync]
path = $rsync_data
read only = no
hosts allow = $rsync_ip
list = no
auth users = rsync
secrets file = /etc/rsync.pass
EOF
cat > /etc/rsync.pass<<EOF
rsync:xxxxxxxxxx
EOF
sed -i "s/yes/no/g" /etc/xinetd.d/rsync
chmod 600 /etc/rsync.pass
service xinetd restart
运行脚本sh rsync.sh
运行脚本
# sh rsync.sh
======================================================
请输入允许同步的客户端IP,多个ip以空格分开:
例如:192.168.0.1 10.0.0.0/8
======================================================
请输入要同步的目录:
======================================================