这篇文章主要讲解了“怎么搭建Rsync服务端”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么搭建Rsync服务端”吧!
#!/bin/bash ############################################################## # File Name: Rsync.sh # Version: V1.0 # Author: Da Kai # Organization: http://dakaige517.blog.51cto.com # Created Time : 2017-06-25 13:06:27 # Description:This is a shell script to install the rsync service ############################################################## . /etc/init.d/functions function install_check(){ rpm -qa rsync if [ $? -eq 0 ] then action "Rsync is installed" /bin/true else echo "Rsync is not installed" yum install rsync -y fi } function install(){ if [ -f /etc/rsyncd.conf ] then echo "/etc/rsyncd.conf is exist." else cat >/etc/rsyncd.conf<<EOF ######rsync_config_______________start #created by oldboy 15:01 2007-6-25 #QQ 1151887353 blog:http://dakaige517.blog.51cto.com ##rsyncd.conf start## uid = rsync gid = rsync use chroot = no max connections = 200 timeout = 300 pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log [backup] path = /backup/ ignore errors read only = false list = false hosts allow = 172.16.1.0/24 #hosts deny = 0.0.0.0/32 auth users = rsync_backup secrets file = /etc/rsync.password #rsync_config_______________end EOF fi awk -F: '{print $1}' /etc/passwd|grep rsync if [ $? -eq 0 ] then echo "rsync is exist" else useradd rsync -s /sbin/nologin -M fi if [ -d /backup ] then echo "/backup is exist." else mkdir -p /backup chown rsync.rsync /backup fi if [ -f /etc/rsync.password ] then echo "/etc/rsync.password is exist." else echo "rsync_backup:123456" >/etc/rsync.password chmod 600 /etc/rsync.password fi rsync --daemon if [ $? -eq 0 ] then action "Rsync service is successfully to start." /bin/true echo 'rsync --daemon' >>/etc/rc.local else action "Rsync service is failed to start" /bin/false fi ps -ef|grep "rsync --daemon" if [ $? -eq 0 ] then action "Rsync service is running." /bin/true else action "Rsync service is not running." /bin/false fi } function add_modul(){ echo -e "Usage:\n[backup]\npath = /backup/" echo "-------添加模块---------" read -p "请添加模块名称: " name read -p "请添加模块相对应的位置(目录)path = " directory mkdir -p $directory cat >>/etc/rsyncd.conf<<EOF $name path = $directory EOF echo "----- 模块添加成功---- -" } install_check install add_modul
感谢各位的阅读,以上就是“怎么搭建Rsync服务端”的内容了,经过本文的学习后,相信大家对怎么搭建Rsync服务端这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。