centos一键安装rsync服务器脚本

post by rocdk890 / 2012-5-19 16:13 Saturday linux技术
  根据上一篇centos搭建rsync服务器然后结合网上脚本修改来的一键安装rsync脚本,名称为install-rsync.sh.当然只有服务端的配置,客户端就要大家自己手动去配置.
#!/bin/bash
#rsync Written by rocdk890 
#For more information please visit https://blog.slogra.com
echo "Please input the rsync username:"
read username
echo "Please input the rsync username password:"
read password
echo "Please input the server ip address:"
read serverip
echo "Please input the allow ip address:"
read allowip
echo "Please input the path you want to rsync:"
read rsyncpath
echo "==========================input all completed========================"
echo "==========================install rsync========================"
yum -y install wget perl
rpm -e rsync
wget http://download.slogra.com/rsync-3.0.7-1.el5.rf.i386.rpm 
rpm -ivh rsync-3.0.7-1.el5.rf.i386.rpm
useradd $username
mkdir /etc/rsyncd
cat >/etc/rsyncd/rsyncd.conf<<eof
# Minimal configuration file for rsync daemon
# See rsync(1) and rsyncd.conf(5) man pages for help
 
# This line is required by the /etc/init.d/rsyncd script
pid file = /var/run/rsyncd.pid   
port = 873
address = $serverip
#uid = nobody
#gid = nobody   
uid = root   
gid = root   
 
use chroot = yes
read only = yes
 
 
#limit access to private LANs
hosts allow=192.168.1.0/255.255.255.0 10.0.1.0/255.255.255.0 $allowip
hosts deny=*
 
max connections = 5
motd file = /etc/rsyncd/rsyncd.motd
 
#This will give you a separate log file
log file = /var/log/rsync.log
 
#This will log every file transferred - up to 85,000+ per user, per sync
#transfer logging = yes
 
log format = %t %a %m %f %b
syslog facility = local3
timeout = 300
 
[$username home]   
path = $rsyncpath   
list=yes
ignore errors
auth users = $username
secrets file = /etc/rsyncd/rsyncd.secrets 
eof
echo "$username:$password" > /etc/rsyncd/rsyncd.secrets
chmod 600 /etc/rsyncd/rsyncd.secrets
cat >/etc/rsyncd/rsyncd.motd<<eof
+++++++++++++++++++++++++++
+ Yofee Packages rsync    +
+++++++++++++++++++++++++++
eof
/usr/bin/rsync --daemon  --config=/etc/rsyncd/rsyncd.conf
echo "/usr/bin/rsync --daemon  --config=/etc/rsyncd/rsyncd.conf" >>/etc/rc.d/rc.local
ps -aux | grep rsync

chmod 700 install-rsync.sh
./install-rsync.sh或sh install-rsync.sh来执行安装.脚本不包括iptables的端口设置部分.

夜空- 本站版权
1、本站所有主题由该文章作者发表,该文章作者与夜空享有文章相关版权
2、其他单位或个人使用、转载或引用本文时必须同时征得该文章作者和夜空的同意
3、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责
4、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意
5、原文链接:blog.slogra.com/post-197.html

附件下载:
install-rsync.rar 2.03KB

标签: centos 配置 搭建 shell 脚本 rsync 一键

评论: