您好,登錄后才能下訂單哦!
這篇文章主要講解了“怎么搭建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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。