CentOS 一键配置rsync服务器脚本
<p><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>1、保存下面的代码为一个文件,上传到服务器端,名称为rsync.sh </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>
</p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<p class="right">
<span><u>复制代码</u></span></p>
<p>
代码如下:</p>
</div>
<p class="msgborder" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
<br>
#!/bin/bash <br>
#rsync Written by zhumaohai <br>
#For more information please visit http://www.centos.bz <br>
echo "Please input the rsync username:" <br>
read username <br>
echo "Please input the rsync username password:" <br>
read password <br>
echo "Please input the server ip address:" <br>
read serverip <br>
echo "Please input the allow ip address:" <br>
read allowip <br>
echo "Please input the path you want to rsync:" <br>
read rsyncpath <br>
echo "==========================input all completed========================" <br>
echo "==========================install rsync========================" <br>
yum -y install rsync <br>
useradd $username <br>
mkdir /etc/rsyncd <br>
cat >/etc/rsyncd/rsyncd.conf<<eof <br>
# Minimal configuration file for rsync daemon <br>
# See rsync(1) and rsyncd.conf(5) man pages for help <br>
# This line is required by the /etc/init.d/rsyncd script <br>
pid file = /var/run/rsyncd.pid <br>
port = 873 <br>
address = $serverip <br>
#uid = nobody <br>
#gid = nobody <br>
uid = root <br>
gid = root <br>
use chroot = yes <br>
read only = yes <br><br>
#limit access to private LANs <br>
hosts allow=192.168.1.0/255.255.255.0 10.0.1.0/255.255.255.0 $allowip <br>
hosts deny=* <br>
max connections = 5 <br>
motd file = /etc/rsyncd/rsyncd.motd <br>
#This will give you a separate log file <br>
#log file = /var/log/rsync.log <br>
#This will log every file transferred - up to 85,000+ per user, per sync <br>
#transfer logging = yes <br>
log format = %t %a %m %f %b <br>
syslog facility = local3 <br>
timeout = 300 <br>
[$username home] <br>
path = $rsyncpath <br>
list=yes <br>
ignore errors <br>
auth users = $username <br>
secrets file = /etc/rsyncd/rsyncd.secrets <br>
eof <br>
echo "$username:$password" > /etc/rsyncd/rsyncd.secrets <br>
chmod 600 /etc/rsyncd/rsyncd.secrets <br>
cat >/etc/rsyncd/rsyncd.motd<<eof <br>
+++++++++++++++++++++++++++ <br>
+ centos.bz rsync 2011-2012 + <br>
+++++++++++++++++++++++++++ <br>
eof <br>
/usr/bin/rsync --daemon --config=/etc/rsyncd/rsyncd.conf <br>
ps -aux | grep rsync </p>
<p>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>2、赋予脚本权限 </span></p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<p class="right">
<span><u>复制代码</u></span></p>
<p>
代码如下:</p>
</div>
<p class="msgborder" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
<br>
chmod +x rsync.sh </p>
<p>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>3、执行脚本 </span></p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
<p class="right">
<span><u>复制代码</u></span></p>
<p>
代码如下:</p>
</div>
<p class="msgborder" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
<br>
./rsync.sh </p>
<p>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>4、客户端同样需要安装rsync</span></p>
頁:
[1]